@monster-orange/den 0.4.18 → 0.4.20

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 (53) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/README.md +14 -13
  3. package/docs/distributions.md +148 -30
  4. package/docs/reference.md +1 -1
  5. package/package.json +2 -1
  6. package/skills/install-den/SKILL.md +35 -75
  7. package/src/shared/agents/den-claude.ts +40 -6
  8. package/src/shared/agents/guardrails/stop-hook.ts +30 -4
  9. package/src/shared/agents/guardrails.ts +40 -4
  10. package/src/shared/agents/handback.ts +22 -4
  11. package/src/shared/agents/personas.ts +32 -5
  12. package/src/shared/agents/runtime.ts +8 -0
  13. package/src/shared/agents/server-agent.ts +57 -0
  14. package/src/shared/agents/server-pack/server.md +45 -0
  15. package/src/shared/environment-manager/workspaces.ts +4 -0
  16. package/src/shared/secrets/index.ts +71 -3
  17. package/src/shared/secrets/onepassword.ts +87 -14
  18. package/src/shared/secrets/op-token.ts +270 -0
  19. package/src/shared/secrets/secret-env.ts +19 -6
  20. package/src/shared/secrets/strategies.ts +6 -0
  21. package/src/shared/secrets/types.ts +8 -0
  22. package/src/ui/cli/agent-ops.ts +41 -6
  23. package/src/ui/cli/create.ts +2 -2
  24. package/src/ui/cli/doctor-command.ts +54 -2
  25. package/src/ui/cli/index.ts +1 -1
  26. package/src/ui/cli/repo-command.ts +8 -1
  27. package/src/ui/cli/repo-detect.ts +58 -0
  28. package/src/ui/cli/server-agent-ops.ts +411 -0
  29. package/src/ui/mcp/server.ts +29 -12
  30. package/src/ui/mcp/tools.ts +4 -2
  31. package/src/ui/server/agent-routes.ts +1 -1
  32. package/src/ui/server/held-actions.ts +35 -7
  33. package/src/ui/server/index.ts +25 -6
  34. package/src/ui/server/public/agents-page.js +10 -1
  35. package/src/ui/server/public/error-page.js +39 -1
  36. package/src/ui/server/public/graph.css +21 -0
  37. package/src/ui/server/public/graph.js +49 -6
  38. package/src/ui/server/public/header.js +29 -7
  39. package/src/ui/server/public/i18n/es.js +38 -0
  40. package/src/ui/server/public/i18n/ja.js +40 -0
  41. package/src/ui/server/public/local-dev.html +22 -1
  42. package/src/ui/server/public/persona-ui.css +6 -0
  43. package/src/ui/server/public/server-agent-page.js +415 -0
  44. package/src/ui/server/public/server-agent.html +222 -0
  45. package/src/ui/server/public/settings-registry.js +22 -0
  46. package/src/ui/server/public/shell.js +67 -6
  47. package/src/ui/server/public/svc-panel.js +27 -14
  48. package/src/ui/server/public/topbar.js +13 -1
  49. package/src/ui/server/route-classes.ts +21 -0
  50. package/src/ui/server/server-agent-routes.ts +176 -0
  51. package/src/ui/server/session-routes.ts +12 -1
  52. package/src/ui/server/ui-assets.ts +2 -0
  53. package/src/ui/server/workspace-routes.ts +3 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,166 @@ All notable changes to Den are documented here. Each release lists the
4
4
  config and manifest changes a distribution must make to move to it under
5
5
  **Migrations**.
6
6
 
