townmouse 0.0.0-stage → 0.4.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +196 -0
  2. package/DESIGN.md +153 -0
  3. package/LICENSE +661 -0
  4. package/README.md +600 -2
  5. package/SECURITY.md +60 -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 +371 -0
  13. package/docs/browser-workspace.md +237 -0
  14. package/docs/panes.md +442 -0
  15. package/native/TownmouseApp.swift +108 -0
  16. package/npm-shrinkwrap.json +1282 -0
  17. package/package.json +93 -4
  18. package/public/apple-touch-icon.png +0 -0
  19. package/public/brand/floydslabs-credit.png +0 -0
  20. package/public/brand/floydslabs-credit.webp +0 -0
  21. package/public/brand/townmouse-aristocrat.webp +0 -0
  22. package/public/brand/townmouse-monocled.webp +0 -0
  23. package/public/browser-picture.mjs +159 -0
  24. package/public/clipboard-text.mjs +5 -0
  25. package/public/favicon-16x16.png +0 -0
  26. package/public/favicon-32x32.png +0 -0
  27. package/public/favicon.ico +0 -0
  28. package/public/favicon.svg +1 -0
  29. package/public/features/app-version.mjs +35 -0
  30. package/public/features/autosave.mjs +80 -0
  31. package/public/features/clipboard.mjs +69 -0
  32. package/public/features/command-palette.mjs +181 -0
  33. package/public/features/desktop-palette.mjs +19 -0
  34. package/public/features/export.mjs +37 -0
  35. package/public/features/file-drop.mjs +77 -0
  36. package/public/features/floating-palette.mjs +113 -0
  37. package/public/features/fontsize.mjs +72 -0
  38. package/public/features/haptic-keys.mjs +42 -0
  39. package/public/features/history-undo.mjs +102 -0
  40. package/public/features/keepalive.mjs +36 -0
  41. package/public/features/keybar-config.mjs +70 -0
  42. package/public/features/keyboard-shortcuts.mjs +74 -0
  43. package/public/features/links.mjs +139 -0
  44. package/public/features/multi-window-sync.mjs +76 -0
  45. package/public/features/osc-bridge.mjs +64 -0
  46. package/public/features/phone-landscape-focus.mjs +157 -0
  47. package/public/features/recent-commands.mjs +100 -0
  48. package/public/features/search.mjs +134 -0
  49. package/public/features/session-lock.mjs +96 -0
  50. package/public/features/session-manager.mjs +251 -0
  51. package/public/features/settings-sync.mjs +77 -0
  52. package/public/features/shortcut-help.mjs +85 -0
  53. package/public/features/smart-completions.mjs +101 -0
  54. package/public/features/smart-suggest.mjs +124 -0
  55. package/public/features/snippets.mjs +85 -0
  56. package/public/features/split-view.mjs +102 -0
  57. package/public/features/status-metrics.mjs +137 -0
  58. package/public/features/stylus-support.mjs +124 -0
  59. package/public/features/swipe-history.mjs +141 -0
  60. package/public/features/swipe-sessions.mjs +85 -0
  61. package/public/features/tab-reorder.mjs +70 -0
  62. package/public/features/theme-system.mjs +51 -0
  63. package/public/features/toast-status.mjs +118 -0
  64. package/public/features/two-finger-menu.mjs +87 -0
  65. package/public/features/voice-input.mjs +244 -0
  66. package/public/features/wake-fullscreen.mjs +67 -0
  67. package/public/features/window-title.mjs +47 -0
  68. package/public/features/zoom.mjs +80 -0
  69. package/public/icon-128.png +0 -0
  70. package/public/icon-180.png +0 -0
  71. package/public/icon-192.png +0 -0
  72. package/public/icon-48.png +0 -0
  73. package/public/icon-512-maskable.png +0 -0
  74. package/public/icon-512.png +0 -0
  75. package/public/icon.svg +1 -0
  76. package/public/index.html +2304 -0
  77. package/public/input-chunks.mjs +22 -0
  78. package/public/input-guard.mjs +218 -0
  79. package/public/manifest.json +56 -0
  80. package/public/panes.css +1433 -0
  81. package/public/panes.html +211 -0
  82. package/public/panes.mjs +3183 -0
  83. package/public/service-worker.js +67 -0
  84. package/public/workspace.css +1621 -0
  85. package/public/workspace.mjs +1715 -0
  86. package/scripts/install-service.sh +303 -0
  87. package/scripts/node-runtime.sh +138 -0
  88. package/scripts/panes +568 -0
  89. package/scripts/prepare-native.sh +35 -0
  90. package/scripts/retire-legacy-service.sh +76 -0
  91. package/scripts/run-hooks +69 -0
  92. package/scripts/townmouse.sh +152 -0
  93. package/scripts/uninstall-service.sh +65 -0
  94. package/src/agent-guide.js +329 -0
  95. package/src/attachments.js +128 -0
  96. package/src/browser-dom.js +548 -0
  97. package/src/browser-workspace.js +1733 -0
  98. package/src/chrome-resolve.js +80 -0
  99. package/src/owner-page.js +43 -0
  100. package/src/pty-permissions.js +99 -0
  101. package/src/regex-worker.js +13 -0
  102. package/src/replay-text.js +189 -0
  103. package/src/request-boundary.js +58 -0
  104. package/src/safe-regex.js +87 -0
  105. package/src/server.js +1582 -0
  106. package/src/shell-resolve.js +42 -0
  107. package/src/static-deps.js +61 -0
  108. package/src/workspace-panes.js +1431 -0
