@7ots/cli 0.1.14 → 0.1.15

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.
@@ -132,6 +132,10 @@ const uiLangOf = (c, fallback) => [process.env.SEVENOTS_LANG, c.lang, String(pro
132
132
  const brainLabel = (b = {}) => (b.kind === 'cli' ? `${b.cli}${b.model ? ` · ${b.model}` : ''}` : b.kind === 'api' ? `${b.provider || 'api'}${b.model ? ` · ${b.model}` : ''}` : b.kind || 'lines');
133
133
 
134
134
  const GAP = { 0: Infinity, 1: 10 * 60_000, 2: 90_000, 3: 20_000 }; // minimum silence between spontaneous lines
135
+ // "important" ones (agent finished / waiting / a new session) obey the annoyance level too: 0 = never a word on its own
136
+ const IMPORTANT_GAP = { 0: Infinity, 1: 5 * 60_000, 2: 60_000, 3: 15_000 };
137
+ const HELLO_GAP = 30 * 60_000; // every new agent session says "start": one hello per half hour is plenty
138
+ const CHAT_QUIET = 90_000; // while you talk to it, no small talk on top of the conversation
135
139
  const CHATTY = { 0: 0, 1: 0.02, 2: 0.12, 3: 0.35 }; // chance to comment a routine event (tool, ok, prompt)
136
140
  const IDLE = { 0: Infinity, 1: 60 * 60_000, 2: 20 * 60_000, 3: 5 * 60_000 }; // idle chatter every…
137
141
 
@@ -173,6 +177,8 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
173
177
  const activity = []; // what happened lately, for the window's feed
174
178
  let thinking = false;
175
179
  let lastSpoke = 0;
180
+ let lastHello = 0;
181
+ let chatUntil = 0;
176
182
  let lastIdle = Date.now();
177
183
  let viewSet = null; // 2D/3D changed in the settings since start: pages that (re)connect pick it up too
178
184
 
@@ -228,11 +234,13 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
228
234
 
229
235
  async function speak(kind, vars = {}, situation = '', { force = false, gesture = null } = {}) {
230
236
  const now = Date.now();
231
- if (!force && (pet.asleep || now - lastSpoke < GAP[annoy])) {
237
+ const quiet = now < chatUntil || (kind === 'hello' && now - lastHello < HELLO_GAP) || (force ? now - lastSpoke < IMPORTANT_GAP[annoy] : pet.asleep || now - lastSpoke < GAP[annoy]);
238
+ if (quiet) {
232
239
  broadcast({ gesture });
233
240
  return;
234
241
  }
235
242
  lastSpoke = now;
243
+ if (kind === 'hello') lastHello = now;
236
244
  let text = '';
237
245
  if (brain.kind !== 'lines' && situation && !thinking) {
238
246
  thinking = true;
@@ -254,7 +262,8 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
254
262
  history.push(text);
255
263
  if (history.length > 6) history.shift();
256
264
  pet.lastTalk = now;
257
- broadcast({ say: text, gesture, thinking: false });
265
+ if (Date.now() < chatUntil) return broadcast({ thinking: false }); // you started talking to it while it thought
266
+ broadcast({ say: text, gesture, thinking: false, ambient: true });
258
267
  }
259
268
 
260
269
  const SITUATION = {
@@ -423,12 +432,12 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
423
432
  log,
424
433
  onSeen: (row) => {
425
434
  broadcast({ seen: row });
426
- if (!row.say || pet.asleep || Date.now() - lastSpoke < GAP[annoy] || Math.random() >= CHATTY[annoy]) return;
435
+ if (!row.say || pet.asleep || Date.now() < chatUntil || Date.now() - lastSpoke < GAP[annoy] || Math.random() >= CHATTY[annoy]) return;
427
436
  lastSpoke = Date.now();
428
437
  pet.lastTalk = lastSpoke;
429
438
  history.push(row.say);
430
439
  if (history.length > 6) history.shift();
431
- broadcast({ say: row.say, gesture: 'point' });
440
+ broadcast({ say: row.say, gesture: 'point', ambient: true });
432
441
  },
433
442
  });
434
443
 
@@ -722,9 +731,11 @@ export function startPetServer({ port = PET_PORT, log = () => {} } = {}) {
722
731
  if (p === '/ask') {
723
732
  const text = String(data.text || '').trim().slice(0, 800);
724
733
  if (!text) return json(400, { error: 'text' });
734
+ chatUntil = Date.now() + CHAT_QUIET;
725
735
  broadcast({ thinking: true, activity: track({ type: 'prompt', text }) });
726
736
  const r = await assistant.ask(text);
727
737
  lastSpoke = Date.now();
738
+ chatUntil = Date.now() + CHAT_QUIET;
728
739
  broadcast({ thinking: false, stir: pet.asleep, say: r.reply, gesture: r.actions.length ? 'nod' : null, point: r.actions.some((a) => a.type === 'open') ? 'browser' : null });
729
740
  return json(200, r);
730
741
  }
package/cli/pet/pet.html CHANGED
@@ -564,13 +564,24 @@
564
564
  if (typeof ch.speak !== 'function') return; // older character bundle
565
565
  lip = ch.speak(text, { durationMs: ms || 500 + text.length * 60 });
566
566
  }
567
- async function speak(text) {
567
+ // one voice at a time: a new line cuts the one playing (small talk never cuts a reply: see the say message)
568
+ const hush = () => {
569
+ if (speak.cur) speak.cur.onended = speak.cur.onerror = null, speak.cur.pause(), (speak.cur = null), talk(false);
570
+ if ('speechSynthesis' in window) speechSynthesis.cancel();
571
+ };
572
+ async function speak(text, reply = false) {
568
573
  if (BOOT.voice?.kind === 'none') return;
574
+ hush();
575
+ const turn = (speak.turn = (speak.turn || 0) + 1);
569
576
  if (BOOT.voice?.kind && BOOT.voice.kind !== 'browser') {
570
577
  try {
571
578
  const r = await post('/tts', { text });
572
579
  if (r.ok) {
573
- const audio = new Audio(URL.createObjectURL(await r.blob()));
580
+ const blob = await r.blob();
581
+ if (turn !== speak.turn) return; // a newer line arrived while this one was synthesizing
582
+ const audio = new Audio(URL.createObjectURL(blob));
583
+ speak.cur = audio;
584
+ speak.reply = reply;
574
585
  audio.onplay = () => {
575
586
  // real audio drives the mouth when possible, else text-timed visemes
576
587
  try {
@@ -584,12 +595,12 @@
584
595
  } catch {}
585
596
  talk(true, clean(text), (audio.duration || 0) * 1000);
586
597
  };
587
- audio.onended = audio.onerror = () => talk(false);
598
+ audio.onended = audio.onerror = () => ((speak.cur = null), talk(false));
588
599
  return await audio.play();
589
600
  }
590
601
  } catch {}
591
602
  }
592
- if (!('speechSynthesis' in window)) return;
603
+ if (turn !== speak.turn || !('speechSynthesis' in window)) return;
593
604
  const u = new SpeechSynthesisUtterance(clean(text));
594
605
  u.lang = id.voice?.lang || lang;
595
606
  u.rate = id.voice?.rate || 1;
@@ -633,14 +644,15 @@
633
644
  }
634
645
  // speech tags ([laugh], <whisper>…: settings → Voice → expressions) go to the voice, never to the bubble (as src/voice/tags.js)
635
646
  const clean = (t) => String(t ?? '').replace(/<\/?(loud|soft|whisper|fast|slow|singing)>/gi, '').replace(/\s*\[(pause|long-pause|laugh|cry|mouth-click|breath|sigh)\]\s*/gi, ' ').replace(/\s{2,}/g, ' ').trim();
636
- function say(raw, withFace = false) {
647
+ function say(raw, withFace = false, ambient = false) {
648
+ if (ambient && speak.cur && speak.reply) return; // small talk waits for the answer to finish
637
649
  const text = clean(raw);
638
650
  showBubble(document.createTextNode(text), Math.max(4500, text.length * 90));
639
651
  talk(true, text); // the mouth moves with the words even without a voice; a real voice re-syncs it
640
652
  clearTimeout(say.t);
641
653
  say.t = setTimeout(() => talk(false), 500 + text.length * 60);
642
654
  if (withFace) react(text);
643
- speak(raw);
655
+ speak(raw, !ambient);
644
656
  }
645
657
  // It asks before acting for you (Orquesta…): Approve / Reject in the bubble, answered on POST /approve.
646
658
  let asking = null;
@@ -730,7 +742,7 @@
730
742
  if (m.gesture) ch.gesture(m.gesture);
731
743
  if (m.morph) ch.morph?.(m.morph);
732
744
  if (m.effect) ch.effect?.(m.effect);
733
- if (m.say) say(m.say, !m.gesture);
745
+ if (m.say) say(m.say, !m.gesture, !!m.ambient);
734
746
  if (m.dance) dance(m.dance);
735
747
  if (m.entrance) entrance(m.entrance);
736
748
  if (m.point && desktop) window.__goal = m.point; // the desktop shell walks it over there
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@7ots/cli",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "7ots.com — your AI companion with a face of its own: a desktop pet that watches over your coding agent (Claude Code and shell hooks), a personal assistant (reminders, alerts, notes, opens sites, sees your screen if allowed) and a reproducible identity (face, personality, voice) for any agent — in apuchat meet calls, Orquesta projects or your own server.",
5
5
  "homepage": "https://7ots.com",
6
6
  "repository": {