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.
- package/CHANGELOG.md +196 -0
- package/DESIGN.md +153 -0
- package/LICENSE +661 -0
- package/README.md +600 -2
- package/SECURITY.md +60 -0
- package/TOWNMOUSE.md +91 -0
- package/assets/brand/mascot/README.md +23 -0
- package/assets/brand/mascot/townmouse-aristocrat.png +0 -0
- package/assets/brand/mascot/townmouse-icon.svg +1 -0
- package/assets/brand/mascot/townmouse-monocled.png +0 -0
- package/bin/townmouse +68 -0
- package/docs/PACKAGING.md +371 -0
- package/docs/browser-workspace.md +237 -0
- package/docs/panes.md +442 -0
- package/native/TownmouseApp.swift +108 -0
- package/npm-shrinkwrap.json +1282 -0
- package/package.json +93 -4
- package/public/apple-touch-icon.png +0 -0
- package/public/brand/floydslabs-credit.png +0 -0
- package/public/brand/floydslabs-credit.webp +0 -0
- package/public/brand/townmouse-aristocrat.webp +0 -0
- package/public/brand/townmouse-monocled.webp +0 -0
- package/public/browser-picture.mjs +159 -0
- package/public/clipboard-text.mjs +5 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +1 -0
- package/public/features/app-version.mjs +35 -0
- package/public/features/autosave.mjs +80 -0
- package/public/features/clipboard.mjs +69 -0
- package/public/features/command-palette.mjs +181 -0
- package/public/features/desktop-palette.mjs +19 -0
- package/public/features/export.mjs +37 -0
- package/public/features/file-drop.mjs +77 -0
- package/public/features/floating-palette.mjs +113 -0
- package/public/features/fontsize.mjs +72 -0
- package/public/features/haptic-keys.mjs +42 -0
- package/public/features/history-undo.mjs +102 -0
- package/public/features/keepalive.mjs +36 -0
- package/public/features/keybar-config.mjs +70 -0
- package/public/features/keyboard-shortcuts.mjs +74 -0
- package/public/features/links.mjs +139 -0
- package/public/features/multi-window-sync.mjs +76 -0
- package/public/features/osc-bridge.mjs +64 -0
- package/public/features/phone-landscape-focus.mjs +157 -0
- package/public/features/recent-commands.mjs +100 -0
- package/public/features/search.mjs +134 -0
- package/public/features/session-lock.mjs +96 -0
- package/public/features/session-manager.mjs +251 -0
- package/public/features/settings-sync.mjs +77 -0
- package/public/features/shortcut-help.mjs +85 -0
- package/public/features/smart-completions.mjs +101 -0
- package/public/features/smart-suggest.mjs +124 -0
- package/public/features/snippets.mjs +85 -0
- package/public/features/split-view.mjs +102 -0
- package/public/features/status-metrics.mjs +137 -0
- package/public/features/stylus-support.mjs +124 -0
- package/public/features/swipe-history.mjs +141 -0
- package/public/features/swipe-sessions.mjs +85 -0
- package/public/features/tab-reorder.mjs +70 -0
- package/public/features/theme-system.mjs +51 -0
- package/public/features/toast-status.mjs +118 -0
- package/public/features/two-finger-menu.mjs +87 -0
- package/public/features/voice-input.mjs +244 -0
- package/public/features/wake-fullscreen.mjs +67 -0
- package/public/features/window-title.mjs +47 -0
- package/public/features/zoom.mjs +80 -0
- package/public/icon-128.png +0 -0
- package/public/icon-180.png +0 -0
- package/public/icon-192.png +0 -0
- package/public/icon-48.png +0 -0
- package/public/icon-512-maskable.png +0 -0
- package/public/icon-512.png +0 -0
- package/public/icon.svg +1 -0
- package/public/index.html +2304 -0
- package/public/input-chunks.mjs +22 -0
- package/public/input-guard.mjs +218 -0
- package/public/manifest.json +56 -0
- package/public/panes.css +1433 -0
- package/public/panes.html +211 -0
- package/public/panes.mjs +3183 -0
- package/public/service-worker.js +67 -0
- package/public/workspace.css +1621 -0
- package/public/workspace.mjs +1715 -0
- package/scripts/install-service.sh +303 -0
- package/scripts/node-runtime.sh +138 -0
- package/scripts/panes +568 -0
- package/scripts/prepare-native.sh +35 -0
- package/scripts/retire-legacy-service.sh +76 -0
- package/scripts/run-hooks +69 -0
- package/scripts/townmouse.sh +152 -0
- package/scripts/uninstall-service.sh +65 -0
- package/src/agent-guide.js +329 -0
- package/src/attachments.js +128 -0
- package/src/browser-dom.js +548 -0
- package/src/browser-workspace.js +1733 -0
- package/src/chrome-resolve.js +80 -0
- package/src/owner-page.js +43 -0
- package/src/pty-permissions.js +99 -0
- package/src/regex-worker.js +13 -0
- package/src/replay-text.js +189 -0
- package/src/request-boundary.js +58 -0
- package/src/safe-regex.js +87 -0
- package/src/server.js +1582 -0
- package/src/shell-resolve.js +42 -0
- package/src/static-deps.js +61 -0
- package/src/workspace-panes.js +1431 -0
package/package.json
CHANGED
|
@@ -1,6 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "townmouse",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0",
|
|
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 && bash tests/townmouse-docs.test.sh && bash tests/townmouse-launch.test.sh && bash tests/install-service-portability.test.sh && bash tests/townmouse-app-build.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 tests/check-version.test.mjs && 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 && scripts/node-runtime.sh exec tests/pane-stability.test.cjs && scripts/node-runtime.sh exec tests/browser-picture-rate.test.cjs && scripts/node-runtime.sh exec tests/resume-replay.test.cjs && scripts/node-runtime.sh exec tests/terminal-fit.test.cjs && npm run test:sessions",
|
|
41
|
+
"test:sessions": "scripts/node-runtime.sh exec tests/session-row.test.cjs",
|
|
42
|
+
"postinstall": "sh scripts/prepare-native.sh",
|
|
43
|
+
"test:security": "node --test tests/request-boundary.test.js tests/request-boundary-integration.test.js",
|
|
44
|
+
"test:panes": "node tests/panes-api.test.cjs && node tests/panes-persistence.test.cjs && node tests/pane-access.test.cjs && node tests/pane-access-ui.test.cjs && node tests/password-results.test.cjs && node tests/owner-key.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",
|
|
45
|
+
"test:agent-control": "scripts/node-runtime.sh exec tests/agent-control.test.cjs",
|
|
46
|
+
"test:voice-routing": "node tests/voice-routing.test.cjs",
|
|
47
|
+
"test:maximize": "node tests/panes-maximize.test.cjs",
|
|
48
|
+
"test:package": "scripts/node-runtime.sh exec tests/package-install.test.cjs",
|
|
49
|
+
"version:check": "node scripts/check-version.mjs",
|
|
50
|
+
"version:bump": "node scripts/check-version.mjs --bump"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@xterm/addon-fit": "^0.11.0",
|
|
54
|
+
"@xterm/addon-search": "^0.16.0",
|
|
55
|
+
"@xterm/addon-web-links": "^0.12.0",
|
|
56
|
+
"@xterm/xterm": "^6.0.0",
|
|
57
|
+
"express": "^5.2.1",
|
|
58
|
+
"node-pty": "^1.1.0",
|
|
59
|
+
"puppeteer": "^25.17.0",
|
|
60
|
+
"uuid": "^14.0.1",
|
|
61
|
+
"ws": "^8.21.1"
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=22 <27"
|
|
65
|
+
},
|
|
66
|
+
"files": [
|
|
67
|
+
"bin/",
|
|
68
|
+
"src/",
|
|
69
|
+
"public/",
|
|
70
|
+
"scripts/node-runtime.sh",
|
|
71
|
+
"scripts/prepare-native.sh",
|
|
72
|
+
"scripts/install-service.sh",
|
|
73
|
+
"scripts/uninstall-service.sh",
|
|
74
|
+
"scripts/retire-legacy-service.sh",
|
|
75
|
+
"scripts/townmouse.sh",
|
|
76
|
+
"scripts/run-hooks",
|
|
77
|
+
"README.md",
|
|
78
|
+
"TOWNMOUSE.md",
|
|
79
|
+
"DESIGN.md",
|
|
80
|
+
"LICENSE",
|
|
81
|
+
"SECURITY.md",
|
|
82
|
+
"CHANGELOG.md",
|
|
83
|
+
"assets/",
|
|
84
|
+
"npm-shrinkwrap.json",
|
|
85
|
+
"scripts/panes",
|
|
86
|
+
"native/",
|
|
87
|
+
"docs/panes.md",
|
|
88
|
+
"docs/browser-workspace.md",
|
|
89
|
+
"docs/PACKAGING.md"
|
|
90
|
+
],
|
|
91
|
+
"author": "Floyd's Labs",
|
|
92
|
+
"bin": {
|
|
93
|
+
"townmouse": "bin/townmouse"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Pictures of a browser page for a person who is looking at it. Both screens
|
|
3
|
+
* use this (a pane's picture on the pane surface, the Browser view on the
|
|
4
|
+
* terminal surface), so the rules live in one place.
|
|
5
|
+
*
|
|
6
|
+
* - A view is "viewed" when a person can see it: the browser tab is showing
|
|
7
|
+
* (not hidden, not minimized) and the view has some area inside the window.
|
|
8
|
+
* - While a view is viewed, one request waits on the server for the next
|
|
9
|
+
* picture, up to `waitMs`. A change is shown as it happens; a still page
|
|
10
|
+
* costs one small request per wait and sends no picture at all.
|
|
11
|
+
* - While a view is not viewed, nothing is asked for, unless `idleMs` is set:
|
|
12
|
+
* then one request per interval keeps its title, address and page prompt
|
|
13
|
+
* current, and the server takes no picture for it.
|
|
14
|
+
* - At most one request is in flight for a view. Becoming viewed asks at once.
|
|
15
|
+
* - A request the server could not hold (all of its waiting slots were taken)
|
|
16
|
+
* is asked again after `retryMs`; a failed one after `failMs`.
|
|
17
|
+
* - `ready`, when given, says whether there is a page to ask about at all.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export function createViewedWatch(element, onChange) {
|
|
21
|
+
let intersecting = false;
|
|
22
|
+
let notified = false;
|
|
23
|
+
const viewed = () => Boolean(element) && !document.hidden && intersecting;
|
|
24
|
+
const notify = () => {
|
|
25
|
+
const now = viewed();
|
|
26
|
+
if (now === notified) return;
|
|
27
|
+
notified = now;
|
|
28
|
+
onChange(now);
|
|
29
|
+
};
|
|
30
|
+
let observer = null;
|
|
31
|
+
if (element && typeof IntersectionObserver === 'function') {
|
|
32
|
+
observer = new IntersectionObserver((entries) => {
|
|
33
|
+
for (const entry of entries) {
|
|
34
|
+
// Edge to edge with the window is not "some area inside it".
|
|
35
|
+
const box = entry.intersectionRect;
|
|
36
|
+
intersecting = entry.isIntersecting && box.width > 0 && box.height > 0;
|
|
37
|
+
}
|
|
38
|
+
notify();
|
|
39
|
+
});
|
|
40
|
+
observer.observe(element);
|
|
41
|
+
} else {
|
|
42
|
+
// Without the observer nothing better is known: assume the person can see it.
|
|
43
|
+
intersecting = Boolean(element);
|
|
44
|
+
}
|
|
45
|
+
document.addEventListener('visibilitychange', notify);
|
|
46
|
+
notify();
|
|
47
|
+
return {
|
|
48
|
+
viewed,
|
|
49
|
+
stop() {
|
|
50
|
+
if (observer) observer.disconnect();
|
|
51
|
+
document.removeEventListener('visibilitychange', notify);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function createPictureLoop({ request, apply, failure, viewed, ready = null, waitMs = 500, retryMs = 60, failMs = 1000, idleMs = null }) {
|
|
57
|
+
let busy = false;
|
|
58
|
+
let wanted = false;
|
|
59
|
+
let held = false;
|
|
60
|
+
let failed = false;
|
|
61
|
+
let nextWait = waitMs;
|
|
62
|
+
let timer = 0;
|
|
63
|
+
let controller = null;
|
|
64
|
+
let seq = 0;
|
|
65
|
+
let source = '';
|
|
66
|
+
let stopped = false;
|
|
67
|
+
let started = 0;
|
|
68
|
+
let ended = 0;
|
|
69
|
+
const finished = [];
|
|
70
|
+
|
|
71
|
+
function ask(delay = 0, wait = waitMs) {
|
|
72
|
+
if (stopped) return;
|
|
73
|
+
// Nothing to ask about (no page is open in the view, say): wait until asked again.
|
|
74
|
+
if (ready && !ready()) return;
|
|
75
|
+
nextWait = wait;
|
|
76
|
+
if (busy) {
|
|
77
|
+
wanted = true;
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// A viewed view is never made to wait to be asked: the request itself
|
|
81
|
+
// waits for the picture. Only the two back-offs are kept as they are.
|
|
82
|
+
const until = viewed() && !failed ? Math.min(delay, retryMs) : delay;
|
|
83
|
+
failed = false;
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
timer = setTimeout(() => { timer = 0; void poll(); }, Math.max(0, until));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async function poll() {
|
|
89
|
+
if (stopped || busy) return;
|
|
90
|
+
if (ready && !ready()) return;
|
|
91
|
+
started += 1;
|
|
92
|
+
busy = true;
|
|
93
|
+
wanted = false;
|
|
94
|
+
controller = new AbortController();
|
|
95
|
+
const watching = viewed();
|
|
96
|
+
let next = idleMs;
|
|
97
|
+
try {
|
|
98
|
+
const snapshot = await request({ watching, since: seq, waitMs: nextWait, signal: controller.signal });
|
|
99
|
+
if (!snapshot) throw new Error('No answer from the browser.');
|
|
100
|
+
if (stopped) return;
|
|
101
|
+
const fresh = Boolean(snapshot.image) && (snapshot.id !== source || snapshot.seq !== seq);
|
|
102
|
+
if (fresh) {
|
|
103
|
+
source = snapshot.id || source;
|
|
104
|
+
seq = Number(snapshot.seq) || 0;
|
|
105
|
+
}
|
|
106
|
+
held = snapshot.held !== false;
|
|
107
|
+
apply(snapshot, fresh);
|
|
108
|
+
// A server from before this change answers without `seq` and takes a
|
|
109
|
+
// picture for every ask: with one, keep to the old pace of about a second.
|
|
110
|
+
next = watching ? ('seq' in snapshot ? (held ? 0 : retryMs) : failMs) : idleMs;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (stopped || controller.signal.aborted) return;
|
|
113
|
+
failed = true;
|
|
114
|
+
failure(error);
|
|
115
|
+
next = watching ? failMs : idleMs;
|
|
116
|
+
} finally {
|
|
117
|
+
controller = null;
|
|
118
|
+
busy = false;
|
|
119
|
+
ended += 1;
|
|
120
|
+
// `null`: not viewed means nothing is asked until the view is viewed again.
|
|
121
|
+
if (next !== null) ask(wanted ? 0 : next, waitMs);
|
|
122
|
+
else if (wanted && viewed()) ask(0, waitMs);
|
|
123
|
+
for (const done of finished.splice(0)) done();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const settle = () => new Promise((resolve) => {
|
|
128
|
+
if (!busy && !timer) resolve();
|
|
129
|
+
else finished.push(resolve);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
ask,
|
|
134
|
+
// Ask now and do not return before that request has been answered. Used
|
|
135
|
+
// when the person has just acted on the page, or the view was just shown.
|
|
136
|
+
async refresh(wait = waitMs) {
|
|
137
|
+
if (stopped) return;
|
|
138
|
+
if (busy) controller.abort(); // A request already waiting is superseded.
|
|
139
|
+
await settle();
|
|
140
|
+
ask(0, wait);
|
|
141
|
+
await settle();
|
|
142
|
+
},
|
|
143
|
+
// The view can no longer be seen. A request that is waiting is let go at
|
|
144
|
+
// once, so it does not hold one of the browser's few connections.
|
|
145
|
+
unseen() {
|
|
146
|
+
clearTimeout(timer);
|
|
147
|
+
timer = 0;
|
|
148
|
+
if (busy) controller.abort();
|
|
149
|
+
else if (idleMs !== null) ask(idleMs);
|
|
150
|
+
},
|
|
151
|
+
stop() {
|
|
152
|
+
stopped = true;
|
|
153
|
+
clearTimeout(timer);
|
|
154
|
+
timer = 0;
|
|
155
|
+
if (controller) controller.abort();
|
|
156
|
+
},
|
|
157
|
+
since: () => seq
|
|
158
|
+
};
|
|
159
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|