@voicethere/agent 0.30.0 → 0.31.0

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.
Files changed (36) hide show
  1. package/README.md +2 -0
  2. package/dist/agent.js +15 -1
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/protocol.d.ts +20 -0
  7. package/dist/protocol.d.ts.map +1 -1
  8. package/dist/protocol.js.map +1 -1
  9. package/dist/runtime.d.ts +26 -1
  10. package/dist/runtime.d.ts.map +1 -1
  11. package/dist/runtime.js +28 -0
  12. package/dist/runtime.js.map +1 -1
  13. package/dist/templates/echo/agent.js +15 -1
  14. package/dist/templates/echo-dc/agent.js +15 -1
  15. package/dist/templates/flow-agent/agent.js +15 -1
  16. package/dist/templates/game-sync/agent.js +15 -1
  17. package/dist/templates/language-switch/agent.js +15 -1
  18. package/dist/templates/llm-agent/agent.js +15 -1
  19. package/dist/templates/llm-board/agent.js +15 -1
  20. package/dist/templates/llm-docs-rag/agent.js +15 -1
  21. package/dist/templates/llm-language-tutor/agent.js +16 -2
  22. package/dist/templates/llm-mcp-service/agent.js +15 -1
  23. package/dist/templates/llm-support-sticky-user/agent.js +15 -1
  24. package/dist/templates/positional-tts/agent.js +15 -1
  25. package/dist/templates/recording-consent/agent.js +15 -1
  26. package/dist/templates/spatial-showcase/agent.js +15 -1
  27. package/dist/templates/speaker-gate/agent.js +15 -1
  28. package/dist/templates/voice-showcase/agent.js +15 -1
  29. package/dist/templates/voice-starter/agent.js +15 -1
  30. package/dist/templates/webhooks/agent.js +15 -1
  31. package/dist/templates/webhooks-redis/agent.js +15 -1
  32. package/dist/templates/world-sync/agent.js +15 -1
  33. package/dist/templates/world-sync-binary/agent.js +15 -1
  34. package/eject/llm/loop.ts +1 -1
  35. package/package.json +1 -1
  36. package/templates/llm-language-tutor/prompt.md +1 -1
@@ -31489,7 +31489,8 @@ function speakerFieldsOf(event) {
31489
31489
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
31490
31490
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
31491
31491
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
31492
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
31492
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
31493
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
31493
31494
  };
31494
31495
  }
31495
31496
  function resolveUserLanguageCode(event) {
@@ -31598,6 +31599,19 @@ async function handleParentMessage(message, handlers) {
31598
31599
  });
31599
31600
  }
31600
31601
  }
31602
+ if (message.event.type === "user_utterance_split") {
31603
+ const split = message.event;
31604
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
31605
+ await handlers.onUserUtteranceSplit?.({
31606
+ sessionId: message.sessionId,
31607
+ fromUtteranceId: split.fromUtteranceId,
31608
+ toUtteranceId: split.toUtteranceId,
31609
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
31610
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
31611
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
31612
+ });
31613
+ }
31614
+ }
31601
31615
  if (message.event.type === "user_language") {
31602
31616
  const language = resolveUserLanguageCode(message.event);
31603
31617
  if (language) {
@@ -31489,7 +31489,8 @@ function speakerFieldsOf(event) {
31489
31489
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
31490
31490
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
31491
31491
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
31492
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
31492
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
31493
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
31493
31494
  };
31494
31495
  }
31495
31496
  function resolveUserLanguageCode(event) {
@@ -31598,6 +31599,19 @@ async function handleParentMessage(message, handlers) {
31598
31599
  });
31599
31600
  }
31600
31601
  }
