clavarium 0.2.236-next.1 → 0.2.237-beta.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.
- package/config/launch/claude-code.sh +40 -19
- package/config/launch/codex.sh +37 -0
- package/config/launch/json-set.mjs +5 -2
- package/config/launch/mcp-relay.mjs +98 -0
- package/config/launch/mcp-sock.sh +31 -0
- package/config/launch/screen-watch.mjs +173 -0
- package/config/launch/toml-block.mjs +26 -0
- package/config/launch/tools-host.mjs +93 -0
- package/config/launch/vibe.sh +40 -0
- package/config/machine/clavarium-beat +44 -0
- package/config/machine/clavarium-beat-one +40 -0
- package/config/machine/clavarium-enter +60 -0
- package/config/tools.json +170 -12
- package/deploy/clavarium-host +385 -31
- package/deploy/clavarium-tunnel +14 -3
- package/deploy/clavarium.mjs +4 -0
- package/deploy/git-read +57 -5
- package/deploy/install.sh +11 -5
- package/deploy/maintenance.html +5 -2
- package/deploy/online.mjs +251 -8
- package/deploy/relay.sh +53 -27
- package/deploy/tunnel.mjs +7 -5
- package/deploy/updater.mjs +168 -25
- package/npm-shrinkwrap.json +245 -19
- package/package.json +9 -6
- package/server/agenda.mjs +140 -0
- package/server/api.mjs +392 -28
- package/server/apikeys.mjs +1372 -0
- package/server/beat.mjs +189 -0
- package/server/binders.mjs +42 -0
- package/server/boxcollect.mjs +276 -0
- package/server/boxes.mjs +348 -29
- package/server/bridge.mjs +13 -4
- package/server/browsers.mjs +364 -0
- package/server/capacity.mjs +37 -10
- package/server/carry.mjs +143 -0
- package/server/catalog.mjs +48 -0
- package/server/contactview.mjs +122 -0
- package/server/conversations.mjs +1122 -46
- package/server/copywork.mjs +34 -0
- package/server/demandes.mjs +251 -0
- package/server/desktop.mjs +102 -0
- package/server/devices.mjs +1 -0
- package/server/dictation-engines.mjs +91 -0
- package/server/dockets.mjs +49 -6
- package/server/door.mjs +19 -5
- package/server/events.mjs +3 -0
- package/server/features.mjs +366 -0
- package/server/files.mjs +43 -1
- package/server/gitaccess.mjs +12 -3
- package/server/gitchecks.mjs +17 -3
- package/server/gitkeeper.mjs +45 -10
- package/server/gitpush.mjs +286 -71
- package/server/gitrunner.mjs +144 -10
- package/server/grants.mjs +47 -11
- package/server/guide.mjs +31 -10
- package/server/health.mjs +138 -12
- package/server/jobs.mjs +138 -0
- package/server/linkguard.mjs +191 -0
- package/server/machinelist.mjs +58 -0
- package/server/mailref.mjs +90 -0
- package/server/mailview.mjs +204 -0
- package/server/main.mjs +425 -47
- package/server/mcpoauth.mjs +338 -0
- package/server/mcpx.mjs +175 -0
- package/server/network.mjs +125 -13
- package/server/profile.mjs +129 -0
- package/server/relayjoin.mjs +67 -0
- package/server/resources.mjs +6 -0
- package/server/revive.mjs +70 -0
- package/server/rooms.mjs +462 -0
- package/server/secrets.mjs +25 -12
- package/server/serverlogs.mjs +30 -4
- package/server/settingswords.mjs +375 -0
- package/server/signinhelp.mjs +239 -0
- package/server/speech.mjs +40 -4
- package/server/spoken.mjs +60 -0
- package/server/sshconsole.mjs +99 -0
- package/server/sshmachine.mjs +76 -0
- package/server/store.mjs +15 -1
- package/server/suggest.mjs +66 -0
- package/server/talk.mjs +228 -55
- package/server/tethers.mjs +223 -13
- package/server/toolbox.mjs +30 -7
- package/server/tools.mjs +38 -6
- package/server/updates.mjs +7 -2
- package/server/vm.mjs +215 -46
- package/server/vmwatch.mjs +82 -23
- package/server/voice.mjs +183 -51
- package/server/wakelearn.mjs +214 -0
- package/server/wakeups.mjs +42 -2
- package/server/watchdog.mjs +102 -0
- package/web/app.js +5590 -1237
- package/web/desk.js +531 -0
- package/web/device.html +15 -2
- package/web/features.js +480 -0
- package/web/index.html +874 -490
- package/web/kit.js +1142 -0
- package/web/links.js +2 -2
- package/web/mail-view.js +386 -0
- package/web/manifest.webmanifest +4 -0
- package/web/style.css +1592 -268
- package/web/voice-core.js +48 -0
- package/web/voice.js +13 -5
package/web/voice-core.js
CHANGED
|
@@ -32,6 +32,31 @@ export function loudness(samples) {
|
|
|
32
32
|
return Number.isFinite(rms) ? rms : 0;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/* HOW LOUD, TO DRAW: the loudness of a block as a level from 0 to 1 that an eye reads as a voice reads to
|
|
36
|
+
an ear, in decibels: a quiet room (-60 dB and below) is 0, a near shout (-12 dB) is 1. */
|
|
37
|
+
export const LEVEL_QUIET_DB = -60;
|
|
38
|
+
export const LEVEL_LOUD_DB = -12;
|
|
39
|
+
export function levelOf(rms) {
|
|
40
|
+
if (typeof rms !== 'number' || !Number.isFinite(rms) || rms <= 0) return 0;
|
|
41
|
+
const db = 20 * Math.log10(rms);
|
|
42
|
+
return Math.round(Math.min(1, Math.max(0, (db - LEVEL_QUIET_DB) / (LEVEL_LOUD_DB - LEVEL_QUIET_DB))) * 100) / 100;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* The same level as the heights of a few thin bars (a share of their full height), as Parley draws it: the
|
|
46
|
+
newest level in the middle, the ones before towards the sides, lower there; a dot when quiet. */
|
|
47
|
+
export const LEVEL_BARS = 5;
|
|
48
|
+
export const LEVEL_DOT = 0.2;
|
|
49
|
+
export function levelBars(recent, n = LEVEL_BARS) {
|
|
50
|
+
const levels = (Array.isArray(recent) ? recent : [recent]).map((v) => (Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : 0));
|
|
51
|
+
const middle = (n - 1) / 2;
|
|
52
|
+
return Array.from({ length: n }, (_, i) => {
|
|
53
|
+
const away = Math.abs(i - middle);
|
|
54
|
+
const level = levels[Math.round(away)] ?? levels.at(-1) ?? 0;
|
|
55
|
+
const shape = middle > 0 ? 1 - 0.4 * (away / middle) : 1;
|
|
56
|
+
return Math.round((LEVEL_DOT + (1 - LEVEL_DOT) * level * shape) * 100) / 100;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
35
60
|
/* THE THRESHOLD FOLLOWS THE ROOM. An absolute threshold measures the world;
|
|
36
61
|
what matters is what rises above the noise HERE. The floor is a low
|
|
37
62
|
quantile of the last thirty seconds; speech is three times the floor. */
|
|
@@ -119,3 +144,26 @@ export function toWav(blocks, rate = RATE) {
|
|
|
119
144
|
}
|
|
120
145
|
return new Uint8Array(bytes);
|
|
121
146
|
}
|
|
147
|
+
|
|
148
|
+
/* PHRASES IN THE ORDER THEY WERE SPOKEN: each is transcribed on its own, and a short one comes back before a
|
|
149
|
+
long one said before it. `order()` takes a place when a phrase ends; that place is later given what to do
|
|
150
|
+
with its result (or nothing: failed, empty), and runs only once every place before it was given its own. */
|
|
151
|
+
export function inOrder() {
|
|
152
|
+
let taken = 0;
|
|
153
|
+
let next = 0;
|
|
154
|
+
const held = new Map();
|
|
155
|
+
return () => {
|
|
156
|
+
const place = taken++;
|
|
157
|
+
let given = false;
|
|
158
|
+
return (run) => {
|
|
159
|
+
if (given) return;
|
|
160
|
+
given = true;
|
|
161
|
+
held.set(place, run);
|
|
162
|
+
while (held.has(next)) {
|
|
163
|
+
const done = held.get(next);
|
|
164
|
+
held.delete(next); next++;
|
|
165
|
+
try { done?.(); } catch { /* one that throws never holds the rest */ }
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
}
|
package/web/voice.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* DICTATION IN THE PAGE: the microphone stays open, each spoken phrase is
|
|
2
2
|
transcribed and handed to whoever listens. The page types it into the
|
|
3
3
|
terminal. See voice-core.js for how a phrase is found. */
|
|
4
|
-
import { RATE, BLOCK, BLOCK_MS, Detector, Segmenter, loudness, toWav } from './voice-core.js';
|
|
4
|
+
import { RATE, BLOCK, BLOCK_MS, Detector, Segmenter, loudness, levelOf, levelBars, toWav, inOrder } from './voice-core.js';
|
|
5
5
|
|
|
6
6
|
/* The operator's pages ask /api; a paired device asks /c/api/<its pairing>,
|
|
7
7
|
known once it has signed in (the page writes it on the document). */
|
|
@@ -16,7 +16,9 @@ const withLanguage = (to) => {
|
|
|
16
16
|
|
|
17
17
|
/* Opens the microphone; resolves with a function that closes it.
|
|
18
18
|
`on.phrase(text)`, `on.state(word)`: calibrating, listening, hearing,
|
|
19
|
-
transcribing; `on.error(message)
|
|
19
|
+
transcribing; `on.error(message)`; `on.level(n)`, if given: how loud the
|
|
20
|
+
microphone is, 0 to 1, each block (about 30 times a second), measured on
|
|
21
|
+
the same stream (no second microphone) for a few bars to follow. `to`: where phrases go, if not the
|
|
20
22
|
usual engine (Settings' "Try it" sends them to the one in its form). */
|
|
21
23
|
async function listen(on, { to } = {}) {
|
|
22
24
|
const stream = await navigator.mediaDevices.getUserMedia({ audio: { echoCancellation: true, noiseSuppression: false, autoGainControl: false } });
|
|
@@ -26,17 +28,19 @@ async function listen(on, { to } = {}) {
|
|
|
26
28
|
const detector = new Detector();
|
|
27
29
|
let pending = 0;
|
|
28
30
|
let closed = false;
|
|
31
|
+
const order = inOrder();
|
|
29
32
|
const tell = () => { if (!closed) on.state(pending > 0 ? 'transcribing' : segmenter.speaking ? 'hearing' : detector.ready() ? 'listening' : 'calibrating'); };
|
|
30
33
|
const segmenter = new Segmenter({
|
|
31
34
|
onStart: () => { on.speech?.(); tell(); },
|
|
32
35
|
onPhrase: async (blocks) => {
|
|
33
36
|
pending++; tell();
|
|
37
|
+
const place = order();
|
|
34
38
|
try {
|
|
35
39
|
const r = await fetch(withLanguage(to ?? `${api()}/voice`), { method: 'POST', headers: { 'content-type': 'audio/wav' }, body: toWav(blocks) });
|
|
36
40
|
const j = await r.json().catch(() => ({}));
|
|
37
41
|
if (!r.ok) throw new Error(j.error || 'The phrase could not be transcribed.');
|
|
38
|
-
if (!closed
|
|
39
|
-
} catch (error) { if (!closed) on.error(error.message); }
|
|
42
|
+
place(j.text ? () => { if (!closed) on.phrase(j.text); } : null);
|
|
43
|
+
} catch (error) { place(null); if (!closed) on.error(error.message); }
|
|
40
44
|
pending--; tell();
|
|
41
45
|
},
|
|
42
46
|
});
|
|
@@ -44,7 +48,9 @@ async function listen(on, { to } = {}) {
|
|
|
44
48
|
node.onaudioprocess = (event) => {
|
|
45
49
|
const samples = Float32Array.from(event.inputBuffer.getChannelData(0));
|
|
46
50
|
const was = segmenter.speaking;
|
|
47
|
-
|
|
51
|
+
const rms = loudness(samples);
|
|
52
|
+
segmenter.feed(detector.hear(rms), count++ * BLOCK_MS, samples);
|
|
53
|
+
if (!closed) { try { on.level?.(levelOf(rms)); } catch { /* a drawing never stops the dictation */ } }
|
|
48
54
|
if (was !== segmenter.speaking || count === 33) tell();
|
|
49
55
|
};
|
|
50
56
|
source.connect(node); node.connect(context.destination);
|
|
@@ -60,5 +66,7 @@ async function listen(on, { to } = {}) {
|
|
|
60
66
|
window.clavariumVoice = {
|
|
61
67
|
available: async () => { try { const r = await fetch(`${api()}/voice`); return r.ok && (await r.json()).available === true; } catch { return false; } },
|
|
62
68
|
listen,
|
|
69
|
+
/* The heights of the bars that show how loud it is (Settings' "Try it" draws them). */
|
|
70
|
+
levelBars,
|
|
63
71
|
};
|
|
64
72
|
window.dispatchEvent(new Event('clavarium-voice-ready'));
|