@tnunamak/dalan 0.6.2 → 0.7.0

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +25 -68
  3. package/bin/dalan.mjs +9 -0
  4. package/bin/dot-worker.mjs +16 -2
  5. package/docs/chatgpt-worker-onboarding.md +10 -14
  6. package/docs/claude-worker-onboarding.md +9 -8
  7. package/docs/codex-to-muse.md +21 -35
  8. package/docs/connect-chatgpt.md +10 -16
  9. package/docs/dalan-upgrade.md +4 -2
  10. package/docs/local-agent-mcp.md +24 -4
  11. package/docs/manual-setup.md +2 -2
  12. package/docs/operations.md +10 -11
  13. package/docs/pull-workers.md +1 -2
  14. package/docs/service-setup.md +94 -170
  15. package/docs/setup-reference.md +5 -5
  16. package/docs/worker-clients.md +4 -4
  17. package/package.json +2 -3
  18. package/scripts/dalan-try-selfcheck.mjs +8 -7
  19. package/scripts/worker-bridge-setup.mjs +91 -81
  20. package/src/as-store.mjs +5 -3
  21. package/src/as.mjs +35 -26
  22. package/src/auth-check.mjs +53 -0
  23. package/src/cli-help.mjs +13 -14
  24. package/src/client-approval.mjs +57 -0
  25. package/src/client-convenience.mjs +166 -0
  26. package/src/client-conveniences.json +106 -0
  27. package/src/client-conveniences.schema.json +97 -0
  28. package/src/connect-cli.mjs +5 -5
  29. package/src/default-home.mjs +36 -0
  30. package/src/follow-current.mjs +25 -0
  31. package/src/gozar-routes.mjs +314 -0
  32. package/src/redirect-policy.mjs +61 -0
  33. package/src/route-setting.mjs +71 -12
  34. package/src/server.mjs +2 -0
  35. package/src/service-auto-update.mjs +8 -1
  36. package/src/service-launchd.mjs +166 -0
  37. package/src/service-update-runtime.mjs +40 -6
  38. package/src/service-update.mjs +20 -14
  39. package/src/service.mjs +175 -63
  40. package/src/setup.mjs +55 -44
  41. package/src/try-exposure.mjs +7 -657
  42. package/src/try-hosted.mjs +71 -101
  43. package/src/try-selfcheck.mjs +15 -8
  44. package/src/try.mjs +9 -13
  45. package/scripts/lib/expose-tailscale.mjs +0 -408
  46. package/src/try-hosted-clients.mjs +0 -46
@@ -1,18 +1,21 @@
1
1
  # Connect ChatGPT as a Dalan worker
2
2
 
3
- This guide takes you from a built-in OAuth connection to one completed job. Use ChatGPT on the web with custom MCP connections enabled for your account or workspace; UI labels can vary. The owner runs Dalan and approves the connection; the ChatGPT user connects the worker and starts its run. One person can perform both roles.
3
+ This guide takes you from a built-in OAuth connection to one completed job. Dalan accepts any MCP client that supports OAuth with Dynamic Client Registration (DCR) and PKCE; ChatGPT is one example, and the steps below are optional conveniences for it. The owner runs Dalan and approves the connection by matching a code; the ChatGPT user connects the worker and starts its run. One person can perform both roles. Use ChatGPT on the web with custom MCP connections enabled for your account or workspace; UI labels can vary.
4
+
5
+ A client you have not listed here follows the same flow: give it the complete MCP URL, let it register itself, then compare the code and redirect in the pending attempt before you approve. Dalan shows a curated name and icon only when the redirect's exact HTTPS origin is a known one, such as `https://chatgpt.com`. That label is a convenience, not proof of who is connecting, and it never decides whether you may approve.
4
6
 