7
+ ## [0.4.20] - 2026-11-09
8
+
9
+ ### Added
10
+
11
+ - **1Password works for a Den running as a service.** A Den under launchd
12
+ does not read your login shell, so `op` had no
13
+ `OP_SERVICE_ACCOUNT_TOKEN` and every 1Password `secret_env` ref failed
14
+ with a bare "not resolved". `secrets.onepassword.token` in
15
+ `config/local/user.yml` (per machine) now says where the token comes
16
+ from: `keychain:<service>` (macOS), `file:<path>` (mode 600 only) or
17
+ `env:<VAR>` (the default is `env:OP_SERVICE_ACCOUNT_TOKEN`, as before).
18
+ A bad value is refused at config load, naming the key. The token is read
19
+ when a ref is resolved, never cached, and goes only into the `op` child's
20
+ env; it is never logged, stored, put in an error, the activity records
21
+ or an API response.
22
+ - **"Not resolved" now says why.** A 1Password ref that fails reports one
23
+ of: no service-account token or session, no access to the vault, item or
24
+ field not found, rate limited, or a short safe summary. A token source
25
+ that fails (keychain item missing, file mode wrong, env var unset) is
26
+ named, never the token.
27
+ - **doctor** adds a `1password` row, "this process has no service-account
28
+ token. Set secrets.onepassword.token.", when 1Password is the provider
29
+ and the source yields none (a warning).
30
+ - **Settings › Secrets** shows the token's source, never the token
31
+ (`GET /api/settings` gains `op_token_source`, a string).
32
+
33
+ ## [0.4.19] - 2026-11-08
34
+
35
+ ### Added
36
+
37
+ - **The server agent (ON-6).** Every Den has its own agent, named after the
38
+ distribution ("Acme agent"), for anything about the server itself: set it
39
+ up, add a repo, fix a failing service, change a setting, explain what's
40
+ running. It belongs to no workspace. It is a normal Den agent underneath
41
+ (record, session, Resume, rotation, hooks), with Den's persona `server`
42
+ and the plain-writing rule, in a reserved scope, `den-server`.
43
+ - It acts only through Den's MCP, which serves it the whole Den. Each
44
+ write (`workspace_create`, `repo_add`, `service_try`) is held for the
45
+ person's Allow, so it only reads until they allow one. It starts in an
46
+ empty folder of its own (`<state_dir>/server-agent`).
47
+ - A fresh Den's first page (`/`, while no workspace has a repo) is that
48
+ agent in a terminal framed as the page, with Open in Agents. With an
49
+ installed runtime that carries Den's tools, it starts by itself, with
50
+ "Let's set up <name>. Where are your repos?", with the folder above the
51
+ Den's as the default, in its first turn. With none, the page shows how
52
+ to install one and the manual path for this Den, from its folder:
53
+ `cd <dir>` → `./bin/<cli> repo add <path>` → `./bin/<cli> up`.
54
+ - After setup it is in the rail (`/server-agent`), ⌘K has "Ask <name>",
55
+ and Agents lists it first, under "Server".
56
+ - Its runtime: the page's Runs on picker (`agents.server_runtime` in
57
+ `config/local/user.yml`), else the first installed one with Den's tools.
58
+ - Its model: the page's Model picker beside it (`agents.server_model`),
59
+ with only the runtime's own models, else Sonnet when the runtime has it.
60
+ A new model takes effect at the next start (a fresh conversation).
61
+ - Den's own MCP tools run without Claude Code's own prompt, for this
62
+ agent only (`mcp__<server>` in its settings file's `permissions.allow`).
63
+ Reads just run; each write still waits for the person's Allow in the
64
+ browser, so it asks once. The org's immediate actions (`mcp.actions`)
65
+ still ask in the terminal (`permissions.ask`). Workspace agents are
66
+ unchanged.
67
+ - On a fresh Den, one line above its terminal: "Claude asks whether to
68
+ trust this folder. Choose Yes." Den doesn't answer Claude's folder-trust
69
+ prompt for the person.
70
+ - `GET /api/server-agent`, `POST /api/server-agent/start`,
71
+ `POST /api/server-agent/runtime` and `POST /api/server-agent/model`.
72
+ Only a person starts it or picks its runtime or model: an agent's token
73
+ or claim gets 403.
74
+
75
+ ### Changed
76
+
77
+ - **The install-den skill does three things only (ON-1, slimmed).** It
78
+ installs Den after checking Node and git, helps pick its name and folder
79
+ (default `~/<name>`), then runs `web up` and hands over the one-time link
80
+ from `web claim-link`: "Den's own agent takes it from there." It no
81
+ longer adds repos, starts services or connects itself to Den's MCP.
82
+ - **`npx @monster-orange/den@latest create`.** The skill, the README, the
83
+ docs, `create`'s own `fix` lines and `--help` name `@latest`. A bare name
84
+ could reuse an older Den cached in `~/.npm/_npx`.
85
+ - **workspace_create makes the workspace active.** On the person's Allow,
86
+ the MCP's `workspace_create` creates the workspace and activates it, so
87
+ `service_try` can start its services. `service_try` on a workspace that
88
+ isn't active says so in the browser ("Start <service> (this activates
89
+ <workspace>)") and does both on the one Allow. Before, the server agent
90
+ was refused with "Workspace is not active", and nothing it could call
91
+ activated one. `<cli> workspace create` is unchanged.
92
+ - **The drafted manifest has a health URL when the dev server's port is
93
+ known.** `manifest_draft` and `repo add` draft
94
+ `health: { local: { url: http://localhost:<port>/ } }` when the start
95
+ script names a port (`--port`, `-p`, `PORT=`) or runs a dev server with a
96
+ fixed default (Vite 5173, Next 3000, Angular 4200, and a few
97
+ more). So the service gets a health check and Visit ↗. `--health` still
98
+ wins. With no port, nothing is guessed.
99
+ - **The ON-4 dry run follows the two agents:** install, the setup link, the
100
+ fresh first page, then the server agent's MCP calls, with `repo_add` and
101
+ `service_try` each allowed from the signed-in browser. It now asserts 5
102
+ minutes or less.
103
+ - **An accessibility check runs with the tests.** axe-core (WCAG 2.0 and
104
+ 2.1 A and AA, plus best practice) scans the rail, an open pinned-service
105
+ panel, the Start agent dialog and the server agent's page, in light and
106
+ dark, at 1440×900 and 390×844. Any violation fails it.
107
+
108
+ ### Fixed
109
+
110
+ - **No Stop hook error at the end of setup.** The server agent was given the build agents' hand-back template, so
111
+ after the service came up it wrote a hand-back, and Den's Stop hook sent it back because a decision didn't end in
112
+ "?". The person saw "Stop hook error" and waited a turn. The server agent now has no hand-back template, and its
113
+ Stop hook skips the hand-back check. It still asks it to explain every ID, and session rotation is unchanged.
114
+
115
+ - **The Stop hook no longer flags Den's own name.** A Den whose name looks
116
+ like an ID (`t2` → "T2") had the server agent's first greeting rejected
117
+ ("'T2' is not explained"), and the person saw "Stop hook error". Den now
118
+ tells the hook the ID-shaped words in its own title and the workspace's
119
+ name (`--known`), and it never flags those. Any other bare ID is still
120
+ flagged.
121
+ - **No What's new over a brand-new Den.** On a fresh Den (no repo in any
122
+ workspace yet, the server agent page's `fresh`) the release notes no
123
+ longer open by themselves over the agent and the approvals. That version
124
+ counts as seen. `/api/server-info` has `fresh`.
125
+ - **The "log in here" line shows on every fresh run.** The server agent
126
+ page chose the line from the runtime picker's runtime, which can read
127
+ none (or another one) while the agent runs. It now uses the runtime the
128
+ agent runs on (`runningRuntime`, from its record). And a start that isn't
129
+ running yet when the page reads it back is read again, a second apart, so
130
+ the terminal and its lines come up without a reload.
131
+ - **The Graph's empty View says where a service is.** With the View on a
132
+ workspace with no services (right after onboarding), Open in Graph for
133
+ a service in another workspace showed "No services in workspace" only.
134
+ It now also says "<service> is in <workspace>, outside this View." with
135
+ Show <workspace>, the same line as over a drawn graph.
136
+ - **Open Terminal on Windows.** On the signed-out page it did nothing on Windows. Windows has no `ssh://` app by default, so
137
+ there the link is gone and the ssh command is the step: "Open Windows Terminal or PowerShell, paste this, and press
138
+ Enter." Elsewhere, if the page still has focus 2 seconds after the click, it says "Nothing opened? Copy the command
139
+ below and paste it into your terminal app." The command and its copy button always show.
140
+
141
+ - **No "down" flash after Start.** Starting a dev server from the
142
+ pinned-service panel showed "starting…", then "down: fetch failed" for
143
+ a second or two, then up. The server's ready event ended "starting…",
144
+ and the header's next health paint still held the service's down result
145
+ from before Start. Now, while a Start or Restart is in flight, a down
146
+ reads "starting…" until the first up or the 120 s timeout. The ready
147
+ event ends it only when health already says up.
148
+ - **Open in Graph says when a service is outside the View.** With the View
149
+ on one workspace, Open in Graph for a service in another landed on a
150
+ Graph without its card. Now the Graph says "<service> is in
151
+ <workspace>, outside this View." with a Show <workspace> button. The
152
+ button switches the View the way the top bar does, then focuses the
153
+ card. The View never switches by itself.
154
+ - **The phone drawer keeps the rail a nav.** Under 720 px, ☰ made the
155
+ rail's `<nav>` itself a dialog, which a nav may not be. The dialog is
156
+ now a box around the rail ("Pages"); focus, Tab, Esc and the scrim work
157
+ as before.
158
+ - **The chosen persona's role and tag are readable.** On the chosen row's
159
+ tint, in light, they were 4.49:1, under 4.5:1. They read in the muted
160
+ colour there now.
161
+
162
+ ### Migrations
163
+
164
+ - No workspace may be named `den-server`: creating one is refused. Rename a
165
+ workspace with that name before moving to 0.4.19.
166
+
7
167
  ## [0.4.18] - 2026-11-08
