clavarium 0.2.273-next.1 → 0.2.275-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,19 +1,19 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.273-next.1",
3
+ "version": "0.2.275-next.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "clavarium",
9
- "version": "0.2.273-next.1",
9
+ "version": "0.2.275-next.1",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
13
13
  "@xterm/xterm": "^6.0.0",
14
14
  "clavarium-binder": "0.1.58-next.1",
15
15
  "clavarium-docket": "0.1.2-next.2",
16
- "clavarium-parley": "0.17.44-next.1",
16
+ "clavarium-parley": "0.17.47-next.1",
17
17
  "clavarium-tether": "0.1.0-next.48",
18
18
  "mammoth": "1.13.0",
19
19
  "mermaid": "11.17.2",
@@ -787,9 +787,9 @@
787
787
  }
788
788
  },
789
789
  "node_modules/clavarium-parley": {
790
- "version": "0.17.44-next.1",
791
- "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.44-next.1.tgz",
792
- "integrity": "sha512-2ISMxfdSZbZzht4n5ug3fRRFHyFPHlZYfVqDZXGr/fxpD1pmF9UXRnjDX4nGmaRegS1AtCGtDI2D3w5HXvL9Yw==",
790
+ "version": "0.17.47-next.1",
791
+ "resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.47-next.1.tgz",
792
+ "integrity": "sha512-Pck1QKcpF3MG7a/h1YQbmUDtBBOsAVfprwKe3ZuL7wcINu5mQ3nxHoYmYO8aZTLoqo3P3UF0JV13iHFvTZHt1Q==",
793
793
  "license": "MIT",
794
794
  "bin": {
795
795
  "parley": "bin/parley.mjs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clavarium",
3
- "version": "0.2.273-next.1",
3
+ "version": "0.2.275-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.",
@@ -46,7 +46,7 @@
46
46
  "@xterm/xterm": "^6.0.0",
47
47
  "clavarium-binder": "0.1.58-next.1",
48
48
  "clavarium-docket": "0.1.2-next.2",
49
- "clavarium-parley": "0.17.44-next.1",
49
+ "clavarium-parley": "0.17.47-next.1",
50
50
  "clavarium-tether": "0.1.0-next.48",
51
51
  "mammoth": "1.13.0",
52
52
  "mermaid": "11.17.2",
package/server/boxes.mjs CHANGED
@@ -134,7 +134,9 @@ export function sentencesOf(text) {
134
134
 
135
135
  /* The words said while an answer is awaited (« Hmm… », « ça prend plus de temps ») -- off (01-11: heard all
136
136
  the time while the box misheard, they made it worse; back once the sound path is sound). */
137
- export const WAITING_WORDS = false;
137
+ /* 03-11: on again, but only the sentence made for THIS request (never a stock phrase), and only when the agent has
138
+ said nothing within THINKING_AFTER_MS. */
139
+ export const WAITING_WORDS = true;
138
140
  /* WHAT THE BOX MEASURED, its sentence ended (firmware 0.1.38): how long, when a voice was heard, the bar it
139
141
  used -- beside the message, with what reached this side. */
140
142
  export function endOf(ep, reason = '') {
@@ -151,7 +153,7 @@ export function endOf(ep, reason = '') {
151
153
  return parts.join(' · ');
152
154
  }
153
155
  /* 02-11: the light turning says it is at work; a word only when it really takes long. */
154
- export const THINKING_AFTER_MS = 15_000;
156
+ export const THINKING_AFTER_MS = 5_000;
155
157
  export const LONGER_AFTER_MS = 12_000;
156
158
  export const THINKING = ['Hmm…', 'Voyons…', 'Hmm, voyons voir…'];
157
159
  /* WHY A BOX LISTENED, in a few words beside the message (01-11): what woke it (and the wake word's score), and
@@ -524,7 +526,7 @@ export class Boxes {
524
526
  /* Made at once, used if the answer is still not there: a reaction to THIS sentence, in its language. */
525
527
  let made = null;
526
528
  this.#react(text).then((t) => { made = t; }).catch(() => {});
527
- link.thinkingA = setTimeout(() => { void say(made || THINKING[Math.floor(Math.random() * THINKING.length)]); }, THINKING_AFTER_MS);
529
+ link.thinkingA = setTimeout(() => { if (made) void say(made); }, THINKING_AFTER_MS);
528
530
  /* One word of waiting, not two (02-11: « je regarde, un instant » again and again). */
529
531
  link.thinkingA.unref?.();
530
532
  }
@@ -535,10 +537,13 @@ export class Boxes {
535
537
  const plain = forSpeech(text);
536
538
  /* 02-11: not even « Je regarde, un instant » in its place -- said each time the agent wrote what it does, it
537
539
  came back again and again. A long or technical one is not said at all. */
538
- const words = doing && (plain.length > 70 || /[\d:;/()[\]→=_]/.test(plain)) ? '' : plain;
540
+ /* Sent to a box on purpose (03-11: "dis au plus tôt ce que tu vas faire"): said as it is written. */
541
+ const aimed = doing && Array.isArray(to) && to.length > 0;
542
+ const words = doing && !aimed && (plain.length > 70 || /[\d:;/()[\]→=_]/.test(plain)) ? '' : plain;
539
543
  if (!words) return;
540
544
  let boxes;
541
- if (doing) {
545
+ if (aimed) boxes = [...this.#links.values()].filter((l) => l.box().conversation === conversation && to.includes(l.box().id));
546
+ else if (doing) {
542
547
  /* "I'm looking in the calendar": once per sentence heard, on the box that heard it, within two minutes. */
543
548
  /* 02-11: what it really does, in its words (« je regarde dans ton agenda »); never a stock phrase. */
544
549
  boxes = [...this.#links.values()].filter((l) => l.box().conversation === conversation && l.heardAt && !l.doingSaid && this.#now() - l.heardAt < DOING_WITHIN_MS);
@@ -570,7 +575,9 @@ export class Boxes {
570
575
  let pcm;
571
576
  try { pcm = await next; } catch (error) { this.#log(`voice box: no voice for the answer (${error.message})`); l.send({ t: 'cue', name: 'error' }); break; }
572
577
  if (i + 1 < parts.length) { next = this.#speak(parts[i + 1]); next.catch(() => {}); }
573
- l.play(pcm, i + 1 === parts.length && (question || chatting) ? 'listen' : null); /* a question is always listened after: an answer is expected */
578
+ /* Listened after only when what it says calls for an answer (03-11: "en fonction de la réponse"): the
579
+ agent says so by asking (parley ask), not the box by guessing. */
580
+ l.play(pcm, i + 1 === parts.length && (question || chatting) ? 'listen' : null);
574
581
  }
575
582
  }
576
583
  }
package/server/talk.mjs CHANGED
@@ -294,7 +294,7 @@ export class Talk {
294
294
  /* What the tool says or asks: a voice box of this conversation may read it aloud (boxes.mjs). */
295
295
  if (event.type === 'agent-said' || event.type === 'agent-asked') this.#spoke(name, event.message?.text ?? '', Array.isArray(event.message?.to) ? event.message.to : null, { asked: event.type === 'agent-asked' });
296
296
  /* What it is doing: said by a box that was just spoken to, so nobody waits in silence. */
297
- if (event.type === 'agent-doing') this.#spoke(name, event.message?.text ?? '', null, { doing: true });
297
+ if (event.type === 'agent-doing') this.#spoke(name, event.message?.text ?? '', Array.isArray(event.message?.to) ? event.message.to : null, { doing: true });
298
298
  const words = texts(this.#lastLang, this.settings().own);
299
299
  if (event.type === 'agent-asked') this.#alert({ title: fill(words['alert-asks'], { name }), body: event.message.text ?? '', url: `/?c=${name}` });
300
300
  if (event.type === 'agent-status' && event.message.state === 'waiting') this.#alert({ title: fill(words['alert-waits'], { name }), body: event.message.text ?? '', url: `/?c=${name}` });
package/server/voice.mjs CHANGED
@@ -229,8 +229,10 @@ export async function quickReaction(config, said, fetcher = fetch) {
229
229
  try {
230
230
  const r = await fetcher(`${base}/chat/completions`, {
231
231
  method: 'POST', redirect: 'error', headers: { 'content-type': 'application/json', authorization: `Bearer ${config.key}` }, signal: AbortSignal.timeout(3000),
232
- body: JSON.stringify({ model: REACTION_MODEL, temperature: 0.8, max_tokens: 24, messages: [
233
- { role: 'system', content: 'Someone just spoke to a voice assistant, which needs a few seconds to answer. Write ONE very short spoken reaction (2 to 7 words) in the SAME language as what they said, natural and warm, that acknowledges it without answering it and without promising anything: e.g. "Bonne question, voyons…", "Ah, intéressant, je regarde.", "Hmm, let me see…". No quotes, no emoji. Answer with the reaction only.' },
232
+ body: JSON.stringify({ model: REACTION_MODEL, temperature: 0.8, max_tokens: 40, messages: [
233
+ /* 03-11: what it is going to do, in context, with a little life ("je fouille dans tes mails, je reviens vers
234
+ toi"), never the same stock phrase. */
235
+ { role: 'system', content: 'Someone just spoke to a voice assistant, which needs some time to answer. Write ONE short spoken sentence (4 to 14 words) in the SAME language as what they said, saying what the assistant is now going to do for THIS request, warm and a little playful, never the same wording twice: e.g. "Je fouille dans tes mails, je reviens vers toi.", "Je jette un œil à ton agenda de demain.", "Let me dig through your files for that.". Never answer the question itself, never invent a result, never promise a time. No quotes, no emoji. Answer with the sentence only.' },
234
236
  { role: 'user', content: String(said).slice(0, 600) }] }),
235
237
  });
236
238
  if (!r.ok) return null;