clavarium 0.2.293-next.1 → 0.2.296-next.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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/boxes.mjs +24 -1
- package/web/app.js +32 -11
- package/web/style.css +17 -3
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.296-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.296-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/boxes.mjs
CHANGED
|
@@ -27,6 +27,11 @@ export const LINK_PATH = '/c/api/box/ws';
|
|
|
27
27
|
/* A firmware a box downloads to update itself: a one-use address, kept a few minutes. */
|
|
28
28
|
export const FIRMWARE_PATH = '/c/api/box/firmware/';
|
|
29
29
|
export const FIRMWARE_MINUTES = 10;
|
|
30
|
+
/* THE WAKE WORD HEARD AGAIN (03-11): « Mésange » and what a dictation makes of it (mes anges, mais sange...). */
|
|
31
|
+
export const CLIP_MAX_BYTES = 16_000 * 2 * 3;
|
|
32
|
+
export const WAKE_HEARD = /\bm[ae]i?s+\s?an?ge?s?\b|\bmes anges?\b|\bmesange|\bmaisange|\bmessage?s?\b/;
|
|
33
|
+
export const WAKE_DROP = process.env.CLAVARIUM_WAKE_DROP === '1';
|
|
34
|
+
const plainWords = (t) => String(t).toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z\s]/g, ' ').replace(/\s+/g, ' ').trim();
|
|
30
35
|
export const SENTENCE_MAX = 300 * 32_000 + 32_000; /* 5 min of 16 kHz 16-bit mono, and some slack */
|
|
31
36
|
export const TRIES_PER_MINUTE = 10;
|
|
32
37
|
export const NAME_MAX = 40;
|
|
@@ -620,6 +625,8 @@ export class Boxes {
|
|
|
620
625
|
r.out.write(data); r.bytes += data.length;
|
|
621
626
|
return;
|
|
622
627
|
}
|
|
628
|
+
/* The wake word's own 1.6 s (wake.clip): kept apart, heard again before the word is trusted. */
|
|
629
|
+
if (link.clip) { if (link.clip.bytes < CLIP_MAX_BYTES) { link.clip.parts.push(Buffer.from(data)); link.clip.bytes += data.length; } return; }
|
|
623
630
|
if (!sentence || link.muted) return;
|
|
624
631
|
size += data.length;
|
|
625
632
|
if (size <= SENTENCE_MAX) sentence.push(Buffer.from(data));
|
|
@@ -650,6 +657,8 @@ export class Boxes {
|
|
|
650
657
|
r.out.end(() => { void this.#recorded(link, r); });
|
|
651
658
|
return;
|
|
652
659
|
}
|
|
660
|
+
if (m.t === 'wake.clip' && m.edge === 'start') { link.clip = { parts: [], bytes: 0 }; return; }
|
|
661
|
+
if (m.t === 'wake.clip' && m.edge === 'end' && link.clip) { const pcm = Buffer.concat(link.clip.parts); link.clip = null; link.wakeCheck = this.#checkWake(link, pcm); return; }
|
|
653
662
|
if (m.t === 'event' && m.name === 'wake.own') { this.#log(`voice box ${box.name}: heard its own voice say the wake word, ignored`); return; }
|
|
654
663
|
if (m.t === 'event' && m.name === 'noise.dropped') { this.#log(`voice box ${box.name}: a sound near full scale was cut by its noise guard`); return; }
|
|
655
664
|
/* The box listens for a sentence while this side still records: the two disagree (a reconnection, a
|
|
@@ -659,7 +668,7 @@ export class Boxes {
|
|
|
659
668
|
this.#log(`voice box ${box.name}: a sentence while recording here, the recording closed`);
|
|
660
669
|
r.out.end(() => { void this.#recorded(link, r); });
|
|
661
670
|
}
|
|
662
|
-
if (m.t === 'listen.start') link.why = whyOf(m);
|
|
671
|
+
if (m.t === 'listen.start') { link.why = whyOf(m); if (m.reason !== 'wake') link.wakeCheck = null; }
|
|
663
672
|
if (m.t === 'listen.start') { if (this.stop(box.id)) this.#log(`voice box ${box.name}: stopped playing, someone speaks`); sentence = []; size = 0; return; }
|
|
664
673
|
if (m.t === 'listen.end' && sentence && m.reason === 'nobody') {
|
|
665
674
|
/* Listened again, nobody spoke: a conversation ends there, in silence. */
|
|
@@ -732,6 +741,12 @@ export class Boxes {
|
|
|
732
741
|
}
|
|
733
742
|
|
|
734
743
|
/* Each step said in the server's log, never what was said: its length only. */
|
|
744
|
+
/* The 1.6 s before the sentence, heard again: is the wake word in it? Its words, and whether it reads as the word. */
|
|
745
|
+
async #checkWake(link, pcm) {
|
|
746
|
+
if (pcm.length < 8_000) return null;
|
|
747
|
+
const heard = String(await this.#hear(wavOf(pcm), link.box().lang) ?? '').trim();
|
|
748
|
+
return { heard, ok: WAKE_HEARD.test(plainWords(heard)) };
|
|
749
|
+
}
|
|
735
750
|
async #heard(link, pcm) {
|
|
736
751
|
const box0 = link.box();
|
|
737
752
|
const seconds = (pcm.length / 32_000).toFixed(1);
|
|
@@ -773,6 +788,14 @@ export class Boxes {
|
|
|
773
788
|
}
|
|
774
789
|
if (!text) { this.#log(`voice box ${box0.name}: ${seconds} s heard, nothing recognised (${soundOf(pcm)})`); await lost("Pardon, je n'ai rien compris. Tu peux répéter ?"); return; }
|
|
775
790
|
const box = link.box();
|
|
791
|
+
/* The wake word heard again (wake.clip): said beside the message; dropped in silence only once that is
|
|
792
|
+
turned on (WAKE_DROP), after its results were looked at -- a real call must never be lost to it. */
|
|
793
|
+
const check = link.wakeCheck ? await link.wakeCheck.catch(() => null) : null; link.wakeCheck = null;
|
|
794
|
+
if (check) {
|
|
795
|
+
link.why = `${link.why ? `${link.why} · ` : ''}mot ${check.ok ? '\u2713' : '\u2717'} « ${check.heard.slice(0, 30)} »`;
|
|
796
|
+
this.#log(`voice box ${box.name}: wake word heard again: ${check.ok ? 'yes' : 'NO'} (« ${check.heard.slice(0, 40)} »)`);
|
|
797
|
+
if (!check.ok && WAKE_DROP) { link.send({ t: 'cue', name: 'done' }); return; }
|
|
798
|
+
}
|
|
776
799
|
/* Only a short order starts a recording ("lance l'enregistrement de la réunion"): a sentence that merely
|
|
777
800
|
mentions recording does not (01-11). */
|
|
778
801
|
if (RECORD_BY_VOICE && RECORD_ASKED.test(text) && text.split(/\s+/).length <= 10 && this.#recordDir && this.#parts) {
|
package/web/app.js
CHANGED
|
@@ -406,13 +406,26 @@
|
|
|
406
406
|
/* ---------- the list of conversations, folded away or not ---------- */
|
|
407
407
|
/* One click hides it and the terminal takes the room; one click brings
|
|
408
408
|
it back. Kept on this device. */
|
|
409
|
-
/*
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
409
|
+
/* THE TOP BAR, ONE COMPONENT (03-11): every page has the conversation's bar -- the button that shows or hides the
|
|
410
|
+
list on its left, a state's dot when there is one, its title, and on its right what that page offers (a
|
|
411
|
+
conversation: Chat, Terminal, Assets, Binders, its settings; a room: its settings; the others: their own
|
|
412
|
+
controls). Built once here from each page's top line: the same element, the same looks, the same place. */
|
|
413
|
+
function topBar(top, { state = null } = {}) {
|
|
414
|
+
const bar = document.createElement('header'); bar.className = 'topbar';
|
|
415
|
+
const fold = document.createElement('button'); fold.type = 'button'; fold.className = 'fold-here'; fold.title = 'Hide or show the list of conversations';
|
|
416
|
+
fold.addEventListener('click', () => $('fold').click());
|
|
417
|
+
bar.append(fold);
|
|
418
|
+
if (state) { const dot = document.createElement('span'); dot.className = 'bar-state'; dot.id = state; dot.setAttribute('aria-hidden', 'true'); bar.append(dot); }
|
|
419
|
+
const title = top.querySelector(':scope > b'); if (title) bar.append(title);
|
|
420
|
+
const right = document.createElement('div'); right.className = 'bar-right';
|
|
421
|
+
right.append(...[...top.childNodes].filter((n) => n.nodeType === 1));
|
|
422
|
+
bar.append(right);
|
|
423
|
+
top.replaceWith(bar);
|
|
424
|
+
return bar;
|
|
425
|
+
}
|
|
426
|
+
for (const top of [...document.querySelectorAll('#places .sheet > .panel-top')]) topBar(top, top.parentElement.id === 'salon' ? { state: 'salon-state' } : {});
|
|
427
|
+
/* A room's settings: on its bar's right, in the same group of views a conversation's settings sit in. */
|
|
428
|
+
{ const views = document.createElement('div'); views.className = 'views'; views.setAttribute('role', 'group'); views.setAttribute('aria-label', 'Room'); views.append($('salon-settings')); $('salon').querySelector('.topbar .bar-right').prepend(views); }
|
|
416
429
|
const applyFold = (folded) => {
|
|
417
430
|
app.dataset.list = folded ? 'folded' : 'open';
|
|
418
431
|
for (const f of [$('fold'), ...document.querySelectorAll('.fold-here')]) {
|
|
@@ -1245,11 +1258,19 @@
|
|
|
1245
1258
|
const roomsNow = () => { try { return Array.isArray(rooms) ? rooms : []; } catch { return []; } };
|
|
1246
1259
|
const roomOpenNow = () => { try { return place === 'salon' ? salonId : ''; } catch { return ''; } };
|
|
1247
1260
|
function roomItem(r) {
|
|
1261
|
+
/* The same row as a conversation's (03-11: « de même nature ») -- its name, when, its last words on one line,
|
|
1262
|
+
its state's dot -- told apart by a small room sign before its name. */
|
|
1248
1263
|
const b = document.createElement('button'); b.type = 'button'; b.className = 'item room-item'; b.dataset.room = r.id;
|
|
1249
|
-
const
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
|
|
1264
|
+
const title = document.createElement('b');
|
|
1265
|
+
const sign = document.createElement('span'); sign.className = 'room-sign'; sign.setAttribute('aria-hidden', 'true');
|
|
1266
|
+
title.append(sign, r.name);
|
|
1267
|
+
b.append(title);
|
|
1268
|
+
if (r.last) {
|
|
1269
|
+
const last = document.createElement('small'); last.className = 'last'; last.textContent = `${r.last.by ? `${r.last.by}: ` : ''}${r.last.text}`; b.append(last);
|
|
1270
|
+
const when = document.createElement('small'); when.className = 'when'; when.textContent = whenWords(Date.parse(r.last.at)); b.append(when); b.dataset.when = 'true';
|
|
1271
|
+
} else { const sub = document.createElement('small'); sub.textContent = `Room \u00b7 ${r.members.filter((m) => m.kind === 'ai').length} AIs`; b.append(sub); }
|
|
1272
|
+
/* Its dot: new words in it waiting (the colour of what waits for you), else ready. */
|
|
1273
|
+
const point = statePoint(r.unread > 0 ? 'wait' : 'ready'); point.title = r.unread > 0 ? `${r.unread} new` : 'Room'; b.append(point);
|
|
1253
1274
|
if (r.id === roomOpenNow()) b.setAttribute('aria-current', 'true');
|
|
1254
1275
|
b.addEventListener('click', () => { void openSalon(r.id); });
|
|
1255
1276
|
return b;
|
package/web/style.css
CHANGED
|
@@ -2278,6 +2278,20 @@ button.salon-switch[aria-checked="true"]::after { left: 18px; background: var(--
|
|
|
2278
2278
|
.nc-card > .salon-members-tools { padding-bottom: 4px; }
|
|
2279
2279
|
.nc-card > .salon-host-box + *, .nc-card > .salon-member-list + * { border-top: 0; }
|
|
2280
2280
|
/* The list's button on each page of its own (03-11), as the conversation's. */
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
.
|
|
2281
|
+
/* THE TOP BAR of every page (03-11): the conversation's header, the same element and looks (header {...} above). */
|
|
2282
|
+
header.topbar { flex-shrink: 0; }
|
|
2283
|
+
header.topbar > .fold-here { font-size: 1rem; line-height: 1; padding: 4px 9px; flex: none; }
|
|
2284
|
+
@media (max-width: 700px) { header.topbar > .fold-here { display: none; } }
|
|
2285
|
+
header.topbar > b { flex: 1 1 auto; font-size: 1rem; }
|
|
2286
|
+
header.topbar > .bar-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
|
|
2287
|
+
header.topbar .bar-state { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
|
|
2288
|
+
header.topbar .views .icon-btn { width: auto; height: auto; }
|
|
2289
|
+
/* Pages with margins of their own: their bar goes edge to edge, as a conversation's. */
|
|
2290
|
+
#places .sheet:not(.as-place) > header.topbar { margin: -14px -14px 4px; }
|
|
2291
|
+
#newconv > header.topbar { margin: -14px -20px 4px; }
|
|
2292
|
+
#salon-new > header.topbar { margin: -14px -20px 4px; }
|
|
2293
|
+
@media (max-width: 700px) { #newconv > header.topbar { margin: -12px -16px 4px; } }
|
|
2294
|
+
/* A room's row in the list (03-11): a conversation's row, with a small sign of a room before its name (Lucide « users »). */
|
|
2295
|
+
.room-sign { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: -2px; background: var(--ink2);
|
|
2296
|
+
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E") center / contain no-repeat;
|
|
2297
|
+
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.87'/%3E%3Cpath d='M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E") center / contain no-repeat; }
|