5
7
  **Just trying it?** Follow the [README hosted trial](../README.md#quickstart). It prints the connector URL and steps for a short hosted demo, then returns the agent's report to your terminal. The rest of this guide sets up a permanent bridge.
6
8
 
7
9
  ## Owner setup
8
10
 
9
- 1. Follow the [service setup](service-setup.md) with a publicly reachable HTTPS origin. Set `DALAN_HOME` to that service's private home and make `dalan` available on your PATH with the [manual setup](manual-setup.md#owner-and-requester-setup) steps. Use the service's worker name wherever this guide says `NAME`.
11
+ 1. Follow the [service setup](service-setup.md): `dalan service install --worker NAME --route tailscale` creates the public HTTPS address. Use the service's worker name wherever this guide says `NAME`.
10
12
 
11
13
  ```sh
12
- dalan status --json
14
+ dalan status
15
+ dalan doctor --auth
13
16
  ```
14
17
 
15
- Status shows the running bridge. Read the complete MCP URL from the private `$DALAN_HOME/resource-url` file. It has the form `https://HOST/<secret>/mcp`; enter the actual URL only in connector setup. A localhost URL cannot reach the bridge from ChatGPT's servers.
18
+ Status shows the running bridge. Read the complete MCP URL from the private connector URL file that install printed. It has the form `https://HOST/<secret>/mcp`; enter the actual URL only in connector setup. A localhost URL cannot reach the bridge from ChatGPT's servers.
16
19
 
17
20
  2. Open a pairing window for that worker.
18
21
 
@@ -20,16 +23,7 @@ This guide takes you from a built-in OAuth connection to one completed job. Use
20
23
  dalan connect start --worker NAME
21
24
  ```
22
25
 
23
- The response shows an open window for `NAME`; the default is ten minutes. Fresh init already allows `https://chatgpt.com/connector_platform_oauth_redirect` and the callback-ID form `https://chatgpt.com/connector/oauth/*`. An existing installation retains its saved allowlist. If its attempt uses the exact callback observed below and that callback is absent, add it before retrying.
24
-
25
- ```sh
26
- printf 'Exact ChatGPT callback shown for this connection: '
27
- IFS= read -r CALLBACK_URL
28
- dalan connect allow-callback "$CALLBACK_URL"
29
- unset CALLBACK_URL
30
- ```
31
-
32
- Compare the complete value with ChatGPT's displayed redirect before running the command. Add only that verified callback, then restart the connection flow.
26
+ The response shows an open window for `NAME`; the default is ten minutes. No callback list is needed: ChatGPT registers itself, and you compare its redirect when you approve.
33
27
 
34
28
  ## ChatGPT user setup
35
29
 
@@ -43,7 +37,7 @@ This guide takes you from a built-in OAuth connection to one completed job. Use
43
37
  dalan connect pending
44
38
  ```
45
39
 
46
- Match the code on the browser page, worker `NAME`, resource, client ID, callback and requested scopes. The client name is untrusted text. Compare the callback with the exact redirect shown by ChatGPT for this connection; it may be the stable redirect or a callback-ID-specific redirect described in [Resolve the exact callback](chatgpt-worker-onboarding.md#2-resolve-the-exact-callback-before-registration). If attempts are ambiguous or a value differs unexpectedly, resolve that before approval.
40
+ Match the code on the browser page, worker `NAME`, resource, client ID, redirect and requested scopes. The client name is untrusted text; a curated ChatGPT label appears only for an exact `https://chatgpt.com` redirect and does not replace the code match. ChatGPT may use the stable redirect or a callback-ID-specific redirect described in [Check the redirect](chatgpt-worker-onboarding.md#2-check-the-redirect-before-approval). If attempts are ambiguous or a value differs unexpectedly, resolve that before approval.
47
41
 
48
42
  ```sh
49
43
  dalan connect approve CODE --worker NAME
@@ -78,6 +72,6 @@ If ChatGPT says “Couldn't discover OAuth settings” or “Some app settings w
78
72
 
79
73
  HTTP 421 means the incoming Host does not match the configured public origin, including any non-default port. Preserve Host through the proxy; forwarding a different `X-Forwarded-Host` does not fix it. See [network setup](service-setup.md).
80
74
 
81
- If the pairing window expired, open it again with `dalan connect start --worker NAME`, restart connection in ChatGPT and compare the new code with pending attempts. If registration reports an unallowed callback, compare its exact scheme, host and path with the expected ChatGPT redirect before adding it. Public discovery probes do not prove browser approval, token exchange or authenticated MCP calls work.
75
+ If the pairing window expired, open it again with `dalan connect start --worker NAME`, restart connection in ChatGPT and compare the new code with pending attempts. If registration is refused, read the reason, then compare the redirect's exact scheme, host and path with what ChatGPT shows for this connection. Public discovery probes do not prove browser approval, token exchange or authenticated MCP calls work.
82
76
 
83
77
  This guide covers ChatGPT on the web; set up a mobile browser separately. Repeat the first job after you reconnect or change endpoint settings, and configure [wake hooks or schedules](pull-workers.md) only after manual jobs work.
@@ -1,5 +1,7 @@
1
1
  # Upgrade to Dalan
2
2
 
3
+ A service made by `dalan service install` updates itself and through `dalan service update`; see [service updates](service-setup.md#service-updates). This guide covers services and checkouts that earlier releases set up, and the ordered steps for a manual upgrade.
4
+
3
5
  `dalan` is the main command. The package also installs `dalan-worker`, `dalan-acp-agent`, `dalan-alert`, `dalan-deadman`, `dalan-heartbeat` and `dalan-pr-reviewer`. It does not install the commands of the `dot-bridge` package; change scripts, units and timers that run `dot-worker`, `dot-deadman`, `dot-heartbeat`, `dot-alert`, `dot-acp-agent` or `dot-pr-reviewer` to the `dalan` or `dalan-*` command. `DALAN_X` takes precedence over `DOT_BRIDGE_X`, including an explicitly empty value except `AUTH_MODE`; an empty `DALAN_AUTH_MODE` falls back to a non-empty legacy auth mode, or stays unset if neither supplies one; an actual legacy fallback emits at most one warning from the main thread in each process. The `DOT_ACP_*` and `DOT_DRAINED_*` adapter settings keep their existing names.
4
6
 
5
7
  ## Pre-upgrade checklist
@@ -10,7 +12,7 @@ Upgrade in this order: drain built-in-auth claims while the old service runs; st
10
12
 
11
13
  **Run a command in the service's environment.** A generated service sets `HOME` (the bridge home), `NODE_ENV=production`, `DALAN_AUTH_MODE=builtin`, `DALAN_BIND_HOST=127.0.0.1`, `DALAN_GOZAR_SERVICE=1`, `DALAN_CATALOG_PROFILE=stable`, `DALAN_ENABLE_WORKSPACE` (`1` when repository tools are on, otherwise `0`), `DALAN_ENABLE_T3_TOOLS` (`1` or `0`), `DALAN_PORT` and `PATH`. Read them, then run each command with those values in front of that one command. Do not `export` them or change `HOME` in your shell: `launchctl` and `systemctl --user` need your own `HOME`.
12
14
 
13
- Your shell can carry more than the service has. The README tells you to `export DALAN_HOME=...` and `DALAN_LOOPBACK=1` for a trial, and `dalan` makes `DALAN_HOME` win over the `HOME` you pass, so an inherited `DALAN_HOME` points every command at the trial, not at the service. `env -u NAME` removes a variable from one command. List the `DALAN_` and `DOT_BRIDGE_` names your shell exports, and remove each one that the service does not set:
15
+ Your shell can carry more than the service has. A trial or a hand-started bridge has you `export DALAN_HOME=...` and `DALAN_LOOPBACK=1`, and `dalan` makes `DALAN_HOME` win over the `HOME` you pass, so an inherited `DALAN_HOME` points every command at the trial, not at the service. `env -u NAME` removes a variable from one command. List the `DALAN_` and `DOT_BRIDGE_` names your shell exports, and remove each one that the service does not set:
14
16
 
15
17
  ```sh
16
18
  env | grep -E '^(DALAN|DOT_BRIDGE)_' | cut -d= -f1
@@ -122,7 +124,7 @@ Before replacing or relinking the old checkout, use `node "$HOME/dalan-drain/bin
122
124
  - macOS: step 1 unloaded the agent, so load it first: `launchctl bootstrap user/$(id -u) ~/Library/LaunchAgents/LABEL.plist`, then `launchctl kickstart -k user/$(id -u)/LABEL`, then `launchctl print user/$(id -u)/LABEL | grep -E 'state|runs'` must show `state = running`. `kickstart` alone fails with exit 113 after `bootout`, because the service is no longer loaded. Keep the `kickstart` after the `bootstrap`: a plist generated by an older release can load with `state = not running` and never start until it is kicked.
123
125
  5. Check the log shows `MCP listening`, run the schema check from [Confirm the schema](#pre-upgrade-checklist) (it must print `66`), then finish a [first-job smoke check](operations.md#smoke-check-an-installed-service).
124
126
 
125
- The upgrade does not rewrite the service that an older release generated. That service keeps its unit or plist name (on macOS, the launchd label that release created), its `DOT_BRIDGE_*` environment names and its `~/.config/dot-bridge`, `~/.local/share/dot-bridge` and `~/.local/state/dot-bridge` directories. It works as it did, and each start logs one deprecation line for the old environment names. `worker-bridge-setup.mjs --remove` finds only the current label. Stop an agent of a release before 0.4.0 and delete its plist by hand before you remove the install; `--purge-home` refuses while another unit file in the user's unit directory names the home or a process holds its `bridge.db` open, and it names what it found. Do not run `worker-bridge-setup.mjs` again for the same worker to "refresh" it: it refuses to overwrite an existing unit.
127
+ The upgrade does not rewrite the service that an older release generated. That service keeps its unit or plist name (on macOS, the launchd label that release created), its `DOT_BRIDGE_*` environment names and its `~/.config/dot-bridge`, `~/.local/share/dot-bridge` and `~/.local/state/dot-bridge` directories. It works as it did, and each start logs one deprecation line for the old environment names. `worker-bridge-setup.mjs --remove` finds only the current label. Stop an agent of a release before 0.4.0 and delete its plist by hand before you remove the install; do not delete a home while another unit file in the user's unit directory names it or a process holds its `bridge.db` open. Do not run `worker-bridge-setup.mjs` again for the same worker to "refresh" it: it refuses to overwrite an existing unit.
126
128
 
127
129
  ## Existing homes and explicit path migration
128
130
 
@@ -15,16 +15,34 @@ Each tool runs the matching `dalan` command with `--json`, so receipts, assignme
15
15
 
16
16
  ## Access
17
17
 
18
- The server has the access of the user who starts it: it reaches the bridge through the local admin socket, as the CLI does. It opens no network port and has no separate credential. Do not run it for someone you would not give `dalan` to. Set `DALAN_HOME` explicitly in this MCP server's environment to the exact home of the running bridge. Use the Home line that the running trial printed. A local `dalan try` prints `$HOME/.local/share/dalan-trial`. A public trial prints `$HOME/.local/share/dalan-hosted-<client>` on a usable Tailscale route, or `$HOME/.local/share/dalan-hosted-<random hex>` on a relay. The trial home is not the CLI's normal default, and `dalan mcp` does not stop to ask which home you meant.
18
+ The server has the access of the user who starts it: it reaches the bridge through the local admin socket, as the CLI does. It opens no network port and has no separate credential. Do not run it for someone you would not give `dalan` to. For a service made by `dalan service install`, `dalan mcp` finds the remembered service home, so you set nothing. For a `dalan try` bridge or a bridge you started by hand, set `DALAN_HOME` in this MCP server's environment to the exact home of the running bridge, using the Home line that the running trial printed. A local `dalan try` prints `$HOME/.local/share/dalan-trial`; a public trial prints its own home. A trial home is not the CLI's normal default, and `dalan mcp` does not stop to ask which home you meant.
19
19
 
20
20
  ## Claude Code
21
21
 
22
- This example uses the home of a local `dalan try`. For a public trial, replace it with the Home line your running bridge printed, and replace `/path/to/dalan` as described below.
22
+ For a service made by `dalan service install`:
23
23
 
24
24
  ```sh
25
- claude mcp add dalan --env DALAN_HOME="$HOME/.local/share/dalan-trial" -- /path/to/dalan mcp
25
+ claude mcp add --scope user dalan -- "$(command -v dalan)" mcp
26
26
  ```
27
27
 
28
+ For a `dalan try` bridge, add its home as an override. This example uses the home of a local `dalan try`; for a public trial, use the Home line your running bridge printed:
29
+
30
+ ```sh
31
+ claude mcp add --scope user dalan --env DALAN_HOME="$HOME/.local/share/dalan-trial" -- "$(command -v dalan)" mcp
32
+ ```
33
+
34
+ Keep `--scope user`. Without it, Claude Code registers the server for the current project only, and a session in another directory does not see it. `dalan mcp` needs Node 24 or newer (`node --version`).
35
+
36
+ ## After a pairing that stopped part way
37
+
38
+ If a client stopped during pairing (a crash, a closed window), the worker name already has an active connection, and approving the retry fails with "already has an active connection". Approve the new code with `--replace`:
39
+
40
+ ```sh
41
+ dalan connect approve CODE --worker W --replace
42
+ ```
43
+
44
+ `--replace` ends the old connection for worker `W`. The new connection receives every queued and future job for `W`, including briefs you approved before the switch. Use it only for a code you started yourself.
45
+
28
46
  ## Codex
29
47
 
30
48
  Add this to `~/.codex/config.toml`:
@@ -36,6 +54,8 @@ args = ["mcp"]
36
54
  env = { DALAN_HOME = "/absolute/path/to/the-running-bridge-home" }
37
55
  ```
38
56
 
57
+ Omit the `env` line for a service made by `dalan service install`.
58
+
39
59
  Replace `/path/to/dalan` with the output of `command -v dalan`, or with `node /path/to/dalan/bin/dalan.mjs` split into `command = "node"` and `args = ["/path/to/dalan/bin/dalan.mjs", "mcp"]`.
40
60
 
41
- Use an absolute home path in the TOML; do not leave `$HOME` or `~` in it. Start a new client session and ask it to call `dalan_status`. Check that the returned status belongs to your running bridge before submitting a job. If the call cannot connect, verify the configured home and run `dalan status --json` in a shell using that same `DALAN_HOME`. For a complete submit-and-result example, follow [Send one small job and read the result](codex-to-muse.md#4-send-one-small-job-and-read-the-result), using your connected worker's name.
61
+ Use an absolute home path in the TOML; do not leave `$HOME` or `~` in it. Start a new client session and ask it to call `dalan_status`. Check that the returned status belongs to your running bridge before submitting a job. If the call cannot connect, verify the configured home and run `dalan status --json` in a shell that selects the same home. For a complete submit-and-result example, follow [Send one small job and read the result](codex-to-muse.md#4-send-one-small-job-and-read-the-result), using your connected worker's name.
@@ -4,7 +4,7 @@
4
4
 
5
5
  `try` runs ordinary `dalan` commands in a private trial home. Use this page to run each piece yourself: to keep the bridge in the foreground, to choose your own worker name, or to set up a client that `try` does not cover. You need the npm package, two shells and a compatible HTTP MCP worker client with OAuth. This page explicitly installs the CLI globally before using bare `dalan` commands; `npx` alone does not put it on your persistent PATH.
6
6
 
7
- For a hosted first result instead, use `npx -y @tnunamak/dalan try` ([hosted trial](../README.md#quickstart)). In `auto` mode, a saved temporary-relay choice selects bundled Gozar. Otherwise Dalan uses a usable Tailscale route, then Gozar if Tailscale is unavailable. When Gozar is selected, Dalan names tunnl.gg, links its terms and privacy notice, and asks for consent before exposure. Gozar then creates an installation-owned key for the `tunnl-gg` relay; Dalan does not pass your SSH keys. The relay terminates TLS and can see the connector URL and traffic. Keep private work out of the demo. A temporary demo link can change or stop without warning; the three-hour trial limit is not an availability promise. Use `--route tailscale` to require Tailscale without a relay fallback. The loopback recipe below creates no public route.
7
+ For a hosted first result instead, use `npx -y @tnunamak/dalan try` ([hosted trial](../README.md#quickstart)). Dalan asks Gozar for a public HTTPS route and asks for consent before exposure; some routes are temporary and some route operators can read the connector URL and traffic. Keep private work out of the demo. A temporary demo link can change or stop without warning; the three-hour trial limit is not an availability promise. For a bridge that keeps running, use `dalan service install` ([service setup](service-setup.md)); it needs no `DALAN_HOME`. The loopback recipe below creates no public route and uses its own home, so it sets `DALAN_HOME` as an override.
8
8
 
9
9
  <a id="owner-and-requester-setup"></a>
10
10
 
@@ -20,7 +20,7 @@ For a hosted first result instead, use `npx -y @tnunamak/dalan try` ([hosted tri
20
20
 
21
21
  **Check:** Node prints `v24` or higher, and npm finishes without an error. The server in step 3 starts Node with a changed `HOME`, so use a Node executable that works then; a version-manager shim can depend on your usual home directory.
22
22
 
23
- 2. Choose a new, private bridge home. It must not exist yet and must not be a `try` home (`init` refuses an existing profile). Export it in every shell that you use, including the server shell; `dalan` reads it as the bridge's home. Keep paths short and free of spaces.
23
+ 2. Choose a new, private bridge home. It must not exist yet and must not be a `try` home (`init` refuses an existing profile). Export it in every shell that you use, including the server shell; `DALAN_HOME` overrides the remembered service home, and `dalan` reads it as this bridge's home. Keep paths short and free of spaces.
24
24
 
25
25
  ```sh
26
26
  export DALAN_HOME="$HOME/.local/share/dalan-manual-trial"
@@ -123,7 +123,7 @@ JS
123
123
 
124
124
  The [first-job walkthrough](../README.md#quickstart) starts with `inputs: []`, `execution_scope: "read-only"`, and explicit `--worker NAME --execution none --deliver none`. It works without a repository grant or host checks. Follow it with receipt-based recovery before a separate repository assignment: `dalan worker allow NAME OWNER/REPO`, then `dalan worker list NAME --json` to verify exact authority. Basic macOS delegation stays on `none`; Linux host checks are an optional, separately admitted branch with the prerequisites below.
125
125
 
126
- Generated setup cleanup is not an exposure-only toggle: `worker-bridge-setup.mjs --worker NAME --home HOME_PATH --remove` (the worker and home used at install; the recorded exposure is looked up in that home) stops/removes its generated services and recorded exposure. It retains the private home unless `--purge-home` is explicitly requested. For ngrok, the separately installed ngrok service still needs the printed stop/uninstall commands; do not infer that those commands ran.
126
+ `dalan service uninstall` stops and removes the service and its update timer; it moves the private home aside to `<home>.removed-<date>` and never deletes it. See [Remove an installation](#remove-an-installation).
127
127
 
128
128
  See the [requester reference](usage.md) for the assignment sequence and [T3 and orchestration integration](t3-integration.md) for the owner thread. The local requester CLI uses a mode 0600 Unix socket at `<home>/.local/share/dalan/admin.sock`. It writes a mode 0600 receipt with a per-request owner capability before submit; the server stores only its hash. Retry the same `request_id`, payload and destination after a lost response. `get` and `cancel` require that receipt. Pause, resume, reconcile and adoption require the separate mode 0600 operator key at `<config>/dalan/operator.key`. Same-UID processes can still read these files; they are not distinct human identities.
129
129
 
@@ -331,7 +331,7 @@ This build refuses startup when `bridge.db` has a SQLite `user_version` above 66
331
331
 
332
332
  ### Restart a service and check its state
333
333
 
334
- Linux (systemd user manager). For `dalan service install`, replace `UNIT.service` with the exact unit printed by install, such as `dalan-<10 hex>.service`. The legacy `scripts/worker-bridge-setup.mjs` uses `dot-bridge-NAME.service`:
334
+ `dalan service status` shows the state of the service that `dalan service install` made, on Linux and macOS. For the service manager itself, use the commands below. On Linux (systemd user manager), replace `UNIT.service` with the exact unit printed by install, such as `dalan-<10 hex>.service`. A service from an earlier release's setup script uses `dot-bridge-NAME.service`:
335
335
 
336
336
  ```sh
337
337
  systemctl --user restart UNIT.service
@@ -339,7 +339,7 @@ systemctl --user is-active UNIT.service
339
339
  journalctl --user -u UNIT.service -n 20
340
340
  ```
341
341
 
342
- macOS (launchd; the Linux-only `dalan service install` does not apply). These commands are for the legacy `scripts/worker-bridge-setup.mjs`. `LABEL` is `org.dalan.dot-bridge-NAME`, or the label of the older release when it generated the service (find the file with `ls ~/Library/LaunchAgents | grep dot-bridge`):
342
+ macOS (launchd). `LABEL` is the label that install printed. For a service from an earlier release's setup script it is `org.dalan.dot-bridge-NAME`, or the label of the older release when it generated the service (find the file with `ls ~/Library/LaunchAgents | grep dot-bridge`):
343
343
 
344
344
  ```sh
345
345
  launchctl kickstart -k user/$(id -u)/LABEL
@@ -357,15 +357,15 @@ launchctl kickstart -k user/$(id -u)/LABEL
357
357
 
358
358
  The generated agent has `KeepAlive`, so launchd starts the bridge again after it exits or is killed. launchd waits about 10 seconds between starts of one agent.
359
359
 
360
- Setup loads the agent into the `user/UID` launchd domain. Earlier releases loaded it into `gui/UID`, and a `gui/UID` domain whose desktop session is idle or locked can be in on-demand-only mode: launchd then neither starts the agent at load nor restarts it after `kill -9`, and `launchctl print` shows `pended nondemand spawn = inefficient`. If your service was set up by an older release, run `worker-bridge-setup.mjs --repoint --worker NAME` (it adds the session types the user domain needs), stop the old agent with `launchctl bootout gui/$(id -u) PLIST`, and load it with the two commands above. `launchctl bootout` takes `gui/$(id -u)` instead of `user/$(id -u)` for an agent that is still loaded in the GUI domain.
360
+ Setup loads the agent into the `user/UID` launchd domain. Earlier releases loaded it into `gui/UID`, and a `gui/UID` domain whose desktop session is idle or locked can be in on-demand-only mode: launchd then neither starts the agent at load nor restarts it after `kill -9`, and `launchctl print` shows `pended nondemand spawn = inefficient`. If your service was set up by an older release, follow the repoint step in the [upgrade guide](dalan-upgrade.md) (it adds the session types the user domain needs), stop the old agent with `launchctl bootout gui/$(id -u) PLIST`, and load it with the two commands above. `launchctl bootout` takes `gui/$(id -u)` instead of `user/$(id -u)` for an agent that is still loaded in the GUI domain.
361
361
 
362
362
  ### Smoke check an installed service
363
363
 
364
- `dalan doctor` is a local check; it does not prove that a worker can finish a job. After setup, a restart or an upgrade, run these with `DALAN_HOME` set to the service's home:
364
+ `dalan doctor` is a local check; it does not prove that a worker can finish a job. After setup, a restart or an upgrade, run these:
365
365
 
366
- 1. `dalan status --json` exits 0 and shows the queue and worker state.
366
+ 1. `dalan status --json` exits 0 and shows the queue and worker state. `dalan doctor --auth` passes the OAuth self-check against the public URL.
367
367
  2. Confirm that the log shows `MCP listening` on the bind address and port configured for this service. Generated built-in-auth services use `127.0.0.1:PORT`; an external-OAuth service behind an HTTPS reverse proxy may use its explicitly configured non-loopback address.
368
- 3. Connect the worker's client as in [worker pairing](manual-setup.md#worker-setup), using the service's HTTPS URL from `$DALAN_HOME/resource-url`. The `try` command does not run against an existing service, and a plain loopback URL is not accepted outside loopback mode.
368
+ 3. Connect the worker's client as in [worker pairing](manual-setup.md#worker-setup), using the service's HTTPS URL from the private `resource-url` file in the service home. The `try` command does not run against an existing service, and a plain loopback URL is not accepted outside loopback mode.
369
369
  4. Submit the repository-free job from [the manual setup](manual-setup.md#submit-finish-and-read-the-result) with `dalan submit --worker NAME --execution none --deliver none --file first-job.json --json`, prompt the worker, then run `dalan wait REQUEST_ID` and `dalan decide REQUEST_ID accepted`. The job must reach `finished`.
370
370
 
371
371
  Restart the service once more and run `dalan get REQUEST_ID`: the job must still be `finished`.
@@ -376,13 +376,12 @@ Remove only what you created. An install can leave these behind:
376
376
 
377
377
  | What | How to remove |
378
378
  |---|---|
379
- | Generated service (systemd unit or launchd plist, and any recorded exposure) | `node scripts/worker-bridge-setup.mjs --remove --worker NAME --home HOME_PATH`. It finds only a service generated under the current names. Stop an agent of a release before 0.4.0 and delete its plist by hand first (`ls ~/Library/LaunchAgents | grep dot-bridge`). |
380
- | Bridge home: database, keys, receipts, artifacts | Add `--purge-home` to the command above, or delete `HOME_PATH` yourself. This destroys private keys and job history. `--purge-home` refuses, and names what it found, while another unit file in the user's unit directory (`~/.config/systemd/user` or `~/Library/LaunchAgents`) names `HOME_PATH`, or while a process holds the home's `bridge.db` open; stop that service first. |
379
+ | Service (systemd unit or launchd agent, update timer and public route) | `dalan service uninstall`. For a service from an earlier release's setup script, see the [upgrade guide](dalan-upgrade.md); an agent of a release before 0.4.0 needs its plist deleted by hand first (`ls ~/Library/LaunchAgents | grep dot-bridge`). |
380
+ | Bridge home: database, keys, receipts, artifacts | Run `dalan service uninstall`, then delete the directory it moved aside (`~/.local/share/dalan-service.removed-<date>` by default). This destroys private keys and job history. Delete it only after no other unit file in the user's unit directory (`~/.config/systemd/user` or `~/Library/LaunchAgents`) names that home and no process holds the home's `bridge.db` open. |
381
381
  | Trial home (`dalan try` keeps it) | Delete `<HOME>/.local/share/dalan-trial` (or the directory given to `try --home`). |
382
382
  | Worker-client registration | `codex mcp remove NAME` or `claude mcp remove --scope user NAME`, with the name you registered (`local` for `try`). Then open the Codex `config.toml` (`$CODEX_HOME/config.toml` if `CODEX_HOME` is set, otherwise `~/.codex/config.toml`) and remove any `[mcp_servers.NAME.tools.*]` tables you added. `codex mcp remove` may already have removed them. |
383
383
  | The `dalan` command | Installed with `npm install -g @tnunamak/dalan`: run `npm uninstall -g @tnunamak/dalan`. Linked from a checkout with `npm link`: run `npm unlink -g @tnunamak/dalan`, then delete the checkout. Started with `npx @tnunamak/dalan try`: npx leaves a copy in its cache. To find only Dalan's entry, run `grep -l '"@tnunamak/dalan"' ~/.npm/_npx/*/package.json`; delete the directory that holds each file it lists, after you check its contents. Do not delete all of `~/.npm/_npx` or run `npm cache clean --force` unless you accept losing the cached copies of other packages too; both are optional. |
384
384
  | Upgrade staging install | The [npm upgrade](dalan-upgrade.md#upgrade-an-npm-install) installs a second copy of Dalan and its dependencies in `$HOME/dalan-new` (or the directory you gave to `npm install --prefix`) for the drain. First check that no service runs code from it. Linux: `grep -Rl dalan-new ~/.config/systemd/user`. macOS: `grep -RSl dalan-new ~/Library/LaunchAgents`. `grep` exits 1 and prints nothing when it finds none; any other exit status, or any error message, means the check failed, so do not delete anything until you fix it. Then delete that one directory, `rm -rf "$HOME/dalan-new"`. It holds no bridge home. Do not delete other npm installs. |
385
- | ngrok service (only with `--expose ngrok`) | If you installed ngrok's system service with the commands setup printed, run `ngrok service stop`, then `ngrok service uninstall`. `--remove` does not run them. |
386
385
  | Setup lock file | `/tmp/dot-bridge-setup-locks-UID/install.lock` is an empty file that setup creates and never deletes. It holds no data; delete it if you want nothing left. |
387
386
  | Older installs | Directories named `dot-bridge` under `~/.config`, `~/.local/share` and `~/.local/state`, if the install predates the rename. |
388
387
 
@@ -616,7 +615,7 @@ The bridge fetches repositories for workspace tools with the GitHub credential o
616
615
 
617
616
  ### Service GitHub access
618
617
 
619
- The shell login used to clone this repository does not authenticate the generated service. The service runs with its own `HOME` and `PATH`; Git askpass calls `gh auth token` inside that environment. Give the service a separate GitHub CLI login in the private home selected by `worker-bridge-setup`. The setup script does not copy a caller's token.
618
+ The shell login used to clone this repository does not authenticate the generated service. The service runs with its own `HOME` and `PATH`; Git askpass calls `gh auth token` inside that environment. Give the service a separate GitHub CLI login in the private home selected by the install (the service home). Install does not copy a caller's token.
620
619
 
621
620
  Run the following as the same Unix user who runs the bridge.
622
621
 
@@ -76,8 +76,7 @@ Maintainer check: from a source checkout installed with `npm ci`, run `node scri
76
76
 
77
77
  ### Poll interval and URL secrecy
78
78
 
79
- - Tailscale Funnel, Cloudflare tunnel or your own proxy: every 60 seconds.
80
- - ngrok: every 300 seconds. The free plan has a monthly request quota, and a 60-second hook uses up much of it. `signal-token` prints the advised interval on stderr.
79
+ - Poll every 60 seconds. The bridge's rate limit (below) allows that interval.
81
80
  - Anyone with the URL can learn whether work is waiting, and nothing more. Store it like a password; if it leaks, run `--rotate` and update the hook.
82
81
  - The bridge limits each source address to about one request every 5 seconds (burst 3), and the whole bridge to 30 per minute. Excess requests get `429` with `Retry-After`. Behind a tunnel, every caller shares one bucket, so keep to the intervals above.
83
82