@voicethere/agent 0.29.3 → 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 (55) 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/llm/agent/redact.d.ts +16 -0
  7. package/dist/llm/agent/redact.d.ts.map +1 -1
  8. package/dist/llm/agent/redact.js +28 -6
  9. package/dist/llm/agent/redact.js.map +1 -1
  10. package/dist/protocol.d.ts +20 -0
  11. package/dist/protocol.d.ts.map +1 -1
  12. package/dist/protocol.js.map +1 -1
  13. package/dist/runtime.d.ts +26 -1
  14. package/dist/runtime.d.ts.map +1 -1
  15. package/dist/runtime.js +28 -0
  16. package/dist/runtime.js.map +1 -1
  17. package/dist/templates/echo/agent.js +15 -1
  18. package/dist/templates/echo-dc/agent.js +15 -1
  19. package/dist/templates/flow-agent/agent.js +27 -7
  20. package/dist/templates/game-sync/agent.js +15 -1
  21. package/dist/templates/language-switch/agent.js +15 -1
  22. package/dist/templates/llm-agent/agent.js +27 -7
  23. package/dist/templates/llm-board/agent.js +60760 -0
  24. package/dist/templates/llm-docs-rag/agent.js +27 -7
  25. package/dist/templates/llm-language-tutor/agent.js +60563 -0
  26. package/dist/templates/llm-mcp-service/agent.js +27 -7
  27. package/dist/templates/llm-support-sticky-user/agent.js +27 -7
  28. package/dist/templates/positional-tts/agent.js +15 -1
  29. package/dist/templates/recording-consent/agent.js +15 -1
  30. package/dist/templates/registry.d.ts.map +1 -1
  31. package/dist/templates/registry.js +50 -0
  32. package/dist/templates/registry.js.map +1 -1
  33. package/dist/templates/spatial-showcase/agent.js +15 -1
  34. package/dist/templates/speaker-gate/agent.js +15 -1
  35. package/dist/templates/voice-showcase/agent.js +15 -1
  36. package/dist/templates/voice-starter/agent.js +15 -1
  37. package/dist/templates/webhooks/agent.js +15 -1
  38. package/dist/templates/webhooks-redis/agent.js +15 -1
  39. package/dist/templates/world-sync/agent.js +15 -1
  40. package/dist/templates/world-sync-binary/agent.js +15 -1
  41. package/eject/llm/loop.ts +1 -1
  42. package/package.json +2 -1
  43. package/templates/README.md +2 -0
  44. package/templates/llm-board/README.md +44 -0
  45. package/templates/llm-board/agent.ts +235 -0
  46. package/templates/llm-board/board.ts +196 -0
  47. package/templates/llm-board/md.d.ts +4 -0
  48. package/templates/llm-board/prompt.md +11 -0
  49. package/templates/llm-board/voicethere.llm.json +49 -0
  50. package/templates/llm-language-tutor/README.md +32 -0
  51. package/templates/llm-language-tutor/agent.ts +22 -0
  52. package/templates/llm-language-tutor/knowledge/lessons.md +121 -0
  53. package/templates/llm-language-tutor/md.d.ts +4 -0
  54. package/templates/llm-language-tutor/prompt.md +9 -0
  55. package/templates/llm-language-tutor/voicethere.llm.json +39 -0
@@ -918,7 +918,8 @@ function speakerFieldsOf(event) {
918
918
  ...typeof e.speaker === "string" && SPEAKER_VERDICTS.includes(e.speaker) ? { speaker: e.speaker } : {},
919
919
  ...typeof e.speakerUnknownReason === "string" ? { speakerUnknownReason: e.speakerUnknownReason } : {},
920
920
  ...typeof e.speakerCheckWindows === "number" ? { speakerCheckWindows: e.speakerCheckWindows } : {},
921
- ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {}
921
+ ...typeof e.speakerRechecked === "boolean" ? { speakerRechecked: e.speakerRechecked } : {},
922
+ ...e.reason === "speaker_split" || e.reason === "speaker_split_redecode_timeout" ? { reason: e.reason } : {}
922
923
  };
923
924
  }
924
925
  function resolveUserLanguageCode(event) {
@@ -1027,6 +1028,19 @@ async function handleParentMessage(message, handlers) {
1027
1028
  });
1028
1029
  }
1029
1030
  }