31602
+ if (message.event.type === "user_utterance_split") {
31603
+ const split = message.event;
31604
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
31605
+ await handlers.onUserUtteranceSplit?.({
31606
+ sessionId: message.sessionId,
31607
+ fromUtteranceId: split.fromUtteranceId,
31608
+ toUtteranceId: split.toUtteranceId,
31609
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
31610
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
31611
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
31612
+ });
31613
+ }
31614
+ }
31601
31615
  if (message.event.type === "user_language") {
31602
31616
  const language = resolveUserLanguageCode(message.event);
31603
31617
  if (language) {
@@ -31489,7 +31489,8 @@ function speakerFieldsOf(event) {
31489
31489
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
31490
31490
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
31491
31491
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
31492
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
31492
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
31493
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
31493
31494
  };
31494
31495
  }
31495
31496
  function resolveUserLanguageCode(event) {
@@ -31598,6 +31599,19 @@ async function handleParentMessage(message, handlers) {
31598
31599
  });
31599
31600
  }
31600
31601
  }
31602
+ if (message.event.type === "user_utterance_split") {
31603
+ const split = message.event;
31604
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
31605
+ await handlers.onUserUtteranceSplit?.({
31606
+ sessionId: message.sessionId,
31607
+ fromUtteranceId: split.fromUtteranceId,
31608
+ toUtteranceId: split.toUtteranceId,
31609
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
31610
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
31611
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
31612
+ });
31613
+ }
31614
+ }
31601
31615
  if (message.event.type === "user_language") {
31602
31616
  const language = resolveUserLanguageCode(message.event);
31603
31617
  if (language) {
@@ -60401,7 +60415,7 @@ var voicethere_llm_default = {
60401
60415
  };
60402
60416
 
60403
60417
  // templates/llm-language-tutor/prompt.md
60404
- var prompt_default = "You are an English conversation tutor for learners at levels A2 to B2. People talk to you by voice, so everything you say is read aloud.\n\nSpeak English only, even if the learner switches to another language. Keep replies to one to three short sentences, in plain words. Do not use markdown, lists, emoji or special characters.\n\nCorrect at most one mistake per turn. Say the learner's sentence again the correct way, then give the reason in a few words. If there is no mistake, say something encouraging in a few words instead. Then ask one follow-up question that keeps the conversation going.\n\nWhen the learner asks about a phrase, an idiom or a lesson topic, call search_knowledge first and answer from what it returns. Never make up the meaning of an idiom that the search did not return. If the search has nothing, say you are not sure and offer a different phrase to practice.\n\nBe patient and friendly. Let the learner finish their thought before you correct anything.\n";
60418
+ var prompt_default = "You are an English conversation tutor for learners at levels A2 to B2. People talk to you by voice, so everything you say is read aloud.\n\nSpeak English only, even if the learner switches to another language. Keep replies to one to three short sentences, in plain words. Do not use markdown, lists, emoji or special characters.\n\nCorrect at most one mistake per turn. Say the learner's sentence again the correct way, then give the reason in a few words. If there is no mistake, say something encouraging in a few words instead. Then ask one follow-up question that keeps the conversation going.\n\nWhen the learner asks about a phrase, an idiom or a lesson topic, call search_knowledge first and answer from what it returns. Call it before you say anything on such a question: do not give a meaning, a guess or a filler sentence first. Never make up the meaning of an idiom that the search did not return. If the search has nothing, say you are not sure and offer a different phrase to practice.\n\nBe patient and friendly. Let the learner finish their thought before you correct anything.\n";
60405
60419
 
60406
60420
  // templates/llm-language-tutor/knowledge/lessons.md
60407
60421
  var lessons_default = `# English practice lessons
@@ -31489,7 +31489,8 @@ function speakerFieldsOf(event) {
31489
31489
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
31490
31490
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
31491
31491
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
31492
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
31492
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
31493
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
31493
31494
  };
31494
31495
  }
31495
31496
  function resolveUserLanguageCode(event) {
@@ -31598,6 +31599,19 @@ async function handleParentMessage(message, handlers) {
31598
31599
  });
31599
31600
  }
31600
31601
  }
31602
+ if (message.event.type === "user_utterance_split") {
31603
+ const split = message.event;
31604
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
31605
+ await handlers.onUserUtteranceSplit?.({
31606
+ sessionId: message.sessionId,
31607
+ fromUtteranceId: split.fromUtteranceId,
31608
+ toUtteranceId: split.toUtteranceId,
31609
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
31610
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
31611
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
31612
+ });
31613
+ }
31614
+ }
31601
31615
  if (message.event.type === "user_language") {
31602
31616
  const language = resolveUserLanguageCode(message.event);
31603
31617
  if (language) {
@@ -31489,7 +31489,8 @@ function speakerFieldsOf(event) {
31489
31489
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
31490
31490
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
31491
31491
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
31492
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
31492
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
31493
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
31493
31494
  };
31494
31495
  }
31495
31496
  function resolveUserLanguageCode(event) {
@@ -31598,6 +31599,19 @@ async function handleParentMessage(message, handlers) {
31598
31599
  });
31599
31600
  }
31600
31601
  }
31602
+ if (message.event.type === "user_utterance_split") {
31603
+ const split = message.event;
31604
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
31605
+ await handlers.onUserUtteranceSplit?.({
31606
+ sessionId: message.sessionId,
31607
+ fromUtteranceId: split.fromUtteranceId,
31608
+ toUtteranceId: split.toUtteranceId,
31609
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
31610
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
31611
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
31612
+ });
31613
+ }
31614
+ }
31601
31615
  if (message.event.type === "user_language") {
31602
31616
  const language = resolveUserLanguageCode(message.event);
31603
31617
  if (language) {
@@ -860,7 +860,8 @@ function speakerFieldsOf(event) {
860
860
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
861
861
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
862
862
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
863
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
863
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
864
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
864
865
  };
865
866
  }
866
867
  function resolveUserLanguageCode(event) {
@@ -969,6 +970,19 @@ async function handleParentMessage(message, handlers) {
969
970
  });
970
971
  }
971
972
  }
973
+ if (message.event.type === "user_utterance_split") {
974
+ const split = message.event;
975
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
976
+ await handlers.onUserUtteranceSplit?.({
977
+ sessionId: message.sessionId,
978
+ fromUtteranceId: split.fromUtteranceId,
979
+ toUtteranceId: split.toUtteranceId,
980
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
981
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
982
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
983
+ });
984
+ }
985
+ }
972
986
  if (message.event.type === "user_language") {
973
987
  const language = resolveUserLanguageCode(message.event);
974
988
  if (language) {
@@ -845,7 +845,8 @@ function speakerFieldsOf(event) {
845
845
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
846
846
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
847
847
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
848
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
848
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
849
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
849
850
  };
850
851
  }
851
852
  function resolveUserLanguageCode(event) {
@@ -954,6 +955,19 @@ async function handleParentMessage(message, handlers) {
954
955
  });
955
956
  }
956
957
  }
958
+ if (message.event.type === "user_utterance_split") {
959
+ const split = message.event;
960
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
961
+ await handlers.onUserUtteranceSplit?.({
962
+ sessionId: message.sessionId,
963
+ fromUtteranceId: split.fromUtteranceId,
964
+ toUtteranceId: split.toUtteranceId,
965
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
966
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
967
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
968
+ });
969
+ }
970
+ }
957
971
  if (message.event.type === "user_language") {
958
972
  const language = resolveUserLanguageCode(message.event);
959
973
  if (language) {
@@ -875,7 +875,8 @@ function speakerFieldsOf(event) {
875
875
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
876
876
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
877
877
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
878
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
878
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
879
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
879
880
  };
880
881
  }
881
882
  function resolveUserLanguageCode(event) {
@@ -984,6 +985,19 @@ async function handleParentMessage(message, handlers) {
984
985
  });
985
986
  }
986
987
  }
988
+ if (message.event.type === "user_utterance_split") {
989
+ const split = message.event;
990
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
991
+ await handlers.onUserUtteranceSplit?.({
992
+ sessionId: message.sessionId,
993
+ fromUtteranceId: split.fromUtteranceId,
994
+ toUtteranceId: split.toUtteranceId,
995
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
996
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
997
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
998
+ });
999
+ }
1000
+ }
987
1001
  if (message.event.type === "user_language") {
988
1002
  const language = resolveUserLanguageCode(message.event);
989
1003
  if (language) {
@@ -845,7 +845,8 @@ function speakerFieldsOf(event) {
845
845
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
846
846
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
847
847
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
848
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
848
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
849
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
849
850
  };
850
851
  }
851
852
  function resolveUserLanguageCode(event) {
@@ -954,6 +955,19 @@ async function handleParentMessage(message, handlers) {
954
955
  });
955
956
  }
956
957
  }
958
+ if (message.event.type === "user_utterance_split") {
959
+ const split = message.event;
960
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
961
+ await handlers.onUserUtteranceSplit?.({
962
+ sessionId: message.sessionId,
963
+ fromUtteranceId: split.fromUtteranceId,
964
+ toUtteranceId: split.toUtteranceId,
965
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
966
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
967
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
968
+ });
969
+ }
970
+ }
957
971
  if (message.event.type === "user_language") {
958
972
  const language = resolveUserLanguageCode(message.event);
959
973
  if (language) {
@@ -844,7 +844,8 @@ function speakerFieldsOf(event) {
844
844
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
845
845
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
846
846
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
847
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
847
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
848
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
848
849
  };
849
850
  }
850
851
  function resolveUserLanguageCode(event) {
@@ -953,6 +954,19 @@ async function handleParentMessage(message, handlers) {
953
954
  });
954
955
  }
955
956
  }
957
+ if (message.event.type === "user_utterance_split") {
958
+ const split = message.event;
959
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
960
+ await handlers.onUserUtteranceSplit?.({
961
+ sessionId: message.sessionId,
962
+ fromUtteranceId: split.fromUtteranceId,
963
+ toUtteranceId: split.toUtteranceId,
964
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
965
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
966
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
967
+ });
968
+ }
969
+ }
956
970
  if (message.event.type === "user_language") {
957
971
  const language = resolveUserLanguageCode(message.event);
958
972
  if (language) {
@@ -844,7 +844,8 @@ function speakerFieldsOf(event) {
844
844
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
845
845
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
846
846
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
847
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
847
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
848
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
848
849
  };
849
850
  }
850
851
  function resolveUserLanguageCode(event) {
@@ -953,6 +954,19 @@ async function handleParentMessage(message, handlers) {
953
954
  });
954
955
  }
955
956
  }
957
+ if (message.event.type === "user_utterance_split") {
958
+ const split = message.event;
959
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
960
+ await handlers.onUserUtteranceSplit?.({
961
+ sessionId: message.sessionId,
962
+ fromUtteranceId: split.fromUtteranceId,
963
+ toUtteranceId: split.toUtteranceId,
964
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
965
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
966
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
967
+ });
968
+ }
969
+ }
956
970
  if (message.event.type === "user_language") {
957
971
  const language = resolveUserLanguageCode(message.event);
958
972
  if (language) {
@@ -847,7 +847,8 @@ function speakerFieldsOf(event) {
847
847
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
848
848
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
849
849
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
850
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
850
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
851
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
851
852
  };
852
853
  }
853
854
  function resolveUserLanguageCode(event) {
@@ -956,6 +957,19 @@ async function handleParentMessage(message, handlers) {
956
957
  });
957
958
  }
958
959
  }
960
+ if (message.event.type === "user_utterance_split") {
961
+ const split = message.event;
962
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
963
+ await handlers.onUserUtteranceSplit?.({
964
+ sessionId: message.sessionId,
965
+ fromUtteranceId: split.fromUtteranceId,
966
+ toUtteranceId: split.toUtteranceId,
967
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
968
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
969
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
970
+ });
971
+ }
972
+ }
959
973
  if (message.event.type === "user_language") {
960
974
  const language = resolveUserLanguageCode(message.event);
961
975
  if (language) {
@@ -11595,7 +11595,8 @@ function speakerFieldsOf(event) {
11595
11595
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
11596
11596
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
11597
11597
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
11598
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
11598
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
11599
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
11599
11600
  };
11600
11601
  }
11601
11602
  function resolveUserLanguageCode(event) {
@@ -11704,6 +11705,19 @@ async function handleParentMessage(message, handlers) {
11704
11705
  });
11705
11706
  }
11706
11707
  }
11708
+ if (message.event.type === "user_utterance_split") {
11709
+ const split = message.event;
11710
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
11711
+ await handlers.onUserUtteranceSplit?.({
11712
+ sessionId: message.sessionId,
11713
+ fromUtteranceId: split.fromUtteranceId,
11714
+ toUtteranceId: split.toUtteranceId,
11715
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
11716
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
11717
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
11718
+ });
11719
+ }
11720
+ }
11707
11721
  if (message.event.type === "user_language") {
11708
11722
  const language = resolveUserLanguageCode(message.event);
11709
11723
  if (language) {
@@ -840,7 +840,8 @@ function speakerFieldsOf(event) {
840
840
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
841
841
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
842
842
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
843
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
843
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
844
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
844
845
  };
845
846
  }
846
847
  function resolveUserLanguageCode(event) {
@@ -949,6 +950,19 @@ async function handleParentMessage(message, handlers) {
949
950
  });
950
951
  }
951
952
  }
953
+ if (message.event.type === "user_utterance_split") {
954
+ const split = message.event;
955
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
956
+ await handlers.onUserUtteranceSplit?.({
957
+ sessionId: message.sessionId,
958
+ fromUtteranceId: split.fromUtteranceId,
959
+ toUtteranceId: split.toUtteranceId,
960
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
961
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
962
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
963
+ });
964
+ }
965
+ }
952
966
  if (message.event.type === "user_language") {
953
967
  const language = resolveUserLanguageCode(message.event);
954
968
  if (language) {
@@ -840,7 +840,8 @@ function speakerFieldsOf(event) {
840
840
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
841
841
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
842
842
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
843
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
843
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
844
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
844
845
  };
845
846
  }
846
847
  function resolveUserLanguageCode(event) {
@@ -949,6 +950,19 @@ async function handleParentMessage(message, handlers) {
949
950
  });
950
951
  }
951
952
  }
953
+ if (message.event.type === "user_utterance_split") {
954
+ const split = message.event;
955
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
956
+ await handlers.onUserUtteranceSplit?.({
957
+ sessionId: message.sessionId,
958
+ fromUtteranceId: split.fromUtteranceId,
959
+ toUtteranceId: split.toUtteranceId,
960
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
961
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
962
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
963
+ });
964
+ }
965
+ }
952
966
  if (message.event.type === "user_language") {
953
967
  const language = resolveUserLanguageCode(message.event);
954
968
  if (language) {
package/eject/llm/loop.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Copied from @voicethere/agent 0.30.0. Package updates no longer change this file.
1
+ // Copied from @voicethere/agent 0.31.0. Package updates no longer change this file.
2
2
  import { randomUUID } from "node:crypto";
3
3
  import {
4
4
  type AgentHandlers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voicethere/agent",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "description": "VoiceThere customer agent SDK — IPC types and runtime helpers for sandboxed child bundles",
5
5
  "type": "module",
6
6
  "exports": {
@@ -4,6 +4,6 @@ Speak English only, even if the learner switches to another language. Keep repli
4
4
 
5
5
  Correct at most one mistake per turn. Say the learner's sentence again the correct way, then give the reason in a few words. If there is no mistake, say something encouraging in a few words instead. Then ask one follow-up question that keeps the conversation going.
6
6
 
7
- When the learner asks about a phrase, an idiom or a lesson topic, call search_knowledge first and answer from what it returns. Never make up the meaning of an idiom that the search did not return. If the search has nothing, say you are not sure and offer a different phrase to practice.
7
+ When the learner asks about a phrase, an idiom or a lesson topic, call search_knowledge first and answer from what it returns. Call it before you say anything on such a question: do not give a meaning, a guess or a filler sentence first. Never make up the meaning of an idiom that the search did not return. If the search has nothing, say you are not sure and offer a different phrase to practice.
8
8
 
9
9
  Be patient and friendly. Let the learner finish their thought before you correct anything.