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
package/docs/panes.md ADDED
@@ -0,0 +1,252 @@
1
+ # Pane Workspace
2
+
3
+ ## Or: Four Panes, One Token, Zero Connection Codes To Copy
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:** Four panes open, one agent asking for a fifth
12
+
13
+ ---
14
+
15
+ Open `/panes.html`, `/panes`, or **Panes** in the workspace sidebar. This is the
16
+ agent-first surface: a workspace tab holds one to four panes, and each pane is
17
+ either a live PTY terminal or a live headless-browser page. Tabs are created by
18
+ the human or by the orchestrator, and every tab can hold a different mix.
19
+
20
+ On first start, with no saved workspace, the pane surface seeds one tab with a
21
+ terminal pane titled **Orchestrator**. That is a real PTY of its own — a second
22
+ shell alongside the standard terminal view — created by the same server process,
23
+ not a second application instance. It is intentional: the workspace opens with a
24
+ place for the orchestrator to work. Keep it.
25
+
26
+ The terminal panes are real PTYs from the embedded TerminalOne engine. The
27
+ browser panes are real Chromium pages rendered by the server. Neither one is a
28
+ screenshot pretending to be a workspace.
29
+
30
+ The server caps the workspace at 24 tabs, four panes per tab, and 24 terminal
31
+ panes. The browser runtime caps open browser contexts at 32. The state response
32
+ carries `maxTabs`, `maxPanesPerTab`, and `maxTerminalPanes`. The caps exist so a
33
+ runaway agent runs out of room before it runs the machine out of memory.
34
+
35
+ ## Human
36
+
37
+ - **Tabs** button in the bottom bar: list, switch, create, and close workspace
38
+ tabs.
39
+ - **Menu**: add a terminal or browser pane to the active tab, or create a tab.
40
+ - **Keyboard**: focus the active terminal; in a browser pane it focuses the
41
+ page-type field.
42
+ - Drag a divider to resize panes, use Arrow/Home/End while a divider is focused,
43
+ or double-click it to reset. Ratios are remembered per tab.
44
+ - The phone key bar above the bottom navigation provides Esc, Tab, sticky
45
+ Ctrl/Alt, C, arrows, Home/End, PgUp/PgDn. Ctrl then C sends SIGINT.
46
+ - Right-click or long-press a terminal for Copy, Paste, Select all, Clear, and
47
+ Reader. Reader is a word-wrapped transcript; the live pane remains a cell
48
+ grid. Menu also has smaller/larger text, and a shortcut sheet.
49
+ - Closing a pane or tab asks first. An answerable `alert`/`confirm`/`prompt`
50
+ appears as a card; a forgotten dialog is dismissed after 30 seconds.
51
+ - Browser panes accept clicks, wheel scrolling, typing, Back, Forward, Reload,
52
+ and an address. The browser is a real Chromium page rendered by the server,
53
+ and its viewport reflows to the pane's actual size.
54
+ - Drop or paste files/images onto a terminal pane. The file is uploaded once
55
+ into the state directory's `attachments/<YYYYMMDD>/` tree (25 MB per request,
56
+ 2,000 files / 512 MB per day) and a shell-quoted absolute path is inserted
57
+ into the PTY. The terminal never receives a base64 stream. An attachment card
58
+ shows the path and URL with Copy/Open actions; dropping onto a browser pane
59
+ opens the loopback URL instead. Buckets older than
60
+ `TOWNMOUSE_ATTACHMENT_RETENTION_DAYS` (default 30) move to
61
+ `attachments-archive` instead of being deleted.
62
+
63
+ ## Agent
64
+
65
+ Each terminal pane is spawned with:
66
+
67
+ ```text
68
+ TOWNMOUSE_API=http://127.0.0.1:<port>/api/panes
69
+ TOWNMOUSE_TOKEN=<workspace token>
70
+ TOWNMOUSE_TAB_ID=<this tab>
71
+ TOWNMOUSE_PANE_ID=<this pane>
72
+ TOWNMOUSE_PANES_CLI=<repo>/scripts/panes
73
+ ```
74
+
75
+ No code is copied between the browser and the terminal. Run the CLI directly:
76
+
77
+ ```sh
78
+ "$TOWNMOUSE_PANES_CLI" state
79
+ "$TOWNMOUSE_PANES_CLI" tab list
80
+ "$TOWNMOUSE_PANES_CLI" tab create --title "Second workspace"
81
+ "$TOWNMOUSE_PANES_CLI" tab close <tab-id>
82
+ "$TOWNMOUSE_PANES_CLI" pane create --tab <tab-id> --kind terminal
83
+ "$TOWNMOUSE_PANES_CLI" pane create --kind browser --url https://example.com
84
+ "$TOWNMOUSE_PANES_CLI" pane url <pane-id> https://example.com
85
+ "$TOWNMOUSE_PANES_CLI" pane run <pane-id> "npm test"
86
+ "$TOWNMOUSE_PANES_CLI" pane input <pane-id> "echo hello"
87
+ "$TOWNMOUSE_PANES_CLI" pane send-text <pane-id> "multi-line prompt"
88
+ "$TOWNMOUSE_PANES_CLI" pane keys <pane-id> ctrl+c
89
+ "$TOWNMOUSE_PANES_CLI" pane wait <pane-id> --match "PASS" --timeout 60000
90
+ "$TOWNMOUSE_PANES_CLI" pane status <pane-id> --state blocked --message "approval?"
91
+ "$TOWNMOUSE_PANES_CLI" pane dialog <pane-id> --accept
92
+ "$TOWNMOUSE_PANES_CLI" pane read <pane-id> --lines 120
93
+ "$TOWNMOUSE_PANES_CLI" pane close <pane-id>
94
+ "$TOWNMOUSE_PANES_CLI" attach ./screenshot.png --pane <pane-id>
95
+ "$TOWNMOUSE_PANES_CLI" active --tab <tab-id> --pane <pane-id>
96
+ ```
97
+
98
+ ### Instruction sheet
99
+
100
+ `panes guide` (or `GET /api/panes/guide`) prints the sheet an agent receives on
101
+ connect: every tool, what it needs, what it returns, and — separately — which
102
+ capabilities this connection has and has not been granted. It describes
103
+ permissions; it does not enlarge them. See
104
+ `docs/plans/townmouse-orchestrator-assessment-2026-11-20-implementation.md`
105
+ for the full mapping of tools to assessment items.
106
+
107
+ ### Pane ids default to the current pane
108
+
109
+ Inside a pane, the pane id can be omitted. The CLI recognises a real id by shape
110
+ (`p_…`) and otherwise falls back to `TOWNMOUSE_PANE_ID`, so `panes pane read` and
111
+ `panes pane browser click` work with no argument.
112
+
113
+ ### Tracked commands
114
+
115
+ `pane run` types a line into the interactive terminal and returns recent output.
116
+ That does **not** prove the command finished. For ordinary, non-interactive
117
+ commands use a tracked job:
118
+
119
+ ```sh
120
+ "$TOWNMOUSE_PANES_CLI" pane exec -- "npm test" # waits, returns exit code
121
+ "$TOWNMOUSE_PANES_CLI" pane exec --no-wait -- "make" # returns a job id
122
+ "$TOWNMOUSE_PANES_CLI" pane job <job-id> # poll it
123
+ ```
124
+
125
+ A job reports `status` (`running` | `completed` | `failed`), `exitCode`,
126
+ `signal`, `stdout`, `stderr`, and truncation flags. Keep the interactive
127
+ terminal for programs such as `dlaude` that stay open and wait for input.
128
+
129
+ ### Clean and raw terminal text
130
+
131
+ `pane read` renders screen text (`replayTranscript`) so escape codes do not
132
+ clutter the output, and `--raw` returns the original terminal data. Both modes
133
+ report `offset`, `bufferStart`, and a `truncated` flag.
134
+
135
+ ### Browser control
136
+
137
+ ```sh
138
+ "$TOWNMOUSE_PANES_CLI" pane browser observe --elements # labelled screenshot + controls
139
+ "$TOWNMOUSE_PANES_CLI" pane browser elements # controls only
140
+ "$TOWNMOUSE_PANES_CLI" pane browser click --ref e12
141
+ "$TOWNMOUSE_PANES_CLI" pane browser click --x 300 --y 200 --observation 42
142
+ "$TOWNMOUSE_PANES_CLI" pane browser type --ref e12 --replace "café 東京"
143
+ "$TOWNMOUSE_PANES_CLI" pane browser key Alt+M
144
+ "$TOWNMOUSE_PANES_CLI" pane browser hover --ref e12
145
+ "$TOWNMOUSE_PANES_CLI" pane browser drag --from-ref e12 --to-ref e15
146
+ "$TOWNMOUSE_PANES_CLI" pane browser scroll --ref e12 --dy 400
147
+ "$TOWNMOUSE_PANES_CLI" pane browser select --ref e12 --value blue
148
+ "$TOWNMOUSE_PANES_CLI" pane browser navigate https://example.com
149
+ "$TOWNMOUSE_PANES_CLI" pane browser wait --text "Saved" --timeout 10000
150
+ "$TOWNMOUSE_PANES_CLI" pane browser sizing fixed --width 1280 --height 800
151
+ ```
152
+
153
+ Controls are identified by role and name, including inside cross-origin frames
154
+ and open shadow roots. Each action returns a `status` (`completed`, `missing`,
155
+ `wrong-kind`, `failed`, `stale`, `unconfirmed`); a coordinate used with a stale
156
+ `--observation` is refused with exit code 4 and a message to look again. Every
157
+ wait is bounded. In `fixed` sizing the owner's viewer scales the picture instead
158
+ of rearranging the page.
159
+
160
+ `pane create` defaults to `TOWNMOUSE_TAB_ID` when `--tab` is omitted. It also
161
+ accepts `--cwd` and `--title`. `tab create` accepts `--activate` when the new
162
+ tab should become active; without it, the CLI creates the tab without moving the
163
+ active tab. The orchestrator can create as many tabs as the server allows; each
164
+ tab holds up to four panes. A single tab can be all terminals, all browsers, or
165
+ any mix.
166
+
167
+ `pane url` requires a browser pane. `pane run` writes the command with a newline
168
+ and returns the last 4,000 characters of output after its wait, flagged
169
+ `confirmed: false` because typing a line is not proof the command finished; use
170
+ `pane exec` for a tracked job. `pane input` writes raw text and does not append a
171
+ newline. Both `pane run` and `pane input` require a terminal pane.
172
+
173
+ `pane send-text` preserves literal text and wraps it in bracketed-paste markers
174
+ by default; pass `--raw` to opt out. `pane keys` accepts logical names including
175
+ `enter`, `esc`, `tab`, `ctrl+c`, `alt+x`, and arrows. `pane wait` long-polls for
176
+ plain text, a regex, an idle interval, or an agent-reported state, and returns
177
+ the matching output with `offset` and `elapsedMs`; the server caps a wait at 120
178
+ seconds. Regex patterns run in a worker thread with a 500 ms deadline, so a
179
+ pattern that backtracks pathologically is terminated and refused instead of
180
+ stalling the server; patterns are capped at 200 characters. `pane status` records
181
+ `working`, `blocked`, `idle`, `done`, or `unknown`
182
+ with an optional message; the pane header colors the badge and state responses
183
+ carry `lastOutputAt`, `idleMs`, `exitCode`, and `exitSignal`. `pane dialog`
184
+ answers a waiting page dialog. `attach` uploads a file with the scoped pane token
185
+ and prints `path`, `url`, `localUrl`, and `relativeUrl`; use `--pane` to insert
186
+ the quoted path as well. Pane order is changed with
187
+ `POST /api/panes/tabs/<tab-id>/reorder` (`paneId`, `index`), or on the client by
188
+ dragging a pane header or Alt+Shift+Arrow.
189
+
190
+ The CLI reads `TOWNMOUSE_API` and `TOWNMOUSE_TOKEN` from the environment and
191
+ falls back to `~/.townmouse/pane-token` when the token is absent. It sends the
192
+ token in `X-Townmouse-Token`; the API also accepts `Authorization: Bearer
193
+ <token>`. The owner bootstrap route is separate: an agent token cannot bootstrap
194
+ the owner workspace.
195
+
196
+ ## Wire facts
197
+
198
+ - Terminal output is an SSE stream at
199
+ `GET /api/panes/panes/<pane-id>/stream?since=<offset>` with
200
+ `Content-Type: text/event-stream`. Each event's JSON payload carries `data` and
201
+ `offset`; the initial replay also reports `exited`. The server keeps the last
202
+ 200,000 characters of output and replays from `since`. It sends a `: ping`
203
+ comment every 15 seconds.
204
+ - If the stream drops, the client falls back to polling
205
+ `GET /api/panes/panes/<pane-id>/read?since=<offset>` every 180 ms. A dropped
206
+ stream is not a dead terminal.
207
+ - Terminal input is batched by the client: keystrokes and pastes are coalesced
208
+ for 12 ms, and at most one `POST /api/panes/panes/<pane-id>/input` is in
209
+ flight. Payloads over 24,000 characters are split into sequential chunks so
210
+ each request stays under the JSON body limit; order is preserved. A burst of
211
+ typing arrives as one ordered request, which is the difference between smooth
212
+ and jittery when the agent is also producing output.
213
+ - Resize is `POST /api/panes/panes/<pane-id>/resize`. Terminal columns are
214
+ clamped to 20-400 and rows to 5-200. Browser panes set a viewport clamped to
215
+ 320-1920 by 240-1200.
216
+ - `POST /api/panes/panes/<pane-id>/start` spawns a deferred terminal at the
217
+ measured cols/rows; the UI creates terminals with `start:false` so the first
218
+ prompt is laid out at the visible width.
219
+ - At most four terminal SSE streams are open at once; additional panes use the
220
+ polling fallback so input and state requests keep an HTTP connection. If a
221
+ reader stops draining, the server ends its stream instead of buffering output
222
+ without limit.
223
+ - `POST /api/panes/panes/<pane-id>/keys` writes named keys; `GET .../wait`
224
+ supports `match`, `regex`, `idleMs`, and `state`; `POST .../status` records
225
+ agent lifecycle; `POST .../browser/dialog` answers a page dialog.
226
+ - State includes an `epoch` minted per server boot and `restored`. After a
227
+ restart the client keeps tabs, pane kinds, titles, cwd, and browser URLs but
228
+ warns that terminal scrollback and running jobs are gone.
229
+ - Owner bootstrap (`GET /api/panes/bootstrap`) requires the HttpOnly owner
230
+ cookie minted on page navigation. A pane token receives 403 there; the token
231
+ is accepted by the pane API and by attachment uploads.
232
+
233
+ The workspace limits are real. The token is real. The panes are real. The old
234
+ way copied a connection string between the browser and the terminal; this one
235
+ hands the agent the environment and gets out of the way.
236
+
237
+ ```text
238
+ ┌──────────────────────────────────────────────────────────┐
239
+ │ DOCUMENT METADATA │
240
+ ├──────────────────────────────────────────────────────────┤
241
+ │ Classification: Technical / Pane Workspace │
242
+ │ Cat Supervision: Bowser, monitoring the pane count │
243
+ │ "I Don't Suck": PASS │
244
+ │ Corporate Feelings: HURT (intended) │
245
+ └──────────────────────────────────────────────────────────┘
246
+ ```
247
+
248
+ **DOCUMENT ENDS**
249
+
250
+ *— Workspace, Floyd's Labs*
251
+ *The Garage — Brown County, Indiana*
252
+ *"Four panes is a workspace. Five is an incident report."*
@@ -0,0 +1,108 @@
1
+ import AppKit
2
+ import Foundation
3
+ import WebKit
4
+
5
+ @main
6
+ @MainActor
7
+ final class TownmouseApp: NSObject, NSApplicationDelegate {
8
+ private var window: NSWindow!
9
+ private var webView: WKWebView!
10
+ private let serviceURL = URL(string: ProcessInfo.processInfo.environment["TOWNMOUSE_URL"] ?? ProcessInfo.processInfo.environment["TERMINALONE_URL"] ?? "http://127.0.0.1:11001")!
11
+
12
+ static func main() {
13
+ let app = NSApplication.shared
14
+ let delegate = TownmouseApp()
15
+ app.delegate = delegate
16
+ app.setActivationPolicy(.regular)
17
+ app.run()
18
+ }
19
+
20
+ func applicationDidFinishLaunching(_ notification: Notification) {
21
+ let configuration = WKWebViewConfiguration()
22
+ configuration.websiteDataStore = .default()
23
+ webView = WKWebView(frame: .zero, configuration: configuration)
24
+ window = NSWindow(
25
+ contentRect: NSRect(x: 0, y: 0, width: 1280, height: 820),
26
+ styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
27
+ backing: .buffered,
28
+ defer: false
29
+ )
30
+ window.title = "Townmouse"
31
+ window.setFrameAutosaveName("TownmouseMainWindow")
32
+ window.contentView = webView
33
+ window.center()
34
+ window.makeKeyAndOrderFront(nil)
35
+ NSApp.activate(ignoringOtherApps: true)
36
+ ensureBackendAndLoad()
37
+ }
38
+
39
+ func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { true }
40
+
41
+ private func ensureBackendAndLoad() {
42
+ DispatchQueue.global(qos: .userInitiated).async { [serviceURL, weak self] in
43
+ if !Self.isHealthy(serviceURL) {
44
+ Self.startBackend()
45
+ }
46
+ let deadline = Date().addingTimeInterval(12)
47
+ while Date() < deadline && !Self.isHealthy(serviceURL) {
48
+ Thread.sleep(forTimeInterval: 0.25)
49
+ }
50
+ let healthy = Self.isHealthy(serviceURL)
51
+ DispatchQueue.main.async { [weak self] in
52
+ guard let self else { return }
53
+ if healthy {
54
+ self.webView.load(URLRequest(url: serviceURL))
55
+ } else {
56
+ self.presentStartupError()
57
+ }
58
+ }
59
+ }
60
+ }
61
+
62
+ nonisolated private static func isHealthy(_ baseURL: URL) -> Bool {
63
+ let healthURL = baseURL.appendingPathComponent("health")
64
+ var request = URLRequest(url: healthURL)
65
+ request.timeoutInterval = 1
66
+ let semaphore = DispatchSemaphore(value: 0)
67
+ var ok = false
68
+ URLSession.shared.dataTask(with: request) { _, response, _ in
69
+ ok = (response as? HTTPURLResponse)?.statusCode == 200
70
+ semaphore.signal()
71
+ }.resume()
72
+ _ = semaphore.wait(timeout: .now() + 1.5)
73
+ return ok
74
+ }
75
+
76
+ nonisolated private static func startBackend() {
77
+ var candidates: [String] = []
78
+ if let configured = ProcessInfo.processInfo.environment["TERMINALONE_T1"] {
79
+ candidates.append(configured)
80
+ }
81
+ if let resource = Bundle.main.path(forResource: "launcher-path", ofType: "txt"),
82
+ let path = try? String(contentsOfFile: resource, encoding: .utf8).trimmingCharacters(in: .whitespacesAndNewlines) {
83
+ candidates.append(path)
84
+ }
85
+ candidates += [
86
+ NSString(string: "~/.local/bin/t1").expandingTildeInPath,
87
+ "/usr/local/bin/t1",
88
+ NSString(string: "~/bin/t1").expandingTildeInPath,
89
+ ]
90
+ guard let launcher = candidates.first(where: { FileManager.default.isExecutableFile(atPath: $0) }) else { return }
91
+ let process = Process()
92
+ process.executableURL = URL(fileURLWithPath: launcher)
93
+ process.arguments = ["--serve-only"]
94
+ process.standardOutput = FileHandle.nullDevice
95
+ process.standardError = FileHandle.nullDevice
96
+ try? process.run()
97
+ }
98
+
99
+ private func presentStartupError() {
100
+ let alert = NSAlert()
101
+ alert.messageText = "Townmouse could not start"
102
+ alert.informativeText = "Run ‘t1 doctor’ in a terminal for the exact cause and repair command."
103
+ alert.alertStyle = .critical
104
+ alert.addButton(withTitle: "OK")
105
+ alert.runModal()
106
+ NSApp.terminate(nil)
107
+ }
108
+ }
package/package.json CHANGED
@@ -1,6 +1,91 @@
1
1
  {
2
2
  "name": "townmouse",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.1",
4
+ "description": "A terminal and agent browser workspace built on TerminalOne.",
5
+ "license": "AGPL-3.0-only",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/CaptainPhantasy/townmouse.git"
9
+ },
10
+ "homepage": "https://floydslabs.com",
11
+ "bugs": {
12
+ "url": "https://github.com/CaptainPhantasy/townmouse/issues"
13
+ },
14
+ "keywords": [
15
+ "terminal",
16
+ "browser",
17
+ "agent",
18
+ "workspace",
19
+ "pty",
20
+ "websocket",
21
+ "xterm",
22
+ "pwa",
23
+ "automation"
24
+ ],
25
+ "main": "src/server.js",
26
+ "packageManager": "npm@10.9.3",
27
+ "scripts": {
28
+ "start": "scripts/node-runtime.sh exec src/server.js",
29
+ "dev": "scripts/node-runtime.sh exec src/server.js",
30
+ "doctor": "scripts/node-runtime.sh doctor",
31
+ "repair": "scripts/node-runtime.sh repair",
32
+ "test": "npm run test:security && bash tests/hooks.test.sh && npm run test:unit && scripts/node-runtime.sh exec tests/smoke-test.js && scripts/node-runtime.sh exec tests/feature-test.js && scripts/node-runtime.sh exec tests/feature-behavior-test.js && scripts/node-runtime.sh exec tests/voice-input.test.js && scripts/node-runtime.sh exec tests/responsive-test.js && npm run test:ui && npm run test:panes && npm run test:agent-control && npm run test:voice-routing",
33
+ "test:unit": "scripts/node-runtime.sh exec tests/input-guard.test.mjs && node --test tests/input-chunks.test.mjs tests/replay-text.test.mjs tests/attachments-retention.test.mjs tests/service-worker.test.js tests/commercial-polish.test.js tests/autosave-restore.test.mjs tests/shell-resolve.test.js tests/static-deps.test.js tests/pty-permissions.test.js tests/chrome-resolve.test.js tests/safe-regex.test.js && node --test tests/clipboard-text.test.mjs",
34
+ "test:smoke": "scripts/node-runtime.sh exec tests/smoke-test.js",
35
+ "test:features": "scripts/node-runtime.sh exec tests/feature-test.js",
36
+ "test:behavior": "scripts/node-runtime.sh exec tests/feature-behavior-test.js",
37
+ "test:voice": "scripts/node-runtime.sh exec tests/voice-input.test.js",
38
+ "test:responsive": "scripts/node-runtime.sh exec tests/responsive-test.js",
39
+ "test:workspace": "scripts/node-runtime.sh exec tests/workspace-journeys.cjs",
40
+ "test:ui": "scripts/node-runtime.sh exec tests/ui-surfaces.test.cjs && scripts/node-runtime.sh exec tests/owner-recovery.test.cjs",
41
+ "postinstall": "sh scripts/prepare-native.sh",
42
+ "test:security": "node --test tests/request-boundary.test.js tests/request-boundary-integration.test.js",
43
+ "test:panes": "node tests/panes-api.test.cjs && node tests/panes-persistence.test.cjs && node tests/resume-width.test.cjs && node tests/attachments-ui.test.cjs && node tests/idle-wake.test.cjs && node tests/multi-window.test.cjs",
44
+ "test:agent-control": "scripts/node-runtime.sh exec tests/agent-control.test.cjs",
45
+ "test:voice-routing": "node tests/voice-routing.test.cjs",
46
+ "test:maximize": "node tests/panes-maximize.test.cjs",
47
+ "test:package": "scripts/node-runtime.sh exec tests/package-install.test.cjs"
48
+ },
49
+ "dependencies": {
50
+ "@xterm/addon-fit": "^0.11.0",
51
+ "@xterm/addon-search": "^0.16.0",
52
+ "@xterm/addon-web-links": "^0.12.0",
53
+ "@xterm/xterm": "^6.0.0",
54
+ "express": "^5.2.1",
55
+ "node-pty": "^1.1.0",
56
+ "puppeteer": "^25.17.0",
57
+ "uuid": "^14.0.1",
58
+ "ws": "^8.21.1"
59
+ },
60
+ "engines": {
61
+ "node": ">=22 <27"
62
+ },
63
+ "files": [
64
+ "bin/",
65
+ "src/",
66
+ "public/",
67
+ "scripts/node-runtime.sh",
68
+ "scripts/prepare-native.sh",
69
+ "scripts/install-service.sh",
70
+ "scripts/uninstall-service.sh",
71
+ "scripts/t1.sh",
72
+ "scripts/run-hooks",
73
+ "README.md",
74
+ "TOWNMOUSE.md",
75
+ "DESIGN.md",
76
+ "LICENSE",
77
+ "SECURITY.md",
78
+ "CHANGELOG.md",
79
+ "assets/",
80
+ "npm-shrinkwrap.json",
81
+ "scripts/panes",
82
+ "native/",
83
+ "docs/panes.md",
84
+ "docs/browser-workspace.md",
85
+ "docs/PACKAGING.md"
86
+ ],
87
+ "author": "Floyd's Labs",
88
+ "bin": {
89
+ "townmouse": "bin/townmouse"
90
+ }
91
+ }
Binary file
@@ -0,0 +1,5 @@
1
+ // OSC 52 carries UTF-8 bytes encoded as base64, not a JavaScript string.
2
+ export function decodeClipboardText(payload) {
3
+ const bytes = Uint8Array.from(atob(payload), (byte) => byte.charCodeAt(0));
4
+ return new TextDecoder('utf-8', { fatal: true }).decode(bytes);
5
+ }
Binary file
Binary file
Binary file