1031
+ if (message.event.type === "user_utterance_split") {
1032
+ const split = message.event;
1033
+ if (typeof split.fromUtteranceId === "string" && split.fromUtteranceId && typeof split.toUtteranceId === "string" && split.toUtteranceId) {
1034
+ await handlers.onUserUtteranceSplit?.({
1035
+ sessionId: message.sessionId,
1036
+ fromUtteranceId: split.fromUtteranceId,
1037
+ toUtteranceId: split.toUtteranceId,
1038
+ ...typeof split.splitAtMs === "number" ? { splitAtMs: split.splitAtMs } : {},
1039
+ ...typeof split.from === "string" && SPEAKER_VERDICTS.includes(split.from) ? { from: split.from } : {},
1040
+ ...typeof split.to === "string" && SPEAKER_VERDICTS.includes(split.to) ? { to: split.to } : {}
1041
+ });
1042
+ }
1043
+ }
1030
1044
  if (message.event.type === "user_language") {
1031
1045
  const language = resolveUserLanguageCode(message.event);
1032
1046
  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) {
@@ -32924,15 +32938,21 @@ var PHONE_RE = /(?<![\w.:/+-])(?:\+|\()?\d[\d ().-]{6,22}\d(?![\w.:/-])/g;
32924
32938
  var MAX_PII_CHARS = 65536;
32925
32939
  var IPV4_RE = /^\d{1,3}(?:\.\d{1,3}){3}$/;
32926
32940
  var ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
32941
+ var NON_DIGIT_RE = /\D/g;
32942
+ var PHONE_SEP_RE = /[ .-]/g;
32943
+ var SPACE_RE = / /g;
32944
+ var DIGITS_RE = /^[0-9]+$/;
32945
+ var IBAN_HEAD_RE = /[A-Z]{2}\d{2}/;
32946
+ var CARD_SEP_RE = /[ -]/g;
32927
32947
  function isPhone(m) {
32928
- const d = m.replace(/\D/g, "");
32948
+ const d = m.replace(NON_DIGIT_RE, "");
32929
32949
  if (d.length < 8 || d.length > 15)
32930
32950
  return false;
32931
32951
  if (IPV4_RE.test(m) || ISO_DATE_RE.test(m))
32932
32952
  return false;
32933
32953
  if (m.startsWith("+") || m.includes("("))
32934
32954
  return true;
32935
- return (m.match(/[ .-]/g) ?? []).length >= 2;
32955
+ return (m.match(PHONE_SEP_RE) ?? []).length >= 2;
32936
32956
  }
32937
32957
  var NON_SECRET_AGENT_KEYS = /* @__PURE__ */ new Set([
32938
32958
  "AGENT_CUSTOMER_CONTEXT",
@@ -32963,7 +32983,7 @@ function luhn(digits) {
32963
32983
  return sum % 10 === 0;
32964
32984
  }
32965
32985
  function ibanValid(raw) {
32966
- const s = raw.replace(/ /g, "").toUpperCase();
32986
+ const s = raw.replace(SPACE_RE, "").toUpperCase();
32967
32987
  if (s.length < 15 || s.length > 34)
32968
32988
  return false;
32969
32989
  const rearranged = s.slice(4) + s.slice(0, 4);
@@ -32971,7 +32991,7 @@ function ibanValid(raw) {
32971
32991
  for (const ch of rearranged) {
32972
32992
  const code = ch.charCodeAt(0);
32973
32993
  const v = code >= 65 && code <= 90 ? String(code - 55) : ch;
32974
- if (!/^[0-9]+$/.test(v))
32994
+ if (!DIGITS_RE.test(v))
32975
32995
  return false;
32976
32996
  for (const digit of v)
32977
32997
  rem = (rem * 10 + (digit.charCodeAt(0) - 48)) % 97;
@@ -32986,7 +33006,7 @@ function redactIbanCandidate(m) {
32986
33006
  if (ibanValid(head))
32987
33007
  return `[redacted:iban]${m.slice(end)}`;
32988
33008
  }
32989
- const next = m.slice(1).search(/[A-Z]{2}\d{2}/);
33009
+ const next = m.slice(1).search(IBAN_HEAD_RE);
32990
33010
  if (next >= 0) {
32991
33011
  const at = next + 1;
32992
33012
  return m.slice(0, at) + redactIbanCandidate(m.slice(at));
@@ -32996,7 +33016,7 @@ function redactIbanCandidate(m) {
32996
33016
  function redactPii(input) {
32997
33017
  const text = input.length > MAX_PII_CHARS ? `${input.slice(0, MAX_PII_CHARS)}[truncated]` : input;
32998
33018
  return text.replace(EMAIL_RE, "[redacted:email]").replace(IBAN_CANDIDATE_RE, redactIbanCandidate).replace(CARD_RE, (m) => {
32999
- const digits = m.replace(/[ -]/g, "");
33019
+ const digits = m.replace(CARD_SEP_RE, "");
33000
33020
  return [15, 16, 19].includes(digits.length) && "3456".includes(digits[0]) && luhn(digits) ? "[redacted:card]" : m;
33001
33021
  }).replace(PHONE_RE, (m) => isPhone(m) ? "[redacted:phone]" : m);
33002
33022
  }