Docs/Reference/Desktop agent daemon

Desktop agent daemon

4 min read
On this page

A tiny daemon that runs on your laptop. Subscribes to your Dokwe workspace's error stream and, when new errors fire, invokes claude -p in the appropriate local repo so your Claude Code / Max subscription investigates and (optionally) opens a PR — no Anthropic API bill, no dokwe-side sandbox.

1. Prerequisites#

  • macOS ≥ 12 or Linux with systemd --user (Ubuntu 22.04+, Fedora, etc.)
  • Claude Code installed and logged in (claude --version works, claude runs interactively). The daemon shells out to your local claude binary using your Max / Pro subscription — it's not an API integration.
  • git on $PATH. Used to check for a dirty working tree before touching a project.
  • A Dokwe MCP token (dkm_…) minted at Dashboard → Errors tab → MCP tokens. Same token used for claude mcp add dokwe … — the daemon reuses it.

2. Install#

One-liner (published binaries — needs the deploy CI merged):

bash
curl -fsSL https://dokwe.com/install/desktop-agent | sh

Build from a local checkout of the monorepo:

bash
git clone git@github.com:FregateLab/zeroDeploy.git
cd zeroDeploy/apps/dokwe-desktop-agent
./install/install.sh --build-from-source

The dokwe repo is private, so a piped install can't git clone it — if you need to build from source, you clone locally first and run the install script from your checkout. --build-from-source needs Go on your machine.

The install script:

  1. Downloads (or builds) the binary → /usr/local/bin/dokwe-desktop-agent
  2. On macOS: installs ~/Library/LaunchAgents/com.dokwe.desktop-agent.plist, loads with launchctl
  3. On Linux: installs ~/.config/systemd/user/dokwe-desktop-agent.service, enables with systemctl --user
  4. Stubs out ~/.config/dokwe-desktop-agent/config.yaml (chmod 600) if missing
  5. Starts the service

After that, edit the config and restart:

bash
$EDITOR ~/.config/dokwe-desktop-agent/config.yaml

# macOS:
launchctl unload ~/Library/LaunchAgents/com.dokwe.desktop-agent.plist
launchctl load   ~/Library/LaunchAgents/com.dokwe.desktop-agent.plist

# Linux:
systemctl --user restart dokwe-desktop-agent

3. Config#

Two ways to manage the config — pick whichever fits.

Set up + iterate without ever opening the yaml file:

bash
# First-run interactive setup
dokwe-desktop-agent init

# Or piecewise
dokwe-desktop-agent auth dkm_...                           # set token
dokwe-desktop-agent link staffnet-saas /Users/you/code/staffnet
dokwe-desktop-agent link my-app      /Users/you/code/my-app
dokwe-desktop-agent set dry_run false                      # flip a bool
dokwe-desktop-agent set rate_limit_per_hour 20

# Check what's configured + service state
dokwe-desktop-agent list
dokwe-desktop-agent status
dokwe-desktop-agent logs -f

# Remove a mapping
dokwe-desktop-agent unlink my-app

Every mutating subcommand auto-restarts the service so the change takes effect immediately. Pass --no-restart if you're batching several edits and want to restart once at the end.

Full command reference: dokwe-desktop-agent help.

3b. Edit the yaml directly#

If you prefer text editing, the config lives at ~/.config/dokwe-desktop-agent/config.yaml with this shape:

yaml
endpoint: "https://dokwe.com"
token:    "dkm_..."

projects:
  staffnet-saas: "/Users/you/code/staffnet"
  my-app:      "/Users/you/code/my-app"

dry_run: true             # v1 default — flip after you trust it
rate_limit_per_hour: 10   # hard cap on real claude invocations
dedup_window_min: 60      # don't re-invoke on same fingerprint within N min

filters:
  environments: [production]
  levels: [error, fatal]

After hand-editing, run dokwe-desktop-agent restart (or the OS service command below) to load the changes. See config.example.yaml for the annotated version.

Note: CLI writes overwrite the file via yaml.Marshal, which drops hand-added comments. If you rely on comments, prefer 3b throughout; if you rely on convenience, prefer 3a.

