@tnunamak/dalan 0.5.2 → 0.6.1

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 (63) hide show
  1. package/CHANGELOG.md +37 -25
  2. package/PROTOCOL.md +16 -4
  3. package/README.md +127 -260
  4. package/SECURITY.md +1 -1
  5. package/bin/dalan.mjs +5 -0
  6. package/bin/dot-worker.mjs +35 -26
  7. package/docs/chatgpt-worker-onboarding.md +5 -5
  8. package/docs/claude-worker-onboarding.md +5 -5
  9. package/docs/codex-to-muse.md +181 -0
  10. package/docs/connect-chatgpt.md +9 -4
  11. package/docs/connection-longevity.md +7 -1
  12. package/docs/dalan-upgrade.md +18 -14
  13. package/docs/deadman.md +5 -3
  14. package/docs/local-agent-mcp.md +8 -6
  15. package/docs/manual-setup.md +8 -8
  16. package/docs/mirror-fetch.md +1 -2
  17. package/docs/operations.md +90 -42
  18. package/docs/operator-duties.md +1 -1
  19. package/docs/owner-integrator.md +2 -2
  20. package/docs/portable-auth-profile.md +12 -14
  21. package/docs/pr-head-reviewer.md +21 -5
  22. package/docs/pr-preflight.md +2 -0
  23. package/docs/pull-queue.md +131 -0
  24. package/docs/pull-workers.md +7 -10
  25. package/docs/redaction.md +1 -1
  26. package/docs/service-setup.md +56 -3
  27. package/docs/setup-reference.md +1 -1
  28. package/docs/t3-integration.md +3 -1
  29. package/docs/t3-result-retry-delivery.md +2 -2
  30. package/docs/t3-reverse-control.md +7 -7
  31. package/docs/usage.md +19 -15
  32. package/docs/worker-clients.md +18 -13
  33. package/package.json +3 -1
  34. package/scripts/dalan-try-selfcheck.mjs +29 -0
  35. package/scripts/lib/expose-tailscale.mjs +1 -1
  36. package/scripts/worker-bridge-setup.mjs +1 -1
  37. package/src/acp-bridge.mjs +18 -12
  38. package/src/as.mjs +41 -0
  39. package/src/child-exit.mjs +18 -0
  40. package/src/child-registry.mjs +94 -0
  41. package/src/cli-help.mjs +25 -11
  42. package/src/demo-worker.mjs +2 -2
  43. package/src/drained-owner.mjs +26 -0
  44. package/src/drained-slot.mjs +20 -3
  45. package/src/mcp-outcome.mjs +10 -1
  46. package/src/mcp-sse.mjs +62 -0
  47. package/src/pr-head-reviewer.mjs +3 -3
  48. package/src/process-inspection.mjs +36 -0
  49. package/src/pull-queue.mjs +159 -0
  50. package/src/route-setting.mjs +24 -0
  51. package/src/server.mjs +157 -29
  52. package/src/service-migrate-workers.mjs +113 -0
  53. package/src/service.mjs +423 -0
  54. package/src/setup.mjs +63 -0
  55. package/src/store.mjs +21 -9
  56. package/src/tool-registry.mjs +3 -1
  57. package/src/try-exposure.mjs +918 -0
  58. package/src/try-hosted-clients.mjs +46 -0
  59. package/src/try-hosted.mjs +444 -0
  60. package/src/try-selfcheck.mjs +168 -0
  61. package/src/try.mjs +63 -17
  62. package/src/workers.mjs +33 -23
  63. package/src/workspace.mjs +10 -3
