townmouse 0.0.0-stage → 0.2.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 (103) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/DESIGN.md +169 -0
  3. package/LICENSE +661 -0
  4. package/README.md +368 -2
  5. package/SECURITY.md +57 -0
  6. package/TOWNMOUSE.md +91 -0
  7. package/assets/brand/mascot/README.md +23 -0
  8. package/assets/brand/mascot/townmouse-aristocrat.png +0 -0
  9. package/assets/brand/mascot/townmouse-icon.svg +1 -0
  10. package/assets/brand/mascot/townmouse-monocled.png +0 -0
  11. package/bin/townmouse +68 -0
  12. package/docs/PACKAGING.md +275 -0
  13. package/docs/browser-workspace.md +184 -0
  14. package/docs/panes.md +252 -0
  15. package/native/TownmouseApp.swift +108 -0
  16. package/package.json +89 -4
  17. package/public/apple-touch-icon.png +0 -0
  18. package/public/brand/floydslabs-credit.png +0 -0
  19. package/public/brand/floydslabs-credit.webp +0 -0
  20. package/public/brand/townmouse-aristocrat.webp +0 -0
  21. package/public/brand/townmouse-monocled.webp +0 -0
  22. package/public/clipboard-text.mjs +5 -0
  23. package/public/favicon-16x16.png +0 -0
  24. package/public/favicon-32x32.png +0 -0
  25. package/public/favicon.ico +0 -0
  26. package/public/favicon.svg +1 -0
  27. package/public/features/autosave.mjs +76 -0
  28. package/public/features/clipboard.mjs +69 -0
  29. package/public/features/command-palette.mjs +181 -0
  30. package/public/features/desktop-palette.mjs +19 -0
  31. package/public/features/export.mjs +37 -0
  32. package/public/features/file-drop.mjs +77 -0
  33. package/public/features/floating-palette.mjs +113 -0
  34. package/public/features/fontsize.mjs +72 -0
  35. package/public/features/haptic-keys.mjs +42 -0
  36. package/public/features/history-undo.mjs +102 -0
  37. package/public/features/keepalive.mjs +36 -0
  38. package/public/features/keybar-config.mjs +70 -0
  39. package/public/features/keyboard-shortcuts.mjs +74 -0
  40. package/public/features/links.mjs +139 -0
  41. package/public/features/multi-window-sync.mjs +74 -0
  42. package/public/features/osc-bridge.mjs +59 -0
  43. package/public/features/phone-landscape-focus.mjs +157 -0
  44. package/public/features/recent-commands.mjs +100 -0
  45. package/public/features/search.mjs +134 -0
  46. package/public/features/session-lock.mjs +96 -0
  47. package/public/features/session-manager.mjs +149 -0
  48. package/public/features/settings-sync.mjs +77 -0
  49. package/public/features/shortcut-help.mjs +85 -0
  50. package/public/features/smart-completions.mjs +101 -0
  51. package/public/features/smart-suggest.mjs +124 -0
  52. package/public/features/snippets.mjs +85 -0
  53. package/public/features/split-view.mjs +102 -0
  54. package/public/features/status-metrics.mjs +114 -0
  55. package/public/features/stylus-support.mjs +124 -0
  56. package/public/features/swipe-history.mjs +141 -0
  57. package/public/features/swipe-sessions.mjs +85 -0
  58. package/public/features/tab-reorder.mjs +62 -0
  59. package/public/features/theme-system.mjs +51 -0
  60. package/public/features/toast-status.mjs +118 -0
  61. package/public/features/two-finger-menu.mjs +87 -0
  62. package/public/features/voice-input.mjs +244 -0
  63. package/public/features/wake-fullscreen.mjs +67 -0
  64. package/public/features/window-title.mjs +40 -0
  65. package/public/features/zoom.mjs +80 -0
  66. package/public/icon-128.png +0 -0
  67. package/public/icon-180.png +0 -0
  68. package/public/icon-192.png +0 -0
  69. package/public/icon-48.png +0 -0
  70. package/public/icon-512-maskable.png +0 -0
  71. package/public/icon-512.png +0 -0
  72. package/public/icon.svg +1 -0
  73. package/public/index.html +1765 -0
  74. package/public/input-chunks.mjs +22 -0
  75. package/public/input-guard.mjs +210 -0
  76. package/public/manifest.json +56 -0
  77. package/public/panes.css +1257 -0
  78. package/public/panes.html +208 -0
  79. package/public/panes.mjs +2625 -0
  80. package/public/service-worker.js +67 -0
  81. package/public/workspace.css +1447 -0
  82. package/public/workspace.mjs +1475 -0
  83. package/scripts/install-service.sh +269 -0
  84. package/scripts/node-runtime.sh +138 -0
  85. package/scripts/panes +439 -0
  86. package/scripts/prepare-native.sh +35 -0
  87. package/scripts/run-hooks +69 -0
  88. package/scripts/t1.sh +113 -0
  89. package/scripts/uninstall-service.sh +49 -0
  90. package/src/agent-guide.js +260 -0
  91. package/src/attachments.js +128 -0
  92. package/src/browser-dom.js +545 -0
  93. package/src/browser-workspace.js +1246 -0
  94. package/src/chrome-resolve.js +80 -0
  95. package/src/pty-permissions.js +99 -0
  96. package/src/regex-worker.js +13 -0
  97. package/src/replay-text.js +189 -0
  98. package/src/request-boundary.js +58 -0
  99. package/src/safe-regex.js +87 -0
  100. package/src/server.js +1122 -0
  101. package/src/shell-resolve.js +42 -0
  102. package/src/static-deps.js +61 -0
  103. package/src/workspace-panes.js +1099 -0