4. Safety switches#

The daemon is opinionated about not surprising you:

SwitchDefaultWhat it does
dry_runtrueLogs "would invoke claude" and stops. First-run safety.
rate_limit_per_hour10Hard cap on real invocations per rolling hour, across all projects.
dedup_window_min60Don't re-invoke on the same fingerprint within N minutes. Regression storms → 1 claude session, not 50.
dirty-tree skipalways onNever invoke on a project whose working tree has uncommitted changes. Stash or commit to unblock.
filters.environments—Only events matching (default: no filter — but the config stub sets [production]).
filters.levels—Only events matching (default: no filter).

Claude is invoked with a prompt that instructs it to ack_issue on success but NOT to resolve_issue — resolution happens when the PR merges, manually. The daemon never marks issues resolved.

5. How events flow to Claude#

  1. An error is ingested at Dokwe (POST /api/ingest/errors/:id).

  2. If it's the first-ever event for that fingerprint on that project, dokwe emits error.event.new on its event bus.

  3. The DesktopAgentGateway fans it out to every connected desktop agent for the workspace.

  4. Your daemon receives the frame, runs filters + rate limit + dedup + dirty-tree check, resolves projectSlug → localPath, then:

    code
    cd <localPath> && claude -p "<prompt>"
  5. Claude uses the dokwe MCP tools you already set up (claude mcp add dokwe …) to fetch full error details, reads local source, proposes a fix, runs tests, commits on dokwe/<fingerprint-prefix>, opens a PR against origin/main.

  6. Claude calls dokwe.ack_issue so the dashboard shows someone is on it.

Regressions (error.regressed) follow the same flow with a slightly different prompt template noting the prior resolve + the deploy that likely broke it.

6. Logs#

macOS:

bash
tail -f ~/Library/Logs/dokwe-desktop-agent/agent.err.log

Linux:

bash
journalctl --user -u dokwe-desktop-agent -f

Every skip decision is logged:

code
[error.new] skip fp=95756def slug=staffnet-saas reason=dirty-tree at /Users/you/code/staffnet
[error.new] skip fp=95756def slug=my-app   reason=dedup (within 60m)
[error.new] skip fp=95756def slug=unknown    reason=no-local-clone (add to config.projects to enable)
[error.new] skip fp=95756def slug=staffnet-saas reason=rate-limit (10/hr cap)
[error.new] skip fp=95756def slug=staffnet-saas reason=filter env="staging" level="warning"

And every real (or dry-run) invocation:

code
[error.new] DRY-RUN fp=95756def slug=staffnet-saas path=/Users/you/code/staffnet cmd="claude -p '...'"
[error.new] INVOKE  fp=95756def slug=staffnet-saas path=/Users/you/code/staffnet
[error.new] INVOKE DONE fp=95756def slug=staffnet-saas

7. Uninstall#

bash
curl -fsSL https://dokwe.com/install/desktop-agent | sh -s -- --uninstall

Removes the binary and the OS service unit. Leaves ~/.config/dokwe- desktop-agent/config.yaml in place in case you want it back — delete manually if you don't.

8. Troubleshooting#

Daemon connects then drops after ~5 minutes. Fixed in the current API version (server sends WS pings every 30s). If still happening, your dokwe API is older than the pings PR — deploy main.

websocat-style smoke test works but daemon doesn't invoke claude. Almost always one of:

  • dry_run: true still set → daemon logs DRY-RUN, doesn't spawn.
  • Project slug not in config.projects → daemon logs skip … reason=no-local-clone.
  • Local repo has uncommitted changes → daemon logs skip … reason=dirty-tree.
  • Rate limit hit → daemon logs skip … reason=rate-limit.

Grep for skip fp= in the log — every skip decision names its reason.

claude not found. Either put claude on $PATH for the service's environment, or set an absolute path in config:

yaml
claude_command: "/opt/homebrew/bin/claude"

Restart takes forever after edit. Not a bug — the reconnect loop uses exponential backoff. New config takes effect on the next connect attempt (up to 60s).