8
168
 
9
169
  ### Added
package/README.md CHANGED
@@ -10,8 +10,8 @@
10
10
  </p>
11
11
 
12
12
  <picture>
13
- <source media="(prefers-color-scheme: dark)" srcset="docs/images/0.4.18/hero-dark.png">
14
- <img src="docs/images/0.4.18/hero-light.png" width="100%" alt="Den's Graph page: the demo workspace's services grouped by application, all healthy, with the status chip and the left rail">
13
+ <source media="(prefers-color-scheme: dark)" srcset="docs/images/0.4.20/hero-dark.png">
14
+ <img src="docs/images/0.4.20/hero-light.png" width="100%" alt="Den's Graph page: the demo workspace's services grouped by application, all healthy, with the status chip and the left rail">
15
15
  </picture>
16
16
 
17
17
  ## Set up by your agent
@@ -22,11 +22,12 @@ Paste this line into your coding agent (Claude Code, Codex, Gemini, Grok, …):
22
22
  Set up Den for me by following https://raw.githubusercontent.com/Monster-Orange/den/main/skills/install-den/SKILL.md
23
23
  ```
24
24
 
25
- The agent follows the [install-den skill](skills/install-den/SKILL.md). It asks you at most three questions,
26
- creates your Den, adds one of your repos without changing it, starts it, checks it, and connects itself to Den's
27
- MCP server. Then it tells you what's running and the URL to open. It never asks for a password in chat, never
28
- edits your repos and sends nothing off your machine. Every step it runs answers in JSON and is safe to re-run:
29
- see [Set up by your agent](docs/distributions.md#set-up-by-your-agent).
25
+ The agent follows the [install-den skill](skills/install-den/SKILL.md). It checks Node and git, installs Den,
26
+ asks you its name and folder, starts it, and hands you a one-time link. Open it: your Den's own agent takes it
27
+ from there. That agent finds your repos, adds them without changing them and starts one, and each change waits
28
+ for you to allow it in the browser. Neither agent asks for a password in chat, edits your repos or sends anything
29
+ off your machine. Every step answers in JSON and is safe to re-run: see
30
+ [Set up by your agent](docs/distributions.md#set-up-by-your-agent) and [The server agent](docs/distributions.md#the-server-agent).
30
31
 
31
32
  ## What Den is
32
33
 
@@ -38,7 +39,7 @@ It doesn't replace your tools. Your repos, Docker, your test runners, your secre
38
39
  yours. Den connects them and turns on good practice from the start.
39
40
 
40
41
  <p align="center">
41
- <img src="docs/images/0.4.18/up.gif" width="100%" alt="make up in the Graph page: every stack down, then demo-api, demo-web and demo-notes come up in dependency order until the status chip reads All 3 healthy">
42
+ <img src="docs/images/0.4.20/up.gif" width="100%" alt="make up in the Graph page: every stack down, then demo-api, demo-web and demo-notes come up in dependency order until the status chip reads All 3 healthy">
42
43
  </p>
43
44
 
44
45
  ## How it helps
@@ -68,10 +69,10 @@ yours. Den connects them and turns on good practice from the start.
68
69
  lives in your own repo.
69
70
 
70
71
  <p align="center">
71
- <img src="docs/images/0.4.18/agents.png" width="49%" alt="The Agents tab: the demo workspace's sessions on the left, and one open in a terminal pane on the right, running demo-api's test and then the service">
72
- <img src="docs/images/0.4.18/workspaces.png" width="49%" alt="The Workspaces page: the demo workspace's repos with their health, mode and Start, Stop, Restart and Logs actions">
73
- <img src="docs/images/0.4.18/status-drawer.png" width="49%" alt="The status drawer: nothing needs attention, and every service in the demo workspace, by application, with its latency">
74
- <img src="docs/images/0.4.18/edge.png" width="49%" alt="The Edge page: the edge container up, its ports and TLS, and every route it serves, Den's own and each stack's, with its upstream">
72
+ <img src="docs/images/0.4.20/agents.png" width="49%" alt="The Agents tab: the demo workspace's sessions on the left, and one open in a terminal pane on the right, running demo-api's test and then the service">
73
+ <img src="docs/images/0.4.20/workspaces.png" width="49%" alt="The Workspaces page: the demo workspace's repos with their health, mode and Start, Stop, Restart and Logs actions">
74
+ <img src="docs/images/0.4.20/status-drawer.png" width="49%" alt="The status drawer: nothing needs attention, and every service in the demo workspace, by application, with its latency">
75
+ <img src="docs/images/0.4.20/edge.png" width="49%" alt="The Edge page: the edge container up, its ports and TLS, and every route it serves, Den's own and each stack's, with its upstream">
75
76
  </p>
76
77
 
77
78
  ## Get started
@@ -79,7 +80,7 @@ yours. Den connects them and turns on good practice from the start.
79
80
  You need Node 22.13 or later, and Docker for anything that runs in containers. mkcert is only needed if you want Den to issue local HTTPS certificates.
80
81
 
81
82
  ```sh