@@ -0,0 +1,131 @@
1
+ # Submit one read-only result to an eligible pool
2
+
3
+ A policy work order lets one of several named workers take a job. It creates one
4
+ ordinary assignment when the first eligible worker claims it. Later attempts stay
5
+ with that worker; Dalan does not assign the slot to another worker automatically.
6
+
7
+ Every candidate must already have access to the job's repository. Listing and
8
+ acquisition both check the current repository grant and approved destination.
9
+ Listing a job does not reserve it or authorize work to start.
10
+
11
+ For workers without a destination declaration, put an explicit `valid_until`
12
+ deadline inside the assignment file itself (the `review.json` passed to `--file`
13
+ carries a `valid_until` field), then submit:
14
+
15
+ ```sh
16
+ dalan submit --file review.json --eligible alpha,beta --execution worker
17
+ ```
18
+
19
+ The assignment must use `execution_scope: "read-only"`. Version 1 accepts
20
+ `execution=none` or `execution=worker`, one result only (a single worker's report,
21
+ not several) and explicit worker names. It rejects host execution, protocol jobs,
22
+ fan-out greater than 1, worker classes, superseding, command keys and backend
23
+ capability requirements (the `--require-capability` option is for direct host
24
+ jobs, not pool jobs). The effective deadline is the earlier of the policy
25
+ deadline and the assignment's `valid_until`.
26
+
27
+ For workers with a declared destination, start with a policy file containing this
28
+ routing object (a destination is declared in the worker's profile; the dry-run
29
+ preview below shows each candidate's destination disclosure):
30
+
31
+ ```json
32
+ {
33
+ "version": 1,
34
+ "allowed_workers": ["alpha", "beta"],
35
+ "fan_out": 1,
36
+ "deadline_at": "2026-12-01T00:00:00Z"
37
+ }
38
+ ```
39
+
40
+ Run `dalan submit --file review.json --policy policy.json --execution worker --dry-run --json`.
41
+ The preview stores no job and returns `destination_disclosures` for each candidate.
42
+ Review each disclosure. Add its exact `revision` to the policy file:
43
+
44
+ ```json
45
+ {
46
+ "routing": {
47
+ "version": 1,
48
+ "allowed_workers": ["alpha", "beta"],
49
+ "fan_out": 1,
50
+ "deadline_at": "2026-12-01T00:00:00Z"
51
+ },
52
+ "destination_revisions": {
53
+ "alpha": "sha256:<alpha revision from the preview>",
54
+ "beta": "sha256:<beta revision from the preview>"
55
+ }
56
+ }
57
+ ```
58
+
59
+ Then run:
60
+
61
+ ```sh
62
+ dalan submit --file review.json --policy policy.json --execution worker --dry-run
63
+ dalan submit --file review.json --policy policy.json --execution worker
64
+ ```
65
+
66
+ A policy file can also contain the routing object directly when no candidate needs
67
+ a destination revision. The owner can use `get`, `wait`, `inbox` and `cancel` with
68
+ the submitted request ID before or after acquisition. Reports and decisions use
69
+ that same request ID and the same saved owner capability.
70
+
71
+ ## Worker flow without a connector refresh
72
+
73
+ Workers connected over MCP use these tools; `list_pending` and `claim` are MCP
74
+ tools, not `dalan` commands.
75
+
76
+ 1. Call `list_pending`. Its existing `assignments` list is unchanged. The new
77
+ `policy_work.items` field contains up to 50 eligible work orders, with priority,
78
+ original queue time and deadline. Normal priority precedes background work.
79
+ 2. If `policy_work.next_page_request_id` is present, call the existing `get` tool
80
+ with that value as `request_id`. Continue until it is null. Pagination captures
81
+ a queue high-water mark; jobs added later appear on the next fresh list. Every
82
+ page checks current eligibility. Page tokens are encrypted and bound to the
83
+ authenticated worker, and survive a bridge restart.
84
+ 3. Call `get` with an offered job's `request_id` to read its assignment. Call
85
+ `claim` with that ID, a claimant and a fresh `acquisition_id`. Respect the
86
+ existing free-lane and pause limits. A race has one winner.
87
+ 4. Use the returned `request_id` and `claim_id` with the existing progress,
88
+ workspace and finish tools. The receipt includes a distinct `work_order_id`. Once acquired, `child_request_id`
89
+ equals the original submitted `request_id`; the child keeps that reserved ID.
90
+ A lost-reply retry must use the original claimant, lease and acquisition ID.
91
+ 5. Read the owner's decision separately. Completion does not accept the result.
92
+
93
+ The eligible backlog is independent of available lanes. An unauthorized worker
94
+ sees neither work-order titles nor a global backlog count. Repository revocation,
95
+ destination drift or connection-set drift removes an unacquired order from that
96
+ worker's claimable set and refuses a new acquisition. Once a child exists, it
97
+ follows ordinary assignment listing rules, including a visible `blocked:true` entry
98
+ when destination policy blocks it. A committed live acquisition retry follows the
99
+ existing grant fences; changing policy does not silently replace its holder.
100
+
101
+ Acquisition commits the child, claim and parent winner in one SQLite transaction.
102
+ A crash before commit leaves the work order available with no child or claim.
103
+ A crash after commit can lose the reply; retrying the same acquisition returns
104
+ the saved child and claim, subject to the ordinary live-grant checks.
105
+
106
+ At its deadline, an unacquired work order is cancelled and no child is created.
107
+ After acquisition, the deadline becomes the child's `valid_until`; ordinary expiry
108
+ rules cancel a queued child, while an active claim is untouched. The deadline does
109
+ not stop an already active claim. Cancel the submitted request ID to revoke an
110
+ active child's authority. Cancellation does not prove external compute stopped.
111
+ The child's report and owner decision remain linked by the submitted request ID
112
+ and `work_order_id`; a finished report is not an accepted result.
113
+
114
+ Version 1 discovers unacquired work through polling `list_pending`. An unacquired
115
+ work order is not a queued assignment for the protocol's re-wake rule, so it adds
116
+ no availability event. Existing events for materialized
117
+ children remain hints. Lease expiry and abandonment use the ordinary child
118
+ recovery path with a fresh acquisition ID, once prior work has verifiably stopped.
119
+ There is no second result slot or cross-worker retry.
120
+
121
+ If the acquired worker is removed or its connection is revoked, lease expiry does
122
+ not offer the order to a different worker. The owner must cancel the submitted
123
+ request ID and submit a fresh request ID for the remaining eligible workers.
124
+ Check that any previous external work has stopped before resubmitting; bridge
125
+ cancellation alone cannot prove that. The cancelled order and its history remain
126
+ separate from the replacement and its result.
127
+
128
+ Pool submission uses the existing MCP tool definitions.
129
+ `pull-catalog-hash-test.mjs` pins all four profiles with T3 tools off and on.
130
+ The database upgrade is additive schema 66; use a pre-upgrade backup to return to
131
+ an older Dalan build.
@@ -48,11 +48,13 @@ Each worker has its own URL. A hook with one worker's URL cannot see other worke
48
48
 
49
49
  The answer is exactly `{"work":true}` or `{"work":false}`. It has no job ids, titles or counts. A wrong token gets `404`, the same as any unknown path. The bridge recomputes the answer at most once every 10 seconds.
50
50
 
51
- A hook, run every N seconds by whatever the vendor offers:
51
+ On the bridge computer, run `dalan connect signal-token --worker NAME` once. Transfer the private file it names to the worker host over a trusted channel and keep it mode 0600. The hook needs only that file, not Dalan's owner socket or connector credentials.
52
+
53
+ On the worker host, set `SIGNAL_FILE` to that file's absolute path and replace `wake` with your worker client's supported start command. Run this hook at the [poll interval below](#poll-interval-and-url-secrecy). Do not echo the URL or enable shell tracing.
52
54
 
53
55
  ```sh
54
- SIGNAL_FILE=$(dalan connect signal-token --worker NAME)
55
- SIGNAL_URL=$(cat "$SIGNAL_FILE") # do not echo the value or enable shell tracing
56
+ SIGNAL_FILE=/absolute/path/to/private-signal-url
57
+ SIGNAL_URL=$(cat "$SIGNAL_FILE") || exit 1
56
58
  curl -fsS "$SIGNAL_URL" | grep -q '"work":true' && wake
57
59
  ```
58
60
 
@@ -70,7 +72,7 @@ A vendor run can stop in the middle of a job. Resume wake exposes an expired own
70
72
  - **Progress nudge (opt in per worker).** In `workers.json` set `"guidance": "resume"` for the worker. `claim` and `get` then add acquisition and progress guidance. The progress interval is half the idle threshold, rounded down to a multiple of 30 seconds, with a minimum of 30 seconds. Thresholds of `120000`, `240000`, and `45000` ms produce intervals of 1 minute, 2 minutes, and 30 seconds. For the default threshold the text is: "Generate one random acquisition_id per run and pass it on every claim call, including retries. Post progress at least every 1 minute with what is done and what remains, so a resumed run can continue; if your run may end, post progress first." With the switch at 0, guidance uses the default threshold. The only valid guidance value is `"resume"`.
71
73
  - **Measure.** `dalan metrics --json` has `resume_wake.by_worker.<worker>`: `resumed`, `lease_expiry_retries`, and `time_to_finish_resumed` against `time_to_finish_lease_expiry` (first queued event to completed, p50/p90). `resume_wake.duplicate_epoch_claims` must be 0. The text form prints `resumed=` and `duplicate_epochs=`. Falsifier: resumed jobs do not finish sooner than lease-expiry jobs.
72
74
 
73
- Test: `node scripts/resume-wake-test.mjs`.
75
+ Maintainer check: from a source checkout installed with `npm ci`, run `node scripts/resume-wake-test.mjs`. The npm package does not include this script.
74
76
 
75
77
  ### Poll interval and URL secrecy
76
78
 
@@ -87,11 +89,6 @@ An unclaimed job stays queued unless a cancellation rule applies. **Preparation
87
89
 
88
90
  ## Vendor notes
89
91
 
90
- | Vendor | Schedule | Hook | Notes |
91
- |---|---|---|---|
92
- | Native scheduler | Periodic hook | Timed worker check | Example configuration |
93
- | Grok Bot | Routines, at least 5 min apart (documented) | Not documented | Needs a Grok account |
94
- | Grok automations | Daily or less often (documented) | Signed webhook trigger (documented) | Needs a Grok account |
95
- | Hosted worker | Scheduled background checks | Client-specific | Verify availability for the target account |
92
+ Scheduling and hook support vary by product, account and workspace policy. Check the vendor's current documentation and the controls available in the intended account before choosing a pattern. Dalan supplies neither a scheduler nor a worker-start command. Until that account's scheduled or hook-driven path has completed a real job, use the manual pattern above.
96
93
 
97
94
  More detail: the "Wake signal for hook-driven workers" section of [portable-auth-profile.md](portable-auth-profile.md) and the hook-driven worker example in [scripts/live-trial/README.md](https://github.com/tnunamak/dalan/blob/main/scripts/live-trial/README.md).
package/docs/redaction.md CHANGED
@@ -18,7 +18,7 @@ The tests are in `scripts/secret-sinks-redaction-test.mjs`, `scripts/redaction-m
18
18
 
19
19
  ## Known residual risks
20
20
 
21
- Redaction catches accidental leaks of registered secrets and known formats. It cannot stop a worker that deliberately encodes a secret it knows, for example as base64. These cases are not masked, and the project accepts them.
21
+ Redaction catches accidental leaks of registered secrets and known formats, including base64 forms of registered values. It cannot prevent deliberate disclosure through unrecognized encodings or transformations. The following cases can pass unmasked.
22
22
 
23
23
  - **Encoded unknown values:** a credential that Dalan did not register is found only in plain text. Its base64 or percent-encoded form, or a JWT payload, is not decoded.
24
24
  - **Split across log lines:** a secret that is split over two separate log entries is not found, because each entry is masked on its own.
@@ -2,6 +2,57 @@
2
2
 
3
3
  Use this guide after a first job works with `dalan try`, when you want a bridge that keeps running or a worker on another computer. Built-in OAuth binds the bridge to `127.0.0.1`; a tunnel or HTTPS reverse proxy forwards worker traffic to that listener. The owner CLI uses a private Unix socket, which must never be exposed through the proxy.
4
4
 
5
+ ## Install one bridge for several workers
6
+
7
+ The Linux-only `dalan service install` creates a systemd user service and registers its HTTPS origin as a Gozar service route. Gozar records and verifies an origin-to-target route that your reverse proxy already serves; it does not edit the proxy. The bridge uses built-in OAuth. Moving a connector to the new URL requires reauthorization and a catalog refresh. All workers use the same stable catalog. The process-wide `legacy-v46` setting remains available for other installations. Its auth keys, worker allowlists and job queue stay in one private home.
8
+
9
+ First prepare the public origin so it 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`. The proxy must pass the secret MCP path, the OAuth discovery and authorization paths, `/signal/*` when used, and `/.well-known/gozar/service` with its query string. TLS terminates at the proxy. Keep the secret path out of proxy logs.
10
+
11
+ 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:
12
+
13
+ ```sh
14
+ dalan service migrate-workers \
15
+ --home "$HOME/.local/share/dalan-service" \
16
+ --source "$HOME/.config/dot-bridge/workers.json" \
17
+ --source "$HOME/OLD_BRIDGE_TWO/.config/dot-bridge/workers.json" \
18
+ --source "$HOME/OLD_BRIDGE_THREE/.config/dot-bridge/workers.json"
19
+ ```
20
+
21
+ 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.
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:
26
+
27
+ ```sh
28
+ dalan service install \
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
34
+ ```
35
+
36
+ The Dalan process listens on `127.0.0.1:8787`. With `--lan-port`, systemd opens the address and matching port in `--target` and forwards it to that loopback listener. A separate target requires this explicit option, even when its numeric port equals the bridge port. Use a distinct non-wildcard address configured on this computer: the example binds 192.0.2.10:8787 separately from 127.0.0.1:8787. Do not use 0.0.0.0 for a same-port forwarder because it collides with loopback. Challenge verification binds the actual receiving socket port to the declared target port; its challenge path has no port override. Translating to a different numeric port is allowed only with an explicit nonempty trusted `--verify-cmd COMMAND`, not challenge verification. Add `--enable-workspace` or `--enable-t3` to enable those host capabilities; each worker must also have its own workspace or T3 grant. Without these options both host capabilities are disabled. If Gozar runs on the same computer and can reach loopback directly, set `--target 127.0.0.1:8787`. `gozar service add` runs after systemd starts the bridge; install succeeds only when Gozar returns a verified route. If the origin filters the Gozar verifier by source IP, pass the trusted host check with `--verify-cmd COMMAND`.
37
+
38
+ Set `DALAN_HOME` to the selected home. The private MCP URL is stored in `$DALAN_HOME/resource-url` with mode 0600. Point the client's connector at that URL and sign in separately for each worker. Repository jobs remain blocked until their allowlists are present. `dalan service install` creates a unit named `dalan-<10 hex>.service`; use the exact unit name printed by install with `systemctl --user status UNIT`, then confirm the public origin returns 404 for `/admin` and accepts the secret MCP path with its original Host header.
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
+
5
56
  ## Keep a local trial working
6
57
 
7
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.
@@ -27,7 +78,7 @@ If you want only a bridge on this computer that stays up, run the server in a te
27
78
 
28
79
  ## Owner setup
29
80
 
30
- 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. The script checks those before writing a service with `--start`.
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.
31
82
 
32
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.
33
84
 
@@ -48,7 +99,7 @@ The domain and label are the ones that `worker-bridge-setup.mjs` writes.
48
99
 
49
100
  The bridge and the worker come back by separate rules:
50
101
 
51
- - **Bridge, Linux.** The generated unit is wanted by `default.target`, so it starts when your systemd user manager starts. Without lingering, that is your first login after the reboot; with lingering (an administrator runs `loginctl enable-linger USER`; setup warns when it is off), it is the boot. Check with `systemctl --user is-active dot-bridge-NAME.service`, which must print `active`.
102
+ - **Bridge, Linux.** The generated unit is wanted by `default.target`, so it starts when your systemd user manager starts. Without lingering, that is your first login after the reboot; with lingering (an administrator runs `loginctl enable-linger USER`; the legacy setup script warns when it is off), it is the boot. Check with `systemctl --user is-active dot-bridge-NAME.service`, which must print `active`.
52
103
  - **Bridge, macOS.** It starts at your login, as described above.
53
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.
54
105
 
@@ -148,9 +199,11 @@ Setup with `--expose tailscale` or `--expose ngrok` can leave the home, service
148
199
  The retry has the form below. It needs the exposure record that those two modes save, so it does not work for an install made with an explicit `--public-url`.
149
200
 
150
201
  ```sh
151
- node scripts/worker-bridge-setup.mjs --retry-public-check --worker NAME --public-url EXPOSURE_URL --port PORT --home HOME_PATH
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
152
203
  ```
153
204
 
205
+ From a source checkout, use `node scripts/worker-bridge-setup.mjs` with the same options.
206
+
154
207
  It should mark the existing exposure verified. A 404 from unauthenticated `/admin` proves the expected public route answers, not that OAuth pairing or a worker job works, so complete both separately.
155
208
 
156
209
  ## Remove a generated service
@@ -1,6 +1,6 @@
1
1
  # Dalan setup reference
2
2
 
3
- Use this page after the [README](../README.md) first-job path works. It lists server settings, requester commands, worker tools and legacy service files. The package and CLI are named `dalan`; the command names of the `dot-bridge` package are not installed.
3
+ Use this page after the [README](../README.md) first-job path works. It lists server settings, requester commands, worker tools and legacy service files. The npm package is `@tnunamak/dalan` and the CLI command is `dalan`; the command names of the `dot-bridge` package are not installed.
4
4
 
5
5
  ## Environment and storage
6
6
 
@@ -18,7 +18,7 @@ DOT_ACP_LABEL="ChatGPT worker" # the label T3 shows
18
18
  DOT_ACP_SOCKET=/path/to/admin.sock # the bridge's admin socket; the default is the default Dalan home, not DALAN_HOME
19
19
  ```
20
20
 
21
- Add one entry for each worker, so a ChatGPT worker and a Muse Spark worker each appear as a model. These adapter settings keep the `DOT_ACP_*` names. Builds also need `DALAN_ACP_BUILD_OWNERS`: see [Builds through the T3 worker provider](#builds-through-the-t3-worker-provider).
21
+ Add one entry for each worker, so a ChatGPT worker and Muse (muse.ai), a hosted cloud agent, each appear as a model. These adapter settings keep the `DOT_ACP_*` names. Builds also need `DALAN_ACP_BUILD_OWNERS`: see [Builds through the T3 worker provider](#builds-through-the-t3-worker-provider).
22
22
 
23
23
  A separate, opt-in feature lets a worker list, read and write T3 threads. It gives the worker write and control access to your T3 threads, so read [T3 tools](t3-reverse-control.md) before you enable it.
24
24
 
@@ -28,6 +28,8 @@ A separate, opt-in feature lets a worker list, read and write T3 threads. It giv
28
28
 
29
29
  Quiet delivery (`none`) is the default. Only for an explicit visible task-thread notice, obtain the exact owner thread ID from `t3_thread_configuration` (current thread). A delegated child returning to its parent may use `orchestrator_capabilities.parentThreadId`. Verify the chosen ID and its environment with `t3code --json threads inspect --thread ID`. T3 delivery requires a CLI that supports `threads inspect`; metadata lookup fails closed if that command fails, without falling back to a transcript read, and quiet delivery needs no T3 CLI. Do not guess the ID from cwd or a recent thread. Protected top-level threads retain notices quietly.
30
30
 
31
+ After verifying the destination, submit with `dalan submit --worker NAME --execution none --deliver t3:THREAD_ID --file job.json --json`. Replace `NAME`, `THREAD_ID` and `job.json` with your worker, verified destination and assignment file. For an ordinary quiet job, keep `--deliver none`.
32
+
31
33
  <a id="main-thread-guard"></a>
32
34
 
33
35
  ## Main-thread guard
@@ -10,11 +10,11 @@ By default, result delivery selects `steer_active` for the latest active run; if
10
10
 
11
11
  ## Focused mock check
12
12
 
13
- Run `node scripts/t3-result-delivery-test.mjs`. The mock persists a receiver receipt, message, run and effect, drops the first response, then accepts a retry from a second transport session. It verifies one persisted effect and stable IDs, but it does not prove behavior against a real receiver.
13
+ From a source checkout installed with `npm ci`, run `node scripts/t3-result-delivery-test.mjs`; the npm package does not include this test script. The mock persists a receiver receipt, message, run and effect, drops the first response, then accepts a retry from a second transport session. It verifies one persisted effect and stable IDs, but it does not prove behavior against a real receiver.
14
14
 
15
15
  ## Owner-run live proof
16
16
 
17
- The harness defaults to dry-run. It reads the supplied SQLite database in read-only mode, verifies that the explicit project maps to the exact supplied repository root, and prints the planned operation. It does not issue auth or dispatch unless `--execute` is present. For execution, it creates an empty scratch thread with the installed `@bvdm/t3code-cli` internal API and a `thread.create` command. The pinned API package version and exported method shapes are checked first. The scratch uses model metadata with approval-required runtime and plan interaction settings; it sends no provider prompt and never calls `launchThread`.
17
+ This harness requires a source checkout installed with `npm ci` and the matching local T3 installation described below; its script is not included in the npm package. It defaults to dry-run. It reads the supplied SQLite database in read-only mode, verifies that the explicit project maps to the exact supplied repository root, and prints the planned operation. It does not issue auth or dispatch unless `--execute` is present. For execution, it creates an empty scratch thread with the installed `@bvdm/t3code-cli` internal API and a `thread.create` command. The pinned API package version and exported method shapes are checked first. The scratch uses model metadata with approval-required runtime and plan interaction settings; it sends no provider prompt and never calls `launchThread`.
18
18
 
19
19
  Each of two result sends uses the real `dispatchT3Result` path, which creates a fresh auth and WebSocket session. Before and after each send, the harness opens the supplied database read-only and checks command receipt, stable message, thread run, and outbox counts. It requires one persisted receipt, message, and held run after the first send; no `provider-turn.start` outbox effect or running/starting run before or after either send; and identical scoped counts after the retry. The scratch thread is left held for owner review. The harness does not archive it or release the run.
20
20
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  With `DALAN_ENABLE_T3_TOOLS=1`, the bridge exposes a small T3 thread wrapper (list, read, create, send, wait and set) through its existing OAuth MCP connection. The wrapper uses `t3code --json --origin http://127.0.0.1:3773` with argument arrays. It can address any T3 project or thread the local CLI can address by an ID of at most 128 bytes; the other tools reject a longer ID from a list result. The bridge does not scope a thread to the worker that calls it: a worker with the `t3` capability has the owner's full authority over every local thread. The tools are off by default, and a fresh `dalan init` worker profile has no `t3` capability. The CLI currently obtains a short-lived administrative T3 session for each operation; the bridge's approved OAuth subject and per-tool scopes remain the remote boundary.
4
4
 
5
- These calls use owner-granted, job-independent authority. They require no `request_id` or `claim_id` and have no assignment epoch, so they are outside job-scoped authority checks, and job expiry or cancellation does not revoke them. To enable the six thread tools, set `DALAN_ENABLE_T3_TOOLS=1` and grant the worker `capabilities: ["t3"]`; both checks apply, including for the legacy single-worker profile, which keeps its capability but still needs the environment setting. When the tools are hidden, direct calls are rejected. Capability, OAuth scope and audit admission always apply.
5
+ These calls use owner-granted, job-independent authority. They require no `request_id` or `claim_id` and have no assignment epoch, so they are outside job-scoped authority checks, and job expiry or cancellation does not revoke them. To advertise the six thread tools, set `DALAN_ENABLE_T3_TOOLS=1`; each call also requires the worker's `capabilities: ["t3"]`, including for the legacy single-worker profile. When the global setting is off, direct calls are rejected as unknown tools. Capability, OAuth scope and audit admission always apply.
6
6
 
7
7
  | MCP tool | Scope | Operation |
8
8
  | --- | --- | --- |
@@ -14,9 +14,9 @@ These calls use owner-granted, job-independent authority. They require no `reque
14
14
  | `t3_thread_set` | `dalan.work` | Change a thread's provider, model, effort, permission or mode. |
15
15
  | `notify_owner` | `dalan.work` | Publish a short message through the configured ntfy alerts path. |
16
16
 
17
- `dalan tell "text"` adds a durable lightweight message to a worker's `list_pending` inbox and emits the existing `assignment.available` event with `{message_id,title}`. The event uses the signed webhook retry path, so the existing subscription wakes the worker. The worker reads it with `get {request_id: message_id}` and removes it from the pending list with `ack_message {message_id}`. Messages do not need assignment claim or finish. `tell` accepts `--json` and `--worker NAME` (default: `dot` if that worker exists, else the only configured worker; with several workers and no `dot`, pass `--worker`); `dalan untell MESSAGE_ID [--worker NAME]` withdraws a pending message.
17
+ `dalan tell "text"` adds a durable lightweight message to a worker's `list_pending` inbox and emits the existing `assignment.available` event with `{message_id,title}`. The event uses the signed webhook retry path, so an existing subscription can notify a client that supports wake-up. The worker reads it with `get {request_id: message_id}` and removes it from the pending list with `ack_message {message_id}`. Messages do not need assignment claim or finish. `tell` accepts `--json` and `--worker NAME` (default: `dot` if that worker exists, else the only configured worker; with several workers and no `dot`, pass `--worker`); `dalan untell MESSAGE_ID [--worker NAME]` withdraws a pending message.
18
18
 
19
- The notification aliases retain their existing `t3` capability, work scope and audit checks. They remain available independently of `DALAN_ENABLE_T3_TOOLS`; this flag controls only the six `t3_thread_*` operations. The `legacy-v46` pin retains its exact twelve-tool catalog and advertises neither notification alias.
19
+ The `notify_owner` tool retains its `t3` capability, work scope and audit checks. Modern catalogs advertise it independently of `DALAN_ENABLE_T3_TOOLS`; this flag controls only the six `t3_thread_*` operations. A worker without `t3` can see the name but its call is denied and audited. The `legacy-v46` pin advertises no notification tool. The earlier notification alias was removed.
20
20
 
21
21
  ## Notification retries outside the job lifecycle
22
22
 
@@ -49,7 +49,7 @@ Audit admission uses persisted rolling windows per `(worker, subject)`. Each den
49
49
  Before refreshing, enable `DALAN_ENABLE_T3_TOOLS=1` and retain the worker’s `t3` capability.
50
50
 
51
51
  1. Open the existing Dalan connector in ChatGPT and select **Refresh** to load the new tool schemas.
52
- 2. T3 tools use the existing `dalan.read`/`dalan.work` scopes (the legacy `dot-bridge.*` names are accepted aliases); re-login only if the current grant lacks `offline_access`.
52
+ 2. T3 tools use the existing `dalan.read`/`dalan.work` scopes; the legacy `dot-bridge.read`/`dot-bridge.work` names are accepted aliases. Refresh the catalog first. Sign in again if the connection is no longer live or the client cannot refresh its credentials. For an external issuer, check its offline-access requirements separately; do not add scopes merely to refresh the tool list.
53
53
  3. Inspect the refreshed tool list for `notify_owner`, `list_tools`, `call_tool_read`, `call_tool_write`, and `ack_message`. If you recreate the connector, upload [t3-connector-icon.png](t3-connector-icon.png) as its icon.
54
54
  4. In a disposable worker conversation, call `t3_thread_list` and `notify_owner`, then inspect `dalan audit --json`. Recheck the original subscribed worker conversation separately.
55
55
 
@@ -57,7 +57,7 @@ Do not trigger a ChatGPT reconnect from the bridge host. The connector's current
57
57
 
58
58
  ## Standing instruction for worker
59
59
 
60
- > You can inspect the owner's T3 threads through this connector. Use `t3_thread_list` and `t3_thread_read`. They can reach any project or thread the local T3 CLI can reach by an ID of at most 128 bytes. Use `notify_owner` for a short out-of-band alert that does not start a T3 turn. Send assignment questions to the exact owner thread. Mark blockers with optional `progress.blocker:true` or start the note with `BLOCKED:` / `QUESTION:` so the bridge forwards them once if you forget. The owner can leave a lightweight message with `dalan tell`; its event wakes you. Find it in `list_pending`, read it with `get`, and call `ack_message` after reading it. It is a message, not an assignment. `run_check` can return `{check_run_id,status:"running"}`; poll `workspace_result` for completion. Upload sealed evidence with `artifact_chunk` in any claimed assignment. Call `list_tools` first to learn the other tools you may use, then run them with `call_tool_read` or `call_tool_write`. All T3 tool calls are audited.
60
+ > You can inspect the owner's T3 threads through this connector. Use `t3_thread_list` and `t3_thread_read`. They can reach any project or thread the local T3 CLI can reach by an ID of at most 128 bytes. Use `notify_owner` for a short out-of-band alert that does not start a T3 turn. Send assignment questions to the exact owner thread. Mark blockers with optional `progress.blocker:true` or start the note with `BLOCKED:` / `QUESTION:` so the bridge forwards them once if you forget. The owner can leave a lightweight message with `dalan tell`; it emits an event, but whether that starts a run depends on your client. Find it in `list_pending`, read it with `get`, and call `ack_message` after reading it. It is a message, not an assignment. `run_check` can return `{check_run_id,status:"running"}`; poll `workspace_result` for completion. Upload sealed evidence with `artifact_chunk` in any claimed assignment. Call `list_tools` first to learn the other tools you may use, then run them with `call_tool_read` or `call_tool_write`. All T3 tool calls are audited.
61
61
 
62
62
  ## After adding or changing tools
63
63
 
@@ -66,7 +66,7 @@ Do not trigger a ChatGPT reconnect from the bridge host. The connector's current
66
66
 
67
67
  ## Catalog freeze
68
68
 
69
- The `stable` catalog omits question tools, and `DALAN_CATALOG_PROFILE=questions-v1` adds `ask_question` and `consume_answer`. In either profile, the six T3 tools require `DALAN_ENABLE_T3_TOOLS=1`; notification aliases retain their capability check. Catalog selection does not split OAuth scopes or add pagination. Catalog v2 is the last advertised change: add abilities by registering tools, which never changes the tool list, and never through tool names, descriptions or schemas (see [Catalog v2](../PROTOCOL.md#catalog-v2)). Compare the running server catalog with the approved profile before any Refresh. If you deploy server support before your clients refresh, keep the default profile until they have refreshed their tool list and restarted.
69
+ The `stable` catalog omits question tools, and `DALAN_CATALOG_PROFILE=questions-v1` adds `ask_question` and `consume_answer`. In either profile, the six T3 tools require `DALAN_ENABLE_T3_TOOLS=1`; `notify_owner` retains its capability check. Catalog selection does not split OAuth scopes or add pagination. Catalog v2 is the last advertised change: add abilities by registering tools, which never changes the tool list, and never through tool names, descriptions or schemas (see [Catalog v2](../PROTOCOL.md#catalog-v2)). Compare the running server catalog with the approved profile before any Refresh. If you deploy server support before your clients refresh, keep the default profile until they have refreshed their tool list and restarted.
70
70
 
71
71
  Clients may cache tool and event schemas. Plan a connector refresh and client restart when changing the catalog.
72
72
 
@@ -76,7 +76,7 @@ The workspace install and check phases both run in a sandbox with its own networ
76
76
 
77
77
  ## Who may hold the t3 capability
78
78
 
79
- The t3 tools act as the owner, with no per-job binding. Pairing a client never grants this capability; the bridge reads it only from the owner's `workers.json`, where it declares that a worker is the owner's own harness. The tools take any thread, project or directory and are not bound to a job, a worker or a repository. Never give `capabilities: ["t3"]` to a worker you do not fully trust with every T3 thread on the computer. A worker without the capability does not see these tools, and a direct call is refused and audited. With the tools on, startup prints a notice naming each worker that holds the capability.
79
+ The t3 tools act as the owner, with no per-job binding. Pairing a client never grants this capability; the bridge reads it only from the owner's `workers.json`, where it declares that a worker is the owner's own harness. The tools take any thread, project or directory and are not bound to a job, a worker or a repository. Never give `capabilities: ["t3"]` to a worker you do not fully trust with every T3 thread on the computer. Modern catalogs advertise the same names to every worker; a worker without the capability receives a denied and audited result when it calls them. With the tools on, startup prints a notice naming each worker that holds the capability.
80
80
 
81
81
  ## Adding abilities without a Refresh
82
82