clavarium 0.2.223-next.1 → 0.2.224-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.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.223-next.1",
3
+ "version": "0.2.224-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.223-next.1",
9
+ "version": "0.2.224-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.223-next.1",
3
+ "version": "0.2.224-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
package/server/boxes.mjs CHANGED
@@ -137,18 +137,16 @@ export function sentencesOf(text) {
137
137
  export const WAITING_WORDS = false;
138
138
  /* WHAT THE BOX MEASURED, its sentence ended (firmware 0.1.38): how long, when a voice was heard, the bar it
139
139
  used -- beside the message, with what reached this side. */
140
- export function endOf(ep) {
140
+ export function endOf(ep, reason = '') {
141
141
  if (!ep || typeof ep !== 'object') return '';
142
- const n = (v) => (Number.isFinite(v) ? v : null);
142
+ const n = (v) => Number.isFinite(v);
143
143
  const sec = (v) => `${v.toFixed(1).replace('.', ',')} s`;
144
- const parts = [];
145
- if (n(ep.s) !== null) parts.push(`écoute ${sec(ep.s)}`);
146
- parts.push(n(ep.heard_at) !== null && ep.heard_at >= 0 ? `voix dès ${sec(ep.heard_at)}` : 'aucune voix détectée');
147
- if (n(ep.bar) !== null) parts.push(`seuil ${Math.round(ep.bar)}`);
148
- if (n(ep.voice) !== null && ep.voice > 0) parts.push(`voix ${Math.round(ep.voice)}`);
149
- if (n(ep.mean) !== null) parts.push(`moyenne ${Math.round(ep.mean)}`);
150
- if (n(ep.room) !== null) parts.push(`pièce ${Math.round(ep.room)}`);
151
- return `boîtier : ${parts.join(', ')}`;
144
+ const parts = [`fin ${String(reason).slice(0, 12)}${n(ep.s) ? ` ${sec(ep.s)}` : ''}`.replace(/\s+/g, ' ').trim()];
145
+ parts.push(n(ep.heard_at) && ep.heard_at >= 0 ? `voix dès ${sec(ep.heard_at)}` : 'sans voix');
146
+ if (n(ep.bar)) parts.push(`seuil ${Math.round(ep.bar)}`);
147
+ if (n(ep.voice) && ep.voice > 0) parts.push(`voix ${Math.round(ep.voice)}`);
148
+ if (n(ep.mean)) parts.push(`moy ${Math.round(ep.mean)}`);
149
+ return parts.join(' · ');
152
150
  }
153
151
  export const THINKING_AFTER_MS = 3_500;
154
152
  export const LONGER_AFTER_MS = 12_000;
@@ -156,10 +154,10 @@ export const THINKING = ['Hmm…', 'Voyons…', 'Hmm, voyons voir…'];
156
154
  /* WHY A BOX LISTENED, in a few words beside the message (01-11): what woke it (and the wake word's score), and
157
155
  what it cut short. */
158
156
  export function whyOf(m) {
159
- const reason = { wake: 'mot d\'éveil', button: 'bouton', follow: 'suite de la conversation', knock: 'toc-toc' }[m?.reason] ?? (m?.reason ? String(m.reason).slice(0, 30) : 'inconnu');
160
- const score = Number.isFinite(m?.score) ? ` (${Math.round(m.score * 100)} %)` : '';
161
- const cut = m?.cut ? ` ; a interrompu ${String(m.cut) === 'its own speech' ? 'sa propre phrase' : 'un son'}` : '';
162
- return `réveil : ${reason}${score}${cut}`;
157
+ const reason = { wake: 'éveil', button: 'bouton', follow: 'suite', knock: 'toc-toc' }[m?.reason] ?? (m?.reason ? String(m.reason).slice(0, 20) : 'inconnu');
158
+ const score = Number.isFinite(m?.score) ? ` ${Math.round(m.score * 100)} %` : '';
159
+ const cut = m?.cut ? ` · a coupé ${String(m.cut) === 'its own speech' ? 'sa phrase' : 'un son'}` : '';
160
+ return `${reason}${score}${cut}`;
163
161
  }
164
162
 
165
163
  /* HOW LOUD WHAT THE BOX SENT WAS (01-11): beside the message, so a sentence that came empty (a wake, then
@@ -173,7 +171,7 @@ export function levelOf(pcm) {
173
171
  export const QUIET_LEVEL = 150;
174
172
  export function soundOf(pcm) {
175
173
  const level = levelOf(pcm);
176
- return `son ${(pcm.length / 32_000).toFixed(1).replace('.', ',')} s, niveau ${level}${level < QUIET_LEVEL ? ' (presque silencieux)' : ''}`;
174
+ return `reçu ${(pcm.length / 32_000).toFixed(1).replace('.', ',')} s niv ${level}${level < QUIET_LEVEL ? ' (silence)' : ''}`;
177
175
  }
178
176
 
179
177
  export const DOING_WITHIN_MS = 120_000;
@@ -654,9 +652,9 @@ export class Boxes {
654
652
  return;
655
653
  }
656
654
  if (m.t === 'listen.end' && m.ep) {
657
- const end = endOf(m.ep);
658
- link.why = `${link.why ? `${link.why} ; ` : ''}fin : ${String(m.reason ?? '').slice(0, 20)} ; ${end}`;
659
- this.#log(`voice box ${box.name}: listen ended (${String(m.reason ?? '').slice(0, 20)}), ${end}`);
655
+ const end = endOf(m.ep, m.reason ?? '');
656
+ link.why = `${link.why ? `${link.why} · ` : ''}${end}`;
657
+ this.#log(`voice box ${box.name}: ${end}`);
660
658
  }
661
659
  if (m.t === 'listen.end' && sentence) {
662
660
  const pcm = Buffer.concat(sentence);
@@ -752,7 +750,7 @@ export class Boxes {
752
750
  link.relay = 0;
753
751
  text = `(réponse entendue de l'appareil, pas de la personne) ${text}`;
754
752
  }
755
- try { await this.#say(box.conversation, text, { id: box.id, name: box.name, ...(box.place ? { place: box.place } : {}), why: `${link.why ? `${link.why} ; ` : ''}${soundOf(pcm)}` }); } catch (error) { this.#log(`voice box ${box.name}: ${seconds} s heard and dictated, but not said in ${box.conversation} (${error.message})`); await lost("Pardon, je n'ai pas pu transmettre ta phrase. Tu peux répéter ?"); return; }
753
+ try { await this.#say(box.conversation, text, { id: box.id, name: box.name, ...(box.place ? { place: box.place } : {}), why: `${link.why ? `${link.why} · ` : ''}${soundOf(pcm)}` }); } catch (error) { this.#log(`voice box ${box.name}: ${seconds} s heard and dictated, but not said in ${box.conversation} (${error.message})`); await lost("Pardon, je n'ai pas pu transmettre ta phrase. Tu peux répéter ?"); return; }
756
754
  this.#log(`voice box ${box.name}: ${seconds} s heard, said in ${box.conversation}`);
757
755
  link.heardAt = this.#now();
758
756
  if (WAITING_WORDS) this.#waitFor(link, text);