@@ -0,0 +1,275 @@
1
+ # Packaging and Release
2
+
3
+ ## Or: How To Ship A Workspace Without Asking A Subscription Committee For Permission
4
+
5
+ ---
6
+
7
+ - **DOCUMENT CLASSIFICATION:** Technical / Moderate Chaos
8
+ - **DATE RECORDED:** 2026-11-15 — Late Enough To Be Useful
9
+ - **LOCATION:** The Garage, Brown County, Indiana
10
+ - **BEVERAGE:** Coffee that tastes like motor oil (fresh pot)
11
+ - **CURRENT STATE:** Gates assembled; signed release still pending
12
+
13
+ ---
14
+
15
+ Townmouse is a local, self-hosted terminal and agent browser workspace. The
16
+ release unit is the server plus its static frontend, not a hosted SaaS. There is
17
+ no per-seat meter, no subscription treadmill, and no boardroom waiting to approve
18
+ a keyboard shortcut. You install it. You run it. You own the machine it runs on.
19
+
20
+ TerminalOne is the embedded terminal engine and remains its own product.
21
+ Townmouse owns the workspace, the browser surfaces, the sharing grants, the pane
22
+ workspace, and the release artifacts. The npm package, CLI, Docker image, data
23
+ directory, and macOS wrapper all carry the Townmouse name.
24
+
25
+ This document is the working plan until the first signed release. Everything
26
+ below is a gate, not a vibe.
27
+
28
+ ## License
29
+
30
+ **AGPL-3.0-only.** The complete license is in `LICENSE`. If a person or company
31
+ runs Townmouse, or a modified version of it, as a network service, they must
32
+ offer the complete corresponding source to the people using that service.
33
+ Distributing the software or a derivative also requires the source. TerminalOne's
34
+ license and copyright notices remain with the portions it supplies.
35
+
36
+ That is not a suggestion, and it is not the kind of thing that gets waived
37
+ because a launch post would look better without it.
38
+
39
+ ## Release channels
40
+
41
+ ### 1. npm (primary, macOS/Linux)
42
+
43
+ - Package name: `townmouse`.
44
+ - `bin`: `townmouse` starts `src/server.js`, prints the URL, and opens a browser
45
+ unless `--no-open` is passed.
46
+ - Runtime: Node 22.x preferred and declared as `>=22 <27`, npm, and a
47
+ Chromium/Chrome binary for browser panes. `scripts/node-runtime.sh` prefers 22
48
+ and falls back to any installed major where node-pty loads, because node-pty
49
+ is built on Node-API.
50
+ - `postinstall` runs `scripts/prepare-native.sh`, which marks node-pty's macOS
51
+ spawn helpers executable. **It is not enough on its own:** npm 12 skips
52
+ dependency install scripts by default (`allow-scripts = [""]`), so the server
53
+ also repairs the helper mode at startup (`src/pty-permissions.js`). An install
54
+ with scripts ignored is the tested case.
55
+ - Browser panes resolve an engine in this order: `TERMINALONE_CHROME`,
56
+ Puppeteer's downloaded build, then a system Chrome/Chromium/Edge/Brave.
57
+ `GET /health` reports `browser.engine`, so an install without a browser says
58
+ so instead of failing at the first pane.
59
+ - `npm run doctor` checks the Node version and native modules; `npm run repair`
60
+ rebuilds node-pty if they do not match.
61
+ - `npm pack` is the release artifact; `npm publish` publishes it under a semver
62
+ tag.
63
+ - `npx townmouse` is the no-install smoke path.
64
+
65
+ **Linux and npm 12.** npm 12 does not run dependency install scripts by default
66
+ (`allow-scripts = [""]`). node-pty ships prebuilds only for macOS and Windows,
67
+ so a Linux install that skipped scripts has no terminal engine. Build it
68
+ explicitly:
69
+
70
+ ```sh
71
+ npm install --allow-scripts=node-pty townmouse
72
+ # or, in an existing install:
73
+ npm rebuild node-pty # needs python3, make, and g++
74
+ npm run doctor # native_modules=ok
75
+ ```
76
+
77
+ The server refuses to start with that explanation rather than a stack trace when
78
+ the engine cannot load. The container channel needs no such step; the image
79
+ compiles node-pty during `npm ci`.
80
+
81
+ The CLI surface is small on purpose:
82
+
83
+ ```sh
84
+ npm ci
85
+ npm start
86
+ npx townmouse
87
+ townmouse --port 11001
88
+ townmouse --port=11001 --no-open
89
+ townmouse --help
90
+ townmouse --version
91
+ npm pack
92
+ npm publish
93
+ ```
94
+
95
+ The server binds to `127.0.0.1`. The CLI does not turn off the loopback listener,
96
+ and neither should you.
97
+
98
+ ### 2. Container (Linux home server)
99
+
100
+ The `Dockerfile` uses `node:22-bookworm-slim`, installs Chromium, sets
101
+ `PUPPETEER_SKIP_DOWNLOAD=1` and `TERMINALONE_CHROME=/usr/bin/chromium`, runs as
102
+ the `node` user, exposes `11001`, and declares volumes for both
103
+ `/home/node/.townmouse` (workspace, attachments, pane token) and
104
+ `/home/node/.config/terminalone` (voice settings).
105
+ It sets `HOST=0.0.0.0` for container port forwarding and
106
+ `TOWNMOUSE_CHROMIUM_NO_SANDBOX=1` because the container has no Chromium sandbox
107
+ setup; both are container-only choices. The host run keeps loopback binding and
108
+ the Chromium sandbox.
109
+
110
+ Build and run:
111
+
112
+ ```sh
113
+ TOWNMOUSE_VERSION=$(node -p "require('./package.json').version") \
114
+ GIT_REVISION=$(git rev-parse HEAD) \
115
+ docker build \
116
+ --build-arg TOWNMOUSE_VERSION="$TOWNMOUSE_VERSION" \
117
+ --build-arg GIT_REVISION="$GIT_REVISION" \
118
+ -t townmouse:"$TOWNMOUSE_VERSION" \
119
+ -t townmouse:latest .
120
+ docker run --rm -p 127.0.0.1:11001:11001 -v townmouse-home:/home/node/.townmouse -v townmouse-config:/home/node/.config/terminalone townmouse
121
+ ```
122
+
123
+ The host port may differ from the container port; the request boundary accepts
124
+ loopback hostnames on any port and still enforces same-origin. Publish only to
125
+ host loopback. Mount project directories explicitly; the terminal starts in
126
+ `/home/node`, not in your project. Health:
127
+
128
+ ```sh
129
+ curl http://127.0.0.1:11001/health
130
+ ```
131
+
132
+ `GET /health` returns `status: "ok"` plus the live session count. If it does not
133
+ answer, the container is not ready, and staring at the logs is cheaper than
134
+ guessing.
135
+
136
+ ### 3. macOS application wrapper
137
+
138
+ `native/TownmouseApp.swift` is a WKWebView shell pointed at `TOWNMOUSE_URL`
139
+ (default `http://127.0.0.1:11001`). It probes `/health`. If nothing answers, it
140
+ tries a separately installed launcher and waits up to 12 seconds before showing
141
+ a startup error.
142
+
143
+ `scripts/install-service.sh` builds a local `Townmouse.app`, installs a launcher,
144
+ and writes the launcher path into the bundle so the wrapper can start the
145
+ backend. The installer scripts ship in the npm package, so this works from a
146
+ global or local install; it is still a local convenience build, not a signed
147
+ distribution.
148
+
149
+ A distributable `.app` must bundle or launch the Node server or npm CLI, use a
150
+ stable data directory, and be codesigned and notarized. Until that is done, there
151
+ is no signed downloadable macOS release. The wrapper is a WebView with
152
+ ambitions, and it knows it.
153
+
154
+ ### 4. Phone/tablet PWA over the tailnet
155
+
156
+ - The app is installable from the browser. The shell and workspace load from the
157
+ local server; live PTYs and browser pages still need that server.
158
+ - Publish with `tailscale serve` on a claimed port, bound to loopback. Never
159
+ expose an owner tool with Funnel without explicit approval.
160
+ - An HTTPS proxy must require authentication before it forwards any request,
161
+ including WebSocket upgrades. It must preserve the public `Host` header and
162
+ the browser `Origin`. `TERMINALONE_TRUSTED_ORIGINS` only allows an address; it
163
+ does not add authentication.
164
+
165
+ ```sh
166
+ TERMINALONE_TRUSTED_ORIGINS=https://townmouse.example.com npm start
167
+ ```
168
+
169
+ The `TERMINALONE_` prefix on that variable and on `TERMINALONE_CHROME` is a
170
+ compatibility name the runtime still reads. Renaming an environment variable is
171
+ a breaking change, not a rebranding exercise. The product name in the UI, package,
172
+ CLI, and data directory is Townmouse.
173
+
174
+ ## Versioning
175
+
176
+ - Semantic versioning: `MAJOR.MINOR.PATCH`.
177
+ - Feature work lands on `feat/*`; releases are tagged from `main`.
178
+ - `CHANGELOG.md` gets a dated section for every release. The punch list is not a
179
+ changelog.
180
+ - Package version, Git tag, Docker tag, and release notes must agree. If they
181
+ disagree, it is not a release; it is a rumor with a download link.
182
+
183
+ ## Release gates
184
+
185
+ 1. `npm ci` from a clean checkout.
186
+ 2. `npm test` green, including `test:panes`, `test:agent-control` (36 journeys),
187
+ and the security suite.
188
+ 3. Four-pane UI acceptance: 2 terminals + 2 browsers, no console errors.
189
+ 4. Attachment test: image upload once, path in PTY, URL serves 200.
190
+ 5. Input test: a burst of keystrokes produces one ordered input POST.
191
+ 6. Codex code and security review has no unresolved findings on the release
192
+ commit.
193
+ 7. `npm pack --dry-run` contains `bin/`, `src/`, `public/panes.*`,
194
+ `scripts/panes`, `LICENSE`, and no secrets or local evidence.
195
+ 8. `npm run test:package` green: the packed tarball installs into a clean
196
+ project with `--ignore-scripts`, starts, serves its engine assets, creates
197
+ `~/.townmouse` with safe modes, spawns a PTY, runs a tracked command, and
198
+ opens a browser pane. This is the gate that catches a dev tree that is not
199
+ the application.
200
+ 9. Docker image builds and answers `/health` on loopback, including when the
201
+ published host port differs from the container port.
202
+
203
+ A release that skips a gate is a branch with a nicer tag. The cats are not
204
+ impressed, and Bella has already walked across the checklist.
205
+
206
+ ## Data and backup
207
+
208
+ - `~/.townmouse/pane-token` — workspace API token, mode 600. The server creates
209
+ it on first run if it is missing.
210
+ - `~/.townmouse/attachments/<YYYYMMDD>/` — dropped files, directories mode 700
211
+ and files mode 600, with a 25 MB per-upload limit.
212
+ - Project files live wherever the member mounted them; never inside the package
213
+ directory.
214
+ - Back up `~/.townmouse` before upgrades. Docker uses the `townmouse-home`
215
+ volume for the same data.
216
+
217
+ ```sh
218
+ cp -a ~/.townmouse ~/.townmouse.backup-$(date +%Y%m%d)
219
+ ```
220
+
221
+ ## Upgrade and rollback
222
+
223
+ - npm: publish under a new version; roll back with
224
+ `npm install -g townmouse@<previous>`.
225
+ - Docker: keep immutable tags (`townmouse:<version>`) and a moving `latest`; roll
226
+ back by running the previous tag.
227
+ - Keep the previous release artifact and its checksums. Data is compatible within
228
+ a minor version; any breaking data change needs a migration note.
229
+
230
+ A rollback path you have not tested is a hope with a shell prompt.
231
+
232
+ ## Known gaps before a public release
233
+
234
+ - The macOS wrapper does not bundle the server yet; it can only start a
235
+ separately installed launcher.
236
+ - Browser panes do not yet bridge native file pickers or downloads.
237
+ - PWA offline coverage is the shell only; live PTYs and browser pages require the
238
+ server.
239
+ - No Windows-signed installer.
240
+ - The pane workspace and the legacy single-browser workspace still coexist; the
241
+ legacy Copy-connection UI is compatibility-only.
242
+
243
+ None of these are secrets. Shipping around them without saying so would be.
244
+
245
+ ## Release checklist
246
+
247
+ - [ ] Version and changelog updated.
248
+ - [ ] Clean `npm ci` and `npm test`.
249
+ - [ ] `npm run test:package` green: the packed tarball installs and runs.
250
+ - [ ] Pane UI/attachment/input evidence refreshed.
251
+ - [ ] Codex review clean on the release commit.
252
+ - [ ] `npm pack` inspected and checksummed.
253
+ - [ ] Docker image built and smoke-tested.
254
+ - [ ] Tag pushed; GitHub release notes; npm publish.
255
+ - [ ] Backup/rollback instructions included.
256
+
257
+ If it is not checked, it is not shipped. That is the entire policy.
258
+
259
+ ```text
260
+ ┌──────────────────────────────────────────────────────────┐
261
+ │ DOCUMENT METADATA │
262
+ ├──────────────────────────────────────────────────────────┤
263
+ │ Classification: Technical / Release │
264
+ │ Cat Supervision: Bella, asleep on the checklist │
265
+ │ Bowser Status: Monitoring routers, not releases │
266
+ │ "I Don't Suck": PASS │
267
+ │ Corporate Feelings: HURT (intended) │
268
+ └──────────────────────────────────────────────────────────┘
269
+ ```
270
+
271
+ **DOCUMENT ENDS**
272
+
273
+ *— Build/Release, Floyd's Labs*
274
+ *The Garage — Brown County, Indiana*
275
+ *"A release is a promise you can install from a clean checkout."*
@@ -0,0 +1,184 @@
1
+ # Browser Workspace
2
+
3
+ ## Or: The Browser Is Real, The Iframe Is Not
4
+
5
+ ---
6
+
7
+ - **DOCUMENT CLASSIFICATION:** Technical / Moderate Chaos
8
+ - **DATE RECORDED:** 2026-11-15 — Late Enough To Be Useful
9
+ - **LOCATION:** The Garage, Brown County, Indiana
10
+ - **BEVERAGE:** Coffee that tastes like motor oil (fresh pot)
11
+ - **CURRENT STATE:** One Chromium engine, several opinions
12
+
13
+ ---
14
+
15
+ Open **Browser** or the **+** in the tab strip to create an isolated Chromium
16
+ page on the terminal host. Enter a web address, search phrase, or localhost URL.
17
+ Navigation, clicking, typing, and scrolling happen in that real page,
18
+ independent of iframe policies. The iframe was a compromise. This is not that.
19
+
20
+ Each tab has its own cookie context. These are workspace browser tabs, not an
21
+ attachment to an existing Safari or Chrome profile. Browser audio, file
22
+ upload/download dialogs, extensions, and password-manager integration are not
23
+ provided by the image-based viewer.
24
+
25
+ ## Pane workspace
26
+
27
+ Open `/panes.html` (or **Panes** in the sidebar) for the split workspace. Each
28
+ workspace tab holds up to four panes in a 2x2 grid; a pane is either a real PTY
29
+ terminal or a real browser page. The browser panes are rendered by the same
30
+ headless-browser backend as the single browser tab, and the terminal panes are
31
+ independent PTY sessions powered by the embedded TerminalOne engine.
32
+
33
+ An agent running in a terminal pane receives:
34
+
35
+ ```text
36
+ TOWNMOUSE_API=http://127.0.0.1:<port>/api/panes
37
+ TOWNMOUSE_TOKEN=<workspace token>
38
+ TOWNMOUSE_TAB_ID=<this tab>
39
+ TOWNMOUSE_PANE_ID=<this pane>
40
+ TOWNMOUSE_PANES_CLI=<repo>/scripts/panes
41
+ ```
42
+
43
+ So it can create tabs, add panes, open URLs, run commands, read output, and send
44
+ input natively. No connection code is copied between the browser and the
45
+ terminal. The pane limits are 24 tabs, four panes per tab, 24 terminal panes, and
46
+ 32 browser contexts. The full command list is in [panes.md](panes.md).
47
+
48
+ ## Layouts
49
+
50
+ - **Desktop:** persistent sidebar, browser tabs in the sidebar, terminal and
51
+ browser split horizontally when a browser is open. The separator is draggable
52
+ left and right; the terminal keeps at least 320px and the browser at least
53
+ 420px.
54
+ - **Tablet:** labeled rail, browser tabs in a strip above the address bar,
55
+ terminal and browser stacked vertically when a browser is open. The separator
56
+ is draggable up and down between a 25% and 75% browser share.
57
+ - **Phone:** bottom navigation with Terminal, Browser, Agent, and Tools. One task
58
+ surface is visible at a time. The key bar collapses to one row; the chevron
59
+ reveals the remaining keys. Browser tabs and sharing controls live in the
60
+ browser surface. The browser and terminal chrome is tightly padded, and after
61
+ seven seconds without a touch it collapses to the content; the bottom
62
+ navigation stays and the next touch wakes the chrome.
63
+
64
+ Three layouts, not one layout stretched until it apologizes.
65
+
66
+ ## Sharing
67
+
68
+ Human tabs start Private. Select **Share** to open the sharing row at every
69
+ width; it starts closed so the page keeps the space. A **Collapse** control
70
+ removes every bar above the page and remembers the choice, leaving a slim strip
71
+ that names the page and brings the controls back. The mascot stays in the
72
+ navigation rail and no longer appears in the working area.
73
+
74
+ This is the **compatibility** path. For agent work, open `/panes.html`; the
75
+ orchestrator receives `TOWNMOUSE_API` and `scripts/panes` directly, with no
76
+ connection code to copy. If you are using the legacy single-browser flow, select
77
+ View only or Allow control, then Copy connection, and paste the connection JSON
78
+ into your terminal agent. Changing permission rotates the token; choosing Private immediately
79
+ rejects subsequent token requests. Commands already executing can finish.
80
+ Closing a tab destroys its context.
81
+
82
+ The supplied endpoint accepts a Bearer token in the `Authorization` header:
83
+
84
+ - `GET /content`: current URL, title, and visible text.
85
+ - `GET /snapshot`: current URL, title, and JPEG image in base64.
86
+ - `POST /action` with JSON: `navigate` (url), `back`, `forward`, `reload`,
87
+ `click` (x,y in the dimensions returned by `/snapshot`), `type` (text), `key`
88
+ (Puppeteer key name), `scroll` (deltaY).
89
+
90
+ View tokens cannot invoke actions or change grants. Never paste the token into a
91
+ visited web page. A token is a key, and web pages are full of people who would
92
+ love a copy of your keys.
93
+
94
+ Choose **Agent** to create a separate context with control granted. Hide view
95
+ keeps the browser running headless. Reopen Agent to observe the same context.
96
+ Revoking access also works on the agent context.
97
+
98
+ The viewer samples images once per second when open. This is remote interaction,
99
+ not a native browser DOM exposed to the viewer's assistive technology. Agents can
100
+ use `/content` for text. Keyboard Tab moves through the workspace interface; the
101
+ Send field, Tab, and Enter buttons interact with page inputs.
102
+
103
+ Localhost means the terminal server host, not the phone or tablet. HTTP and HTTPS
104
+ are supported; file URLs and embedded URL credentials are rejected.
105
+
106
+ ## Agent control
107
+
108
+ The agent surface describes what it sees and what it did. It does not make an
109
+ agent guess from a picture alone, and it does not report success it cannot show.
110
+
111
+ - **Observations.** `GET /api/browser/:id/observe` returns a screenshot plus a
112
+ label: observation id, capture time, viewport size, scroll offset, address,
113
+ title, and a revision counter. `?elements=1` adds the controls.
114
+ - **Controls by identity.** `GET /api/browser/:id/elements` catalogs controls
115
+ across every frame (including cross-origin iframes) and open shadow roots with
116
+ role, accessible name, value, state, box, and a stable `ref` (`e12`). The ref
117
+ is a DOM marker, not an index, so it survives unrelated re-renders.
118
+ - **Actions.** `POST /api/browser/:id/action` accepts `click`, `hover`, `drag`,
119
+ `type`, `key`, `scroll`, `select`, `navigate`, `back`, `forward`, and `reload`,
120
+ by `ref` or by coordinate. Key combinations such as `Alt+M` are supported;
121
+ `type` with `replace: true` clears the field first.
122
+ - **Results.** Every action returns `status`: `completed`, `missing`,
123
+ `wrong-kind`, `failed`, `stale`, or `unconfirmed`, plus the focused control and
124
+ its value where useful. A coordinate cites the observation it came from; if
125
+ the page's geometry moved, the action is refused with `409` and an instruction
126
+ to look again.
127
+ - **Waiting.** `POST /api/browser/:id/wait` waits for an address, title, text,
128
+ selector, or field value, always bounded by a timeout.
129
+ - **Scrolling.** `scroll` with a ref or selector scrolls that element's own
130
+ scroll box; without one it scrolls the page deliberately.
131
+ - **Sizing.** `POST /api/browser/:id/sizing` with `mode: fixed` locks the page
132
+ viewport so the owner's viewer scales the picture instead of rearranging the
133
+ page. `mode: fit` restores the old behaviour.
134
+
135
+ `docs/plans/townmouse-orchestrator-assessment-2026-11-20-implementation.md`
136
+ maps each of these to the assessment item it answers, and
137
+ `tests/agent-control.test.cjs` exercises them against a real browser.
138
+
139
+ ## Runtime and trust
140
+
141
+ Puppeteer is a production dependency; `npm ci` downloads its compatible
142
+ Chromium. `TERMINALONE_CHROME` can select an operator-installed compatible
143
+ binary. The name is a compatibility holdover; the binary it points at is just
144
+ Chromium. Use the pinned runtime by default.
145
+
146
+ The existing loopback listener and request-origin checks protect workspace
147
+ routes. User control keys stay in page memory and are never embedded in page
148
+ URLs. API responses use no-store. At most 32 browser contexts can remain open.
149
+
150
+ Grants protect cooperative API clients, not hostile processes that already have
151
+ unrestricted access to the host shell or the browser owner's application. The
152
+ local server has the user's existing authority. Keep remote access behind the
153
+ existing authenticated proxy in [PACKAGING.md](PACKAGING.md).
154
+
155
+ Browser sessions and grants are in memory. Restarting the server closes them;
156
+ saved browser profiles and seamless session persistence are not implemented. No,
157
+ "seamless" is not a feature we are hiding. It does not exist.
158
+
159
+ ## Validation
160
+
161
+ `npm run test:workspace` starts the workspace and its own local preview site,
162
+ then exercises terminal input, tabs, sharing, revocation, the agent browser,
163
+ hidden-agent navigation, reduced motion, and the phone, tablet, and desktop
164
+ layouts. It captures evidence at 393×852, 820×1180, 1440×900, and 1920×1080.
165
+
166
+ [DESIGN.md](../DESIGN.md) lists the five named motions and the device-specific
167
+ structures.
168
+
169
+ ```text
170
+ ┌──────────────────────────────────────────────────────────┐
171
+ │ DOCUMENT METADATA │
172
+ ├──────────────────────────────────────────────────────────┤
173
+ │ Classification: Technical / Browser Workspace │
174
+ │ Cat Supervision: Bella, asleep on the tab strip │
175
+ │ "I Don't Suck": PASS │
176
+ │ Corporate Feelings: HURT (intended) │
177
+ └──────────────────────────────────────────────────────────┘
178
+ ```
179
+
180
+ **DOCUMENT ENDS**
181
+
182
+ *— Workspace, Floyd's Labs*
183
+ *The Garage — Brown County, Indiana*
184
+ *"A browser tab should be a browser, not a JPEG with a dream."*