opencharm 0.8.1 → 0.8.2

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/dist/main.mjs CHANGED
@@ -997,7 +997,7 @@ function sendAdmin(socketPath, request) {
997
997
  }
998
998
  //#endregion
999
999
  //#region package.json
1000
- var version = "0.8.1";
1000
+ var version = "0.8.2";
1001
1001
  function channelToCube(value) {
1002
1002
  if (value < 48) return 0;
1003
1003
  if (value < 115) return 1;
@@ -3361,6 +3361,10 @@ var TurnController = class {
3361
3361
  #generation = 0;
3362
3362
  #controller;
3363
3363
  #speaking = false;
3364
+ #questions = 0;
3365
+ #questionsEnd;
3366
+ #endQuestions = () => {};
3367
+ #questionStarts = /* @__PURE__ */ new Set();
3364
3368
  #playedBy = 0;
3365
3369
  #asking;
3366
3370
  #endFace;
@@ -3507,6 +3511,12 @@ var TurnController = class {
3507
3511
  if (ask) this.#asking = async (text, options) => {
3508
3512
  asking = true;
3509
3513
  clearTimeout(timer);
3514
+ if (this.#questions++ === 0) {
3515
+ this.#questionsEnd = new Promise((resolve) => {
3516
+ this.#endQuestions = resolve;
3517
+ });
3518
+ for (const notify of this.#questionStarts) notify();
3519
+ }
3510
3520
  try {
3511
3521
  return await ask(text, {
3512
3522
  ...options,
@@ -3514,6 +3524,10 @@ var TurnController = class {
3514
3524
  });
3515
3525
  } finally {
3516
3526
  asking = false;
3527
+ if (--this.#questions === 0) {
3528
+ this.#questionsEnd = void 0;
3529
+ this.#endQuestions();
3530
+ }
3517
3531
  if (!signal.aborted) timer = startClock();
3518
3532
  }
3519
3533
  };
@@ -3722,14 +3736,36 @@ var TurnController = class {
3722
3736
  state: "start"
3723
3737
  });
3724
3738
  }
3739
+ const sleep = this.#deps.sleep ?? sleepMs;
3740
+ const now = this.#deps.now ?? Date.now;
3741
+ const aborted = new Promise((resolve) => signal.addEventListener("abort", () => resolve("aborted"), { once: true }));
3725
3742
  this.#deps.send({
3726
3743
  type: "tts",
3727
3744
  state: "sentence_start",
3728
3745
  text
3729
3746
  });
3730
- const sleep = this.#deps.sleep ?? sleepMs;
3731
3747
  clock.pause();
3732
- await Promise.race([sleep(readingMs(text)), new Promise((resolve) => signal.addEventListener("abort", () => resolve(), { once: true }))]);
3748
+ let remaining = readingMs(text);
3749
+ while (going()) {
3750
+ if (this.#questionsEnd) {
3751
+ await Promise.race([this.#questionsEnd, aborted]);
3752
+ continue;
3753
+ }
3754
+ const from = now();
3755
+ let notify = () => {};
3756
+ const question = new Promise((resolve) => {
3757
+ notify = () => resolve("question");
3758
+ });
3759
+ this.#questionStarts.add(notify);
3760
+ const outcome = await Promise.race([
3761
+ sleep(remaining).then(() => "read"),
3762
+ aborted,
3763
+ question
3764
+ ]);
3765
+ this.#questionStarts.delete(notify);
3766
+ if (outcome !== "question") break;
3767
+ remaining = Math.max(0, remaining - (now() - from));
3768
+ }
3733
3769
  clock.resume();
3734
3770
  }
3735
3771
  #failureLine(error) {
@@ -5019,7 +5055,7 @@ function formatIdentity(unit, version, commit) {
5019
5055
  let cached;
5020
5056
  function identity() {
5021
5057
  if (cached) return cached;
5022
- const commit = "e06b6db";
5058
+ const commit = "da4ff95";
5023
5059
  cached = {
5024
5060
  version: `cli@${version}`,
5025
5061
  commit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencharm",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "An open-source body for the AI agent you already run: a face, a voice, one key. Claude Code, Codex, Gemini CLI, Hermes, OpenClaw or any ACP or OpenAI-compatible agent; on a small board, your Mac's notch or the browser.",
5
5
  "type": "module",
6
6
  "bin": {
Binary file