@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.
- package/CHANGELOG.md +23 -0
- package/README.md +25 -68
- package/bin/dalan.mjs +9 -0
- package/bin/dot-worker.mjs +16 -2
- package/docs/chatgpt-worker-onboarding.md +10 -14
- package/docs/claude-worker-onboarding.md +9 -8
- package/docs/codex-to-muse.md +21 -35
- package/docs/connect-chatgpt.md +10 -16
- package/docs/dalan-upgrade.md +4 -2
- package/docs/local-agent-mcp.md +24 -4
- package/docs/manual-setup.md +2 -2
- package/docs/operations.md +10 -11
- package/docs/pull-workers.md +1 -2
- package/docs/service-setup.md +94 -170
- package/docs/setup-reference.md +5 -5
- package/docs/worker-clients.md +4 -4
- package/package.json +2 -3
- package/scripts/dalan-try-selfcheck.mjs +8 -7
- package/scripts/worker-bridge-setup.mjs +91 -81
- package/src/as-store.mjs +5 -3
- package/src/as.mjs +35 -26
- package/src/auth-check.mjs +53 -0
- package/src/cli-help.mjs +13 -14
- package/src/client-approval.mjs +57 -0
- package/src/client-convenience.mjs +166 -0
- package/src/client-conveniences.json +106 -0
- package/src/client-conveniences.schema.json +97 -0
- package/src/connect-cli.mjs +5 -5
- package/src/default-home.mjs +36 -0
- package/src/follow-current.mjs +25 -0
- package/src/gozar-routes.mjs +314 -0
- package/src/redirect-policy.mjs +61 -0
- package/src/route-setting.mjs +71 -12
- package/src/server.mjs +2 -0
- package/src/service-auto-update.mjs +8 -1
- package/src/service-launchd.mjs +166 -0
- package/src/service-update-runtime.mjs +40 -6
- package/src/service-update.mjs +20 -14
- package/src/service.mjs +175 -63
- package/src/setup.mjs +55 -44
- package/src/try-exposure.mjs +7 -657
- package/src/try-hosted.mjs +71 -101
- package/src/try-selfcheck.mjs +15 -8
- package/src/try.mjs +9 -13
- package/scripts/lib/expose-tailscale.mjs +0 -408
- package/src/try-hosted-clients.mjs +0 -46
package/docs/service-setup.md
CHANGED
|
@@ -1,249 +1,173 @@
|
|
|
1
1
|
# Run Dalan as a service
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Install Dalan once to keep your MCP agent connected to your Mac or Linux computer. You do not need to run the trial first.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Before you begin, install Node.js 24 or newer and Tailscale with Funnel enabled. Your agent's account must allow custom MCP connectors. The commands below are the same on macOS and Linux.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Tailscale prerequisite.** `--route tailscale` publishes through Tailscale Funnel, which your tailnet administrator must allow (a `funnel` entry in the tailnet access controls; HTTPS and MagicDNS must be on too). If Funnel is not allowed, Dalan stops before it publishes anything and tells you which setup step is missing, or prints Tailscale's own refusal. Enable Funnel once at <https://tailscale.com/kb/1223/funnel>, then run the command again. Other routes need no Tailscale setting; `dalan setup` lists them.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
<a id="owner-setup"></a>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Install and connect your agent
|
|
12
|
+
|
|
13
|
+
This example names your worker `assistant`. Choose another lowercase name if you prefer, and use it in every command.
|
|
12
14
|
|
|
13
15
|
```sh
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
--source "$HOME/OLD_BRIDGE_TWO/.config/dot-bridge/workers.json" \
|
|
18
|
-
--source "$HOME/OLD_BRIDGE_THREE/.config/dot-bridge/workers.json"
|
|
16
|
+
npm install -g @tnunamak/dalan
|
|
17
|
+
dalan service install --worker assistant --route tailscale
|
|
18
|
+
dalan connect start --worker assistant
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Optionally pass `--source-db PATH` for each old job database. The helper opens it read-only and writes a private `service-migration.json` checklist containing active subscription counts, callback origins and destination approval counts. It omits callback paths, query strings, signing secrets and encrypted records. This checklist grants no authority. Re-enrol every connector, call `events/subscribe` with a fresh signing key, and approve each new destination revision. Without `--source-db`, the checklist still records those required steps but has no old subscription inventory. For a brand-new bridge, skip migration and pass `--worker NAME` once for each worker instead; those initial workers have empty repository allowlists, no capabilities, and no host execution.
|
|
24
|
-
|
|
25
|
-
Replace `192.0.2.10` below with the address configured on this computer, then run the install after the proxy route reaches the target:
|
|
21
|
+
Dalan installs a background service, chooses a free port and remembers its settings. No environment variables or manual server process are needed.
|
|
26
22
|
|
|
23
|
+
Add the private connector URL shown by Dalan to the agent's MCP settings. Start sign-in in that client, then check the pending request:
|
|
27
24
|
```sh
|
|
28
|
-
dalan
|
|
29
|
-
--home "$HOME/.local/share/dalan-service" \
|
|
30
|
-
--public-url https://bridge.example.com \
|
|
31
|
-
--port 8787 \
|
|
32
|
-
--target 192.0.2.10:8787 \
|
|
33
|
-
--lan-port 8787
|
|
25
|
+
dalan connect pending
|
|
34
26
|
```
|
|
35
27
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
The service starts when the systemd user manager starts. `dalan service install` does not check or warn whether user lingering is enabled. Without lingering, the user manager may start only after the user logs in after a reboot. If the bridge must start before login, ask an administrator to run `loginctl enable-linger USER` for the account that owns the bridge.
|
|
41
|
-
|
|
42
|
-
`--write-units-only` writes the systemd unit files without initializing the bridge home, starting systemd or calling Gozar. It is for offline inspection; run the normal install to finish setup.
|
|
43
|
-
|
|
44
|
-
### Restarting and backing up built-in sign-ins
|
|
45
|
-
|
|
46
|
-
With compatible code, a restart using the same private home and issuer preserves an unexpired built-in OAuth access token while its grant and connection remain live. The issuer includes the public origin and secret path. Access tokens last up to one hour.
|
|
47
|
-
|
|
48
|
-
Before an upgrade or restore, stop the bridge and every other writer and make a consistent SQLite backup. Preserve the complete active private config directory, including `as.json`, `as-jwks.json`, `as-cookie-keys.json`, `as.sqlite` and its sibling `as-storage.key`; the keys alone cannot restore sign-ins. Follow the [backup and rollback steps](operations.md#upgrade-and-rollback).
|
|
49
|
-
|
|
50
|
-
For the built-in public-client flow, a client that loses a refresh response can recover it only by retrying the identical request within five seconds, while the successor token and connection remain live. A retry after that window can fail and require the client to pair again. This is not a promise of recovery after a longer outage or across incompatible code or storage changes.
|
|
51
|
-
|
|
52
|
-
## Legacy setup with `scripts/worker-bridge-setup.mjs`
|
|
53
|
-
|
|
54
|
-
The sections below document the separate legacy setup script, not `dalan service install`. The script supports the Linux and macOS setup options shown below. In particular, its `dot-bridge-NAME.service` unit name and lingering warning do not apply to `dalan service install`.
|
|
55
|
-
|
|
56
|
-
## Keep a local trial working
|
|
57
|
-
|
|
58
|
-
Setup has no local-only service mode, and it needs either `--public-url https://HOST` or `--expose tailscale` (or `--expose ngrok`, for the [ngrok](https://ngrok.com/) tunnel service), so a service always has an HTTPS origin. Dalan does not supply a launchd or systemd recipe for a bridge that serves only `127.0.0.1`, and it cannot convert the paired trial home into a service. Do not point setup at the trial home: it needs a fresh home.
|
|
59
|
-
|
|
60
|
-
To go from a trial to a service:
|
|
61
|
-
|
|
62
|
-
1. Keep the trial home if you want its results. Save them first, while `dalan try` still runs: with `DALAN_HOME` set to the trial home, run `dalan inbox --all --json` to list the request IDs, then `dalan get REQUEST_ID --json > result-REQUEST_ID.json` for each result you want. Then stop `dalan try` with Ctrl-C.
|
|
63
|
-
2. Run setup below with a new home. It makes a new bridge, with its own keys and port.
|
|
64
|
-
3. Pair the worker again, as the setup steps below describe. Re-running `try` or pairing replaces the worker client's old connection. Remove the old entry first with `codex mcp remove NAME` or `claude mcp remove --scope user NAME`.
|
|
65
|
-
4. Run the first job again on the new bridge. Read old results from the files you saved in step 1. To read a result you did not save, the trial bridge must run again: `dalan get` asks the running bridge through the admin socket in `DALAN_HOME`, so with the trial stopped it fails with `connect ECONNREFUSED`, and setting `DALAN_HOME` does not start it. Start the retained trial bridge by hand, from the Dalan checkout or package directory, on the port that its `as.json` names (the trial home is tied to that port), then read the result from a second shell:
|
|
66
|
-
|
|
67
|
-
```sh
|
|
68
|
-
export DALAN_HOME=TRIAL_HOME
|
|
69
|
-
port="$(sed -n 's#.*"public_url": *"http://127.0.0.1:\([0-9][0-9]*\)".*#\1#p' "$(dalan paths --config-root)/as.json")"
|
|
70
|
-
HOME="$DALAN_HOME" DALAN_LOOPBACK=1 DALAN_AUTH_MODE=builtin DALAN_PORT="$port" node src/server.mjs
|
|
71
|
-
# second shell, with DALAN_HOME set to TRIAL_HOME again:
|
|
72
|
-
dalan get REQUEST_ID --json
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Stop it with Ctrl-C when you have read the results. Do not run `dalan try` for this, because it pairs the worker again and replaces the worker client's connection to the new bridge. If the new service already listens on the trial's port, read the old results before you start the service.
|
|
76
|
-
|
|
77
|
-
If you want only a bridge on this computer that stays up, run the server in a terminal as the [manual setup](manual-setup.md#owner-and-requester-setup) describes, which is the supported local path.
|
|
78
|
-
|
|
79
|
-
## Owner setup
|
|
80
|
-
|
|
81
|
-
You need the installed package (from `npm install -g @tnunamak/dalan`) or a checkout, a stable Node.js 24 LTS or newer executable, a fresh private bridge home, and a free port from 1024 through 65535. Use short, space-free paths without symlinks; on Linux, starting the service needs a running systemd user manager; on macOS, it needs the user's launchd domain (`user/UID`), which exists while that user has a login session. `worker-bridge-setup.mjs` does not check the Node.js version.
|
|
82
|
-
|
|
83
|
-
On macOS the service is a LaunchAgent. A LaunchAgent starts when you log in to the Mac and stops when you log out, so it does not run after a reboot until someone logs in and you cannot rely on it for unattended availability.
|
|
84
|
-
|
|
85
|
-
**After a reboot on macOS:**
|
|
86
|
-
|
|
87
|
-
- **Check:** log in, then run `dalan status --json` (with `DALAN_HOME` set to the service home) and send one first job to prove the worker path still works.
|
|
88
|
-
- **Check the agent itself:** run `launchctl print user/$(id -u)/org.dalan.dot-bridge-NAME | grep -E 'state|pid|runs'`. Setup loads the agent into the `user/UID` domain, and `state = running` with a `pid` means the bridge is up.
|
|
89
|
-
|
|
90
|
-
**Symptom: `launchctl print` prints `Could not find service`.**
|
|
91
|
-
|
|
92
|
-
- That print only says that the agent is not in the `user/UID` domain; it does not say the service failed.
|
|
93
|
-
- **Check:** run `dalan status --json`, and run the same `launchctl print` with `gui/$(id -u)` in place of `user/$(id -u)`. An agent that an older release loaded lives in `gui/UID`.
|
|
94
|
-
- **Action:** if neither shows `state = running` and `dalan status --json` fails, load the agent with the `bootstrap` and `kickstart` lines in [Restart a service and check its state](operations.md#restart-a-service-and-check-its-state).
|
|
95
|
-
|
|
96
|
-
The domain and label are the ones that `worker-bridge-setup.mjs` writes.
|
|
97
|
-
|
|
98
|
-
### After a reboot
|
|
28
|
+
Compare the pending code with the code in your client. If they match, replace `CODE` with that code:
|
|
29
|
+
```sh
|
|
30
|
+
dalan connect approve CODE --worker assistant
|
|
31
|
+
```
|
|
99
32
|
|
|
100
|
-
|
|
33
|
+
Do not approve a code you did not request, and do not share the connector URL or codes.
|
|
101
34
|
|
|
102
|
-
|
|
103
|
-
- **Bridge, macOS.** It starts at your login, as described above.
|
|
104
|
-
- **Worker, both systems.** Dalan has no worker scheduler, and nothing wakes the worker when the bridge returns. Jobs wait in the queue until a worker run claims them. The supported way is manual, and it takes three steps. First wait until `dalan status --json` answers, with `DALAN_HOME` set to the service home. Then prompt the worker in its own client, for example: "Use Dalan to list pending work. Claim the oldest job you may claim, read it, report progress and finish it exactly as instructed. Stop when nothing is pending." In Codex, `codex exec "PROMPT" < /dev/null` runs that without a screen (see [worker clients](worker-clients.md)). Last, check that the job moved: `dalan wait REQUEST_ID` returns `finished`, or `dalan get REQUEST_ID --json` shows the report.
|
|
35
|
+
Next, [send your first job](../README.md#give-your-connected-agent-a-job), using `assistant` as the worker name. Dalan queues jobs; you must ask your agent to claim them. A new installation has no repository grants or permission to run host checks.
|
|
105
36
|
|
|
106
|
-
|
|
37
|
+
### Optional checks
|
|
107
38
|
|
|
108
|
-
|
|
39
|
+
After pairing, use these if you need to diagnose the service:
|
|
40
|
+
```sh
|
|
41
|
+
dalan status
|
|
42
|
+
dalan doctor --auth
|
|
43
|
+
```
|
|
109
44
|
|
|
110
|
-
|
|
45
|
+
The authentication check tests the public route and sign-in flow, not whether an agent can complete a job.
|
|
111
46
|
|
|
112
|
-
###
|
|
47
|
+
### More workers and advanced setup
|
|
113
48
|
|
|
114
|
-
|
|
49
|
+
Repeat `--worker NAME` in the install command to configure several workers, and pair each separately. A worker name starts with a lowercase letter, uses lowercase letters, digits, hyphens or underscores, and is at most 32 characters; `pool` and `unknown` are reserved.
|
|
115
50
|
|
|
116
|
-
|
|
51
|
+
### Pairing details
|
|
117
52
|
|
|
118
|
-
|
|
119
|
-
|---|---|
|
|
120
|
-
| `/<secret>/mcp` | Carries worker MCP requests. |
|
|
121
|
-
| `/.well-known/oauth-protected-resource/<secret>/mcp` | Identifies the protected resource and authorization server. |
|
|
122
|
-
| `/.well-known/oauth-authorization-server/<secret>/oauth` | Publishes OAuth endpoints. |
|
|
123
|
-
| `/.well-known/openid-configuration/<secret>/oauth` | Provides the discovery alias. |
|
|
124
|
-
| `/<secret>/oauth` and `/<secret>/oauth/*` | Handle OAuth and browser pairing. |
|
|
125
|
-
| `/signal/*` | Answers wake hooks when configured. |
|
|
53
|
+
A client on this computer with a loopback callback needs `--confirm-redirect` with the exact redirect that `pending` shows; see [worker pairing](manual-setup.md#worker-setup). A worker on another computer follows [Native client on a remote HTTPS bridge](worker-clients.md#native-client-on-a-remote-https-bridge). Then run [submit, finish and read the result](manual-setup.md#submit-finish-and-read-the-result) with `--worker NAME`.
|
|
126
54
|
|
|
127
|
-
|
|
55
|
+
Where the README and manual setup use the trial worker `local`, use your service's `NAME`:
|
|
128
56
|
|
|
129
|
-
|
|
57
|
+
- Submission: `dalan submit --worker NAME ...` for the first job and for every repository job.
|
|
58
|
+
- Repository grants: `dalan worker allow NAME OWNER/REPO` and `dalan worker list NAME --json`.
|
|
130
59
|
|
|
131
|
-
|
|
132
|
-
node scripts/worker-bridge-setup.mjs --worker NAME --public-url https://bridge.example.com --port PORT --home HOME_PATH --start
|
|
133
|
-
```
|
|
60
|
+
`wait`, `get` and `decide` select the job by request ID and take no worker flag.
|
|
134
61
|
|
|
135
|
-
|
|
62
|
+
The rest of this guide covers advanced routes, migration, updates and removal. None is required for the first connection.
|
|
136
63
|
|
|
137
|
-
|
|
138
|
-
node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs" --worker NAME --public-url https://bridge.example.com --port PORT --home HOME_PATH --start
|
|
139
|
-
```
|
|
64
|
+
### An existing reverse proxy
|
|
140
65
|
|
|
141
|
-
|
|
66
|
+
If you already serve a stable HTTPS address through your own reverse proxy, register that address with Gozar instead of asking Gozar for a new route:
|
|
142
67
|
|
|
143
|
-
|
|
68
|
+
```sh
|
|
69
|
+
dalan service install --worker NAME --public-url https://HOST --port N --target HOST:PORT
|
|
70
|
+
```
|
|
144
71
|
|
|
145
|
-
|
|
146
|
-
dalan status --json
|
|
147
|
-
```
|
|
72
|
+
Gozar records and verifies an origin-to-target route that your reverse proxy already serves; it does not edit the proxy. Prepare the proxy first so the public origin forwards to the address in `--target`. Preserve the public `Host` header. The bridge rejects requests with another Host, including requests that try to replace it with `X-Forwarded-Host`. TLS ends at the proxy. Keep the secret path out of proxy logs.
|
|
148
73
|
|
|
149
|
-
|
|
74
|
+
The proxy must forward these routes without removing their prefixes, methods, query strings, authorization headers or cookies:
|
|
150
75
|
|
|
151
|
-
|
|
76
|
+
| Route | Purpose |
|
|
77
|
+
|---|---|
|
|
78
|
+
| `/<secret>/mcp` | Carries worker MCP requests. |
|
|
79
|
+
| `/.well-known/oauth-protected-resource/<secret>/mcp` | Identifies the protected resource and authorization server. |
|
|
80
|
+
| `/.well-known/oauth-authorization-server/<secret>/oauth` | Publishes OAuth endpoints. |
|
|
81
|
+
| `/.well-known/openid-configuration/<secret>/oauth` | Provides the discovery alias. |
|
|
82
|
+
| `/<secret>/oauth` and `/<secret>/oauth/*` | Handle OAuth and browser pairing. |
|
|
83
|
+
| `/signal/*` | Answers wake hooks when configured. |
|
|
84
|
+
| `/.well-known/gozar/service` | Answers the Gozar check, with its query string. |
|
|
152
85
|
|
|
153
|
-
|
|
154
|
-
- Submission: `dalan submit --worker NAME ...` for the first job and for every repository job.
|
|
155
|
-
- Repository grants: `dalan worker allow NAME OWNER/REPO` and `dalan worker list NAME --json`.
|
|
86
|
+
An unauthenticated request to `/admin` on the public origin must return 404. The Dalan process listens on `127.0.0.1:PORT`. When the target is another address on this computer, pass `--lan-port N`; the service then opens the target address and forwards it to the loopback listener. Use a distinct non-wildcard address, not 0.0.0.0, which collides with loopback. If Gozar runs on this computer and reaches loopback directly, use `--target 127.0.0.1:PORT`. Challenge verification binds the receiving socket port to the declared target port. Translating to a different numeric port needs an explicit, trusted `--verify-cmd COMMAND`. If the origin filters the Gozar verifier by source IP, pass the same option. Install succeeds only when Gozar returns a verified route.
|
|
156
87
|
|
|
157
|
-
|
|
88
|
+
### Migrate an older bridge
|
|
158
89
|
|
|
159
|
-
|
|
90
|
+
For existing installations, create the new home and copy each worker's repository allowlist. Replace the example paths with the old bridge homes on this computer:
|
|
160
91
|
|
|
161
|
-
|
|
92
|
+
```sh
|
|
93
|
+
dalan service migrate-workers \
|
|
94
|
+
--home "$HOME/.local/share/dalan-service" \
|
|
95
|
+
--source "$HOME/.config/dot-bridge/workers.json" \
|
|
96
|
+
--source "$HOME/OLD_BRIDGE_TWO/.config/dot-bridge/workers.json" \
|
|
97
|
+
--source "$HOME/OLD_BRIDGE_THREE/.config/dot-bridge/workers.json"
|
|
98
|
+
```
|
|
162
99
|
|
|
163
|
-
|
|
100
|
+
The helper reads the source files without changing them. If an older home has no `workers.json`, it can read the adjacent `workers-repos.json` migration journal. It preserves worker names and repository allowlists, and copies supported worker capabilities and guidance. It does not copy OAuth registrations, tokens, jobs or results. The new bridge starts with `default_execution: none`. Workspace access defaults to denied; add `--workspace-worker NAME` for each worker that needs an explicit workspace grant. This option records the owner's grant; it does not require an earlier audit record. Existing explicit `workspaceAllowed` and T3 capability settings are retained. Destination declarations are copied, but old destination approvals bind old jobs and connections, so each new job requires a fresh approval.
|
|
164
101
|
|
|
165
|
-
|
|
166
|
-
brew install tailscale && sudo brew services start tailscale && sudo tailscale up
|
|
167
|
-
```
|
|
102
|
+
Optionally pass `--source-db PATH` for each old job database. The helper opens it read-only and writes a private `service-migration.json` checklist containing active subscription counts, callback origins and destination approval counts. It omits callback paths, query strings, signing secrets and encrypted records. This checklist grants no authority. Re-enrol every connector, call `events/subscribe` with a fresh signing key, and approve each new destination revision. Without `--source-db`, the checklist still records those required steps but has no old subscription inventory. For a brand-new bridge, skip migration and pass `--worker NAME` once for each worker instead; those initial workers have empty repository allowlists, no capabilities, and no host execution.
|
|
168
103
|
|
|
169
|
-
|
|
170
|
-
2. **Signed in.** Run `tailscale version` and `tailscale status`. The host must show as signed in.
|
|
171
|
-
3. **MagicDNS** (Tailscale's automatic DNS names for your devices). Turn it on at the [DNS page](https://console.tailscale.com/admin/dns).
|
|
172
|
-
4. **HTTPS Certificates.** On the same page, choose Enable HTTPS. Your machine's name then appears in public certificate transparency logs.
|
|
173
|
-
5. **Funnel policy.** In [Access controls](https://console.tailscale.com/admin/acls), add Funnel to the policy (the "Add Funnel to policy" button).
|
|
174
|
-
6. **Your shell user.** The user who runs setup must be allowed to manage Tailscale without `sudo`. If `tailscale funnel status` asks for `sudo`, run `sudo tailscale set --operator="$USER"` once.
|
|
104
|
+
### Move from a trial to a service
|
|
175
105
|
|
|
176
|
-
|
|
106
|
+
A service needs a fresh home; do not point it at a trial home. To keep trial results, save them first while `dalan try` still runs: with `DALAN_HOME` set to the trial home that `try` printed, run `dalan inbox --all --json` to list request IDs, then `dalan get REQUEST_ID --json > result-REQUEST_ID.json` for each result you want. Then stop the trial with Ctrl-C, install the service, and pair the worker again. Pairing replaces the worker client's old connection; remove the old entry first with `codex mcp remove NAME` or `claude mcp remove --scope user NAME`.
|
|
177
107
|
|
|
178
|
-
|
|
179
|
-
node scripts/worker-bridge-setup.mjs --worker NAME --port PORT --home HOME_PATH --expose tailscale --start
|
|
180
|
-
```
|
|
108
|
+
### Keep the service running
|
|
181
109
|
|
|
182
|
-
|
|
110
|
+
On Linux the service starts when the systemd user manager starts. Without lingering, that may be your first login after a reboot. If the bridge must start before login, ask an administrator to run `loginctl enable-linger USER` for the account that owns the bridge; install does not check or warn about it. On macOS the LaunchAgent starts when you log in and stops when you log out, so it does not run unattended after a reboot until someone logs in.
|
|
183
111
|
|
|
184
|
-
|
|
185
|
-
node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs" --worker NAME --port PORT --home HOME_PATH --expose tailscale --start
|
|
186
|
-
```
|
|
112
|
+
`--write-units-only` writes the service files without initializing the bridge home, starting the service or calling Gozar. It is for offline inspection; run the normal install to finish setup.
|
|
187
113
|
|
|
188
|
-
|
|
114
|
+
### Restarting and backing up built-in sign-ins
|
|
189
115
|
|
|
190
|
-
|
|
116
|
+
With compatible code, a restart using the same private home and issuer preserves an unexpired built-in OAuth access token while its grant and connection remain live. The issuer includes the public origin and secret path. Access tokens last up to one hour.
|
|
191
117
|
|
|
192
|
-
|
|
193
|
-
2. A worker on this computer follows [worker pairing](manual-setup.md#worker-setup). A worker on another computer follows [Native client on a remote HTTPS bridge](worker-clients.md#native-client-on-a-remote-https-bridge). Then run [submit, finish and read the result](manual-setup.md#submit-finish-and-read-the-result), replacing `local` with `NAME` in every command.
|
|
118
|
+
Before an upgrade or restore, stop the bridge and every other writer and make a consistent SQLite backup. Preserve the complete active private config directory, including `as.json`, `as-jwks.json`, `as-cookie-keys.json`, `as.sqlite` and its sibling `as-storage.key`; the keys alone cannot restore sign-ins. Follow the [backup and rollback steps](operations.md#upgrade-and-rollback).
|
|
194
119
|
|
|
195
|
-
|
|
120
|
+
For the built-in public-client flow, a client that loses a refresh response can recover it only by retrying the identical request within five seconds, while the successor token and connection remain live. A retry after that window can fail and require the client to pair again. This is not a promise of recovery after a longer outage or across incompatible code or storage changes.
|
|
196
121
|
|
|
197
|
-
|
|
122
|
+
<a id="after-a-reboot"></a>
|
|
198
123
|
|
|
199
|
-
|
|
124
|
+
## After a reboot
|
|
200
125
|
|
|
201
|
-
|
|
202
|
-
node "$(npm root -g)/@tnunamak/dalan/scripts/worker-bridge-setup.mjs" --retry-public-check --worker NAME --public-url EXPOSURE_URL --port PORT --home HOME_PATH
|
|
203
|
-
```
|
|
126
|
+
The bridge and the worker come back by separate rules:
|
|
204
127
|
|
|
205
|
-
|
|
128
|
+
- **Bridge.** Linux starts it with the systemd user manager (see lingering above). macOS starts it at your login. Check with `dalan service status` and `dalan status`.
|
|
129
|
+
- **Your agent.** Dalan does not start or schedule the agent. Once `dalan status` answers, open the client where you connected the agent and ask it: “Use Dalan to list pending jobs, claim the oldest job within your permissions, follow its brief, report progress and finish it. Stop when no jobs remain.” Check the result with `dalan wait REQUEST_ID` or `dalan get REQUEST_ID --json`, replacing `REQUEST_ID` with your job's ID.
|
|
206
130
|
|
|
207
|
-
|
|
131
|
+
A schedule or hook in the worker's vendor tool is outside Dalan's supported path; [pull workers](pull-workers.md#ways-to-start-a-run) lists the patterns and what they cost. A queued job still expires under the [preparation-expiry rule](pull-workers.md#jobs-the-worker-never-takes) if no worker claims it in time.
|
|
208
132
|
|
|
209
133
|
## Service updates
|
|
210
134
|
|
|
211
|
-
|
|
135
|
+
New installs enable a daily update check with up to one hour of random delay: a systemd user timer on Linux and a launchd agent on macOS. A missed run can run after the user manager or login session next starts. Installation with `--no-auto-update` disables the timer; `--auto-update` explicitly enables it. Reinstalling preserves the saved choice unless you pass one of those flags. The timer needs your systemd user manager to run; it does not configure login lingering.
|
|
212
136
|
|
|
213
137
|
```sh
|
|
214
|
-
dalan service update --check
|
|
215
|
-
dalan service update
|
|
216
|
-
dalan service status --
|
|
217
|
-
dalan service auto-update off
|
|
218
|
-
dalan service auto-update on
|
|
138
|
+
dalan service update --check
|
|
139
|
+
dalan service update
|
|
140
|
+
dalan service status --json
|
|
141
|
+
dalan service auto-update off
|
|
142
|
+
dalan service auto-update on
|
|
219
143
|
```
|
|
220
144
|
|
|
221
|
-
The home defaults to `~/.local/share/dalan-service
|
|
145
|
+
The home defaults to `~/.local/share/dalan-service` and Dalan remembers it; pass `--home DIR` only to select a different one. `service status` shows the selected version, saved automatic-update preference and last update result. Use `systemctl --user list-timers` to inspect the actual timer schedule. Turning updates off prevents future starts; it does not cancel an update already running. Preference changes refuse while an update holds the home lock. A release that was rolled back is recorded and skipped on later runs, including the timer; `dalan service update --retry` tries it again, and a newer or republished release is attempted normally. `service status` shows it as `failed_release`.
|
|
222
146
|
|
|
223
|
-
`--check` queries the public npm registry for the latest stable `@tnunamak/dalan` version and reports availability without installation or restart. A normal update installs the exact release under `
|
|
147
|
+
`--check` queries the public npm registry for the latest stable `@tnunamak/dalan` version and reports availability without installation or restart. A normal update installs the exact release under `HOME/versions/<version>`, with npm integrity checks and install scripts disabled. The registry's integrity value binds the downloaded bytes to its metadata; it is not an independent publisher signature. The original package must remain available until the first successful update. Later starts use the selected package through `HOME/current`.
|
|
224
148
|
|
|
225
149
|
Before switching, Dalan starts the candidate on a scratch loopback port against a private copy of the worker configuration, fresh mutable state, and synthetic keys made for that check. It never receives the service's signing, cookie, storage or operator keys. It checks initialization, ping and complete tool descriptors for every configured worker, then compares them with the running bridge. An unreachable worker, failed check or incomplete catalog stops the update. This local check does not test the public HTTPS route or hosted-client OAuth sign-in.
|
|
226
150
|
|
|
227
151
|
If a descriptor changes, the candidate stays staged and the last result is `connector_refresh_required`. To authorize switching to that release, run:
|
|
228
152
|
|
|
229
153
|
```sh
|
|
230
|
-
dalan service update --yes
|
|
154
|
+
dalan service update --yes
|
|
231
155
|
```
|
|
232
156
|
|
|
233
157
|
Refresh the Dalan connector in each hosted client after that switch. `--yes` allows the catalog change; it does not skip integrity, scratch checks or post-restart health checks. The timer never supplies it. Equal catalogs permit an automatic switch, but they cannot prove equal tool behavior or authorization semantics. Restarting interrupts connections and can interrupt in-progress requests.
|
|
234
158
|
|
|
235
159
|
While a switch is in progress, the restarted candidate refuses every worker call, OAuth request and owner command with a retryable 503 (`service_updating`, with `Retry-After`) and starts no background writer, until the update commits or rolls back. A rollback restores the saved state, so no change that Dalan acknowledged can be lost. Hosted clients retry after the window. For a switch, Dalan stops the bridge, saves its persistent configuration and data, selects the candidate, restarts the unit and checks local health and catalogs. On failure it attempts to stop the candidate, restore the previous selection and saved state, then restart and check the old version. A failed rollback is reported separately. An interrupted switch leaves a transaction record for recovery. Recovery runs when the service starts (an `ExecStartPre` step, `dalan service recover`) and again on the next update attempt; it does nothing while another update is running. Retention keeps three staged versions, including the active and previous versions. This is update recovery, not a replacement for your own backups.
|
|
236
160
|
|
|
237
|
-
A service installed by 0.6.0 or 0.6.1 is adopted by its first `dalan service update` with no other step: Dalan reads the package path and node binary from the service unit, keeps that node binary, and leaves the original package in place until a later update succeeds. To turn on the daily timer for such a service, run `dalan service auto-update on`, or enroll it the long way: install the current Dalan package, then repeat its original `dalan service install` command with the same home, origin, port and target. Enrollment preserves keys and worker grants, changes the unit's package path and restarts it. Its timer stays off unless you pass `--auto-update` or run `service auto-update on`. A modified unit is refused for inspection. These update commands cover the service made by `dalan service install`; the older
|
|
161
|
+
A service installed by 0.6.0 or 0.6.1 is adopted by its first `dalan service update` with no other step: Dalan reads the package path and node binary from the service unit, keeps that node binary, and leaves the original package in place until a later update succeeds. To turn on the daily timer for such a service, run `dalan service auto-update on`, or enroll it the long way: install the current Dalan package, then repeat its original `dalan service install` command with the same home, origin, port and target. Enrollment preserves keys and worker grants, changes the unit's package path and restarts it. Its timer stays off unless you pass `--auto-update` or run `service auto-update on`. A modified unit is refused for inspection. These update commands cover the service made by `dalan service install`; services from the older setup script are not enrolled automatically.
|
|
238
162
|
|
|
239
|
-
## Remove
|
|
240
|
-
|
|
241
|
-
Use the same worker and home that created it. The full list of things an uninstall must remove (service, homes, trial home, client entries, lock file) is in [operations](operations.md#remove-an-installation).
|
|
163
|
+
## Remove the service
|
|
242
164
|
|
|
243
165
|
```sh
|
|
244
|
-
|
|
166
|
+
dalan service uninstall
|
|
245
167
|
```
|
|
246
168
|
|
|
247
|
-
|
|
169
|
+
This stops and removes the service, its update timer or agent and its public route. It never deletes data: the private home, keys and state move to `<home>.removed-<date>`, and the command prints that path. Delete that directory yourself when you want the data gone. A modified service definition may need inspection instead of automatic removal. The full list of things an uninstall must remove (homes, trial home, client entries) is in [operations](operations.md#remove-an-installation).
|
|
170
|
+
|
|
171
|
+
## Legacy
|
|
248
172
|
|
|
249
|
-
|
|
173
|
+
Installations made by `scripts/worker-bridge-setup.mjs` in earlier releases keep working; that script is kept for compatibility only. See [operations](operations.md#restart-a-service-and-check-its-state) and the [upgrade guide](dalan-upgrade.md) to manage or replace one.
|
package/docs/setup-reference.md
CHANGED
|
@@ -4,12 +4,12 @@ Use this page after the [README](../README.md) first-job path works. It lists se
|
|
|
4
4
|
|
|
5
5
|
## Environment and storage
|
|
6
6
|
|
|
7
|
-
Set server variables in the process or service environment, then restart the bridge. Only the `dalan` command reads `DALAN_HOME`; it does not replace the server's `HOME`.
|
|
7
|
+
Set server variables in the process or service environment, then restart the bridge. Only the `dalan` command reads `DALAN_HOME`; it does not replace the server's `HOME`. A service made by `dalan service install` needs none: `dalan` remembers its home.
|
|
8
8
|
|
|
9
9
|
| Setting | Effect |
|
|
10
10
|
|---|---|
|
|
11
11
|
| `HOME` | Selects the bridge's private configuration, state and requester receipts. The server and requester must use the same home. |
|
|
12
|
-
| `DALAN_HOME` | The `dalan` command uses this directory as its `HOME`, so it reads the home of a server started with that `HOME`. `dalan try` uses it as the default trial home. |
|
|
12
|
+
| `DALAN_HOME` | The `dalan` command uses this directory as its `HOME`, so it reads the home of a server started with that `HOME`. It overrides the remembered service home. `dalan try` uses it as the default trial home. |
|
|
13
13
|
| `DALAN_AUTH_MODE=builtin` | Uses the built-in OAuth authorization server. `oauth` selects an external issuer instead. |
|
|
14
14
|
| `DALAN_LOOPBACK=1` | Runs authenticated HTTP on loopback only. Requires `DALAN_AUTH_MODE=builtin` and a fixed `DALAN_PORT`; the public URL must be `http://127.0.0.1:<port>`. |
|
|
15
15
|
| `DALAN_PORT` | Sets the HTTP listener port; the server default is 8787. |
|
|
@@ -23,7 +23,7 @@ The corresponding old `DOT_BRIDGE_*` environment names remain readable for compa
|
|
|
23
23
|
|
|
24
24
|
## Requester commands
|
|
25
25
|
|
|
26
|
-
The table lists the common commands. Run `dalan help --all` to see every command.
|
|
26
|
+
The table lists the common commands. Run `dalan help --all` to see every command. Every command must read the same home and private receipts: a service home is remembered; for a trial or a bridge you started by hand, export `DALAN_HOME` in each shell.
|
|
27
27
|
|
|
28
28
|
| Command | Result |
|
|
29
29
|
|---|---|
|
|
@@ -66,7 +66,7 @@ For upgrades, use the [changelog](../CHANGELOG.md) and [operations procedure](op
|
|
|
66
66
|
|
|
67
67
|
## Legacy service examples
|
|
68
68
|
|
|
69
|
-
The `dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfcheck.timer` examples are in `systemd/`. Keep these filenames when installing them for an existing deployment so service dependencies and timer targets still resolve. The legacy templates retain their original checkout default for compatibility. Set each example's `WorkingDirectory` to the deployed checkout and set `PATH` to a Node.js 24 installation before installing it. Units installed as copies, and drop-ins, do not need to change. A unit installed as a symbolic link to `dot-bridge.service`, `dot-bridge-selfcheck.service` or `dot-bridge-selfcheck.timer` in the repository root breaks when you update the checkout, because 0.5.0 removes those root links: before you update, point each such link at the same file in `systemd/`, then run `systemctl --user daemon-reload`. For a new installation,
|
|
69
|
+
The `dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfcheck.timer` examples are in `systemd/`. Keep these filenames when installing them for an existing deployment so service dependencies and timer targets still resolve. The legacy templates retain their original checkout default for compatibility. Set each example's `WorkingDirectory` to the deployed checkout and set `PATH` to a Node.js 24 installation before installing it. Units installed as copies, and drop-ins, do not need to change. A unit installed as a symbolic link to `dot-bridge.service`, `dot-bridge-selfcheck.service` or `dot-bridge-selfcheck.timer` in the repository root breaks when you update the checkout, because 0.5.0 removes those root links: before you update, point each such link at the same file in `systemd/`, then run `systemctl --user daemon-reload`. For a new installation, use `dalan service install` ([service guide](service-setup.md)). The external self-check is deployment-specific; configure it before enabling its timer.
|
|
70
70
|
|
|
71
71
|
<a id="names-you-may-see"></a>
|
|
72
72
|
|
|
@@ -74,7 +74,7 @@ The `dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfche
|
|
|
74
74
|
|
|
75
75
|
Earlier versions of Dalan used other names. Some remain so that existing installations keep working; use `dalan` and `DALAN_*` names for anything new.
|
|
76
76
|
|
|
77
|
-
- **`dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfcheck.timer`** are legacy systemd templates in `systemd/`. Do not use them for a new install; use `
|
|
77
|
+
- **`dot-bridge.service`, `dot-bridge-selfcheck.service` and `dot-bridge-selfcheck.timer`** are legacy systemd templates in `systemd/`. Do not use them for a new install; use `dalan service install`.
|
|
78
78
|
- **`.dot-bridge.json`** is the older name of a repository's check file, `.dalan.json`. Dalan still reads it when `.dalan.json` is absent.
|
|
79
79
|
- **`dot-bridge.*` OAuth scopes and `DOT_BRIDGE_*` settings** are older names that still work; the `dot-worker` command is replaced by `dalan`. They do not limit which client can be a worker.
|
|
80
80
|
- **T3 Code** is a separate desktop app for running coding agents. Dalan has an optional integration with it (the `t3.*` scopes, [T3 tools](t3-reverse-control.md) and [operator-registered tools](worker-clients.md#operator-registered-tools)). Ordinary jobs do not need it.
|
package/docs/worker-clients.md
CHANGED
|
@@ -179,16 +179,16 @@ Each native attempt is approved by its own code, and a later attempt cannot take
|
|
|
179
179
|
|
|
180
180
|
### Worked example: Codex CLI on another computer
|
|
181
181
|
|
|
182
|
-
This example uses a bridge from
|
|
182
|
+
This example uses a bridge from `dalan service install --worker NAME --route ROUTE` ([service setup](service-setup.md)) and Codex CLI on the worker computer. No reverse proxy and no domain of your own are involved.
|
|
183
183
|
|
|
184
|
-
1. On the bridge computer,
|
|
184
|
+
1. On the bridge computer, allow the callback and open a pairing window:
|
|
185
185
|
|
|
186
186
|
```sh
|
|
187
187
|
dalan connect allow-callback 'http://127.0.0.1/callback'
|
|
188
188
|
dalan connect start --worker NAME
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
2. Copy the private file
|
|
191
|
+
2. Copy the private connector URL file that install printed (`resource-url` in the service home, `~/.local/share/dalan-service/resource-url` by default) to the worker computer over a trusted channel such as `scp`, and keep it at mode 0600, because it holds the bridge's secret path.
|
|
192
192
|
3. On the worker computer, add the server. The command prints an authorization URL and waits:
|
|
193
193
|
|
|
194
194
|
```sh
|
|
@@ -199,7 +199,7 @@ This example uses a bridge from the [Tailscale Funnel setup](service-setup.md#wi
|
|
|
199
199
|
5. On the bridge computer, run `dalan connect pending`. Compare the code and the redirect with the page, then run `dalan connect approve CODE --worker NAME --confirm-redirect REDIRECT`.
|
|
200
200
|
6. **Check:** `codex mcp add` ends with `Successfully logged in.` Add the five tool approvals from the [Codex CLI section](#native-cli-worker-codex-cli) to the worker computer's `config.toml`. Submit the README's first job with `--worker NAME`, run `codex exec` on the worker computer, then use `dalan wait`, `get` and `decide` on the bridge computer.
|
|
201
201
|
|
|
202
|
-
To undo it, run `codex mcp remove NAME` on the worker computer, and `
|
|
202
|
+
To undo it, run `codex mcp remove NAME` on the worker computer, and `dalan service uninstall` on the bridge computer; that removes the service and its public route.
|
|
203
203
|
|
|
204
204
|
## Worker names and more than one worker
|
|
205
205
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tnunamak/dalan",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "An MCP job bridge for bounded agent work, durable progress, results, and owner review.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"scripts/monitor-targets.mjs",
|
|
25
25
|
"scripts/worker-bridge-setup.mjs",
|
|
26
26
|
"scripts/upgrade-drain.mjs",
|
|
27
|
-
"scripts/lib/expose-tailscale.mjs",
|
|
28
27
|
"scripts/live-trial/common.mjs",
|
|
29
28
|
"docs/",
|
|
30
29
|
"CONTRIBUTING.md",
|
|
@@ -54,7 +53,7 @@
|
|
|
54
53
|
},
|
|
55
54
|
"dependencies": {
|
|
56
55
|
"@agentclientprotocol/sdk": "1.8.0",
|
|
57
|
-
"@tnunamak/gozar": "0.1
|
|
56
|
+
"@tnunamak/gozar": "^0.2.1",
|
|
58
57
|
"oidc-provider": "9.13.0"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Run against a live `dalan try --public` trial before adding the connector in
|
|
3
|
-
// node scripts/dalan-try-selfcheck.mjs --home <trial home> [--
|
|
2
|
+
// Run against a live `dalan try --public` trial before adding the connector in an MCP client:
|
|
3
|
+
// node scripts/dalan-try-selfcheck.mjs --home <trial home> [--redirect HTTPS_URI] [--wait 300]
|
|
4
4
|
// The trial's authorization server must be on its public origin: a constraint of the trial, not of OAuth.
|
|
5
5
|
// It acts as a real OAuth client and waits for you to approve the connection (y) in the trial terminal.
|
|
6
6
|
import fs from 'node:fs';
|
|
7
7
|
import path from 'node:path';
|
|
8
|
-
import {
|
|
8
|
+
import { validateRedirectUri } from '../src/redirect-policy.mjs';
|
|
9
|
+
import { runSelfCheck, SELFCHECK_REDIRECT } from '../src/try-selfcheck.mjs';
|
|
9
10
|
|
|
10
11
|
const args = process.argv.slice(2);
|
|
11
12
|
const option = name => { const i = args.indexOf(name); return i >= 0 ? args[i + 1] : undefined; };
|
|
12
|
-
const home = option('--home'),
|
|
13
|
+
const home = option('--home'), redirect = option('--redirect') ?? SELFCHECK_REDIRECT, wait = Number(option('--wait') ?? 300);
|
|
13
14
|
let url = process.env.DALAN_TRY_URL;
|
|
14
15
|
if (!url && home) { try { url = fs.readFileSync(path.join(home, 'resource-url'), 'utf8').trim(); } catch { /* reported below */ } }
|
|
15
|
-
if (!url || !
|
|
16
|
-
process.stderr.write('usage: node scripts/dalan-try-selfcheck.mjs --home <trial home> [--
|
|
16
|
+
if (!url || !validateRedirectUri(redirect).ok) {
|
|
17
|
+
process.stderr.write('usage: node scripts/dalan-try-selfcheck.mjs --home <trial home> [--redirect HTTPS_URI] [--wait seconds]\n(or set DALAN_TRY_URL to the trial\'s MCP URL; it is a credential, so it is never taken from an argument)\n');
|
|
17
18
|
process.exit(2);
|
|
18
19
|
}
|
|
19
20
|
const controller = new AbortController();
|
|
20
21
|
process.once('SIGINT', () => controller.abort());
|
|
21
22
|
process.once('SIGTERM', () => controller.abort());
|
|
22
23
|
try {
|
|
23
|
-
const { ok } = await runSelfCheck({ url,
|
|
24
|
+
const { ok } = await runSelfCheck({ url, redirect, approveWaitMs: wait * 1000, signal: controller.signal, say: line => process.stdout.write(`${line}\n`) });
|
|
24
25
|
process.exit(ok ? 0 : 1);
|
|
25
26
|
} catch {
|
|
26
27
|
// The error text can hold the credential URL, so none of it is printed.
|