@tnunamak/dalan 0.6.2 → 0.8.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 +53 -0
- package/CONTRIBUTING.md +4 -0
- package/PROTOCOL.md +2 -0
- package/README.md +81 -84
- package/bin/dalan.mjs +9 -0
- package/bin/dot-worker.mjs +29 -4
- package/contracts/adapter-qualification.schema.json +170 -0
- 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/local-agent-requester.md +46 -0
- package/docs/manual-setup.md +2 -2
- package/docs/operations.md +12 -13
- package/docs/pull-workers.md +1 -2
- package/docs/service-setup.md +110 -163
- package/docs/setup-reference.md +6 -6
- package/docs/t3-question-relationship.md +43 -0
- package/docs/t3-reverse-control.md +12 -8
- package/docs/t3-wake-fence-r4.md +42 -0
- package/docs/test-suite-isolation.md +204 -0
- package/docs/worker-clients.md +6 -4
- package/package.json +5 -3
- package/qualification/README.md +13 -0
- package/qualification/mcp.json +121 -0
- package/qualification/protocol-v0.json +127 -0
- package/scripts/dalan-try-selfcheck.mjs +8 -7
- package/scripts/worker-bridge-setup.mjs +91 -81
- package/src/admin-socket.mjs +2 -1
- package/src/answer-journal.mjs +200 -0
- package/src/as-store.mjs +5 -3
- package/src/as.mjs +35 -26
- package/src/auth-check.mjs +59 -0
- package/src/cli-help.mjs +16 -16
- 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/destinations/index.mjs +6 -0
- package/src/destinations/none.mjs +3 -0
- package/src/destinations/t3.mjs +63 -6
- package/src/execution.mjs +20 -2
- package/src/follow-current.mjs +27 -0
- package/src/gozar-routes.mjs +315 -0
- package/src/host-budget.mjs +17 -11
- package/src/host-execution-policy.mjs +2 -2
- package/src/host-stop-reverify.mjs +6 -4
- package/src/integrator.mjs +3 -1
- package/src/redirect-policy.mjs +61 -0
- package/src/route-setting.mjs +71 -12
- package/src/server.mjs +64 -12
- package/src/service-auto-update.mjs +8 -1
- package/src/service-launchd.mjs +186 -0
- package/src/service-migrate-workers.mjs +12 -2
- package/src/service-update-runtime.mjs +40 -6
- package/src/service-update.mjs +20 -14
- package/src/service.mjs +211 -63
- package/src/setup.mjs +55 -44
- package/src/store.mjs +77 -14
- package/src/submission-policy.mjs +8 -4
- package/src/t3.mjs +21 -2
- package/src/tool-registry.mjs +54 -8
- 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/src/workers.mjs +4 -3
- package/src/workspace.mjs +94 -15
- package/scripts/lib/expose-tailscale.mjs +0 -408
- package/src/try-hosted-clients.mjs +0 -46
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
This file lists user-visible changes, newest first. Check the section for your target release before you upgrade.
|
|
4
4
|
|
|
5
|
+
## 0.8.0
|
|
6
|
+
|
|
7
|
+
**After you update, refresh every hosted connector you use (for example ChatGPT).** The `ask_question` tool now takes an optional `purpose` input, so the tool list the connector cached is out of date. Remove and re-add the connector, or use the connector's refresh action, so it reads the new list.
|
|
8
|
+
|
|
9
|
+
- **A worker can mark a question as a human-only decision.** `ask_question` takes an optional `purpose`: `clarification` (the default), `human_decision`, `authentication` or `tool_permission`. For any other value, the wake message tells the parent that a human must decide and gives it no answer command. Answering such a question also needs the operator key, not only the job's owner capability. Clarification questions behave as before. This is routing policy, not confinement: a process that can read the operator key file can use it.
|
|
10
|
+
- **`dalan answer` now survives a crash or a lost reply.** It saves the exact answer before it sends it, and sends the same answer again if the reply never arrives, so the worker gets it once. It now also works on protocol jobs, which refused it before. A different text for a question you already answered is refused on your machine, and an answer over 4096 bytes is refused with its byte count instead of cut short.
|
|
11
|
+
- **A stopped or interrupted parent is no longer woken by a worker's question or result.** Dalan holds the wake, keeps it in `dalan inbox`, and sends it once when the parent thread runs again. A repeated question wake now arrives once. Because T3 reports a stop and an interrupt the same way, a parent you only interrupted also stays held until it runs again. Question text in a wake is now shown as untrusted data.
|
|
12
|
+
- **Workers can accept jobs that require protocol features.** A worker's configuration can now name an adapter, and jobs that require a capability such as `identified_questions` are accepted only when that adapter is on the repository's list of verified adapters. An absent or unverified adapter refuses the job at submission and stores nothing. The qualification records ship in the package.
|
|
13
|
+
- **A worker with T3 access reaches only its own job's conversations.** Listing, reading, waiting, sending and setting now cover only the T3 threads that a claimed, unexpired job names; other conversations are hidden and refused, and a revoked grant stops later calls. Creating arbitrary threads is refused.
|
|
14
|
+
- **A job whose sensitive files were withheld shows its host checks again.** When a host job was admitted with some sensitive files withheld, `claim` and `get` reported that no host check could run (`scope_paths_read_isolation_unavailable`), although admission had accepted the job. They now show whether a check can still run, and refuse only when another sensitive file in the tree is not withheld, the tree or policy cannot be read, or the scope was narrowed.
|
|
15
|
+
- **Install and update are safer on macOS and with migrated workers.** A migrated worker policy with a capacity setting now installs. On macOS, install and update stop the existing LaunchAgent before replacing its plist and stop on an unknown launchd state before allocating a route. A fixture check that failed under restrictive umasks now passes.
|
|
16
|
+
- **Database migrations 67 to 69 run on first start.** They add the question purpose, the wake-hold records and the worker T3 scope, and keep existing rows. Back up the database before you update: a build older than 0.8.0 does not support the migrated database, so do not point 0.7.0 at it.
|
|
17
|
+
- Test-only: parallel test suites no longer share ports, systemd unit names, setup locks or scratch directories, and a new acceptance test covers question relationships across the CLI and T3 requesters.
|
|
18
|
+
|
|
19
|
+
- **Install checks setup before requesting a public route.** `dalan service install` now runs every check that only reads (the worker profile, the home, the service package link, service and automatic-update unit collisions, Gozar's state path and, on Linux, the user systemd manager) before it asks Gozar for a route. This includes macOS LaunchAgent plists. `--write-units-only` no longer asks Gozar for a route. A later file-write or startup failure can still leave a route. Install never closes a route on failure because it may have reused one; once the service receipt is written, `dalan service uninstall` can use its recorded handle to remove it.
|
|
20
|
+
- **Install names two common setup problems.** A `--home` whose admin socket path is too long for the system (107 bytes on Linux, 103 on macOS) is refused first, with the length, the limit and the fix: a shorter `--home`. A user systemd manager that cannot be reached is named, with `systemctl --user status` to see why and the note that a login session or `loginctl enable-linger` may be needed.
|
|
21
|
+
- **`dalan doctor --auth` explains your own pairing window.** When a pairing window for the same worker is already open, the check still fails and leaves the window alone, and now says it is your own window: finish pairing the client, or run `dalan connect stop`, then run doctor again.
|
|
22
|
+
- **A command with `--home` no longer runs the default home's version.** `dalan` hands each command to the version that the default home's service runs. With `--home DIR` (or `--home=DIR`) you name another home, so the installed `dalan` now runs the command itself. `DALAN_HOME` works as before.
|
|
23
|
+
- The [local-agent requester guide](docs/local-agent-requester.md) now passes the brief in single quotes, so the shell cannot run `$(...)` or backticks from it, and shows how to write a single quote inside the brief. It also no longer says that `report.summary` is always one line.
|
|
24
|
+
|
|
25
|
+
- Gozar's next step is now shown even when its error code is new to Dalan. The step is shown as sanitized text; Dalan does not act on it.
|
|
26
|
+
|
|
27
|
+
- Dalan now depends on Gozar `^0.3.0`, the route manager used to publish the bridge's HTTPS address.
|
|
28
|
+
- `dalan service migrate-workers` carries the claim-capacity setting from the source `limits.json` into the new home; conflicting source capacities are refused.
|
|
29
|
+
- Status now warns after 15 minutes without claim progress or tool activity, even while the lease remains live. Set `claim_idle_warning_ms` in `limits.json` to change the warning threshold. This observation does not cancel jobs or change leases.
|
|
30
|
+
- macOS service teardown now distinguishes a loaded agent, an explicitly absent agent and an unknown launchctl result. An unknown result stops teardown before either agent's plist is removed.
|
|
31
|
+
- The repository-job walkthrough now shows when to prompt the hosted worker, inspect its report and record acceptance. It also explains workspace setup limits for an existing service.
|
|
32
|
+
- The service guide now states macOS's loopback-only target restriction and that an update check missed during shutdown or logout does not catch up at login.
|
|
33
|
+
- Automatic-update failures roll back to the previous package on Linux and macOS. Tailscale session routes use port 8443, or 10000 when busy; service routes choose the first free port of 443, 8443 and 10000.
|
|
34
|
+
|
|
35
|
+
## 0.7.0
|
|
36
|
+
|
|
37
|
+
Install, run and update Dalan with three commands on Linux and macOS:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
npm install -g @tnunamak/dalan
|
|
41
|
+
dalan service install --worker NAME --route tailscale
|
|
42
|
+
dalan connect start --worker NAME
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- **One command installs a service on macOS and Linux.** `dalan service install --worker NAME --route ROUTE` creates a systemd user service on Linux or a launchd LaunchAgent on macOS, publishes it through [Gozar](https://www.npmjs.com/package/@tnunamak/gozar), and prints the public address, where the private connector URL file is, the next command and a health check. Run it again and nothing changes. It asks for your approval of the route first; `--yes` approves after you have read the disclosure. An address you already serve stays possible with `--public-url`, `--port` and `--target`.
|
|
46
|
+
- **One default home.** Commands find the service home without `DALAN_HOME`. Install records it in a small pointer file (`~/.config/dalan/home`); `DALAN_HOME` still overrides it. `dalan service uninstall` removes the service, its update timer or agent and its route, and moves the home aside to `<home>.removed-<date>` instead of deleting your keys and job history.
|
|
47
|
+
- **Automatic updates on macOS too.** A launchd update agent checks once a day, like the systemd timer on Linux. The `dalan` command on your PATH follows the version the updater switched to, so the command and the service do not drift. `DALAN_NO_FOLLOW=1` turns that off.
|
|
48
|
+
- **Updates work on npm 12.** `dalan service update` downloads the release tarball itself, checks it against the registry's sha512 integrity and installs from that local file. npm 12 refuses a remote tarball URL as a dependency (`EALLOWREMOTE`), which would have stopped every automatic update.
|
|
49
|
+
- **Updates adopt older services.** `dalan service update` now adopts a service installed by 0.6.0 or 0.6.1, including a unit that names its package directory with a trailing slash and a server that has no update gate.
|
|
50
|
+
- **Any OAuth MCP client can connect.** Dalan accepts a client it has not seen before when its redirect address is a plain HTTPS address or a native loopback address, and the owner approval code stays mandatory. The consent page and `dalan connect pending` show the client name as untrusted text, the redirect host and the full redirect address. The older callback allow-list still loads and only adds entries.
|
|
51
|
+
- **Routes only through Gozar 0.2.** Dalan no longer starts tunnels or runs Tailscale commands itself. It asks Gozar for the route, shows the disclosure Gozar returns, and never falls back to another route. `--route` takes a name you configured in Gozar or the label of an offered route, such as `tailscale`. Tailscale Funnel uses an unused port on this device, so an existing listener is never replaced.
|
|
52
|
+
- **`dalan doctor --auth`** runs the OAuth sign-in flow (discovery, registration, PKCE, token, MCP initialize and tool list) against the public address and prints a PASS or FAIL line per step without printing a secret.
|
|
53
|
+
- `dalan submit --wait` prints the request ID and the worker prompt before it waits. The guides now show `claude mcp add --scope user`, how to retry with `--replace`, and that Node 24 or newer is required.
|
|
54
|
+
- Documentation uses only the commands above. `worker-bridge-setup.mjs` remains for older setups and is no longer in the guides.
|
|
55
|
+
|
|
56
|
+
Upgrade note: `@tnunamak/gozar` 0.2.1 is now a dependency (`^0.2.1`). A service that a release before 0.7.0 generated keeps working; move it with a fresh `dalan service install`.
|
|
57
|
+
|
|
5
58
|
## 0.6.2
|
|
6
59
|
|
|
7
60
|
- Add `dalan service update`, `--check`, automatic-update on/off and update status for Linux systemd services. New installs enable daily checks with jitter. Releases install side by side with npm integrity checks, local self-checks and a complete tool-catalog comparison for each configured worker. Changed descriptors stage until an explicit `--yes`; refresh hosted connectors after that switch. Failed switches attempt to restore the previous package and saved persistent state, and report rollback failures. See [service updates](docs/service-setup.md#service-updates) for limits and enrollment of older services.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -15,6 +15,10 @@ DALAN_HOST_CHECKS=0 npm test
|
|
|
15
15
|
|
|
16
16
|
`DALAN_HOST_CHECKS=0` turns host checks off by default; tests that exercise host checks may still turn them on.
|
|
17
17
|
|
|
18
|
+
For concurrent runs, use a separate Git worktree and a separate short `TMPDIR` for each run (for example `/tmp/s-a-$$` and `/tmp/s-b-$$`). The temporary directory must exist before the run starts. Unix socket paths must fit within 107 bytes. Each test owns its temporary homes, databases, listeners, and host-check systemd units; installed dependencies and the toolchain may be shared read-only. Host-check resource ceilings apply per check, so concurrent runs add their resource use together.
|
|
19
|
+
|
|
20
|
+
New HTTP fixtures should bind port `0` and read the listening port. A fixture that must write its URL before starting a child should use `reservedPort({ start })` from `src/test-support/port.mjs` and report an actual bind failure with `error.code = 'EADDRINUSE'`; the helper then retries setup on another port. Calling `reservedPort()` without a startup callback only supplies a candidate, which can be taken before the listener binds. Tests that deliberately exercise a named or occupied port must retain that behavior rather than silently changing ports.
|
|
21
|
+
|
|
18
22
|
Some upgrade tests also run against the source of releases from before Dalan was public. Maintainers keep those archives outside the repository and set `DALAN_PREPUBLIC_FIXTURES` to their directory; without it, those tests skip with the reason "pre-public release fixtures not present".
|
|
19
23
|
|
|
20
24
|
## Changes
|
package/PROTOCOL.md
CHANGED
|
@@ -99,6 +99,8 @@ This section records the historical questions-v1 contract. The conformance adapt
|
|
|
99
99
|
|
|
100
100
|
The owner lists questions with `dalan questions REQUEST_ID --json` and answers one with `dalan answer REQUEST_ID QUESTION_ID "answer text" --json`. These commands use the saved per-request owner capability. The corresponding Unix-socket routes are `GET /questions?id=REQUEST_ID` and `POST /answer {id,question_id,text}`. An answer requires an existing question from the current live grant. Missing, terminal, stale and already answered questions are refused; a second answer cannot replace the first. An answer remains awaiting consumption across restart. It queues an ordinary `assignment.available` event with the existing request/title payload; private notification metadata binds the wake to the question and epoch.
|
|
101
101
|
|
|
102
|
+
`ask_question` also takes an optional `purpose`: `clarification` (the default), `human_decision`, `authentication` or `tool_permission` (schema 67). Any value but `clarification` marks a question that only a human may answer: a choice, a sign-in or a permission grant. The wake that reaches the parent names what the human must do, says a human must decide, and carries no answer command. `POST /answer` for such a question needs the operator key (`x-operator-key`) in addition to the owner capability. The owner capability alone is refused with `FORBIDDEN` and nothing is stored. `get` and `GET /questions` show `purpose` only when it is not `clarification`; a clarification keeps its earlier shape. The same question ID asked again under another purpose is a `KEY_CONFLICT`. On one host this is routing and credential policy, not confinement: a process that can read the operator key file can use it. `dalan answer` sends only the owner capability today, so a person answers such a question with the operator key through the admin socket until the CLI sends it.
|
|
103
|
+
|
|
102
104
|
`consume_answer {request_id,claim_id,question_id}` returns the saved answer and records its first consumption atomically. It requires the original current grant and refuses an unanswered question. An exact repeat under a live nonterminal job returns the same answer with `duplicate:true`. Cancelled and finished jobs refuse consumption, including a duplicate read; this does not change committed finish-receipt retries. Worker `get` includes question records without claim credentials or OAuth subject. A `completed` finish refuses `QUESTION_OPEN` while that grant has any unconsumed question, including an answered question. A `blocked` or `failed` finish may terminate without an answer; unanswered questions remain visible through owner `questions` as open audit facts, with no fabricated consumption or further authority. Questions from a prior epoch cannot block the new grant, and the new grant cannot answer or consume them. It must ask a fresh question and receive its own answer. Cancellation still permits audit-only late evidence under the existing rules.
|
|
103
105
|
|
|
104
106
|
Schema 55 stores questions and their answer-wake associations. Ask, answer and first consumption append native lifecycle events with explicit `question:ask:ID`, `question:answer:ID` and `question:consume:ID` reasons. State and events commit together, and the conformance adapter projects these native facts; it does not infer answers from timestamps or keep a separate answer store. This revision adds no general command keys, revision compare-and-swap, or full profile-conformance claim. The historical v1 section below describes its pinned older source; v2 remains the authority and lease contract.
|
package/README.md
CHANGED
|
@@ -1,143 +1,124 @@
|
|
|
1
1
|
# Dalan
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Put your MCP-only agent to work on coding jobs from your Mac or Linux computer. The hosted agent is the worker: it connects to your local Dalan bridge over MCP and claims jobs you queue. With explicit repository grants and workspace setup, it can return findings or a patch for you to review. You decide whether to apply changes. Dalan does not run a model or start the agent.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
npx -y @tnunamak/dalan try
|
|
7
|
-
```
|
|
5
|
+
Before you begin, install [Node.js](https://nodejs.org) 24 or newer and [Tailscale](https://tailscale.com/download) with Funnel enabled. Your agent's account must allow custom MCP connectors.
|
|
8
6
|
|
|
9
|
-
**
|
|
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.
|
|
10
8
|
|
|
11
9
|
<a id="quickstart"></a>
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
You need Node.js 24 or newer, Linux or macOS (or WSL), and a hosted client account or workspace that permits custom MCP connectors.
|
|
16
|
-
|
|
17
|
-
Start Dalan in an interactive terminal:
|
|
11
|
+
**Just exploring?** Run a temporary, text-only trial:
|
|
18
12
|
|
|
19
13
|
```sh
|
|
20
|
-
|
|
14
|
+
npm install -g @tnunamak/dalan
|
|
15
|
+
dalan try --public --route tailscale
|
|
21
16
|
```
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
When Dalan selects Gozar, it names tunnl.gg, links its [terms](https://tunnl.gg/terms) and [privacy notice](https://tunnl.gg/privacy), and asks for consent before exposure. After you consent, Gozar creates a key for this installation and opens a route through its key-bound `tunnl-gg` relay. Dalan does not use or pass your SSH keys. The relay terminates TLS and can see the connector URL and traffic. Keep private code and secrets out of the demo.
|
|
26
|
-
|
|
27
|
-
A temporary demo link can change or stop without warning, including within minutes. Dalan checks the original address and ends the trial when it detects a route change or loss. The trial ends after three hours at most; that is a limit on the trial, not a promise about the link. If the address changes or the route stops, start a fresh trial and replace the connector URL.
|
|
18
|
+
Follow the terminal instructions to add the connector and approve only the matching sign-in code. Paste the supplied prompt into your agent's chat. Success is a report returned to your terminal.
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
2. **Approve the sign-in.** Compare the code in the browser with the code in your terminal. Approve only when they match.
|
|
31
|
-
3. **Send the prompt.** Paste Dalan's prompt into a chat with the connector enabled. Dalan queues the demo job; it does not start the hosted chat for you.
|
|
32
|
-
4. **Review the report.** Read the report in your terminal before you accept or reject it.
|
|
33
|
-
|
|
34
|
-
The hosted demo is a text job, not a repository review. It grants no repository access. Your agent uses its own account, limits and billing; Dalan does not run a model.
|
|
20
|
+
The trial has no repository access. Keep private code and secrets out of it. It ends after three hours at most. Its public link can change or stop without warning. For a local-only trial that opens no public route, run `dalan try --local`; to connect a worker client by hand, see [manual setup](docs/manual-setup.md#worker-setup). For a persistent connection, use the installation steps below.
|
|
35
21
|
|
|
36
22
|
### Stop a trial
|
|
37
23
|
|
|
38
|
-
Ctrl-C stops the trial
|
|
39
|
-
|
|
40
|
-
If Gozar returns a cleanup-pending status for this trial, Dalan provides a recovery command that stops by port. Gozar does not bind that command to a session ID, so the route can change before the command runs. Inspect the current route before using it.
|
|
24
|
+
Ctrl-C stops the trial and cancels a route that is still starting. Dalan closes its forwarding gate and attempts to remove its route. If it cannot confirm cleanup, it reports that. When Gozar cannot confirm route ownership, Dalan leaves the route alone and gives no stop command.
|
|
41
25
|
|
|
42
|
-
|
|
26
|
+
If Gozar reports cleanup as pending, Dalan prints a recovery command that stops by port. Gozar does not bind that command to a session, so inspect the current route before you run it.
|
|
43
27
|
|
|
44
|
-
|
|
28
|
+
A trial prints its own home. Set `DALAN_HOME` to that home before you run other `dalan` commands against the trial. On stop, Dalan removes the connector URL file and the bridge's secret file for temporary routes.
|
|
45
29
|
|
|
46
|
-
|
|
47
|
-
npx -y @tnunamak/dalan try --local
|
|
48
|
-
```
|
|
30
|
+
<a id="expose-your-bridge"></a>
|
|
49
31
|
|
|
50
|
-
|
|
32
|
+
## Install a persistent connection
|
|
51
33
|
|
|
52
|
-
|
|
34
|
+
This example names your hosted worker `assistant`; use that name consistently.
|
|
53
35
|
|
|
54
|
-
|
|
36
|
+
If you plan repository jobs, include `--enable-workspace` in the service install command below.
|
|
55
37
|
|
|
56
|
-
|
|
38
|
+
If you tried the temporary trial first, save any results you want (see [service setup](docs/service-setup.md)), stop it with Ctrl-C, and unset the trial's `DALAN_HOME` before you install:
|
|
57
39
|
|
|
58
40
|
```sh
|
|
59
|
-
|
|
60
|
-
npx -y @tnunamak/dalan try --public --route tailscale --client chatgpt
|
|
41
|
+
unset DALAN_HOME
|
|
61
42
|
```
|
|
62
43
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
An explicit `--route tailscale` trial uses HTTPS port 443. When the port is available, Dalan opens its own Funnel rule for the trial and attempts to remove only that rule when it stops. If another rule already holds port 443, Dalan can start an isolated, temporary Tailscale node instead. It does not reuse or change the other rule. That node uses a new address and may need a one-time sign-in. A new address needs a new client sign-in.
|
|
66
|
-
|
|
67
|
-
If the public address does not answer, the trial prints `TLS certificate: ok` or `TLS certificate: error (...)`. The trial keeps a masked copy of the temporary node's log as `tailscaled.log` in the trial home.
|
|
68
|
-
|
|
69
|
-
### Choose another relay
|
|
70
|
-
|
|
71
|
-
`--route gozar` explicitly selects the Gozar relay. Dalan still asks for consent before it exposes the route.
|
|
72
|
-
|
|
73
|
-
`--route localhost.run` remains available as an explicit option. It uses OpenSSH and a temporary third-party relay. The relay terminates TLS and can inspect the connector URL and forwarded traffic. Dalan prints this notice before it starts the route. The address can change or stop without warning. Dalan attempts to close the route and reports cleanup it cannot confirm.
|
|
74
|
-
|
|
75
|
-
In `auto` mode, a saved Gozar choice or an older saved localhost.run choice selects Gozar. Otherwise, auto uses a usable Tailscale route and selects Gozar when Tailscale is unavailable.
|
|
76
|
-
|
|
77
|
-
<a id="expose-your-bridge"></a>
|
|
78
|
-
|
|
79
|
-
## Install a long-running bridge
|
|
80
|
-
|
|
81
|
-
Install the CLI:
|
|
44
|
+
The persistent service uses a fresh home and needs a new sign-in. Do not reuse the trial home.
|
|
82
45
|
|
|
83
46
|
```sh
|
|
84
47
|
npm install -g @tnunamak/dalan
|
|
48
|
+
dalan service install --worker assistant --route tailscale
|
|
49
|
+
dalan connect start --worker assistant
|
|
85
50
|
```
|
|
86
51
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
If any tool descriptor changes, Dalan stages the release and records `connector_refresh_required` without switching. Run `dalan service update --yes --home DIR` to authorize that switch, then refresh the Dalan connector in each hosted client. The daily timer never passes `--yes`. Use `dalan service status --home DIR` for the last result, or `dalan service auto-update off --home DIR` to disable future scheduled checks. Pass `--no-auto-update` during installation to opt out. Existing service preferences are preserved. See [update and recovery details](docs/service-setup.md#service-updates). These commands support Linux systemd services; they do not add launchd support.
|
|
92
|
-
|
|
93
|
-
For an existing bridge, migrate worker settings into a new home before you install the service. Repeat `--source` for each old workers file. Use `--workspace-worker` for each worker that needs workspace access:
|
|
52
|
+
Add the private connector URL shown by Dalan to your agent's MCP settings and start sign-in. Compare the code shown in your client with the pending code in your terminal:
|
|
53
|
+
```sh
|
|
54
|
+
dalan connect pending
|
|
55
|
+
```
|
|
94
56
|
|
|
57
|
+
Only if they match, replace `CODE` below with that code and approve:
|
|
95
58
|
```sh
|
|
96
|
-
dalan
|
|
97
|
-
--home "$HOME/.local/share/dalan-service" \
|
|
98
|
-
--source "$HOME/OLD_BRIDGE/.config/dot-bridge/workers.json" \
|
|
99
|
-
--source-db "$HOME/OLD_BRIDGE/.local/share/dot-bridge/bridge.db" \
|
|
100
|
-
--workspace-worker WORKER
|
|
59
|
+
dalan connect approve CODE --worker assistant
|
|
101
60
|
```
|
|
102
61
|
|
|
103
|
-
|
|
62
|
+
Keep the connector URL and pairing codes private. You are ready to send a job when the client finishes sign-in.
|
|
63
|
+
|
|
64
|
+
Dalan runs as a user service. On macOS it starts at login and stops at logout. On Linux it follows the systemd user manager; starting before login needs administrator setup. Installing a service does not start your AI agent. On macOS, jobs run with `--execution none`.
|
|
104
65
|
|
|
105
|
-
|
|
66
|
+
Automatic updates are enabled by default. Updates that change the tools exposed to your agent require approval and a connector refresh. See [service setup](docs/service-setup.md) for diagnostics, update controls, other routes and recovery.
|
|
106
67
|
|
|
107
68
|
## Give your connected agent a job
|
|
108
69
|
|
|
109
|
-
In another terminal,
|
|
70
|
+
In another terminal, send a text-only job to the worker you just connected. If you chose a name other than `assistant`, use it instead. `--execution none` lets the job run no commands on your computer; `--deliver none` sends the result nowhere except back to Dalan, where you read it:
|
|
110
71
|
|
|
111
72
|
```sh
|
|
112
|
-
dalan submit --worker
|
|
73
|
+
dalan submit --worker assistant --execution none --deliver none --brief "Explain what a database index does. Do not read files, run commands or call external services."
|
|
113
74
|
```
|
|
114
75
|
|
|
115
|
-
|
|
76
|
+
This first job needs no repository and returns a report, not a patch. Copy the request ID that Dalan prints. In the connected agent's chat, send this, replacing `REQUEST_ID` with that ID:
|
|
116
77
|
|
|
117
|
-
|
|
78
|
+
> Use Dalan to claim job REQUEST_ID, follow its brief, report progress, and finish with your answer. Do not expand its permissions.
|
|
79
|
+
|
|
80
|
+
Queuing a job does not start the agent. After you have prompted it, replace `REQUEST_ID` with the same ID, then wait and read the result:
|
|
118
81
|
|
|
119
82
|
```sh
|
|
120
83
|
dalan wait REQUEST_ID
|
|
121
84
|
dalan get REQUEST_ID --json
|
|
122
85
|
```
|
|
123
86
|
|
|
124
|
-
Read the report
|
|
87
|
+
Read the answer in `report.result` and its outcome in `report.outcome`. A missing or null report means there is no report yet. A blocked or failed outcome is not a successful answer.
|
|
88
|
+
|
|
89
|
+
`wait` defaults to 300 seconds. Exit 0 means finished, 3 a question or blocker, 4 cancelled, 5 the worker is on a usage break, and 124 timed out with the job still open. After a nonzero exit, inspect the job with `dalan get` before you continue. Do not submit again only because the wait timed out.
|
|
90
|
+
|
|
91
|
+
Only after you read a finished answer and find it useful, record your decision:
|
|
125
92
|
|
|
126
93
|
```sh
|
|
127
94
|
dalan decide REQUEST_ID accepted
|
|
128
95
|
```
|
|
129
96
|
|
|
130
|
-
A finished job and an accepted result are separate steps. Acceptance
|
|
97
|
+
A finished job and an accepted result are separate steps. Acceptance records your review; it does not change your files.
|
|
98
|
+
|
|
99
|
+
The text-only job above returns no patch to apply. A later [repository job](#separate-repository-assignment) can return one. Inspect it first, then replace `REQUEST_ID` with that job's ID and `PATH` with your local repository directory:
|
|
131
100
|
|
|
132
101
|
```sh
|
|
133
102
|
dalan apply REQUEST_ID --dir PATH
|
|
134
103
|
```
|
|
135
104
|
|
|
105
|
+
<a id="send-jobs-from-your-local-agent"></a>
|
|
106
|
+
|
|
107
|
+
## Send jobs from your local agent
|
|
108
|
+
|
|
109
|
+
A local coding agent with a shell (Claude Code, Codex CLI) can be the requester. It runs `dalan submit`, `wait`, `get` and `decide`. The hosted agent, such as Muse, stays the worker: it connects over MCP and claims the job. The requester needs no MCP connection. Copy the [instruction block](docs/local-agent-requester.md#instructions-to-paste) into your agent's instructions.
|
|
110
|
+
|
|
136
111
|
<a id="separate-repository-assignment"></a>
|
|
137
112
|
|
|
138
113
|
## Give a worker a repository job
|
|
139
114
|
|
|
140
|
-
The
|
|
115
|
+
The text-only job proves pairing and reporting, not coding access. Keep using the same persistent bridge home and connected worker from the installation above. Before submitting a repository job, install Git and Python 3.8 or newer on the bridge computer, provide a host GitHub credential that can read the repository, and enable workspace access for both the host and worker. Then grant only the repository below. A repository grant alone does not enable workspaces.
|
|
116
|
+
|
|
117
|
+
The [manual setup guide](docs/manual-setup.md#owner-and-requester-setup) creates a separate loopback bridge in a new home; it is not an upgrade path for your persistent service. If your existing service has no workspace access, stop before submitting a repository job. Reinstalling with `--enable-workspace` is refused because the saved service configuration must match; it cannot enable workspace access in place.
|
|
118
|
+
|
|
119
|
+
The first repository job below reads one file at a pinned commit. It does not edit files or run checks. The trial has no repository access.
|
|
120
|
+
|
|
121
|
+
Replace `WORKER` with your worker's name (`assistant` above) and `OWNER/REPO` with the repository:
|
|
141
122
|
|
|
142
123
|
```sh
|
|
143
124
|
dalan worker allow WORKER OWNER/REPO
|
|
@@ -150,7 +131,7 @@ Revoke access when the worker no longer needs it:
|
|
|
150
131
|
dalan worker deny WORKER OWNER/REPO
|
|
151
132
|
```
|
|
152
133
|
|
|
153
|
-
For a read-only repository job, replace the request ID, repository and full commit SHA below. Choose a file that exists at that commit:
|
|
134
|
+
For a read-only repository job, replace the request ID (`req_` plus a new lowercase UUID), repository and full commit SHA below. Choose a file that exists at that commit:
|
|
154
135
|
|
|
155
136
|
```json
|
|
156
137
|
{
|
|
@@ -164,12 +145,28 @@ For a read-only repository job, replace the request ID, repository and full comm
|
|
|
164
145
|
}
|
|
165
146
|
```
|
|
166
147
|
|
|
167
|
-
Save it as `repository-job.json
|
|
148
|
+
Save it as `repository-job.json`. Replace `WORKER` as above, then submit:
|
|
168
149
|
|
|
169
150
|
```sh
|
|
170
151
|
dalan submit --worker WORKER --execution none --deliver none --file repository-job.json --json
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Copy the request ID that `submit` prints. In your connected hosted agent's chat, send this, replacing `REQUEST_ID` with that ID:
|
|
155
|
+
|
|
156
|
+
> Use Dalan to claim job REQUEST_ID, follow its brief, report progress, and finish with your answer. Do not expand its permissions.
|
|
157
|
+
|
|
158
|
+
Queuing does not start the agent. After you have prompted it, use the same bridge home and request ID to wait and read the report:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
171
161
|
dalan wait REQUEST_ID
|
|
172
|
-
dalan get REQUEST_ID
|
|
162
|
+
dalan get REQUEST_ID --json
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Inspect `report.result` and `report.outcome`. A missing or null report means there is no report yet; a blocked or failed outcome is not a successful answer. After a nonzero `wait` exit, inspect the job before continuing, as described for the first job above.
|
|
166
|
+
|
|
167
|
+
Pause here to review the finished report. Only if you find it useful, record acceptance:
|
|
168
|
+
|
|
169
|
+
```sh
|
|
173
170
|
dalan decide REQUEST_ID accepted
|
|
174
171
|
```
|
|
175
172
|
|
|
@@ -180,7 +177,7 @@ The host's GitHub credential must be able to read the repository. For local clon
|
|
|
180
177
|
|
|
181
178
|
## Connect any MCP worker
|
|
182
179
|
|
|
183
|
-
Any client that speaks HTTP MCP and completes the bridge's OAuth sign-in can be a worker. Start with the [worker guide](docs/worker-clients.md)
|
|
180
|
+
Any client that speaks HTTP MCP and completes the bridge's OAuth sign-in can be a worker. Start with the [worker guide](docs/worker-clients.md).
|
|
184
181
|
|
|
185
182
|
| Client | Guide |
|
|
186
183
|
|---|---|
|
|
@@ -193,14 +190,14 @@ Any client that speaks HTTP MCP and completes the bridge's OAuth sign-in can be
|
|
|
193
190
|
|
|
194
191
|
## Upgrade
|
|
195
192
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
For a compatible-code restart, built-in OAuth keeps an unexpired access token only when the bridge uses the same private home and issuer and its grant and connection remain live. Access tokens last up to one hour. Before an upgrade or restore, stop the bridge and every other writer, then 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](docs/operations.md#upgrade-and-rollback).
|
|
193
|
+
For an installed service, follow [service updates](docs/service-setup.md#service-updates). Dalan checks daily by default; a tool-catalog change waits for your approval before switching and requires a refresh in each connected client.
|
|
199
194
|
|
|
200
|
-
For
|
|
195
|
+
For an older or manually managed installation, follow the [upgrade guide](docs/dalan-upgrade.md). Before upgrading or restoring, use the [backup and rollback instructions](docs/operations.md#upgrade-and-rollback). Do not copy keys alone or mix files from different backups.
|
|
201
196
|
|
|
202
197
|
## Reference
|
|
203
198
|
|
|
199
|
+
Replace `REQUEST_ID` with a job's ID.
|
|
200
|
+
|
|
204
201
|
| Need | Command or guide |
|
|
205
202
|
| --- | --- |
|
|
206
203
|
| Command help | `dalan help --all` |
|
package/bin/dalan.mjs
CHANGED
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
import fs from 'node:fs';
|
|
5
5
|
import os from 'node:os';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
7
8
|
import { unsupportedRuntime } from '../src/runtime-check.mjs';
|
|
9
|
+
import { followTarget, handOver } from '../src/follow-current.mjs';
|
|
10
|
+
import { readDefaultHome } from '../src/default-home.mjs';
|
|
8
11
|
import { resolveHelp } from '../src/cli-help.mjs';
|
|
12
|
+
// Follow the version the service runs, so the CLI and the service never drift. Then find the recorded home without DALAN_HOME.
|
|
13
|
+
const followed = followTarget({ ownBin: fileURLToPath(import.meta.url), argv: process.argv.slice(2) });
|
|
14
|
+
if (followed) handOver(followed);
|
|
15
|
+
else {
|
|
16
|
+
if (!process.env.DALAN_HOME && !['try', 'service', 'setup'].includes(process.argv[2])) { const recorded = readDefaultHome(); if (recorded) process.env.DALAN_HOME = recorded; }
|
|
9
17
|
if (['--version', '-v'].includes(process.argv[2])) {
|
|
10
18
|
const { version } = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
|
|
11
19
|
process.stdout.write(`${version}\n`);
|
|
@@ -41,3 +49,4 @@ if (help) {
|
|
|
41
49
|
if (process.env.DALAN_HOME) process.env.HOME = path.resolve(process.env.DALAN_HOME);
|
|
42
50
|
await import('./dot-worker.mjs');
|
|
43
51
|
}
|
|
52
|
+
}
|
package/bin/dot-worker.mjs
CHANGED
|
@@ -26,6 +26,7 @@ import { RESOURCE_LIMITS_UNAVAILABLE } from '../src/host-execution-policy.mjs';
|
|
|
26
26
|
import { summarizeRejections } from '../src/rejections.mjs';
|
|
27
27
|
import { VERDICT_EXIT, formatVerdict } from '../src/work-order.mjs';
|
|
28
28
|
import { connectCommand } from '../src/connect-cli.mjs';
|
|
29
|
+
import { runAuthCheck } from '../src/auth-check.mjs';
|
|
29
30
|
import { initAsFiles, rotateKeys } from '../src/as-files.mjs';
|
|
30
31
|
import { docsUrl } from '../src/docs-url.mjs';
|
|
31
32
|
import { workerPrompt } from '../src/worker-prompt.mjs';
|
|
@@ -36,6 +37,9 @@ import { applyPatch } from '../src/patch-apply.mjs';
|
|
|
36
37
|
import { terminalSafe, jsonTerminalSafe } from '../src/terminal-safe.mjs';
|
|
37
38
|
import { loadOwnerWorkers, parseWorkers, submitTarget, updateWorkerRepoPolicy, writeGenericProfile, writeLegacyMarker, readWorkerRepoHistory, seedWorkerRepos, inspectGrantAudit, AUDIT_INTEGRITY_HINT } from '../src/workers.mjs';
|
|
38
39
|
import { adminSocketPathError } from '../src/admin-socket.mjs';
|
|
40
|
+
import { answerThroughJournal } from '../src/answer-journal.mjs';
|
|
41
|
+
// An answer reply that takes longer than this counts as lost; the journaled envelope is sent again.
|
|
42
|
+
const ANSWER_TIMEOUT_MS=30000;
|
|
39
43
|
|
|
40
44
|
// Every line this command writes to stderr can quote a worker's report, error or path. JSON lines stay JSON; the rest is made inert.
|
|
41
45
|
const writeStderr=console.error.bind(console);
|
|
@@ -85,7 +89,7 @@ function bridgeNotRunning(error) {
|
|
|
85
89
|
if(selected) return Object.assign(error,{message:`cannot reach the bridge: no bridge is running for DALAN_HOME=${selected} (${cause})`,fix:[`start the bridge for this home the way you set it up (${docsUrl('docs/manual-setup.md','owner-and-requester-setup')}), then run this command again`]});
|
|
86
90
|
return Object.assign(error,{message:`cannot reach the bridge: DALAN_HOME is not set and no bridge is running in ${home} (${cause})`,fix:[`export DALAN_HOME=DIR for the bridge home you made, or start a trial bridge with: ${cli} try`]});
|
|
87
91
|
}
|
|
88
|
-
function request(route, method = 'GET', payload, headers={}) {
|
|
92
|
+
function request(route, method = 'GET', payload, headers={}, timeoutMs=0) {
|
|
89
93
|
return new Promise((resolve, reject) => {
|
|
90
94
|
const bytes = payload ? JSON.stringify(payload) : '';
|
|
91
95
|
const transportFailure=error=>reject(Object.assign(error.syscall==='connect'&&['ENOENT','ECONNREFUSED'].includes(error.code)?bridgeNotRunning(error):error,{kind:'transport'}));
|
|
@@ -103,6 +107,7 @@ function request(route, method = 'GET', payload, headers={}) {
|
|
|
103
107
|
else resolve(value);
|
|
104
108
|
});
|
|
105
109
|
});
|
|
110
|
+
if(timeoutMs>0) req.setTimeout(timeoutMs,()=>req.destroy(Object.assign(new Error(`admin request timed out after ${timeoutMs} ms`),{code:'ETIMEDOUT'})));
|
|
106
111
|
req.on('error',transportFailure); req.end(bytes);
|
|
107
112
|
});
|
|
108
113
|
}
|
|
@@ -333,7 +338,7 @@ async function waitDrained() {
|
|
|
333
338
|
}
|
|
334
339
|
}
|
|
335
340
|
async function main() {
|
|
336
|
-
let result, waitOutput=false, plainOutput=false;
|
|
341
|
+
let result, waitOutput=false, plainOutput=false, earlyId=false;
|
|
337
342
|
const help=resolveHelp([command,...args]);
|
|
338
343
|
if(help){ if(help.stream==='stdout') console.log(help.text); else console.error(help.text); process.exitCode=help.code; return; }
|
|
339
344
|
switch (command) {
|
|
@@ -506,6 +511,8 @@ async function main() {
|
|
|
506
511
|
}
|
|
507
512
|
for(const w of result?.submission_warnings??[]) console.error(`dalan: WARNING: ${w}`);
|
|
508
513
|
if(dryRun) { if(!json) console.error(formatVerdict(result)); process.exitCode=VERDICT_EXIT[result.verdict]??0; break; }
|
|
514
|
+
// A person driving a worker by hand needs the ID while the wait runs. On a terminal the lines go to stdout; piped, they go to stderr so stdout stays the one JSON result.
|
|
515
|
+
if(args.includes('--wait')&&!json) { (process.stdout.isTTY?console.log:console.error)(`Request ID: ${id}\nSend your worker: ${workerPrompt(id)}`); earlyId=true; }
|
|
509
516
|
if(args.includes('--wait')) { result=await waitForAssignment(id,option('--timeout')); indexArtifacts(id,result); waitOutput=true; process.exitCode=waitExitCode(result.status); if(!json) waitTimeoutNote(id,result); }
|
|
510
517
|
// Discovery labels are not capabilities. Report only the persisted, validated binding.
|
|
511
518
|
const producer=typeof saved.producer==='string'&&producerPattern.test(saved.producer)?saved.producer:null;
|
|
@@ -514,7 +521,7 @@ async function main() {
|
|
|
514
521
|
binding,wake:args.includes('--wait')?'wait_returned':delivery==='none'?'not_registered_by_this_submit':'delivery_destination'};
|
|
515
522
|
if(json) result={...result,recovery};
|
|
516
523
|
// Human mode: one plain next step on stderr, so stdout stays the JSON document. --json carries the full recovery record.
|
|
517
|
-
else endNote=`${briefGiven?`Request ID: ${id}\nSend your worker: ${workerPrompt(id)}\n`:''}Next: ${recovery.wake==='wait_returned'?`read the result with: ${recovery.get}`:recovery.wake==='delivery_destination'?`the result goes to ${delivery}; check it any time with: ${recovery.get}`:`send your worker the job, then run: ${cli} wait ${id} (check it any time with: ${recovery.get})`}${recovery.inbox?`. List your jobs with: ${recovery.inbox}`:''}`;
|
|
524
|
+
else endNote=`${briefGiven&&!earlyId?`Request ID: ${id}\nSend your worker: ${workerPrompt(id)}\n`:''}Next: ${recovery.wake==='wait_returned'?`read the result with: ${recovery.get}`:recovery.wake==='delivery_destination'?`the result goes to ${delivery}; check it any time with: ${recovery.get}`:`send your worker the job, then run: ${cli} wait ${id} (check it any time with: ${recovery.get})`}${recovery.inbox?`. List your jobs with: ${recovery.inbox}`:''}`;
|
|
518
525
|
// On a terminal, a person reads the output: show the human lines instead of the JSON receipt. Piped output stays
|
|
519
526
|
// the JSON document, so scripts that read submit's standard output keep working; --json always prints it.
|
|
520
527
|
if(!json&&!waitOutput&&process.stdout.isTTY) { result=`Request ID: ${id}${briefGiven?`\nSend your worker: ${workerPrompt(id)}`:''}`; plainOutput=true; endNote=endNote.split('\n').filter(l=>!l.startsWith('Request ID: ')&&!l.startsWith('Send your worker: ')).join('\n'); }
|
|
@@ -559,7 +566,14 @@ async function main() {
|
|
|
559
566
|
case 'wait': { refuseUnknownOptions('wait',{flags:['--json','--drained'],values:['--timeout','--producer-thread','--max-claimed','--max-queued']}); if(args.includes('--drained')) { result=await waitDrained(); waitOutput=true; process.exitCode=drainedExitCodes[result.status]; break; } const id=args[0]; if(!id||id.startsWith('-')) throw new Error(`wait needs a request ID: ${cli} wait REQUEST_ID (list your jobs with: ${cli} inbox --all)`); result=await waitForAssignment(id,option('--timeout')); indexArtifacts(id,result); waitOutput=true; process.exitCode=waitExitCode(result.status); if(!json&&process.stdout.isTTY) { result=formatWaitLine(result,{id,cli,seconds:option('--timeout')===null?300:Number(option('--timeout'))}); plainOutput=true; } else if(!json) waitTimeoutNote(id,result); break; }
|
|
560
567
|
case 'note': { if(args.some(a=>a.startsWith('-')&&a!=='--json')) throw new Error('note accepts only --json as an option'); const [id,...parts]=args.filter(a=>a!=='--json'),text=parts.join(' '); if(!id||!text) throw new Error('note requires request id and text'); result=await request('/note','POST',{id,text},{'x-owner-capability':receipt(id).token}); break; }
|
|
561
568
|
case 'questions': { const ids=args.filter(a=>a!=='--json');if(ids.length!==1||ids[0].startsWith('-')) throw new Error('questions requires one request id (optional --json)');result=await request('/questions?id='+encodeURIComponent(ids[0]),'GET',null,{'x-owner-capability':receipt(ids[0]).token});break; }
|
|
562
|
-
case 'answer': { if(args.some(a=>a.startsWith('-')&&a!=='--json')) throw new Error('answer accepts only --json as an option');const [id,questionId,...parts]=args.filter(a=>a!=='--json'),text=parts.join(' ');if(!id||!questionId||!text) throw new Error('answer requires request id, question id and text');
|
|
569
|
+
case 'answer': { if(args.some(a=>a.startsWith('-')&&a!=='--json')) throw new Error('answer accepts only --json as an option');const [id,questionId,...parts]=args.filter(a=>a!=='--json'),text=parts.join(' ');if(!id||!questionId||!text) throw new Error('answer requires request id, question id and text');
|
|
570
|
+
// Every answer goes through the journal: the key and expected revision are saved before the first send, so a crash or a lost reply is retried with the same envelope.
|
|
571
|
+
const owner=()=>({'x-owner-capability':receipt(id).token});
|
|
572
|
+
result=await answerThroughJournal({receiptsDir:receipts,job:id,questionId,text,
|
|
573
|
+
readRevision:async()=>{const got=await request('/get?id='+encodeURIComponent(id)+'&peek=1','GET',null,owner());return Number.isSafeInteger(got.protocol_revision)?got.protocol_revision:null;},
|
|
574
|
+
post:envelope=>request('/answer','POST',envelope,owner(),ANSWER_TIMEOUT_MS),
|
|
575
|
+
readQuestion:async()=>(await request('/questions?id='+encodeURIComponent(id),'GET',null,owner())).questions.find(q=>q.question_id===questionId)});
|
|
576
|
+
break; }
|
|
563
577
|
case 'tell': { const worker=option('--worker'),rest=args.filter((a,i)=>a!=='--worker'&&args[i-1]!=='--worker');if(rest.some(a=>a.startsWith('-')&&a!=='--json')) throw new Error('tell accepts --worker NAME and --json');const text=rest.filter(a=>a!=='--json').join(' ');if(!text) throw new Error('tell requires text');result=await request('/tell','POST',{text,...(worker?{worker}:{})});break; }
|
|
564
578
|
case 'untell': { const worker=option('--worker'),rest=args.filter((a,i)=>a!=='--worker'&&args[i-1]!=='--worker'&&a!=='--json');if(rest.length!==1||rest[0].startsWith('-')) throw new Error('untell requires message ID (optional --worker NAME, --json)');result=await request('/untell','POST',{message_id:rest[0],...(worker?{worker}:{})});break; }
|
|
565
579
|
case 'audit': { const since=option('--since'); result=await request('/audit'+(since?'?since='+encodeURIComponent(since):''),'GET',null,{'x-operator-key':operator()}); break; }
|
|
@@ -692,6 +706,17 @@ async function main() {
|
|
|
692
706
|
break;
|
|
693
707
|
}
|
|
694
708
|
case 'doctor': {
|
|
709
|
+
if(args.includes('--auth')) {
|
|
710
|
+
// A real OAuth client walk against this home's public MCP URL; the owner approval goes through the admin socket and is revoked after.
|
|
711
|
+
if(args.includes('--checks')) throw new Error('doctor: --auth and --checks cannot be combined');
|
|
712
|
+
if(args.includes('--worker')&&(!option('--worker')||option('--worker').startsWith('--'))) throw new Error('--worker requires a name');
|
|
713
|
+
const lines=[];
|
|
714
|
+
const workersFile=readEnv('DALAN_WORKERS_FILE')||defaultPath(home,'.config/dot-bridge/workers.json');
|
|
715
|
+
const outcome=await runAuthCheck({home,workers:fs.existsSync(workersFile)?[...loadOwnerWorkers(workersFile).workers.keys()]:[],worker:option('--worker')??undefined,request,operator,say:line=>lines.push(line)});
|
|
716
|
+
if(!outcome.ok) process.exitCode=outcome.partial?2:1;
|
|
717
|
+
result=json?{ok:outcome.ok,results:outcome.results}:lines.join('\n');plainOutput=!json;
|
|
718
|
+
break;
|
|
719
|
+
}
|
|
695
720
|
if(args.includes('--checks')) {
|
|
696
721
|
// Local only: the owner's checks.json against each repo's default-branch tree (mirror). Warnings never fail the command; errors do.
|
|
697
722
|
const repos=lintChecksFile();
|