package/README.md CHANGED
@@ -1,3 +1,601 @@
1
- # Temporary Holding Version
1
+ # Townmouse
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Or: The terminal is the house. The browser is the town. The mouse runs both.
4
+
5
+ <img src="public/brand/townmouse-monocled.webp" alt="Townmouse, the monocled colonial mouse holding a terminal sign" width="260">
6
+
7
+ **DOCUMENT CLASSIFICATION:** PRODUCT README / CAFFEINATED / ANTI-CORPORATE
8
+ **DATE RECORDED:** 2026-11-15 — 2:47 AM, because that is when the real work happens
9
+ **LOCATION:** The garage, Brown County, Indiana
10
+ **BEVERAGE:** Coffee that tastes like motor oil (fresh pot)
11
+ **CAT SUPERVISION:** Bella on quality assurance; Bowser monitoring the routers
12
+ **CURRENT STATE:** Terminal open, browser open, no subscription in sight
13
+
14
+ Townmouse is a terminal and agent browser workspace that runs on your own
15
+ machine. A live PTY shell and live Chromium pages share one workspace. You can
16
+ work in both. So can an agent. No hosted dashboard, no per-seat invoice, no
17
+ "contact sales" button lurking behind the terminal.
18
+
19
+ This is local software: a Node server and a static front end. The server listens
20
+ on `127.0.0.1` at port 11002 by default, and anything the terminal runs has your
21
+ account's authority. That is the deal. Treat it like a loaded shell, because it
22
+ is one. Port 11001 belongs to TerminalOne, the terminal engine Townmouse embeds,
23
+ so the two products run side by side on one machine.
24
+
25
+ ## What it does (Or: Fewer tabs, more work)
26
+
27
+ - **Terminal.** A real PTY with your shell, the key bar, themes, and the
28
+ existing terminal feature modules. Every shell you open is a session with a
29
+ chip in the top row: click a chip to go back to that shell, close it from its
30
+ chip or from the Sessions list, and give it a name in the list. A shell keeps
31
+ running while you look at another one, until you close it or the app stops;
32
+ at most ten run at once. The footer shows the shell, working directory, and
33
+ uptime. The terminal does not pretend to be a text box.
34
+ - **Pane workspace.** The native path for agent work. Open `/panes.html` for a
35
+ 2x2 grid of up to four live panes per tab, each one a terminal or a browser
36
+ page. The orchestrator agent creates and drives them through the injected
37
+ `TOWNMOUSE_API` and `scripts/panes` interface. No connection code is copied
38
+ between the browser and the terminal. Browser viewports reflow to the pane,
39
+ and dropped or pasted files upload once and arrive in the terminal as a real
40
+ path.
41
+ - **Browser.** Real Chromium pages on the terminal host, each in its own context
42
+ with its own cookies, not an iframe wearing a trench coat. The pane workspace
43
+ is the native way to use them; the single-browser workspace remains for
44
+ compatibility.
45
+ - **Agent browser.** A separate context with control granted. Hide view keeps it
46
+ running headless; reopen Agent to observe the same context. In the pane
47
+ workspace, the agent works through the injected environment, on its own panes
48
+ and on the owner's panes the owner has granted. The single-browser view keeps
49
+ its bearer-token path for compatibility.
50
+ - **Three layouts.** Desktop sidebar, tablet rail, phone bottom navigation. The
51
+ phone shows one task surface at a time; its key bar collapses to one row and
52
+ expands on demand. After seven seconds without a touch, the phone chrome drops
53
+ away except the bottom navigation. The next touch wakes it. No mystery meat
54
+ chrome.
55
+ - **Installable.** Add it to the home screen on iPad or iPhone. The shell and
56
+ workspace load from the local server. Offline coverage is the shell only; live
57
+ PTYs and browser pages still need the server.
58
+
59
+ ### The three layouts (Or: One product, three rooms)
60
+
61
+ ![Desktop layout](docs/screenshots/desktop-1440x900.png)
62
+ ![Tablet layout](docs/screenshots/tablet-820x1180.png)
63
+ ![Phone layout](docs/screenshots/phone-393x852.png)
64
+
65
+ Desktop keeps a persistent sidebar and runs terminal and browser side by side;
66
+ tablet replaces it with a labeled rail and stacks the surfaces over an
67
+ always-visible key bar; phone uses bottom navigation for one surface at a time
68
+ and folds the key bar into a compact row.
69
+
70
+ ## Requirements (Or: The parts you actually need)
71
+
72
+ Node.js 22.x (preferred; 22–26 are accepted) and npm on macOS or Linux. Puppeteer
73
+ is a production dependency because browser tabs and panes are real Chromium
74
+ pages; `npm ci` downloads a compatible Chromium. If that download is skipped —
75
+ npm 12 skips dependency install scripts by default — TownMouse falls back to an
76
+ installed Chrome, Chromium, Edge, or Brave. Set `TERMINALONE_CHROME` to choose a
77
+ specific binary. `GET /health` reports which engine resolved. The pages need a
78
+ browser that marks its own requests: Chrome 76 or later, Safari 16.4 or later,
79
+ or Firefox 90 or later.
80
+
81
+ On Linux, npm 12 skips dependency install scripts by default and node-pty has no
82
+ prebuilt Linux binary; install with `--allow-scripts=node-pty`, or run
83
+ `npm rebuild node-pty`, then `npm run doctor`. The container needs neither.
84
+
85
+ `npm run doctor` checks the Node version and native modules. If `node-pty`
86
+ needs rebuilding, `npm run repair` does that. The engine is native code; it is
87
+ not going to apologize for needing a compiler.
88
+
89
+ ## Run it (Or: Four doors, one room)
90
+
91
+ ### From source (Or: The workbench)
92
+
93
+ ```sh
94
+ git clone https://github.com/CaptainPhantasy/townmouse.git
95
+ cd townmouse
96
+ npm ci
97
+ npm start
98
+ ```
99
+
100
+ Open `http://localhost:11002`. The server binds to `127.0.0.1`. A terminal can
101
+ run commands with your account's permissions; keep the server on loopback
102
+ unless you have an authenticated proxy in front.
103
+
104
+ ### From npm (Or: The package is the product)
105
+
106
+ ```sh
107
+ npm install -g townmouse
108
+ townmouse --version
109
+ townmouse # starts the server and opens the workspace
110
+ townmouse --port 12000 --no-open
111
+ ```
112
+
113
+ `npx townmouse` runs it without a global install. The command starts the server,
114
+ prints the URL, and opens a browser unless `--no-open` is passed; `--help` and
115
+ `--version` do what they say.
116
+
117
+ A running copy says which version it is by itself: on the line under the Menu
118
+ title in the pane workspace, on the line under the Settings title in the
119
+ terminal workspace, and in the window title. `GET /health` returns it as
120
+ `version`.
121
+
122
+ The first run creates `~/.townmouse` (mode 0700) holding the workspace token
123
+ (mode 0600) and the attachment tree. Back that directory up before upgrades; it
124
+ is the part that is yours.
125
+
126
+ ```sh
127
+ npm run doctor # Node version and native modules
128
+ npm run repair # rebuild node-pty if the engine and the runtime disagree
129
+ ```
130
+
131
+ On Linux with npm 12, dependency install scripts are skipped by default and
132
+ node-pty has no Linux prebuild. Allow the build, or rebuild afterwards, then
133
+ check:
134
+
135
+ ```sh
136
+ npm install -g --allow-scripts=node-pty townmouse
137
+ # or, in an existing install:
138
+ npm rebuild node-pty
139
+ npm run doctor
140
+ ```
141
+
142
+ If the terminal engine cannot load, the server says so and names those remedies
143
+ instead of printing a stack trace.
144
+
145
+ On macOS, the installed package can also run as an always-on service with its own
146
+ `townmouse` launcher:
147
+
148
+ ```sh
149
+ "$(npm root -g)/townmouse/scripts/install-service.sh"
150
+ townmouse # starts the service if needed, then opens the workspace
151
+ "$(npm root -g)/townmouse/scripts/uninstall-service.sh"
152
+ ```
153
+
154
+ The service is `com.floyd.townmouse` on port 11002. TerminalOne keeps its own
155
+ service, port 11001 and `t1`; installing Townmouse never takes them over.
156
+
157
+ Upgrade, roll back, uninstall:
158
+
159
+ ```sh
160
+ npm install -g townmouse@latest # upgrade
161
+ npm install -g townmouse@0.2.1 # roll back to a known version
162
+ npm rm -g townmouse # uninstall
163
+ ```
164
+
165
+ Data is compatible within a minor version. A breaking data change would get a
166
+ migration note, not a shrug.
167
+
168
+ ### From the release tarball (Or: When the registry is not the route)
169
+
170
+ Every release attaches the exact tarball and its checksum, byte for byte the
171
+ same artifact the registry serves:
172
+
173
+ ```sh
174
+ VERSION=0.2.1 # set to the release you want
175
+ curl -LO "https://github.com/CaptainPhantasy/townmouse/releases/download/v$VERSION/townmouse-$VERSION.tgz"
176
+ curl -LO "https://github.com/CaptainPhantasy/townmouse/releases/download/v$VERSION/SHA256SUMS"
177
+ shasum -a 256 -c SHA256SUMS
178
+ npm install -g "./townmouse-$VERSION.tgz"
179
+ ```
180
+
181
+ ### With Docker (Or: The room in a box)
182
+
183
+ ```sh
184
+ TOWNMOUSE_VERSION=$(node -p "require('./package.json').version") \
185
+ GIT_REVISION=$(git rev-parse HEAD) \
186
+ docker build \
187
+ --build-arg TOWNMOUSE_VERSION="$TOWNMOUSE_VERSION" \
188
+ --build-arg GIT_REVISION="$GIT_REVISION" \
189
+ -t townmouse:"$TOWNMOUSE_VERSION" \
190
+ -t townmouse:latest .
191
+ docker run --rm -p 127.0.0.1:11002:11002 \
192
+ -v townmouse-home:/home/node/.townmouse \
193
+ -v townmouse-config:/home/node/.config/terminalone \
194
+ townmouse:latest
195
+ ```
196
+
197
+ The image carries Open Container labels for its version and the exact commit it
198
+ was built from, so an image can be traced back to the source. It is built
199
+ locally today; a registry tag will be added when the registry is chosen.
200
+
201
+ The image uses `node:22-alpine` and installs Chromium. The volume holds
202
+ the workspace data. Mount project directories explicitly; the terminal starts
203
+ in `/home/node`. `GET /health` returns `status: "ok"`.
204
+
205
+ Inside the container the server listens on `0.0.0.0` so Docker can forward the
206
+ port; the `-p 127.0.0.1:...` above is what keeps it off your network. Do not
207
+ publish it on `0.0.0.0` without an authenticated HTTPS proxy. Chromium runs
208
+ without its sandbox in this image because the container has no user namespace
209
+ setup for it; treat the image as a trusted single-user boundary.
210
+
211
+ ## Use it from a phone or tablet (Or: The tailnet is the front door)
212
+
213
+ The app installs from the browser on iPad or iPhone. The workspace and terminal
214
+ shell come from the local server; live PTYs and browser pages need it running.
215
+
216
+ Do not expose the raw loopback server. Put an HTTPS proxy or tunnel in front
217
+ that requires you to sign in before it forwards **any** request, including
218
+ WebSocket connections. Start Townmouse with the exact public address:
219
+
220
+ ```sh
221
+ TERMINALONE_TRUSTED_ORIGINS=https://townmouse.example.com npm start
222
+ # or, from an installed package:
223
+ TERMINALONE_TRUSTED_ORIGINS=https://townmouse.example.com townmouse --no-open
224
+ ```
225
+
226
+ The proxy must forward to `http://127.0.0.1:11002`, preserve the public `Host`
227
+ header and browser `Origin`, and support WebSocket upgrades. The setting takes
228
+ exact HTTPS origins separated by commas; wildcards, paths, embedded credentials,
229
+ and plain HTTP remote addresses are rejected. It allows an address. It does not
230
+ add authentication. Keep the server on loopback and let the proxy do the
231
+ sign-in.
232
+
233
+ On a tailnet, publish with `tailscale serve` on a claimed port bound to
234
+ loopback. Never expose it with Funnel without explicit approval. The mesh is the
235
+ gate; the server is not the gate.
236
+
237
+ ## The pane workspace (Or: Four panes, one token, zero codes to copy)
238
+
239
+ The pane workspace is the native path for agent work. Open `/panes.html`,
240
+ `/panes`, or **Panes** in the workspace sidebar.
241
+
242
+ A workspace tab holds up to four panes in a 2x2 grid. Each pane is a live PTY
243
+ terminal or a live headless-browser page. Tabs are created by the human or by
244
+ the orchestrator, and every tab can hold a different mix. The server caps the
245
+ workspace at 24 tabs and four panes per tab, with 24 terminal panes. The browser
246
+ runtime caps open browser contexts at 32. That gives a runaway agent a ceiling
247
+ before it gives the machine a funeral.
248
+
249
+ ### For a person (Or: The controls you actually touch)
250
+
251
+ **Tabs** in the bottom bar lists, switches, creates, and closes workspace tabs.
252
+ **Menu** adds a terminal or browser pane, opens Reader, adjusts terminal text,
253
+ or shows the shortcut sheet. **Keyboard** focuses the active terminal; in a
254
+ browser pane it focuses the page-type field. `Alt+T` creates a tab, `Alt+1..9`
255
+ selects one, `Alt+Arrow` moves pane focus, `Alt+Shift+Arrow` reorders a pane,
256
+ `Alt+M` maximizes (the pane header also carries a visible maximize/restore control), and `Alt+W` asks before closing the active pane. Drag a pane
257
+ header to reorder it, or drag the divider between panes to resize them.
258
+
259
+ Browser panes accept clicks, wheel scrolling, touch-drag scrolling, typing,
260
+ Back, Forward, Reload, and an address. The browser is a real Chromium page
261
+ rendered by the server, and its viewport reflows to the pane's actual size so
262
+ text wraps at the pane edge. `alert`/`confirm`/`prompt` dialogs wait for an
263
+ answer in a pane card (or `panes pane dialog`) instead of deadlocking the page.
264
+
265
+ **Your panes are yours.** Each pane you open says in its header what an agent
266
+ may do in it, under **Agent access**: **Private**, **View only**, or **Allow
267
+ control**. These are the same three levels, in the same words, as the browser
268
+ tab's Share row. Yours start Private, and no agent can see into one, read from
269
+ it or type into it until you say so. When an agent needs one of your panes, it
270
+ asks; the ask appears on that pane, with its reason, and you answer there: View
271
+ only, Allow control, or Not now. Setting a pane back to Private ends what an
272
+ agent was doing on it at once. The Orchestrator pane, and any pane an agent
273
+ opens, belong to the agents, and are marked that way.
274
+
275
+ Drop or paste a file or image onto a terminal pane. The file is uploaded once
276
+ into the state directory's `attachments/<date>/` tree (25 MB per request; daily
277
+ quota; old buckets archived), and a shell-quoted absolute path is inserted into
278
+ the PTY; the terminal never receives a base64 stream. The attachment card shows
279
+ the path and URL, and the browser pane can open the loopback URL. This is the
280
+ drag-and-drop people have expected since roughly 1995.
281
+
282
+ ### For an agent (Or: The environment is the handshake)
283
+
284
+ Each terminal pane is spawned with:
285
+
286
+ ```text
287
+ TOWNMOUSE_API=http://127.0.0.1:<port>/api/panes
288
+ TOWNMOUSE_TOKEN=<workspace token>
289
+ TOWNMOUSE_TAB_ID=<this tab>
290
+ TOWNMOUSE_PANE_ID=<this pane>
291
+ TOWNMOUSE_PANES_CLI=<repo>/scripts/panes
292
+ ```
293
+
294
+ No code is copied between the browser and the terminal. Run the CLI directly:
295
+
296
+ ```bash
297
+ "$TOWNMOUSE_PANES_CLI" guide
298
+ "$TOWNMOUSE_PANES_CLI" state
299
+ "$TOWNMOUSE_PANES_CLI" tab create --title "Second workspace"
300
+ "$TOWNMOUSE_PANES_CLI" pane create --kind terminal
301
+ "$TOWNMOUSE_PANES_CLI" pane create --kind browser --url https://example.com
302
+ "$TOWNMOUSE_PANES_CLI" pane exec <pane-id> -- "npm test" # tracked job, exit code
303
+ "$TOWNMOUSE_PANES_CLI" pane run <pane-id> "npm test" # typed line, unconfirmed
304
+ "$TOWNMOUSE_PANES_CLI" pane wait <pane-id> --match "PASS" --timeout 60000
305
+ "$TOWNMOUSE_PANES_CLI" pane read <pane-id> --lines 120 # clean screen text
306
+ "$TOWNMOUSE_PANES_CLI" pane read <pane-id> --raw
307
+ "$TOWNMOUSE_PANES_CLI" pane browser observe --elements
308
+ "$TOWNMOUSE_PANES_CLI" pane browser click --ref e12
309
+ "$TOWNMOUSE_PANES_CLI" pane browser type --ref e12 --replace "café 東京"
310
+ "$TOWNMOUSE_PANES_CLI" pane browser key Alt+M
311
+ "$TOWNMOUSE_PANES_CLI" pane browser scroll --ref e12 --dy 400
312
+ "$TOWNMOUSE_PANES_CLI" pane browser wait --text "Saved" --timeout 10000
313
+ "$TOWNMOUSE_PANES_CLI" pane browser sizing fixed --width 1280 --height 800
314
+ "$TOWNMOUSE_PANES_CLI" pane status <pane-id> --state blocked
315
+ "$TOWNMOUSE_PANES_CLI" pane text <pane-id>
316
+ "$TOWNMOUSE_PANES_CLI" pane request <pane-id> --level control --message "why"
317
+ "$TOWNMOUSE_PANES_CLI" attach ./screenshot.png --pane <pane-id>
318
+ ```
319
+
320
+ `panes guide` prints the instruction sheet an agent gets on connect: every tool,
321
+ what it needs, what it returns, and what this connection may not do. `pane
322
+ create` defaults to the current tab; a tab holds up to four panes and can mix
323
+ terminals and browsers freely.
324
+
325
+ A pane you open through the CLI or the API is yours to use, and so is the
326
+ Orchestrator pane. A pane the owner opened is Private to you until they give it
327
+ View only (you can read it) or Allow control (you can read and drive it).
328
+ `panes state` says what you have on every pane, under `agentAccess`; a Private
329
+ pane of the owner's appears there as an empty shape. A refusal names the pane's
330
+ level and the command to ask for more:
331
+
332
+ ```sh
333
+ "$TOWNMOUSE_PANES_CLI" pane request <pane-id> --level view|control --message "what you need it for"
334
+ ```
335
+
336
+ The ask is shown on that pane, and the command waits for the answer (up to two
337
+ minutes; `--timeout` changes it, `--no-wait` returns at once, `--cancel`
338
+ withdraws it). It exits 0 when the owner gives access, 3 while the answer is
339
+ still waiting, and 5 when the owner says Not now. A pane the owner just said Not
340
+ now to cannot be asked about for five minutes. To show the owner one of your own
341
+ panes, report it with `pane status` and bring it forward with `panes active`.
342
+
343
+ `pane exec` runs one non-interactive command as a tracked job and returns its id,
344
+ status, exit code, and output; `pane job` reads it again. `pane run` types into
345
+ the interactive terminal and does not prove the command finished. `pane read`
346
+ returns clean screen text; `--raw` keeps the original escape data. `pane wait`
347
+ blocks on text, a regex, an idle interval, or an agent-reported state, always
348
+ with a timeout. Regex patterns run in a worker thread with a deadline, so a
349
+ pathological pattern is refused instead of stalling the server.
350
+
351
+ Browser panes are driven by ref from `pane browser observe --elements`: role,
352
+ name, value, state, and box, across cross-origin frames and open shadow roots.
353
+ Coordinate clicks still work. Every action reports completed, missing,
354
+ wrong-kind, failed, stale, or unconfirmed, and a target from a changed page is
355
+ refused with "look again". `pane text` reads the page's visible text and says
356
+ when it was cut short. The owner's view of a browser pane is refreshed quickly
357
+ only while someone can see it (up to 30 pictures a second while the page is
358
+ changing) and not at all while they cannot; an agent's `observe` is its own
359
+ capture and does not depend on that.
360
+
361
+ Status is three separate facts, not one badge: the program is running or exited;
362
+ the agent last reported a state (with the age of that report); and the last
363
+ tracked command has its own result. `attach` uploads with the scoped pane token
364
+ and prints the path and URL.
365
+
366
+ The workspace survives a server restart: tab titles, pane kinds, terminal
367
+ working directories, browser URLs, pane order, and the active tab are saved in
368
+ `~/.townmouse/workspace.json`. The PTYs start fresh, because a shell process
369
+ does not survive its server. The layout does; the client sees a new epoch and
370
+ is told that scrollback and running jobs were not restored.
371
+
372
+ ## Shell sessions (Or: every shell is accounted for)
373
+
374
+ Every shell on the terminal screen is a session, and the top row lists them:
375
+ one chip per live shell, in the order you opened them. A chip names its shell
376
+ (`Shell 1`, `Shell 2`, or a name you give it), the current one is marked, and
377
+ the title reads `Townmouse / <name>`. Clicking a chip, or pressing Enter on it
378
+ from the keyboard, always takes you to that shell. It never starts another.
379
+ Left and Right move between chips. On a phone the chips give way to the
380
+ Sessions list, which the session pill opens.
381
+
382
+ A shell keeps running while you look at another one, and after you close the
383
+ browser or the computer sleeps, until you close it or the app stops. At most
384
+ ten run at once. The Sessions list says how many are in use, and starting an
385
+ eleventh is refused with that reason.
386
+
387
+ ### For a person (Or: three things to do with a shell)
388
+
389
+ - **Switch.** Click a chip, or open the session pill (it names the current
390
+ shell) and choose from the list.
391
+ - **Name.** In the Sessions list, press the pencil beside a shell. Enter
392
+ saves; Escape keeps the old name. Names are unique.
393
+ - **Close.** Press the × on a chip, or Close in the list, or Close terminal in
394
+ Tools. Every close asks first and names the shell. Confirming ends that
395
+ shell and anything still running in it. If you closed the shell you were in,
396
+ the window moves to the next one. If it was the only one, the terminal area
397
+ says so and offers Start a shell. A shell is never started on your behalf.
398
+
399
+ A reload brings back the same row and the same current shell. Come back to a
400
+ shell by any route, a switch, a reload or a window opened anew, and it shows
401
+ its recent output, once, and takes your typing at once. An app restart
402
+ ends every shell, because each shell is a process of the app. Afterwards the
403
+ window shows one new shell and says that the earlier ones ended. Nothing from
404
+ before is listed as if it were still running.
405
+
406
+ ### For an agent (Or: the same list, the same actions)
407
+
408
+ The shells agents start in the terminal row answer under `/api/sessions` with
409
+ the same workspace token as the pane API, and in the command-line tool as
410
+ `panes session`. A shell belongs to whoever started it: these commands reach
411
+ the shells agents started, `session list` shows those and only counts yours,
412
+ and an agent cannot rename, show or close a shell you started.
413
+
414
+ ```bash
415
+ "$TOWNMOUSE_PANES_CLI" session list
416
+ "$TOWNMOUSE_PANES_CLI" session create --name build --cwd ~/code/app
417
+ "$TOWNMOUSE_PANES_CLI" session rename build --name tests
418
+ "$TOWNMOUSE_PANES_CLI" session activate tests # only when the owner asked to see it
419
+ "$TOWNMOUSE_PANES_CLI" session close tests
420
+ ```
421
+
422
+ A session is named by its name, its id, or the first eight or more characters
423
+ of its id, among the shells in `session list`. Creating and renaming leave the
424
+ shell the owner is looking at alone, and the owner sees each change in the row
425
+ at once. `activate` is the one action that moves the owner's view: every open
426
+ Townmouse terminal window shows that shell. Close the shells you start. They
427
+ do not go away on their own.
428
+
429
+ ## The single-browser workspace (Or: The compatibility wing)
430
+
431
+ The pane workspace is the native path. The original single-browser workspace
432
+ remains for compatibility: the terminal surface, a tab strip of browser tabs,
433
+ and a separate agent browser.
434
+
435
+ Open **Browser** or a new tab. Enter a web address, search phrase, or localhost
436
+ URL. Navigation, clicks, typing, and scrolling happen in the real page on the
437
+ terminal host, not in an iframe.
438
+
439
+ Human tabs start Private. **Share** opens the permission row at every width -
440
+ View only, Allow control, Copy connection, Read page, Close tab - and it starts
441
+ closed so the page keeps the space. Changing the permission rotates the token;
442
+ choosing Private rejects subsequent token requests; closing a tab destroys its
443
+ context. A **Collapse** control removes every bar above the page and remembers
444
+ the choice, leaving a slim strip that names the page and brings the controls
445
+ back. The mascot stays in the navigation rail. On a phone, the tab strip,
446
+ address bar, and type row sit at the bottom above the remote keyboard; the
447
+ address bar carries back, forward, reload, and Go.
448
+
449
+ The agent browser is a separate context with control granted. Hide view keeps it
450
+ running headless; reopen Agent to observe the same context. Its bearer-token API
451
+ is documented in [docs/browser-workspace.md](docs/browser-workspace.md). For
452
+ agent work in the pane workspace, use the injected environment and
453
+ `scripts/panes` instead; there is no connection code to copy.
454
+
455
+ ## Security and limits (Or: Bad news first, then the receipts)
456
+
457
+ - The terminal runs with your account's permissions. Keep the server on loopback
458
+ unless an authenticated proxy is in front.
459
+ - Browser tabs and panes are isolated Chromium contexts with their own cookies,
460
+ not your personal Safari or Chrome profile. They are not a security boundary
461
+ against a process that already has unrestricted access to the host.
462
+ - Grants protect cooperative API clients. They do not protect against a hostile
463
+ process with host access.
464
+ - On the pane workspace, a pane the person opens is Private to agents until they
465
+ grant View only or Allow control from that pane's header. The server enforces
466
+ it on every route, not only in the page: an agent cannot read, type into,
467
+ move, resize or close a Private pane, and sees none of its title, address,
468
+ folder or output. What an agent has on a pane is stated in every state
469
+ response (`agentAccess`). An agent's own panes, and the Orchestrator pane, are
470
+ every agent's to use.
471
+ - On the terminal screen, a shell you open is yours: an agent cannot rename it,
472
+ bring your window to it, or close it, and its name and folder are not shown
473
+ to agents, only counted. The server enforces this on every route, not only in
474
+ the page. A shell an agent opens is any agent's to rename, show and close.
475
+ - The server tells the owner's page from an agent by the key each presents,
476
+ never by a field in the request. The page is handed its own key once, by a
477
+ route that answers only a page reached by a navigation in a browser and only
478
+ to that page's own request; agents hold the workspace token. Neither is asked
479
+ for the other.
480
+ - **What the per-pane setting holds against, and what it does not.** It holds
481
+ against an agent's own key (the `panes` command, a pane's environment). It
482
+ does not hold against a program on the same Mac that presents itself as the
483
+ owner's page: one making ordinary requests is refused, but one that sends a
484
+ browser's navigation details on purpose, or drives a real browser, is not told
485
+ apart from the page. That is what the next stage, agents separated from the
486
+ owner, is for.
487
+ - Browser sessions and grants live in memory. Restarting the server closes them;
488
+ saved browser profiles and seamless session persistence are not implemented.
489
+ The pane layout survives a restart; the grants on your panes do not, so your
490
+ panes come back Private and an agent asks again.
491
+ - Shell sessions are processes of the app. Each keeps running, with or without
492
+ a viewer, until it is closed; all of them end when the app stops.
493
+ - Browser audio, native file-picker and download dialogs, extensions, and
494
+ password-manager integration are not provided. Dropped files use the
495
+ attachment path above.
496
+ - The browser viewer is image-based: it is remote interaction, not a native DOM
497
+ exposed to the viewer's assistive technology.
498
+ - A password field's value never comes back from a page, on any route: not in an
499
+ element catalog, not in the result of a click or of typing, not in the report
500
+ of the focused field, and a password field cannot be waited on. An agent can
501
+ focus and type into one without reading it, and the page still receives what
502
+ was typed.
503
+
504
+ ### Your data (Or: The files that stay yours)
505
+
506
+ Workspace data lives in `~/.townmouse`:
507
+
508
+ - `pane-token` — the workspace API token, mode 600.
509
+ - `attachments/<date>/` — dropped files, mode 700/600.
510
+ - `workspace.json` — tabs, panes, URLs, and the active tab, mode 600.
511
+ - `~/.config/terminalone/voice.json` — voice command, model, language, and
512
+ arguments, mode 600. Outside `~/.townmouse`, so a Docker run mounts it as the
513
+ second volume.
514
+
515
+ Back up `~/.townmouse` before upgrades. Project files live wherever you mounted
516
+ them, never inside the package directory. Docker uses the `townmouse-home`
517
+ volume for the same data.
518
+
519
+ ## Development (Or: Tests before vibes)
520
+
521
+ The project keeps its own test suite and its release gates use it; the suite is
522
+ not part of the installed package. `npm start` runs the workspace from source,
523
+ and `npm run doctor` checks the native engine.
524
+
525
+ Design notes live in [DESIGN.md](DESIGN.md). The product follows the Legacy
526
+ Design Studio's Frontend Design workflow, with the Open Design anti-AI-slop
527
+ review as its supplemental checklist.
528
+
529
+ More docs:
530
+
531
+ - [docs/panes.md](docs/panes.md) — pane workspace and agent CLI.
532
+ - [docs/browser-workspace.md](docs/browser-workspace.md) — browser tabs and the legacy bearer-token API.
533
+ - [docs/PACKAGING.md](docs/PACKAGING.md) — npm, Docker, the macOS wrapper, release gates, and backup.
534
+ - [TOWNMOUSE.md](TOWNMOUSE.md) — product boundary and origin.
535
+
536
+ ## Status (Or: Version 0.2.1, and honest about it)
537
+
538
+ Version 0.2.1. 0.1.0 was the first product cut. Available from npm as
539
+ `townmouse@0.2.1`, as a checksummed tarball on the GitHub release, and as a
540
+ locally built container image. Two working surfaces: the single terminal/browser
541
+ workspace and the pane workspace. The pane workspace is the
542
+ native path for agent work; the single-browser workspace remains for
543
+ compatibility. Known limits are under Security and in
544
+ [docs/PACKAGING.md](docs/PACKAGING.md).
545
+
546
+ ## Terminal engine (Or: The engine stays in the engine bay)
547
+
548
+ The terminal is TerminalOne, the canonical standalone PTY from Floyd’s Labs,
549
+ embedded in Townmouse. The terminal surface — PTY, session resume, key bar,
550
+ themes, and feature modules — comes from the engine. Townmouse owns the browser
551
+ workspace, agent browser, view/control grants, the pane system, and the
552
+ interface. Browser-workspace features do not go upstream into TerminalOne. See
553
+ [TOWNMOUSE.md](TOWNMOUSE.md) for the product boundary and origin.
554
+
555
+ ## Credits (Or: The cats get a logo, not the product)
556
+
557
+ Built at [Floyd’s Labs](https://floydslabs.com). The creator credit in the app
558
+ uses the Floyd’s Labs neon-cats mark. Bella and Bowser did not review this README,
559
+ but Bella walked across the keyboard at least once, which counts as QA.
560
+
561
+ ## License (Or: The give-back rule)
562
+
563
+ AGPL-3.0-only. If you run Townmouse, or a modified version of it, as a network
564
+ service, you must offer the complete corresponding source to the people who use
565
+ it. Distributing it also requires the source. TerminalOne's license and
566
+ copyright notices remain with the portions it supplies.
567
+
568
+ ### Why AGPL-3.0-only (Or: Because the subscription treadmill can keep walking)
569
+
570
+ At Floyd’s Labs we build local tools that should stay useful to the people who
571
+ run them. We release Townmouse under the GNU Affero General Public License v3,
572
+ and only v3, for three plain reasons:
573
+
574
+ - **Open Exchange.** The work should be available to independent developers,
575
+ self-hosters, and hobbyists for personal and local use.
576
+ - **The Give-Back Rule.** If you modify Townmouse and expose it as a network
577
+ service, the AGPL requires you to offer your modified source under the same
578
+ terms.
579
+ - **Passive Protection.** The license keeps self-funded lab work a shared asset.
580
+ A proprietary service cannot build on Townmouse without making its modified
581
+ source available under the same terms.
582
+
583
+ That is the point. Nobody gets to take the garage work, put a Patagonia vest on
584
+ it, and charge rent for the terminal.
585
+
586
+ ---
587
+
588
+ ┌──────────────────────────────────────────────────────────┐
589
+ │ DOCUMENT METADATA │
590
+ ├──────────────────────────────────────────────────────────┤
591
+ │ Classification: Product README / Floyd's Labs │
592
+ │ Cat Supervision: Bella approved; Bowser monitoring │
593
+ │ "I Don't Suck": PASS │
594
+ │ Corporate Feelings: HURT (intended) │
595
+ └──────────────────────────────────────────────────────────┘
596
+
597
+ **DOCUMENT ENDS**
598
+
599
+ *— The Garage, Product Documentation Division*
600
+ *Floyd’s Labs — Brown County, Indiana*
601
+ *“The terminal is the house. The browser is the town. The mouse is the product.”*
package/SECURITY.md ADDED
@@ -0,0 +1,60 @@
1
+ # Security Policy
2
+
3
+ ## Or: Keep The Shell In The House And The Browser In The Town
4
+
5
+ Townmouse is a terminal and agent browser workspace. It runs a real shell and real browser pages on your machine, with your account's permissions — that is the whole point, and also the whole risk. It embeds TerminalOne as its terminal engine. Treat the workspace as an administrative tool for a host you trust.
6
+
7
+ Written in the garage in Brown County, Indiana. The coffee is terrible. The rules are not.
8
+
9
+ ## Supported Versions
10
+
11
+ Security fixes land on `main`, or they do not land. Only the latest commit on the `main` branch is supported with security updates.
12
+
13
+ | Version | Supported |
14
+ | ------- | ------------------ |
15
+ | main | :white_check_mark: |
16
+ | < main | :x: |
17
+
18
+ ## Reporting a Vulnerability
19
+
20
+ **Do not open a public issue for security vulnerabilities.** A public issue tells everyone, including the people you would rather not tell.
21
+
22
+ Report vulnerabilities privately via **GitHub Security Advisories**:
23
+
24
+ 1. Go to the [Security tab](https://github.com/CaptainPhantasy/townmouse/security) on the Townmouse repository.
25
+ 2. Click **Report a vulnerability**.
26
+ 3. Describe the issue in detail: what is affected, how to reproduce it, and the potential impact.
27
+
28
+ ### What to expect
29
+
30
+ - **Response:** Best-effort. No guaranteed SLA. We will not pretend otherwise.
31
+ - **Disclosure:** Coordinated disclosure — a fix will ship before the advisory is published.
32
+ - **Credit:** Reporters are credited in the advisory and changelog unless they request anonymity.
33
+
34
+ ### Out of scope
35
+
36
+ - Issues in third-party dependencies (report upstream to the dependency maintainers)
37
+ - Social engineering or phishing attacks
38
+ - Physical access to the host machine
39
+ - Vulnerabilities that require the attacker to already have shell access to the machine running Townmouse
40
+
41
+ ## Security model
42
+
43
+ - Townmouse binds to `127.0.0.1` by default. Keep it on loopback. An HTTPS proxy or tunnel in front must authenticate **every** request before it forwards it, including WebSocket upgrades. `TERMINALONE_TRUSTED_ORIGINS` allows an address; it does not add authentication.
44
+ - A terminal runs commands with your account's permissions. Browser tabs are isolated Chromium contexts, not your personal Safari or Chrome profile.
45
+ - View and control grants protect cooperative API clients. They are not a security boundary against a process that already has unrestricted access to the host.
46
+ - On the pane workspace, a pane the owner opens is Private to agents until the owner grants View only or Allow control from its header. The server enforces the level on every route and tells the owner's page from an agent by the key presented, never by a field in the request. An agent's own panes, and the Orchestrator pane, are every agent's to use.
47
+ - **What the per-pane setting holds against, and what it does not.** It holds against an agent's own key: the `panes` command, and the token in a pane's environment. It does not hold against a program on the same Mac that presents itself as the owner's page. The owner's key is handed only to a page reached by a navigation in a browser (`Sec-Fetch-Mode: navigate`) and only to that page's own request (`Sec-Fetch-Site: same-origin`), so a program making ordinary requests is refused and told what an agent does instead; a program that sends those details on purpose, or drives a real browser, is not told apart from the page, because nothing that looks only at an HTTP request can tell them apart. Separating agents from the owner at that level is the next stage.
48
+ - No route returns a password field's value: not the element catalog, not the result of a click or of typing, not the report of the focused element, and a password field cannot be waited on.
49
+ - Browser sessions and grants are held in memory; restarting the server closes them. At most 32 browser contexts can remain open.
50
+ - Browser audio, file upload/download dialogs, extensions, and password-manager integration are not provided.
51
+ - The request boundary accepts any port on a loopback hostname so a container can be published on a different host port. It still requires an exact same-origin `Origin`/`Host` match, so a page served from another local port cannot drive the server. A non-loopback hostname must be listed in `TERMINALONE_TRUSTED_ORIGINS` as an exact HTTPS origin.
52
+ - On macOS the server makes node-pty's `spawn-helper` executable inside its own installed package at startup. npm 12 does not run dependency install scripts by default, and the tarball does not carry the mode bit; without the repair every terminal fails. The change is a mode bit on a file inside the package the server is already running from.
53
+ - Browser panes use `TERMINALONE_CHROME` when set, otherwise Puppeteer's downloaded build, otherwise an installed Chrome, Chromium, Edge, or Brave. `GET /health` reports which one resolved. None of these are the user's personal profile.
54
+
55
+ *Townmouse is AGPL-3.0-only.*
56
+
57
+ ---
58
+
59
+ *— Floyd's Labs, The Garage*
60
+ *"Bowser watches the router. We watch the door."*