82
- npx @monster-orange/den create acme # your own Den, named after your product
83
+ npx @monster-orange/den@latest create acme # your own Den, named after your product
83
84
  cd acme && npm install
84
85
  ./bin/acme register ../shop-api # add a repo (repeat for each one)
85
86
  ./bin/acme up # start everything, in order
@@ -19,8 +19,8 @@ Den's own checkout is itself a distribution, named `den`.
19
19
  ## Create one
20
20
 
21
21
  ```sh
22
- npx @monster-orange/den create acme # writes ./acme
23
- npx @monster-orange/den create acme ~/src/acme-dev --title "Acme Dev"
22
+ npx @monster-orange/den@latest create acme # writes ./acme
23
+ npx @monster-orange/den@latest create acme ~/src/acme-dev --title "Acme Dev"
24
24
  ```
25
25
 
26
26
  From a Den checkout, `./bin/den create acme ../acme` does the same.
@@ -72,26 +72,33 @@ Set up Den for me by following https://raw.githubusercontent.com/Monster-Orange/
72
72
 
73
73
  That file is the install-den skill, also in the package at
74
74
  `skills/install-den/SKILL.md`: plain Markdown any agent can follow, with
75
- Claude skill front matter. `den --help` prints the line. The skill runs the
76
- commands below. Each one takes `--json`, never prompts, and is safe to
75
+ Claude skill front matter. `den --help` prints the line. The skill does three
76
+ things only: it installs Den (after checking Node and git), helps the person
77
+ pick its name and folder (default `~/<name>`), then runs `web up` and hands
78
+ over the one-time link from `web claim-link`: "Den's own agent takes it from
79
+ there." It adds no repo and creates no workspace: that is
80
+ [the server agent](#the-server-agent)'s job. Every command below also stays a
81
+ person's own: `npm i -g @monster-orange/den` → `den create <name>` →
82
+ `<cli> repo add` → `<cli> up` skips both agents. The skill runs the first
83
+ of the commands below, and the server agent the rest through MCP. Each one takes `--json`, never prompts, and is safe to
77
84
  re-run. With `--json`, stdout carries exactly one JSON object and the
78
85
  command's log goes to stderr. When `ok` is false the object says why
79
86
  (`error`) and carries either a command the agent can run (`fix`) or a
80
87
  question for the person (`ask`, sometimes with `choices`).
81
88
 
82
- | Step | Answers |
83
- | ---------------------------------------------------------- | ---------------------------------------------------------------------------- |
84
- | `npx @monster-orange/den create <name> [dir] --yes --json` | `{ ok, dir, cli, existed, files, port, portPicked?, next }` |
85
- | `<cli> repo add <path\|git-url> --json` | `{ ok, existed, repo, workspace, mode, path, manifest, services, next }` |
86
- | `<cli> repo detect <folder> --json` | `{ ok, path, repos, workspaces, truncated, skipped, rule, next }` |
87
- | `<cli> repo add <path> --dry-run --json` | `{ ok, dryRun, repo, workspace, path, manifest, draft, validation, next }` |
88
- | `<cli> onboard status --json` | `{ ok, checks: [{ id, status, detail, fix?, ask? }], next }` |
89
- | `<cli> up <repo> --json` | `{ ok, workspace, services: [{ address, result, health, detail? }], next }` |
90
- | `<cli> web up --no-open --json` | `{ ok, url, port, version? }` |
91
- | `<cli> doctor --json` | `{ ok, checks: [{ id, status, detail, url?, port?, fix?, ask? }] }` |
92
- | `<cli> mcp connect --runtime <runtime> --json` | `{ ok, server, clients: [{ id, ok, said, file?, changed? }], restart, web }` |
93
- | `<cli> down <repo> --json` | `{ ok, workspace, services, all? }` |
94
- | `<cli> web down --json` | `{ ok, url, port, running, stopped }` |
89
+ | Step | Answers |
90
+ | ----------------------------------------------------------------- | ---------------------------------------------------------------------------- |
91
+ | `npx @monster-orange/den@latest create <name> [dir] --yes --json` | `{ ok, dir, cli, existed, files, port, portPicked?, next }` |
92
+ | `<cli> repo add <path\|git-url> --json` | `{ ok, existed, repo, workspace, mode, path, manifest, services, next }` |
93
+ | `<cli> repo detect <folder> --json` | `{ ok, path, repos, workspaces, truncated, skipped, rule, next }` |
94
+ | `<cli> repo add <path> --dry-run --json` | `{ ok, dryRun, repo, workspace, path, manifest, draft, validation, next }` |
95
+ | `<cli> onboard status --json` | `{ ok, checks: [{ id, status, detail, fix?, ask? }], next }` |
96
+ | `<cli> up <repo> --json` | `{ ok, workspace, services: [{ address, result, health, detail? }], next }` |
97
+ | `<cli> web up --no-open --json` | `{ ok, url, port, version? }` |
98
+ | `<cli> doctor --json` | `{ ok, checks: [{ id, status, detail, url?, port?, fix?, ask? }] }` |
99
+ | `<cli> mcp connect --runtime <runtime> --json` | `{ ok, server, clients: [{ id, ok, said, file?, changed? }], restart, web }` |
100
+ | `<cli> down <repo> --json` | `{ ok, workspace, services, all? }` |
101
+ | `<cli> web down --json` | `{ ok, url, port, running, stopped }` |
95
102
 
96
103
  ### repo add
97
104
 
@@ -119,7 +126,12 @@ question for the person (`ask`, sometimes with `choices`).
119
126
  the answer has `ask` and `choices`, nothing is written, and a re-run names
120
127
  the command with `--run "<cmd>"`. A Makefile `test` target or a
121
128
  `package.json` `test` script becomes the repo's `tests.unit`.
122
- `--health <url>` adds an HTTP health check.
129
+ `--health <url>` adds an HTTP health check. Without it, when the start
130
+ script names a port (`--port`, `-p`, `PORT=`) or runs a dev server with a
131
+ fixed default port (Vite 5173, Next 3000, Angular 4200,
132
+ Gatsby 8000, webpack-dev-server 8080), the side-car gets
133
+ `http://localhost:<port>/` as its health URL, so the service has Visit ↗.
134
+ No port: no health URL is guessed.
123
135
  - The workspace is `-w <workspace>` (made and activated if it doesn't exist),
124
136
  else the focused one, else a new `default` workspace.
125
137
  - The same repo again answers `ok` with `existed: true`. A different repo
@@ -184,11 +196,11 @@ token (an MCP server outside an agent's session, or anything else on this
184
196
  machine) reads "Something on this machine (no agent identity) wants to:",
185
197
  with "If you didn't ask an agent to do this, Deny." under it.
186
198
 
187
- | MCP tool | What Allow runs |
188
- | ------------------ | ------------------------------------------------------- |
189
- | `workspace_create` | The Workspaces page's create: an empty workspace |
190
- | `repo_add` | `repo add <path> --json`, a local folder inside home |
191
- | `service_try` | `up` for one service, as the Services page's Start does |
199
+ | MCP tool | What Allow runs |
200
+ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
201
+ | `workspace_create` | The Workspaces page's create: an empty workspace, made active |
202
+ | `repo_add` | `repo add <path> --json`, a local folder inside home |
203
+ | `service_try` | `up` for one service, as the Services page's Start does; an inactive workspace is activated first ("Start <service> (this activates <workspace>)") |
192
204
 
193
205
  - **Den writes the dialog.** Its line and its Review come from the action
194
206
  and its arguments, never from the agent. `repo_add`'s Review is its dry
@@ -607,12 +619,12 @@ The backend is a strategy, chosen with `secrets.provider` in the org config
607
619
  (per engineer in `config/local/user.yml`, per shell with
608
620
  `<PREFIX>_SECRETS_PROVIDER`):
609
621
 
610
- | `secrets.provider` | What it is |
611
- | ------------------ | ---------------------------------------------------------------------------------------- |
612
- | `none` | No store. Nothing is resolved, no CLI is run; `den create` scaffolds this |
613
- | `env` | Plain environment variables of the process running Den |
614
- | `doppler` | The `doppler` CLI (`secrets.doppler: { project, config }` for a default scope) |
615
- | `1password` | The `op` CLI (`secrets.onepassword.account` for the account, else your own `OP_ACCOUNT`) |
622
+ | `secrets.provider` | What it is |
623
+ | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
624
+ | `none` | No store. Nothing is resolved, no CLI is run; `den create` scaffolds this |
625
+ | `env` | Plain environment variables of the process running Den |
626
+ | `doppler` | The `doppler` CLI (`secrets.doppler: { project, config }` for a default scope) |
627
+ | `1password` | The `op` CLI (`secrets.onepassword.account` for the account, else your own `OP_ACCOUNT`; [a service-account token for a service](#1password-for-a-den-running-as-a-service)) |
616
628
 
617
629
  ```yaml
618
630
  # config/acme.yml
@@ -787,6 +799,49 @@ OPENAI_API_KEY (names only; not resolved in a dry run)`.
787
799
  (`[A-Za-z_][A-Za-z0-9_]*`). A `stacks:` entry in the org config takes
788
800
  `secret_env` too.
789
801
 
802
+ ## 1Password for a Den running as a service
803
+
804
+ A Den started by launchd or systemd does not read your login shell, so
805
+ `op` has no `OP_SERVICE_ACCOUNT_TOKEN` and every 1Password ref fails.
806
+ `secrets.onepassword.token` says where this machine keeps the
807
+ service-account token. It is per machine: Den reads it from
808
+ `config/local/user.yml` only, and a value in the distribution's config is
809
+ ignored.
810
+
811
+ ```yaml
812
+ # config/local/user.yml
813
+ secrets:
814
+ onepassword:
815
+ token: keychain:op-service-account # or file:~/.config/op/token | env:OP_SERVICE_ACCOUNT_TOKEN
816
+ ```
817
+
818
+ | Value | Where the token comes from |
819
+ | -------------------- | ------------------------------------------------------------------------------------------------------------------------ |
820
+ | `keychain:<service>` | macOS: `security find-generic-password -s <service> -w`, run with no shell. Refused on other systems |
821
+ | `file:<path>` | A file whose mode is exactly 600 (a group or other bit refuses it). `~` expands; a trailing newline is dropped |
822
+ | `env:<VAR>` | The env var `<VAR>` of the process running Den. With no key set the default is `env:OP_SERVICE_ACCOUNT_TOKEN`, as before |
823
+
824
+ - **Checked at config load.** A value that is none of these shapes is
825
+ refused, naming `secrets.onepassword.token`. The message never repeats
826
+ the value.
827
+ - **Read each time.** The token is read when a ref is resolved, never
828
+ cached or written anywhere, and passed only in the `op` child's env as
829
+ `OP_SERVICE_ACCOUNT_TOKEN`. It is never in a log, an error, the activity
830
+ records or an API response.
831
+ - **Why a ref failed.** A `secret_env` key that does not resolve says why,
832
+ in plain words: no service-account token or session; no access to the
833
+ vault; item or field not found; rate limited; or a short summary of
834
+ what `op` said. When the token source itself fails (the keychain item is
835
+ missing, the file's mode is wrong, the env var is unset) the message
836
+ names the source, never the token.
837
+ - **doctor.** With `secrets.provider: 1password` and a source that yields
838
+ no token, `doctor` adds a `1password` row: "this process has no
839
+ service-account token. Set secrets.onepassword.token." It is a warning,
840
+ not a failure (a signed-in `op` app needs no token). `doctor` only looks
841
+ a keychain item up; it never reads the token.
842
+ - **Settings.** Settings › Secrets shows the source (`keychain: <service>`,
843
+ `file: <path>`, `env: <VAR>` or "not set"), never the token.
844
+
790
845
  ## The edge and TLS
791
846
 
792
847
  The edge is one Traefik per org that routes `<name>.<edge.domain>` (and
@@ -1609,7 +1664,12 @@ user, and the CLI does that for you:
1609
1664
  the 10 minutes, and an expired code is a click away from a new one.
1610
1665
  From a computer with SSH access to it, the page gives the one-liner
1611
1666
  (`ssh <host> '<cli> web approve <code>'`) and, when the host is a name,
1612
- an Open Terminal (`ssh://`) link;
1667
+ an Open Terminal (`ssh://`) link. On Windows, which has no `ssh://`
1668
+ app by default, there is no link: the one-liner is the step, with
1669
+ "Open Windows Terminal or PowerShell, paste this, and press Enter."
1670
+ Elsewhere, if the page still has focus 2 seconds after a click on Open
1671
+ Terminal (no app took the link), it says "Nothing opened? Copy the
1672
+ command below and paste it into your terminal app.";
1613
1673
  - **Other ways**, collapsed: the one-time link with
1614
1674
  `web login --origin`.
1615
1675
 
@@ -2261,6 +2321,64 @@ start` and `<cli> doctor` say why den-pty is unavailable.
2261
2321
  limit) is refused with that reason; point `<PREFIX>_HOME` somewhere
2262
2322
  shorter.
2263
2323
 
2324
+ ## The server agent
2325
+
2326
+ Every Den has its own agent, named after the distribution ("Acme agent"),
2327
+ for anything about the server itself: set it up, add a repo, fix a failing
2328
+ service, change a setting, explain what's running. It belongs to no
2329
+ workspace. It is a normal Den agent underneath (its record, its session,
2330
+ Resume after a restart, rotation and Den's hooks), with Den's persona
2331
+ `server` and the plain-writing rule, in a reserved scope, `den-server`: no
2332
+ workspace may take that name.
2333
+
2334
+ - **It acts only through Den's MCP.** Its MCP server
2335
+ (`<cli> mcp --workspace den-server --actor agent:server`) serves the whole
2336
+ Den, not one workspace, so it may use the onboarding tools a workspace's
2337
+ agent is refused. Every write (`workspace_create`, `repo_add`,
2338
+ `service_try`) is [held for the person](#onboarding-writes-held-for-the-person):
2339
+ until they allow one in the browser, it only reads. It starts in an empty
2340
+ folder of its own (`<state_dir>/server-agent`), with no checkout to edit,
2341
+ and its runtime asks before every command (`permission_mode: ask`).
2342
+ Den's own MCP tools are the exception, for this agent only: its settings
2343
+ file allows `mcp__<server>` (the `--mcp-config` server), so reads just
2344
+ run and each write asks once, in the browser. The org's immediate actions
2345
+ (`mcp.actions`) stay in `permissions.ask`. On a fresh Den the page says
2346
+ above its terminal: "Claude asks whether to trust this folder. Choose
2347
+ Yes." Den doesn't answer that prompt for the person.
2348
+ - **Where it lives.** On a fresh Den (no repo in any workspace yet), the
2349
+ first page, `/`, is that agent in a terminal framed as the page, with
2350
+ Open in Agents as the way out. After setup it is one click away in the
2351
+ rail ("Acme agent", `/server-agent`), and ⌘K has "Ask Acme". Agents lists
2352
+ it first, under "Server", not under a workspace.
2353
+ - **Its onboarding:** `onboard_status`, then "Let's set up Acme. Where are
2354
+ your repos? I'll look in <the folder above the Den's> unless you name
2355
+ another folder." in its first turn, `repos_detect` and suggested workspaces, `workspace_create`,
2356
+ `manifest_draft` and `repo_add` for each repo, `service_try` (and
2357
+ `doctor` when it fails), then "Here's what's running, and three things to
2358
+ try next."
2359
+ - **What runs it.** A catalog runtime that is installed and carries Den's
2360
+ tools: the person's choice (`agents.server_runtime` in
2361
+ `config/local/user.yml`, set from the page's Runs on picker), else the
2362
+ first one found. Den can tell a runtime is installed, not that it is
2363
+ logged in: one that isn't asks in its own terminal, on the page. On a
2364
+ fresh Den with such a runtime it starts by itself, once per page load;
2365
+ after setup it starts only from its Start button. With no runtime, the
2366
+ page shows how to install one and the manual path for this Den, from its
2367
+ folder: `cd <dir>`, `./bin/<cli> repo add <path>`, `./bin/<cli> up`.
2368
+ - **Its model.** The page's Model picker, beside Runs on, offers the
2369
+ runtime's own models (`agents.server_model`). With none saved, Sonnet
2370
+ when the runtime has it, else the runtime's default. A new model starts
2371
+ a fresh conversation at the next start.
2372
+ - **Only a person starts it or picks its runtime or model.** An agent's token, or a
2373
+ request claiming to be an agent, is refused (403).
2374
+
2375
+ | Route | What it does |
2376
+ | -------------------------------- | --------------------------------------------------------------------------- |
2377
+ | `GET /api/server-agent` | Its name, runtime (or none), state, session, fresh, manual |
2378
+ | `POST /api/server-agent/start` | `{ runtime? }`: start it, or resume or relaunch it |
2379
+ | `POST /api/server-agent/runtime` | `{ runtime: id \| null }`: the person's choice of runtime |
2380
+ | `POST /api/server-agent/model` | `{ model: id \| null }`: the person's choice of model, one of the runtime's |
2381
+
2264
2382
  ## Agents
2265
2383
 
2266
2384
  An agent is a **persona** (who) in a **workspace** (where), run by a
package/docs/reference.md CHANGED
@@ -7,7 +7,7 @@ The technical reference that used to be the README. It will be split into separa
7
7
  1. **Create** a distribution named after your product:
8
8
 
9
9
  ```sh
10
- npx @monster-orange/den create acme # → ./acme
10
+ npx @monster-orange/den@latest create acme # → ./acme
11
11
  cd acme && npm install
12
12
  ```
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monster-orange/den",
3
- "version": "0.4.18",
3
+ "version": "0.4.20",
4
4
  "description": "Den: a local multi-repo dev orchestrator, HTTPS edge and E2E harness",
5
5
  "type": "module",
6
6
  "bin": {
@@ -90,6 +90,7 @@
90
90
  "@types/semver": "7.7.1",
91
91
  "@typescript-eslint/eslint-plugin": "^7.18.0",
92
92
  "@typescript-eslint/parser": "^7.18.0",
93
+ "axe-core": "4.10.3",
93
94
  "eslint": "^8.56.0",
94
95
  "husky": "^8.0.3",
95
96
  "jest": "^29.7.0",