clavarium 0.2.220-next.1 → 0.2.222-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.220-next.1",
3
+ "version": "0.2.222-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.220-next.1",
9
+ "version": "0.2.222-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.220-next.1",
3
+ "version": "0.2.222-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
@@ -132,6 +132,24 @@ export function sentencesOf(text) {
132
132
  return out.filter(Boolean);
133
133
  }
134
134
 
135
+ /* The words said while an answer is awaited (« Hmm… », « ça prend plus de temps ») -- off (01-11: heard all
136
+ the time while the box misheard, they made it worse; back once the sound path is sound). */
137
+ export const WAITING_WORDS = false;
138
+ /* WHAT THE BOX MEASURED, its sentence ended (firmware 0.1.38): how long, when a voice was heard, the bar it
139
+ used -- beside the message, with what reached this side. */
140
+ export function endOf(ep) {
141
+ if (!ep || typeof ep !== 'object') return '';
142
+ const n = (v) => (Number.isFinite(v) ? v : null);
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(', ')}`;
152
+ }
135
153
  export const THINKING_AFTER_MS = 3_500;
136
154
  export const LONGER_AFTER_MS = 12_000;
137
155
  export const THINKING = ['Hmm…', 'Voyons…', 'Hmm, voyons voir…'];
@@ -523,7 +541,9 @@ export class Boxes {
523
541
  /* A question: the box listens again right after, no wake word needed. So does a box in CONVERSATION:
524
542
  asked for ("mode conversation") -- never by itself any more (01-11);
525
543
  it ends when nobody answers, or on "fin de la conversation". */
526
- const question = !doing && (asked || /\?\s*$/.test(words));
544
+ /* Only a question asked on purpose (parley ask) opens listening; one that merely ends in « ? » does not
545
+ any more (01-11: each follow-up listen took in the room and came back as invented words). */
546
+ const question = !doing && asked;
527
547
  for (const l of boxes) { l.answeredAt = this.#now(); clearTimeout(l.thinkingA); clearTimeout(l.thinkingB); }
528
548
  for (const l of boxes) {
529
549
  /* An answer -- to a sentence heard within a minute -- may open the conversation; something said
@@ -630,6 +650,11 @@ export class Boxes {
630
650
  link.send({ t: 'cue', name: 'done' });
631
651
  return;
632
652
  }
653
+ if (m.t === 'listen.end' && m.ep) {
654
+ const end = endOf(m.ep);
655
+ link.why = `${link.why ? `${link.why} ; ` : ''}fin : ${String(m.reason ?? '').slice(0, 20)} ; ${end}`;
656
+ this.#log(`voice box ${box.name}: listen ended (${String(m.reason ?? '').slice(0, 20)}), ${end}`);
657
+ }
633
658
  if (m.t === 'listen.end' && sentence) {
634
659
  const pcm = Buffer.concat(sentence);
635
660
  sentence = null;
@@ -686,7 +711,7 @@ export class Boxes {
686
711
  let text;
687
712
  /* A sentence that goes nowhere is said so, in words, rather than with a beep nobody can read (31-10). */
688
713
  const lost = async (words) => {
689
- try { link.play(await this.#speak(words), 'listen'); } catch { link.send({ t: 'cue', name: 'error' }); }
714
+ try { link.play(await this.#speak(words)); } catch { link.send({ t: 'cue', name: 'error' }); } /* not listened after: a loop of « pardon » on room noise (01-11) */
690
715
  };
691
716
  try {
692
717
  const said = [];
@@ -727,7 +752,7 @@ export class Boxes {
727
752
  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; }
728
753
  this.#log(`voice box ${box.name}: ${seconds} s heard, said in ${box.conversation}`);
729
754
  link.heardAt = this.#now();
730
- this.#waitFor(link, text);
755
+ if (WAITING_WORDS) this.#waitFor(link, text);
731
756
  link.recent = [...(link.recent ?? []), link.heardAt];
732
757
  if (/\bmode conversation\b/i.test(text)) link.chat = true;
733
758
  if (/\b(?:fin|arr[eê]te|stop)\w*\b.{0,20}\b(?:conversation|[ée]couter)\b/i.test(text)) { link.chat = false; link.recent = []; }