Your day, dawn to dusk — local-first, auditable, yours.
Daythread is a local-first personal agent reference implementation: living memory, multi-step plans, a policy/approval gate, a tamper-evident ledger, proactivity budgets, connectors, declarative skills, a model gateway, an MCP client, a scheduler, backups, and a local HTTP API. Everything runs on your machine with zero third-party dependencies.
This is the working baseline for the design in
docs/DESIGN.md. It is intentionally
written in Python 3.9+ standard library so the core mechanics can be run,
audited, and ported to the Rust/Tauri target without a build toolchain.
v0.24.0 — brand and UI redesign. Interfaces may still change. The goal is a small, correct, auditable core with tests (239 at this milestone, ~78% line coverage, 75% gate), not feature breadth.
- Living memory: structured facts with provenance, confidence, tags, sensitivity, score, edit history, supersede, conflict detection, tombstones, deterministic text extraction, JSON import/export, and FTS5-ranked search with a LIKE fallback.
- Plan runtime: validated DAGs, policy aggregation, approval gate, idempotency keys, per-step retries, checkpoints, resume, cancel, multi-step undo, and execution budgets.
- Tamper-evident ledger: append-only events and hash-chained run steps;
dt ledger <run> --verifyrecomputes the chain. - Proactivity: signals, candidate scoring, interrupt budget, quiet hours, delivery deferral, and accept/ignore/mute feedback.
- Scheduler: idempotent morning/evening/maintenance ticks, notification outbox, quiet-hour queueing, and a daemon loop.
- Model gateway: pluggable providers, local deterministic provider,
OpenAI-compatible HTTP + SSE streaming, fallback chain with retries/backoff,
local_onlyegress policy, encrypted response cache, daily token budget, and usage ledger. - MCP client: JSON-RPC 2.0 stdio client, server registry, tool discovery,
and
mcp.callbehind the approval gate. - MCP server:
dt mcp serveexposes briefs, memory, tasks, calendar, approvals, connectors, approval-gated plan proposals, resources (daythread://today, memory facts), and prompts. Sensitive resources are blocked. Read-only by default. - Connectors: manifest-based registry, mock providers, OAuth2 + PKCE
with a loopback callback, encrypted token storage and refresh, Google and
Microsoft 365 Calendar/Mail adapters, Feishu/Lark Calendar and Tasks
adapters, read sync with retry/backoff, pagination, and incremental cursors
(Google
syncToken, MicrosoftdeltaLink), and approval-gated write actions (create/move events, draft/send mail, create tasks). - Skills: declarative plans with explicit capabilities, builtin skills, install/uninstall, and validation.
- Backup/restore: checksummed versioned bundles, secret redaction, verify, merge or replace restore.
- Secrets: optional AES-256-GCM + scrypt vault with a
0600master key, andsecret:references for MCP environment variables. - E2EE sync: passphrase-encrypted bundles, verify/import, plus a
self-hosted relay (
dt relay serve) for multi-device push/pull; secrets stay device-local and the relay only sees ciphertext. - Daythread Bench v0: memory insert/search, proactivity, runtime plans, and safety checks in a throwaway home.
- Local HTTP API: bearer auth, Host allowlist, persistent per-token rate
limits, request IDs, pagination, OpenAPI document, facts, runs, approvals,
candidates, notifications, connectors, models, ask, signed webhooks, and
Prometheus metrics. Binds
127.0.0.1only. - Hardening: atomic run leases, step timeouts, subprocess isolation for
external/MCP/connector/shell tools with process-group kill, optional macOS
sandbox-exec, bubblewrap, or Docker sandbox, retention/pruning, signed/ encrypted backups, encrypted model cache, sensitivity filters, MCP command allowlist, OAuth revoke/scope checks, relay TLS/retention/device tokens. - Operations: schema migrations,
doctor, structured audit log, metrics, config settings, JSON/Markdown export, migration matrix, contract tests, load smoke, Dockerfile, and CI. - Privacy/DSAR: per-subject export, soft/hard forget, tombstone purge, and audit records.
- Dashboard:
dt uiserves a loopback dashboard for briefs, approvals, runs, and memory search. - Native shell:
desktop/is a SwiftUI macOS app that drivesdt(Today, runs, approve/reject/undo, memory search) and builds an ad-hoc signed.app. - Cross-platform shell:
desktop-tauri/is a Tauri v2 app (Rust command + web UI) that drives the samedtCLI;cargo build --releaseverified andmake tauri-bundleproduces a.app+.dmg. - Release: wheel build, SHA256SUMS, CycloneDX-style SBOM, HMAC/Ed25519 manifest, and a signed DSSE/in-toto attestation covering artifacts + SBOM.
- Compliance evidence:
dt compliance evidenceexports controls, settings, stats, and known gaps for audits. - Sidecar:
make sidecarbuilds a standalonedtbinary for Tauri.
No telemetry. Network access only happens if you explicitly configure an OpenAI-compatible provider or an MCP server.
cd daythread
python3 -m daythread demo
python3 -m daythread ask "what should I focus on?"
python3 -m daythread tick --job morning
python3 -m daythread notifications
python3 -m daythread bench
make testInstall the dt command:
python3 -m pip install -e .
# optional encryption/sync support:
python3 -m pip install -e ".[crypto]"
dt doctorUse a custom home:
export DAYTHREAD_HOME="$PWD/.daythread"
dt initdt init | migrate | doctor | demo
dt fact add|list|show|edit|rm|search|extract|history|conflicts|import
dt task list|create|done|update
dt brief [--evening]
dt plan "<intent>" [--execute] [--file plan.json] [--idempotency-key K] [--taint untrusted]
dt act <tool> --arg k=v [--idempotency-key K]
dt runs | show | approve | reject | undo | resume | cancel | ledger
dt policy show|set
dt ask "<text>" [--task NAME] [--no-cache] [--stream]
dt model list|usage
dt mcp add|list|remove|tools|call|serve
dt webhook secret set|rm | webhook sign | webhook events
dt signal add|list
dt proactive [--deliver]
dt candidate list
dt feedback <candidate-id> accept|ignore|mute
dt tick [--job morning|evening|maintenance]
dt daemon [--interval 60] [--max-ticks N]
dt notifications | scheduler list
dt connector list|auth|revoke|connect|disconnect|sync|state|reset|call|items
dt skill list|show|install|run|uninstall
dt secret set <name> | list | rm
dt sync export|import|verify|push|pull|devices [--passphrase-env DAYTHREAD_PASSPHRASE]
dt sync push ... [--if-match ETAG] [--on-conflict fail|pull]
dt relay serve [--dir DIR] [--port 8788] [--token-env DAYTHREAD_RELAY_TOKEN]
dt relay devices add|list|remove [--file PATH]
dt bench [--facts N] [--runs N]
dt ui [--port 8765] [--no-browser]
dt config show|set
dt metrics | audit | export [--format md|json] [--include-sensitive]
dt maintenance stats|prune [--older-than N] [--keep-runs N] [--vacuum]
dt privacy export|forget|purge
dt compliance evidence [--out FILE]
dt fact list|search ... [--include-sensitive]
dt backup [--out DIR] [--passphrase-env DAYTHREAD_BACKUP_PASSPHRASE]
dt restore <file> [--verify] [--replace] [--trust] [--passphrase-env ...]
dt serve [--host 127.0.0.1] [--port 8765] [--print-token] [--rotate-token]
[--certfile cert.pem --keyfile key.pem]
# Multi-step plan: draft, then external send. Approval is required.
dt plan "send maya@example.com | Deck | Latest" --execute
dt approve <run-id>
# Inspect and verify the audit chain.
dt ledger <run-id> --verify
# Reversible multi-step plan (custom JSON).
cat > plan.json <<'JSON'
{"steps": [
{"id": "s1", "tool": "note.write", "args": {"path": "a.md", "content": "A"}},
{"id": "s2", "tool": "note.write", "args": {"path": "b.md", "content": "B"}, "depends_on": ["s1"]}
]}
JSON
dt plan --file plan.json --execute
dt undo <run-id>
# Model gateway (local by default; configure a remote provider explicitly).
dt ask "summarize my day"
dt ask --stream "summarize my day"
dt config set model.egress local_only # forbid remote providers
dt config set model.provider openai.compatible
dt config set model.model gpt-4o-mini
export OPENAI_API_KEY=...
dt ask "summarize my day"
# MCP client: connect to another MCP server.
dt mcp add echo --command "python3 /path/to/server.py"
dt mcp tools echo
dt mcp call echo echo --arg text=hello
dt approve <run-id>
# MCP server: expose Daythread to Claude/Cursor (read-only by default).
dt mcp serve
dt mcp serve --allow-write
# Signed webhooks (HMAC + timestamp + dedupe).
dt webhook secret set github
dt webhook sign github --payload '{"id":"evt-1","title":"Deploy finished"}'
dt webhook events
# Scheduler and notifications.
dt tick --job morning
dt notifications
dt daemon --interval 60
# Mock connectors and skills.
dt connector connect mock.gmail
dt connector sync mock.gmail
dt skill run inbox.triage
# Real Google connectors (requires the crypto extra).
python3 -m pip install -e ".[crypto]"
dt config set oauth.google.client_id "<client-id>"
dt config set oauth.google.client_secret_ref "env:GOOGLE_CLIENT_SECRET"
dt connector auth google.calendar --no-browser # open the printed URL
dt connector auth google.gmail --no-browser
dt connector sync google.calendar
dt connector sync google.gmail
dt connector state google.calendar
dt connector sync google.calendar --reset
# Write actions (always approved before execution).
dt connector call google.calendar create_event \
--arg title="Design review" --arg start=2026-11-26T15:00:00Z --arg end=2026-11-26T16:00:00Z
dt connector call google.gmail create_draft \
--arg to=maya@example.com --arg subject=Deck --arg body="Latest version."
dt approve <run-id>
# Microsoft 365 OAuth.
dt config set oauth.microsoft.client_id "<client-id>"
dt config set oauth.microsoft.client_secret_ref "env:MS_CLIENT_SECRET"
dt connector auth microsoft.calendar --no-browser
dt connector auth microsoft.mail --no-browser
dt connector sync microsoft.calendar
dt connector call microsoft.mail create_draft \
--arg to=maya@example.com --arg subject=Deck --arg body="Latest version."
# Feishu / Lark.
dt config set oauth.feishu.client_id "<app-id>"
dt config set oauth.feishu.client_secret_ref "env:FEISHU_APP_SECRET"
dt connector auth feishu.calendar --no-browser
dt connector sync feishu.tasks
dt connector call feishu.tasks create_task --arg title="Review deck" --arg due=2026-11-27T10:00:00Z
# Backup and restore (signed; optionally encrypted).
dt backup
DAYTHREAD_BACKUP_PASSPHRASE=... dt backup
dt restore ~/.daythread/backups/daythread-*.json --verify
dt restore ~/.daythread/backups/daythread-*.json
dt restore ~/.daythread/backups/daythread-*.json --trust # new device / new home
# Retention and housekeeping.
dt maintenance stats
dt maintenance prune --older-than 90 --keep-runs 200 --vacuum
# Privacy / DSAR.
dt privacy export --subject maya --out maya.json
dt privacy forget --subject maya
dt privacy forget --subject maya --hard
dt privacy purge --older-than 30
# Load smoke, coverage, release, container build, native shell.
make load
make coverage
make release
python3 scripts/release.py --generate-key release.pem
python3 scripts/release.py --build --signing-key release.pem
make attest
make sidecar
make docker
make app # SwiftUI dist/Daythread.app
make tauri # Tauri release build
make tauri-bundle # Tauri .app + .dmg
open dist/Daythread.app
# Local dashboard.
dt ui
# Encrypted secrets and E2EE file sync.
dt secret set OPENAI_KEY # prompts on a TTY, or pipe stdin
dt sync export
DAYTHREAD_PASSPHRASE=... dt sync import ~/.daythread/sync/daythread-sync-*.json --verify
# E2EE multi-device relay.
dt relay serve --port 8788
DAYTHREAD_RELAY_TOKEN=... dt sync push --relay http://127.0.0.1:8788 --device laptop
DAYTHREAD_RELAY_TOKEN=... dt sync pull --relay http://127.0.0.1:8788 --device laptop
DAYTHREAD_RELAY_TOKEN=... dt sync devices --relay http://127.0.0.1:8788
# Benchmark the local core.
dt bench --facts 500 --runs 50
# Local API (optionally HTTPS).
dt serve --print-token
dt serve --port 8765
dt serve --certfile cert.pem --keyfile key.pemRegister this loopback redirect URI in the Google Cloud console for the client:
http://127.0.0.1 (dynamic port). Tokens are AES-GCM encrypted at rest; sync
happens only after an explicit authorization.
CLI (dt) / HTTP API
└─ runtime.py plan engine: DAG, policy, approval, retries,
idempotency, checkpoints, resume, undo, budgets
├─ planner.py normalize / validate / toposort / preview / intents
├─ policy.py read / write / external / destructive → allow / ask / deny
├─ tools.py capabilities, risk tiers, undo recipes, sandbox exec
├─ tool_runner.py subprocess entry point for isolated tools
├─ sandbox.py macOS sandbox-exec profile for isolated tools
├─ ui.py loopback dashboard HTML
├─ memory.py facts, provenance, history, supersede, conflicts, extract
├─ ledger.py append-only events + hash-chained steps
├─ proactivity.py signals, candidates, interrupt budget, feedback
├─ connectors.py manifests, mock + Google providers, idempotent sync
├─ oauth.py OAuth2 + PKCE, loopback callback, encrypted tokens
├─ mcp.py JSON-RPC 2.0 stdio client + server registry
├─ mcp_server.py expose Daythread as an MCP stdio server
├─ models.py provider routing, cache, budgets, usage
├─ scheduler.py anchored ticks, notifications, maintenance
├─ backup.py checksummed, HMAC-signed backup/restore
├─ privacy.py per-subject export/forget and tombstone purge
├─ crypto.py optional AES-GCM/scrypt + encrypted secret vault
├─ sync.py passphrase-encrypted E2EE file sync + relay transport
├─ relay.py self-hosted opaque bundle relay
├─ bench.py Daythread Bench v0
└─ skills.py declarative, validated plans
└─ brief.py morning / evening briefs
└─ export.py JSON / Markdown export
└─ obs.py audit log, metrics, structured logging
└─ server.py local-only API: auth, rate limits, pagination
└─ migrations.py forward-only schema migrations (v4)
└─ errors.py domain errors with stable HTTP codes
The native shell lives in desktop/ (SwiftUI, macOS 13+) and the cross-platform
shell in desktop-tauri/ (Tauri v2). Both call dt from PATH; set
DAYTHREAD_BIN to override. Data lives in $DAYTHREAD_HOME/daythread.db
(default ~/.daythread).
Notes, drafts, sandbox files, backups, the API token, and the notification
outbox live under the same home. Nothing leaves the machine unless you
configure a remote model provider or MCP server.
Start the server and read the token:
dt serve --print-token
dt serve --port 8765Then:
curl -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8765/v1/today
curl -H "Authorization: Bearer $TOKEN" "http://127.0.0.1:8765/v1/facts?limit=20&offset=0"
curl -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"text":"hello"}' http://127.0.0.1:8765/v1/ask
curl http://127.0.0.1:8765/v1/openapi.jsonThe API includes request IDs (X-Request-Id), per-token rate limiting
(api.rate_limit_per_minute, default 120), pagination, and stable error codes.
- Confirm before external:
externalanddestructivedefault toask. Approving a plan is explicit and recorded. - Tamper-evident: every run step is SHA-256 chained over its canonical payload plus the previous hash.
- Idempotency: external/destructive steps refuse to resume after an uncertain outcome; local writes use deterministic IDs or overwrite semantics.
- Undo or mark irreversible: tools return an undo recipe or explicitly
declare
irreversible; multi-step undo runs in reverse and refuses if any step is irreversible. - Least authority: tools stay under
DAYTHREAD_HOME; shell execution is allowlisted, path-restricted, timeout-bounded, and approval-gated. - MCP: servers are explicitly registered, run without a shell, and tool
calls are
externalby default. - Local API:
127.0.0.1only, bearer token in a0600file, rate limited, no CORS. - Backups: checksummed, HMAC-signed, optional passphrase AES-GCM
encryption, versioned, and redact known secrets.
restore --trustis required when the master key is not present. - Taint:
taint=untrusted(external agent content, webhooks, email) forces approval for every non-read step even if the policy would auto-allow. - Runtime leases: only one executor can claim a run; leases expire and are released on completion/failure. External/MCP/connector/shell steps run in a subprocess and are killed by process group on timeout, including server worker threads. Local steps use a main-thread signal timeout; cancellation is checked between steps.
- Retention: old events, steps, audit, usage, messages, and connector items can be pruned; pending runs are always kept.
- Sensitivity:
secret/healthfacts are hidden from list/search/export/ MCP/briefs unless--include-sensitiveis passed. - API: Host allowlist, persistent rate limits, no internal error details.
- MCP: executable allowlist plus a scoped child environment.
- Secrets: encrypted with AES-GCM; the master key is
0600and never leaves the device.secret:references keep literals out of MCP configs. - E2EE sync: bundles are authenticated with AES-GCM; secrets are excluded from sync by design.
- OAuth: authorization-code + PKCE,
statevalidation, loopback-only callback, encrypted tokens, and refresh-on-expiry. Client secrets come fromenv:orsecret:references, never the command line. Google, Microsoft 365, Feishu, and Lark are supported. - Network egress: calls made through
daythread.netuse one guard whose address policy is deny-by-default;net.allow_private=1/net.allow_hostsare the explicit opt-in for LAN connectors, and link-local metadata (169.254.169.254) and carrier-grade NAT (100.64.0.0/10) stay denied even then.net.max_bytesandnet.max_header_bytesare budgets for one call, shared by every redirect hop (8 MiB and 64 KiB by default), so a call cannot multiply its allowance by redirecting;net.max_redirectsbounds the hops and both vetted addresses of a host are tried in turn when one refuses the connection. The remaining directurlopencall sites (models.py,oauth.py,sync.py,connectors.py) are migrated to the guard in#142 (c); until that lands this bullet describes the guard, not every call in the tree. - Model egress:
model.egress=local_onlyrejects non-local providers; retries use bounded exponential backoff; streaming is opt-in. - Webhooks: generic HMAC-SHA256, Microsoft
clientState+ validation handshake, Google channel token, and FeishuX-Lark-Signature; per-source encrypted secrets, rate limits, dedupe, and per-item signals. - Sync cursors: Google
syncTokenand MicrosoftdeltaLinkare persisted per connector;410/resync-required clears the cursor and does a full sync.dt connector resetclears it manually. - MCP resources: sensitive (
secret/health) facts are excluded and cannot be read by URI. - OS sandbox:
sandbox.backend=sandbox-execrestricts file writes to the Daythread home/temp and denies network forshell.run(macOS).sandbox.backend=dockerruns isolated tools in a read-only container with a home mount and configurable network;sandbox.backend=bwrapuses Linux namespaces with--unshare-netfor shell tools. - Dashboard: loopback-only, CSP-protected, and embeds the bearer token only
in the local page. Disable with
api.ui_enabled=0. - Release: SHA256SUMS + SBOM; the manifest includes the SBOM SHA256 and is
HMAC- or Ed25519-signed. The DSSE/in-toto attestation is verifiable with
scripts/attest.py --verify. - Native shells: the SwiftUI and Tauri apps invoke the local
dtCLI with the same permissions; review commands before use and keepdton a trusted path. - MCP server: read-only by default; write tools are hidden unless
--allow-writeis set; plans proposed by external agents require approval. - Connector actions are
externalby default: a run is created and must be approved before any event is created, moved, drafted, or sent. - Relay: stores only AES-GCM ciphertext, requires a bearer token, writes
0600files, enforces a body-size limit, supports TLS/certificates, DELETE, retention, and optional per-device tokens. Put it behind TLS for remote use.
See SECURITY.md for reporting and scope.
make test
# or
python3 -m unittest discover -s tests -vCoverage includes migrations, memory history/supersede/conflicts/extraction, planner validation/cycles, multi-step runtime, retries, resume, budgets, proactivity budgets/feedback, connectors, skills, model gateway (providers, cache, budgets, fallback), MCP stdio transport, scheduler ticks, backup/restore, the HTTP API (auth, pagination, rate limits, request IDs, OpenAPI), and CLI.
- Feishu sync tokens, provider-specific webhook verification, and webhook subscriptions.
- Rust daemon + Tauri desktop shell, ported from this reference.
- Expand Daythread Bench into a public, reproducible benchmark suite.
- Hosted deployment, observability backend, and compliance program.
- Linux/Docker sandboxing and cosign/SBOM attestations for releases.
The identity is built around a single thread from dawn to dusk: a warm
sunrise dot, a cool dusk dot, and one arc that connects them. The palette pairs
#FFB86B / #FF8E72 (dawn) with #7AA2FF / #B28CFF (dusk) on a deep navy
canvas. The same tokens drive the web dashboard, Tauri app, and SwiftUI shell.
Assets: assets/icon.svg, assets/logo.svg, assets/logo-mark.svg,
assets/AppIcon.icns; regenerate with make icons.
docs/CLI.md— command referencedocs/API.md— HTTP API, webhooks, errors, paginationdocs/COMPLIANCE.md— data inventory, DSAR, retention, SOC 2-style mapping, incident responsedocs/RELEASE.md— signing, attestation, sidecar, CIdocs/competitive/2026-11-27-auditable-reversible-execution.md— capability memo v1.1 (auditable reversible execution; competitor claims marked unverified)
See docs/COMPLIANCE.md for data inventory, DSAR,
retention, encryption, SOC 2-style control mapping, incident response, and
known gaps. It is a guide, not a certification.
Apache-2.0. See LICENSE.
