@livekit/agents-plugin-livekit 0.1.2 → 1.0.0-next.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 (91) hide show
  1. package/dist/hf_utils.cjs +272 -0
  2. package/dist/hf_utils.cjs.map +1 -0
  3. package/dist/hf_utils.d.cts +40 -0
  4. package/dist/hf_utils.d.ts +40 -0
  5. package/dist/hf_utils.d.ts.map +1 -0
  6. package/dist/hf_utils.js +237 -0
  7. package/dist/hf_utils.js.map +1 -0
  8. package/dist/hf_utils.test.cjs +330 -0
  9. package/dist/hf_utils.test.cjs.map +1 -0
  10. package/dist/hf_utils.test.d.cts +2 -0
  11. package/dist/hf_utils.test.d.ts +2 -0
  12. package/dist/hf_utils.test.d.ts.map +1 -0
  13. package/dist/hf_utils.test.js +307 -0
  14. package/dist/hf_utils.test.js.map +1 -0
  15. package/dist/index.cjs +27 -10
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +2 -2
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +24 -6
  21. package/dist/index.js.map +1 -1
  22. package/dist/turn_detector/base.cjs +202 -0
  23. package/dist/turn_detector/base.cjs.map +1 -0
  24. package/dist/turn_detector/base.d.cts +52 -0
  25. package/dist/turn_detector/base.d.ts +52 -0
  26. package/dist/turn_detector/base.d.ts.map +1 -0
  27. package/dist/turn_detector/base.js +172 -0
  28. package/dist/turn_detector/base.js.map +1 -0
  29. package/dist/turn_detector/constants.cjs +44 -0
  30. package/dist/turn_detector/constants.cjs.map +1 -0
  31. package/dist/turn_detector/constants.d.cts +7 -0
  32. package/dist/turn_detector/constants.d.ts +7 -0
  33. package/dist/turn_detector/constants.d.ts.map +1 -0
  34. package/dist/turn_detector/constants.js +16 -0
  35. package/dist/turn_detector/constants.js.map +1 -0
  36. package/dist/turn_detector/english.cjs +52 -0
  37. package/dist/turn_detector/english.cjs.map +1 -0
  38. package/dist/turn_detector/english.d.cts +11 -0
  39. package/dist/turn_detector/english.d.ts +11 -0
  40. package/dist/turn_detector/english.d.ts.map +1 -0
  41. package/dist/turn_detector/english.js +26 -0
  42. package/dist/turn_detector/english.js.map +1 -0
  43. package/dist/turn_detector/index.cjs +53 -0
  44. package/dist/turn_detector/index.cjs.map +1 -0
  45. package/dist/turn_detector/index.d.cts +5 -0
  46. package/dist/turn_detector/index.d.ts +5 -0
  47. package/dist/turn_detector/index.d.ts.map +1 -0
  48. package/dist/turn_detector/index.js +23 -0
  49. package/dist/turn_detector/index.js.map +1 -0
  50. package/dist/turn_detector/multilingual.cjs +144 -0
  51. package/dist/turn_detector/multilingual.cjs.map +1 -0
  52. package/dist/turn_detector/multilingual.d.cts +15 -0
  53. package/dist/turn_detector/multilingual.d.ts +15 -0
  54. package/dist/turn_detector/multilingual.d.ts.map +1 -0
  55. package/dist/turn_detector/multilingual.js +118 -0
  56. package/dist/turn_detector/multilingual.js.map +1 -0
  57. package/dist/turn_detector/utils.cjs +54 -0
  58. package/dist/turn_detector/utils.cjs.map +1 -0
  59. package/dist/turn_detector/utils.d.cts +35 -0
  60. package/dist/turn_detector/utils.d.ts +35 -0
  61. package/dist/turn_detector/utils.d.ts.map +1 -0
  62. package/dist/turn_detector/utils.js +29 -0
  63. package/dist/turn_detector/utils.js.map +1 -0
  64. package/dist/turn_detector/utils.test.cjs +196 -0
  65. package/dist/turn_detector/utils.test.cjs.map +1 -0
  66. package/dist/turn_detector/utils.test.d.cts +2 -0
  67. package/dist/turn_detector/utils.test.d.ts +2 -0
  68. package/dist/turn_detector/utils.test.d.ts.map +1 -0
  69. package/dist/turn_detector/utils.test.js +195 -0
  70. package/dist/turn_detector/utils.test.js.map +1 -0
  71. package/package.json +7 -6
  72. package/src/hf_utils.test.ts +392 -0
  73. package/src/hf_utils.ts +365 -0
  74. package/src/index.ts +32 -9
  75. package/src/turn_detector/base.ts +238 -0
  76. package/src/turn_detector/constants.ts +16 -0
  77. package/src/turn_detector/english.ts +27 -0
  78. package/src/turn_detector/index.ts +21 -0
  79. package/src/turn_detector/multilingual.ts +145 -0
  80. package/src/turn_detector/utils.test.ts +231 -0
  81. package/src/turn_detector/utils.ts +76 -0
  82. package/dist/turn_detector.cjs +0 -129
  83. package/dist/turn_detector.cjs.map +0 -1
  84. package/dist/turn_detector.d.cts +0 -22
  85. package/dist/turn_detector.d.ts +0 -22
  86. package/dist/turn_detector.d.ts.map +0 -1
  87. package/dist/turn_detector.js +0 -102
  88. package/dist/turn_detector.js.map +0 -1
  89. package/dist/turn_detector.onnx +0 -0
  90. package/src/turn_detector.onnx +0 -0
  91. package/src/turn_detector.ts +0 -121
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Text normalization utilities for EOU turn detector
3
+ */
4
+ /**
5
+ * Simple unicode category detection for punctuation
6
+ * Mimics Python's unicodedata.category() for punctuation detection
7
+ */
8
+ export declare function getUnicodeCategory(char: string): string;
9
+ /**
10
+ * Normalizes text to match the training data format used by the EOU model
11
+ *
12
+ * This function applies the following transformations:
13
+ * 1. Converts to lowercase
14
+ * 2. Applies Unicode NFKC normalization
15
+ * 3. Removes all punctuation except apostrophes (') and hyphens (-)
16
+ * 4. Collapses multiple whitespace characters into single spaces
17
+ * 5. Trims leading and trailing whitespace
18
+ *
19
+ * @param text - The input text to normalize
20
+ * @returns The normalized text
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * normalizeText("Hi, how can I help you today?")
25
+ * // Returns: "hi how can i help you today"
26
+ *
27
+ * normalizeText("I'm a well-trained assistant!")
28
+ * // Returns: "i'm a well-trained assistant"
29
+ *
30
+ * normalizeText("Price: $19.99 (20% off).")
31
+ * // Returns: "price 1999 20 off"
32
+ * ```
33
+ */
34
+ export declare function normalizeText(text: string): string;
35
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/turn_detector/utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkBlD"}
@@ -0,0 +1,29 @@
1
+ function getUnicodeCategory(char) {
2
+ const code = char.codePointAt(0);
3
+ if (!code) return "";
4
+ if (code >= 33 && code <= 47 || // !"#$%&'()*+,-./
5
+ code >= 58 && code <= 64 || // :;<=>?@
6
+ code >= 91 && code <= 96 || // [\]^_`
7
+ code >= 123 && code <= 126 || // {|}~
8
+ code >= 160 && code <= 191 || // Latin-1 punctuation
9
+ code >= 8192 && code <= 8303 || // General punctuation
10
+ code >= 12288 && code <= 12351) {
11
+ return "P";
12
+ }
13
+ return "";
14
+ }
15
+ function normalizeText(text) {
16
+ if (!text) return "";
17
+ let normalized = text.toLowerCase().normalize("NFKC");
18
+ normalized = Array.from(normalized).filter((ch) => {
19
+ const category = getUnicodeCategory(ch);
20
+ return !(category.startsWith("P") && ch !== "'" && ch !== "-");
21
+ }).join("");
22
+ normalized = normalized.replace(/\s+/g, " ").trim();
23
+ return normalized;
24
+ }
25
+ export {
26
+ getUnicodeCategory,
27
+ normalizeText
28
+ };
29
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/turn_detector/utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Text normalization utilities for EOU turn detector\n */\n\n/**\n * Simple unicode category detection for punctuation\n * Mimics Python's unicodedata.category() for punctuation detection\n */\nexport function getUnicodeCategory(char: string): string {\n const code = char.codePointAt(0);\n if (!code) return '';\n\n // Basic punctuation ranges (simplified version to match Python unicodedata.category)\n if (\n (code >= 0x21 && code <= 0x2f) || // !\"#$%&'()*+,-./\n (code >= 0x3a && code <= 0x40) || // :;<=>?@\n (code >= 0x5b && code <= 0x60) || // [\\]^_`\n (code >= 0x7b && code <= 0x7e) || // {|}~\n (code >= 0xa0 && code <= 0xbf) || // Latin-1 punctuation\n (code >= 0x2000 && code <= 0x206f) || // General punctuation\n (code >= 0x3000 && code <= 0x303f)\n ) {\n // CJK symbols and punctuation\n return 'P';\n }\n return '';\n}\n\n/**\n * Normalizes text to match the training data format used by the EOU model\n *\n * This function applies the following transformations:\n * 1. Converts to lowercase\n * 2. Applies Unicode NFKC normalization\n * 3. Removes all punctuation except apostrophes (') and hyphens (-)\n * 4. Collapses multiple whitespace characters into single spaces\n * 5. Trims leading and trailing whitespace\n *\n * @param text - The input text to normalize\n * @returns The normalized text\n *\n * @example\n * ```typescript\n * normalizeText(\"Hi, how can I help you today?\")\n * // Returns: \"hi how can i help you today\"\n *\n * normalizeText(\"I'm a well-trained assistant!\")\n * // Returns: \"i'm a well-trained assistant\"\n *\n * normalizeText(\"Price: $19.99 (20% off).\")\n * // Returns: \"price 1999 20 off\"\n * ```\n */\nexport function normalizeText(text: string): string {\n if (!text) return '';\n\n let normalized = text.toLowerCase().normalize('NFKC');\n\n // Remove punctuation except apostrophes and hyphens\n // Using character-by-character approach to match Python logic\n normalized = Array.from(normalized)\n .filter((ch) => {\n const category = getUnicodeCategory(ch);\n return !(category.startsWith('P') && ch !== \"'\" && ch !== '-');\n })\n .join('');\n\n // Collapse whitespace and trim\n normalized = normalized.replace(/\\s+/g, ' ').trim();\n\n return normalized;\n}\n"],"mappings":"AAYO,SAAS,mBAAmB,MAAsB;AACvD,QAAM,OAAO,KAAK,YAAY,CAAC;AAC/B,MAAI,CAAC,KAAM,QAAO;AAGlB,MACG,QAAQ,MAAQ,QAAQ;AAAA,EACxB,QAAQ,MAAQ,QAAQ;AAAA,EACxB,QAAQ,MAAQ,QAAQ;AAAA,EACxB,QAAQ,OAAQ,QAAQ;AAAA,EACxB,QAAQ,OAAQ,QAAQ;AAAA,EACxB,QAAQ,QAAU,QAAQ;AAAA,EAC1B,QAAQ,SAAU,QAAQ,OAC3B;AAEA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AA2BO,SAAS,cAAc,MAAsB;AAClD,MAAI,CAAC,KAAM,QAAO;AAElB,MAAI,aAAa,KAAK,YAAY,EAAE,UAAU,MAAM;AAIpD,eAAa,MAAM,KAAK,UAAU,EAC/B,OAAO,CAAC,OAAO;AACd,UAAM,WAAW,mBAAmB,EAAE;AACtC,WAAO,EAAE,SAAS,WAAW,GAAG,KAAK,OAAO,OAAO,OAAO;AAAA,EAC5D,CAAC,EACA,KAAK,EAAE;AAGV,eAAa,WAAW,QAAQ,QAAQ,GAAG,EAAE,KAAK;AAElD,SAAO;AACT;","names":[]}
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ var import_vitest = require("vitest");
3
+ var import_utils = require("./utils.cjs");
4
+ (0, import_vitest.describe)("getUnicodeCategory", () => {
5
+ (0, import_vitest.it)("should identify basic ASCII punctuation", () => {
6
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("!")).toBe("P");
7
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)('"')).toBe("P");
8
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("#")).toBe("P");
9
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("$")).toBe("P");
10
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("%")).toBe("P");
11
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("&")).toBe("P");
12
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("'")).toBe("P");
13
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("(")).toBe("P");
14
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)(")")).toBe("P");
15
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("*")).toBe("P");
16
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("+")).toBe("P");
17
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)(",")).toBe("P");
18
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("-")).toBe("P");
19
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)(".")).toBe("P");
20
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("/")).toBe("P");
21
+ });
22
+ (0, import_vitest.it)("should identify colon/semicolon punctuation", () => {
23
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)(":")).toBe("P");
24
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)(";")).toBe("P");
25
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("<")).toBe("P");
26
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("=")).toBe("P");
27
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)(">")).toBe("P");
28
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("?")).toBe("P");
29
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("@")).toBe("P");
30
+ });
31
+ (0, import_vitest.it)("should identify bracket punctuation", () => {
32
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("[")).toBe("P");
33
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\\")).toBe("P");
34
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("]")).toBe("P");
35
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("^")).toBe("P");
36
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("_")).toBe("P");
37
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("`")).toBe("P");
38
+ });
39
+ (0, import_vitest.it)("should identify brace punctuation", () => {
40
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("{")).toBe("P");
41
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("|")).toBe("P");
42
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("}")).toBe("P");
43
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("~")).toBe("P");
44
+ });
45
+ (0, import_vitest.it)("should identify extended punctuation", () => {
46
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\xA1")).toBe("P");
47
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\xBF")).toBe("P");
48
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\xAB")).toBe("P");
49
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\xBB")).toBe("P");
50
+ });
51
+ (0, import_vitest.it)("should not identify letters as punctuation", () => {
52
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("a")).toBe("");
53
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("A")).toBe("");
54
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("z")).toBe("");
55
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("Z")).toBe("");
56
+ });
57
+ (0, import_vitest.it)("should not identify numbers as punctuation", () => {
58
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("0")).toBe("");
59
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("1")).toBe("");
60
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("9")).toBe("");
61
+ });
62
+ (0, import_vitest.it)("should not identify whitespace as punctuation", () => {
63
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)(" ")).toBe("");
64
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)(" ")).toBe("");
65
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\n")).toBe("");
66
+ });
67
+ (0, import_vitest.it)("should handle empty string", () => {
68
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("")).toBe("");
69
+ });
70
+ (0, import_vitest.it)("should handle unicode characters", () => {
71
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\xE9")).toBe("");
72
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\xF1")).toBe("");
73
+ (0, import_vitest.expect)((0, import_utils.getUnicodeCategory)("\xE7")).toBe("");
74
+ });
75
+ });
76
+ (0, import_vitest.describe)("normalizeText", () => {
77
+ (0, import_vitest.describe)("basic functionality", () => {
78
+ (0, import_vitest.it)("should convert to lowercase", () => {
79
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("HELLO")).toBe("hello");
80
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("HeLLo")).toBe("hello");
81
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("WORLD")).toBe("world");
82
+ });
83
+ (0, import_vitest.it)("should remove basic punctuation", () => {
84
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Hello!")).toBe("hello");
85
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Hello?")).toBe("hello");
86
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Hello.")).toBe("hello");
87
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Hello,")).toBe("hello");
88
+ });
89
+ (0, import_vitest.it)("should preserve apostrophes", () => {
90
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("I'm happy")).toBe("i'm happy");
91
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("don't worry")).toBe("don't worry");
92
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("it's great")).toBe("it's great");
93
+ });
94
+ (0, import_vitest.it)("should preserve hyphens", () => {
95
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("well-trained")).toBe("well-trained");
96
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("state-of-the-art")).toBe("state-of-the-art");
97
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("co-worker")).toBe("co-worker");
98
+ });
99
+ (0, import_vitest.it)("should collapse multiple whitespace", () => {
100
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("hello world")).toBe("hello world");
101
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("multiple spaces here")).toBe("multiple spaces here");
102
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("tab spaces")).toBe("tab spaces");
103
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("newline\n\nspaces")).toBe("newline spaces");
104
+ });
105
+ (0, import_vitest.it)("should trim leading and trailing whitespace", () => {
106
+ (0, import_vitest.expect)((0, import_utils.normalizeText)(" hello ")).toBe("hello");
107
+ (0, import_vitest.expect)((0, import_utils.normalizeText)(" \nhello \n")).toBe("hello");
108
+ (0, import_vitest.expect)((0, import_utils.normalizeText)(" hello world ")).toBe("hello world");
109
+ });
110
+ });
111
+ (0, import_vitest.describe)("comprehensive test cases", () => {
112
+ (0, import_vitest.it)("should handle the basic greeting case", () => {
113
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Hi, how can I help you today?")).toBe("hi how can i help you today");
114
+ });
115
+ (0, import_vitest.it)("should handle contractions and hyphens", () => {
116
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("I'm a well-trained assistant!")).toBe("i'm a well-trained assistant");
117
+ });
118
+ (0, import_vitest.it)("should remove various punctuation types", () => {
119
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Hello!!! What??? Price: $19.99 (20% off).")).toBe(
120
+ "hello what price 1999 20 off"
121
+ );
122
+ });
123
+ (0, import_vitest.it)("should handle multiple spaces", () => {
124
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Multiple spaces here")).toBe("multiple spaces here");
125
+ });
126
+ (0, import_vitest.it)("should handle unicode characters", () => {
127
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Caf\xE9 entr\xE9es na\xEFve r\xE9sum\xE9")).toBe("caf\xE9 entr\xE9es na\xEFve r\xE9sum\xE9");
128
+ });
129
+ (0, import_vitest.it)("should handle mixed punctuation and unicode", () => {
130
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("\xBFC\xF3mo est\xE1s? \xA1Muy bien!")).toBe("c\xF3mo est\xE1s muy bien");
131
+ });
132
+ });
133
+ (0, import_vitest.describe)("edge cases", () => {
134
+ (0, import_vitest.it)("should handle empty string", () => {
135
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("")).toBe("");
136
+ });
137
+ (0, import_vitest.it)("should handle whitespace-only string", () => {
138
+ (0, import_vitest.expect)((0, import_utils.normalizeText)(" ")).toBe("");
139
+ (0, import_vitest.expect)((0, import_utils.normalizeText)(" \n ")).toBe("");
140
+ });
141
+ (0, import_vitest.it)("should handle punctuation-only string", () => {
142
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("!!!")).toBe("");
143
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("???")).toBe("");
144
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("...")).toBe("");
145
+ });
146
+ (0, import_vitest.it)("should handle mixed punctuation and preserved characters", () => {
147
+ (0, import_vitest.expect)((0, import_utils.normalizeText)(`!@#$%^&*()_+-={}[]|\\:;"'<>?,./`)).toBe("-'");
148
+ });
149
+ (0, import_vitest.it)("should handle numbers with punctuation", () => {
150
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("$19.99")).toBe("1999");
151
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("(555) 123-4567")).toBe("555 123-4567");
152
+ });
153
+ (0, import_vitest.it)("should handle special unicode punctuation", () => {
154
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Hello\u2026 world!")).toBe("hello world");
155
+ (0, import_vitest.expect)((0, import_utils.normalizeText)('"Quoted text"')).toBe("quoted text");
156
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("'Single quotes'")).toBe("'single quotes'");
157
+ });
158
+ });
159
+ (0, import_vitest.describe)("unicode normalization", () => {
160
+ (0, import_vitest.it)("should apply NFKC normalization", () => {
161
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("caf\xE9")).toBe("caf\xE9");
162
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("na\xEFve")).toBe("na\xEFve");
163
+ });
164
+ (0, import_vitest.it)("should handle combining characters", () => {
165
+ const eWithCombiningAcute = "cafe\u0301";
166
+ const precomposedE = "caf\xE9";
167
+ (0, import_vitest.expect)((0, import_utils.normalizeText)(eWithCombiningAcute)).toBe((0, import_utils.normalizeText)(precomposedE));
168
+ });
169
+ });
170
+ (0, import_vitest.describe)("real-world examples", () => {
171
+ (0, import_vitest.it)("should handle typical assistant responses", () => {
172
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Hello! How can I assist you today?")).toBe(
173
+ "hello how can i assist you today"
174
+ );
175
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("I'm here to help with any questions you might have.")).toBe(
176
+ "i'm here to help with any questions you might have"
177
+ );
178
+ });
179
+ (0, import_vitest.it)("should handle typical user queries", () => {
180
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("What's the weather like?")).toBe("what's the weather like");
181
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Can you help me with my order?")).toBe("can you help me with my order");
182
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("I need assistance, please!")).toBe("i need assistance please");
183
+ });
184
+ (0, import_vitest.it)("should handle incomplete sentences", () => {
185
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("What is the weather in")).toBe("what is the weather in");
186
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("I am looking for")).toBe("i am looking for");
187
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Could you please")).toBe("could you please");
188
+ });
189
+ (0, import_vitest.it)("should handle multilingual text", () => {
190
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Bonjour! Comment \xE7a va?")).toBe("bonjour comment \xE7a va");
191
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("\xA1Hola! \xBFC\xF3mo est\xE1s?")).toBe("hola c\xF3mo est\xE1s");
192
+ (0, import_vitest.expect)((0, import_utils.normalizeText)("Guten Tag! Wie geht es Ihnen?")).toBe("guten tag wie geht es ihnen");
193
+ });
194
+ });
195
+ });
196
+ //# sourceMappingURL=utils.test.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/turn_detector/utils.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { describe, expect, it } from 'vitest';\nimport { getUnicodeCategory, normalizeText } from './utils.js';\n\ndescribe('getUnicodeCategory', () => {\n it('should identify basic ASCII punctuation', () => {\n expect(getUnicodeCategory('!')).toBe('P');\n expect(getUnicodeCategory('\"')).toBe('P');\n expect(getUnicodeCategory('#')).toBe('P');\n expect(getUnicodeCategory('$')).toBe('P');\n expect(getUnicodeCategory('%')).toBe('P');\n expect(getUnicodeCategory('&')).toBe('P');\n expect(getUnicodeCategory(\"'\")).toBe('P');\n expect(getUnicodeCategory('(')).toBe('P');\n expect(getUnicodeCategory(')')).toBe('P');\n expect(getUnicodeCategory('*')).toBe('P');\n expect(getUnicodeCategory('+')).toBe('P');\n expect(getUnicodeCategory(',')).toBe('P');\n expect(getUnicodeCategory('-')).toBe('P');\n expect(getUnicodeCategory('.')).toBe('P');\n expect(getUnicodeCategory('/')).toBe('P');\n });\n\n it('should identify colon/semicolon punctuation', () => {\n expect(getUnicodeCategory(':')).toBe('P');\n expect(getUnicodeCategory(';')).toBe('P');\n expect(getUnicodeCategory('<')).toBe('P');\n expect(getUnicodeCategory('=')).toBe('P');\n expect(getUnicodeCategory('>')).toBe('P');\n expect(getUnicodeCategory('?')).toBe('P');\n expect(getUnicodeCategory('@')).toBe('P');\n });\n\n it('should identify bracket punctuation', () => {\n expect(getUnicodeCategory('[')).toBe('P');\n expect(getUnicodeCategory('\\\\')).toBe('P');\n expect(getUnicodeCategory(']')).toBe('P');\n expect(getUnicodeCategory('^')).toBe('P');\n expect(getUnicodeCategory('_')).toBe('P');\n expect(getUnicodeCategory('`')).toBe('P');\n });\n\n it('should identify brace punctuation', () => {\n expect(getUnicodeCategory('{')).toBe('P');\n expect(getUnicodeCategory('|')).toBe('P');\n expect(getUnicodeCategory('}')).toBe('P');\n expect(getUnicodeCategory('~')).toBe('P');\n });\n\n it('should identify extended punctuation', () => {\n expect(getUnicodeCategory('¡')).toBe('P');\n expect(getUnicodeCategory('¿')).toBe('P');\n expect(getUnicodeCategory('«')).toBe('P');\n expect(getUnicodeCategory('»')).toBe('P');\n });\n\n it('should not identify letters as punctuation', () => {\n expect(getUnicodeCategory('a')).toBe('');\n expect(getUnicodeCategory('A')).toBe('');\n expect(getUnicodeCategory('z')).toBe('');\n expect(getUnicodeCategory('Z')).toBe('');\n });\n\n it('should not identify numbers as punctuation', () => {\n expect(getUnicodeCategory('0')).toBe('');\n expect(getUnicodeCategory('1')).toBe('');\n expect(getUnicodeCategory('9')).toBe('');\n });\n\n it('should not identify whitespace as punctuation', () => {\n expect(getUnicodeCategory(' ')).toBe('');\n expect(getUnicodeCategory('\\t')).toBe('');\n expect(getUnicodeCategory('\\n')).toBe('');\n });\n\n it('should handle empty string', () => {\n expect(getUnicodeCategory('')).toBe('');\n });\n\n it('should handle unicode characters', () => {\n expect(getUnicodeCategory('é')).toBe('');\n expect(getUnicodeCategory('ñ')).toBe('');\n expect(getUnicodeCategory('ç')).toBe('');\n });\n});\n\ndescribe('normalizeText', () => {\n describe('basic functionality', () => {\n it('should convert to lowercase', () => {\n expect(normalizeText('HELLO')).toBe('hello');\n expect(normalizeText('HeLLo')).toBe('hello');\n expect(normalizeText('WORLD')).toBe('world');\n });\n\n it('should remove basic punctuation', () => {\n expect(normalizeText('Hello!')).toBe('hello');\n expect(normalizeText('Hello?')).toBe('hello');\n expect(normalizeText('Hello.')).toBe('hello');\n expect(normalizeText('Hello,')).toBe('hello');\n });\n\n it('should preserve apostrophes', () => {\n expect(normalizeText(\"I'm happy\")).toBe(\"i'm happy\");\n expect(normalizeText(\"don't worry\")).toBe(\"don't worry\");\n expect(normalizeText(\"it's great\")).toBe(\"it's great\");\n });\n\n it('should preserve hyphens', () => {\n expect(normalizeText('well-trained')).toBe('well-trained');\n expect(normalizeText('state-of-the-art')).toBe('state-of-the-art');\n expect(normalizeText('co-worker')).toBe('co-worker');\n });\n\n it('should collapse multiple whitespace', () => {\n expect(normalizeText('hello world')).toBe('hello world');\n expect(normalizeText('multiple spaces here')).toBe('multiple spaces here');\n expect(normalizeText('tab\\t\\tspaces')).toBe('tab spaces');\n expect(normalizeText('newline\\n\\nspaces')).toBe('newline spaces');\n });\n\n it('should trim leading and trailing whitespace', () => {\n expect(normalizeText(' hello ')).toBe('hello');\n expect(normalizeText('\\t\\nhello\\t\\n')).toBe('hello');\n expect(normalizeText(' hello world ')).toBe('hello world');\n });\n });\n\n describe('comprehensive test cases', () => {\n it('should handle the basic greeting case', () => {\n expect(normalizeText('Hi, how can I help you today?')).toBe('hi how can i help you today');\n });\n\n it('should handle contractions and hyphens', () => {\n expect(normalizeText(\"I'm a well-trained assistant!\")).toBe(\"i'm a well-trained assistant\");\n });\n\n it('should remove various punctuation types', () => {\n expect(normalizeText('Hello!!! What??? Price: $19.99 (20% off).')).toBe(\n 'hello what price 1999 20 off',\n );\n });\n\n it('should handle multiple spaces', () => {\n expect(normalizeText('Multiple spaces here')).toBe('multiple spaces here');\n });\n\n it('should handle unicode characters', () => {\n expect(normalizeText('Café entrées naïve résumé')).toBe('café entrées naïve résumé');\n });\n\n it('should handle mixed punctuation and unicode', () => {\n expect(normalizeText('¿Cómo estás? ¡Muy bien!')).toBe('cómo estás muy bien');\n });\n });\n\n describe('edge cases', () => {\n it('should handle empty string', () => {\n expect(normalizeText('')).toBe('');\n });\n\n it('should handle whitespace-only string', () => {\n expect(normalizeText(' ')).toBe('');\n expect(normalizeText('\\t\\n ')).toBe('');\n });\n\n it('should handle punctuation-only string', () => {\n expect(normalizeText('!!!')).toBe('');\n expect(normalizeText('???')).toBe('');\n expect(normalizeText('...')).toBe('');\n });\n\n it('should handle mixed punctuation and preserved characters', () => {\n expect(normalizeText('!@#$%^&*()_+-={}[]|\\\\:;\"\\'<>?,./')).toBe(\"-'\");\n });\n\n it('should handle numbers with punctuation', () => {\n expect(normalizeText('$19.99')).toBe('1999');\n expect(normalizeText('(555) 123-4567')).toBe('555 123-4567');\n });\n\n it('should handle special unicode punctuation', () => {\n expect(normalizeText('Hello… world!')).toBe('hello world');\n expect(normalizeText('\"Quoted text\"')).toBe('quoted text');\n expect(normalizeText(\"'Single quotes'\")).toBe(\"'single quotes'\");\n });\n });\n\n describe('unicode normalization', () => {\n it('should apply NFKC normalization', () => {\n expect(normalizeText('café')).toBe('café');\n expect(normalizeText('naïve')).toBe('naïve');\n });\n\n it('should handle combining characters', () => {\n const eWithCombiningAcute = 'caf\\u0065\\u0301';\n const precomposedE = 'café';\n expect(normalizeText(eWithCombiningAcute)).toBe(normalizeText(precomposedE));\n });\n });\n\n describe('real-world examples', () => {\n it('should handle typical assistant responses', () => {\n expect(normalizeText('Hello! How can I assist you today?')).toBe(\n 'hello how can i assist you today',\n );\n expect(normalizeText(\"I'm here to help with any questions you might have.\")).toBe(\n \"i'm here to help with any questions you might have\",\n );\n });\n\n it('should handle typical user queries', () => {\n expect(normalizeText(\"What's the weather like?\")).toBe(\"what's the weather like\");\n expect(normalizeText('Can you help me with my order?')).toBe('can you help me with my order');\n expect(normalizeText('I need assistance, please!')).toBe('i need assistance please');\n });\n\n it('should handle incomplete sentences', () => {\n expect(normalizeText('What is the weather in')).toBe('what is the weather in');\n expect(normalizeText('I am looking for')).toBe('i am looking for');\n expect(normalizeText('Could you please')).toBe('could you please');\n });\n\n it('should handle multilingual text', () => {\n expect(normalizeText('Bonjour! Comment ça va?')).toBe('bonjour comment ça va');\n expect(normalizeText('¡Hola! ¿Cómo estás?')).toBe('hola cómo estás');\n expect(normalizeText('Guten Tag! Wie geht es Ihnen?')).toBe('guten tag wie geht es ihnen');\n });\n });\n});\n"],"mappings":";AAGA,oBAAqC;AACrC,mBAAkD;AAAA,IAElD,wBAAS,sBAAsB,MAAM;AACnC,wBAAG,2CAA2C,MAAM;AAClD,kCAAO,iCAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,kCAAO,iCAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,kCAAO,iCAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,kCAAO,iCAAmB,GAAG,CAAC,EAAE,K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AC;AAED,8BAAS,uBAAuB,MAAM;AACpC,0BAAG,6CAA6C,MAAM;AACpD,oCAAO,4BAAc,oCAAoC,CAAC,EAAE;AAAA,QAC1D;AAAA,MACF;AACA,oCAAO,4BAAc,qDAAqD,CAAC,EAAE;AAAA,QAC3E;AAAA,MACF;AAAA,IACF,CAAC;AAED,0BAAG,sCAAsC,MAAM;AAC7C,oCAAO,4BAAc,0BAA0B,CAAC,EAAE,KAAK,yBAAyB;AAChF,oCAAO,4BAAc,gCAAgC,CAAC,EAAE,KAAK,+BAA+B;AAC5F,oCAAO,4BAAc,4BAA4B,CAAC,EAAE,KAAK,0BAA0B;AAAA,IACrF,CAAC;AAED,0BAAG,sCAAsC,MAAM;AAC7C,oCAAO,4BAAc,wBAAwB,CAAC,EAAE,KAAK,wBAAwB;AAC7E,oCAAO,4BAAc,kBAAkB,CAAC,EAAE,KAAK,kBAAkB;AACjE,oCAAO,4BAAc,kBAAkB,CAAC,EAAE,KAAK,kBAAkB;AAAA,IACnE,CAAC;AAED,0BAAG,mCAAmC,MAAM;AAC1C,oCAAO,4BAAc,4BAAyB,CAAC,EAAE,KAAK,0BAAuB;AAC7E,oCAAO,4BAAc,iCAAqB,CAAC,EAAE,KAAK,uBAAiB;AACnE,oCAAO,4BAAc,+BAA+B,CAAC,EAAE,KAAK,6BAA6B;AAAA,IAC3F,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/turn_detector/utils.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,195 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { getUnicodeCategory, normalizeText } from "./utils.js";
3
+ describe("getUnicodeCategory", () => {
4
+ it("should identify basic ASCII punctuation", () => {
5
+ expect(getUnicodeCategory("!")).toBe("P");
6
+ expect(getUnicodeCategory('"')).toBe("P");
7
+ expect(getUnicodeCategory("#")).toBe("P");
8
+ expect(getUnicodeCategory("$")).toBe("P");
9
+ expect(getUnicodeCategory("%")).toBe("P");
10
+ expect(getUnicodeCategory("&")).toBe("P");
11
+ expect(getUnicodeCategory("'")).toBe("P");
12
+ expect(getUnicodeCategory("(")).toBe("P");
13
+ expect(getUnicodeCategory(")")).toBe("P");
14
+ expect(getUnicodeCategory("*")).toBe("P");
15
+ expect(getUnicodeCategory("+")).toBe("P");
16
+ expect(getUnicodeCategory(",")).toBe("P");
17
+ expect(getUnicodeCategory("-")).toBe("P");
18
+ expect(getUnicodeCategory(".")).toBe("P");
19
+ expect(getUnicodeCategory("/")).toBe("P");
20
+ });
21
+ it("should identify colon/semicolon punctuation", () => {
22
+ expect(getUnicodeCategory(":")).toBe("P");
23
+ expect(getUnicodeCategory(";")).toBe("P");
24
+ expect(getUnicodeCategory("<")).toBe("P");
25
+ expect(getUnicodeCategory("=")).toBe("P");
26
+ expect(getUnicodeCategory(">")).toBe("P");
27
+ expect(getUnicodeCategory("?")).toBe("P");
28
+ expect(getUnicodeCategory("@")).toBe("P");
29
+ });
30
+ it("should identify bracket punctuation", () => {
31
+ expect(getUnicodeCategory("[")).toBe("P");
32
+ expect(getUnicodeCategory("\\")).toBe("P");
33
+ expect(getUnicodeCategory("]")).toBe("P");
34
+ expect(getUnicodeCategory("^")).toBe("P");
35
+ expect(getUnicodeCategory("_")).toBe("P");
36
+ expect(getUnicodeCategory("`")).toBe("P");
37
+ });
38
+ it("should identify brace punctuation", () => {
39
+ expect(getUnicodeCategory("{")).toBe("P");
40
+ expect(getUnicodeCategory("|")).toBe("P");
41
+ expect(getUnicodeCategory("}")).toBe("P");
42
+ expect(getUnicodeCategory("~")).toBe("P");
43
+ });
44
+ it("should identify extended punctuation", () => {
45
+ expect(getUnicodeCategory("\xA1")).toBe("P");
46
+ expect(getUnicodeCategory("\xBF")).toBe("P");
47
+ expect(getUnicodeCategory("\xAB")).toBe("P");
48
+ expect(getUnicodeCategory("\xBB")).toBe("P");
49
+ });
50
+ it("should not identify letters as punctuation", () => {
51
+ expect(getUnicodeCategory("a")).toBe("");
52
+ expect(getUnicodeCategory("A")).toBe("");
53
+ expect(getUnicodeCategory("z")).toBe("");
54
+ expect(getUnicodeCategory("Z")).toBe("");
55
+ });
56
+ it("should not identify numbers as punctuation", () => {
57
+ expect(getUnicodeCategory("0")).toBe("");
58
+ expect(getUnicodeCategory("1")).toBe("");
59
+ expect(getUnicodeCategory("9")).toBe("");
60
+ });
61
+ it("should not identify whitespace as punctuation", () => {
62
+ expect(getUnicodeCategory(" ")).toBe("");
63
+ expect(getUnicodeCategory(" ")).toBe("");
64
+ expect(getUnicodeCategory("\n")).toBe("");
65
+ });
66
+ it("should handle empty string", () => {
67
+ expect(getUnicodeCategory("")).toBe("");
68
+ });
69
+ it("should handle unicode characters", () => {
70
+ expect(getUnicodeCategory("\xE9")).toBe("");
71
+ expect(getUnicodeCategory("\xF1")).toBe("");
72
+ expect(getUnicodeCategory("\xE7")).toBe("");
73
+ });
74
+ });
75
+ describe("normalizeText", () => {
76
+ describe("basic functionality", () => {
77
+ it("should convert to lowercase", () => {
78
+ expect(normalizeText("HELLO")).toBe("hello");
79
+ expect(normalizeText("HeLLo")).toBe("hello");
80
+ expect(normalizeText("WORLD")).toBe("world");
81
+ });
82
+ it("should remove basic punctuation", () => {
83
+ expect(normalizeText("Hello!")).toBe("hello");
84
+ expect(normalizeText("Hello?")).toBe("hello");
85
+ expect(normalizeText("Hello.")).toBe("hello");
86
+ expect(normalizeText("Hello,")).toBe("hello");
87
+ });
88
+ it("should preserve apostrophes", () => {
89
+ expect(normalizeText("I'm happy")).toBe("i'm happy");
90
+ expect(normalizeText("don't worry")).toBe("don't worry");
91
+ expect(normalizeText("it's great")).toBe("it's great");
92
+ });
93
+ it("should preserve hyphens", () => {
94
+ expect(normalizeText("well-trained")).toBe("well-trained");
95
+ expect(normalizeText("state-of-the-art")).toBe("state-of-the-art");
96
+ expect(normalizeText("co-worker")).toBe("co-worker");
97
+ });
98
+ it("should collapse multiple whitespace", () => {
99
+ expect(normalizeText("hello world")).toBe("hello world");
100
+ expect(normalizeText("multiple spaces here")).toBe("multiple spaces here");
101
+ expect(normalizeText("tab spaces")).toBe("tab spaces");
102
+ expect(normalizeText("newline\n\nspaces")).toBe("newline spaces");
103
+ });
104
+ it("should trim leading and trailing whitespace", () => {
105
+ expect(normalizeText(" hello ")).toBe("hello");
106
+ expect(normalizeText(" \nhello \n")).toBe("hello");
107
+ expect(normalizeText(" hello world ")).toBe("hello world");
108
+ });
109
+ });
110
+ describe("comprehensive test cases", () => {
111
+ it("should handle the basic greeting case", () => {
112
+ expect(normalizeText("Hi, how can I help you today?")).toBe("hi how can i help you today");
113
+ });
114
+ it("should handle contractions and hyphens", () => {
115
+ expect(normalizeText("I'm a well-trained assistant!")).toBe("i'm a well-trained assistant");
116
+ });
117
+ it("should remove various punctuation types", () => {
118
+ expect(normalizeText("Hello!!! What??? Price: $19.99 (20% off).")).toBe(
119
+ "hello what price 1999 20 off"
120
+ );
121
+ });
122
+ it("should handle multiple spaces", () => {
123
+ expect(normalizeText("Multiple spaces here")).toBe("multiple spaces here");
124
+ });
125
+ it("should handle unicode characters", () => {
126
+ expect(normalizeText("Caf\xE9 entr\xE9es na\xEFve r\xE9sum\xE9")).toBe("caf\xE9 entr\xE9es na\xEFve r\xE9sum\xE9");
127
+ });
128
+ it("should handle mixed punctuation and unicode", () => {
129
+ expect(normalizeText("\xBFC\xF3mo est\xE1s? \xA1Muy bien!")).toBe("c\xF3mo est\xE1s muy bien");
130
+ });
131
+ });
132
+ describe("edge cases", () => {
133
+ it("should handle empty string", () => {
134
+ expect(normalizeText("")).toBe("");
135
+ });
136
+ it("should handle whitespace-only string", () => {
137
+ expect(normalizeText(" ")).toBe("");
138
+ expect(normalizeText(" \n ")).toBe("");
139
+ });
140
+ it("should handle punctuation-only string", () => {
141
+ expect(normalizeText("!!!")).toBe("");
142
+ expect(normalizeText("???")).toBe("");
143
+ expect(normalizeText("...")).toBe("");
144
+ });
145
+ it("should handle mixed punctuation and preserved characters", () => {
146
+ expect(normalizeText(`!@#$%^&*()_+-={}[]|\\:;"'<>?,./`)).toBe("-'");
147
+ });
148
+ it("should handle numbers with punctuation", () => {
149
+ expect(normalizeText("$19.99")).toBe("1999");
150
+ expect(normalizeText("(555) 123-4567")).toBe("555 123-4567");
151
+ });
152
+ it("should handle special unicode punctuation", () => {
153
+ expect(normalizeText("Hello\u2026 world!")).toBe("hello world");
154
+ expect(normalizeText('"Quoted text"')).toBe("quoted text");
155
+ expect(normalizeText("'Single quotes'")).toBe("'single quotes'");
156
+ });
157
+ });
158
+ describe("unicode normalization", () => {
159
+ it("should apply NFKC normalization", () => {
160
+ expect(normalizeText("caf\xE9")).toBe("caf\xE9");
161
+ expect(normalizeText("na\xEFve")).toBe("na\xEFve");
162
+ });
163
+ it("should handle combining characters", () => {
164
+ const eWithCombiningAcute = "cafe\u0301";
165
+ const precomposedE = "caf\xE9";
166
+ expect(normalizeText(eWithCombiningAcute)).toBe(normalizeText(precomposedE));
167
+ });
168
+ });
169
+ describe("real-world examples", () => {
170
+ it("should handle typical assistant responses", () => {
171
+ expect(normalizeText("Hello! How can I assist you today?")).toBe(
172
+ "hello how can i assist you today"
173
+ );
174
+ expect(normalizeText("I'm here to help with any questions you might have.")).toBe(
175
+ "i'm here to help with any questions you might have"
176
+ );
177
+ });
178
+ it("should handle typical user queries", () => {
179
+ expect(normalizeText("What's the weather like?")).toBe("what's the weather like");
180
+ expect(normalizeText("Can you help me with my order?")).toBe("can you help me with my order");
181
+ expect(normalizeText("I need assistance, please!")).toBe("i need assistance please");
182
+ });
183
+ it("should handle incomplete sentences", () => {
184
+ expect(normalizeText("What is the weather in")).toBe("what is the weather in");
185
+ expect(normalizeText("I am looking for")).toBe("i am looking for");
186
+ expect(normalizeText("Could you please")).toBe("could you please");
187
+ });
188
+ it("should handle multilingual text", () => {
189
+ expect(normalizeText("Bonjour! Comment \xE7a va?")).toBe("bonjour comment \xE7a va");
190
+ expect(normalizeText("\xA1Hola! \xBFC\xF3mo est\xE1s?")).toBe("hola c\xF3mo est\xE1s");
191
+ expect(normalizeText("Guten Tag! Wie geht es Ihnen?")).toBe("guten tag wie geht es ihnen");
192
+ });
193
+ });
194
+ });
195
+ //# sourceMappingURL=utils.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/turn_detector/utils.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { describe, expect, it } from 'vitest';\nimport { getUnicodeCategory, normalizeText } from './utils.js';\n\ndescribe('getUnicodeCategory', () => {\n it('should identify basic ASCII punctuation', () => {\n expect(getUnicodeCategory('!')).toBe('P');\n expect(getUnicodeCategory('\"')).toBe('P');\n expect(getUnicodeCategory('#')).toBe('P');\n expect(getUnicodeCategory('$')).toBe('P');\n expect(getUnicodeCategory('%')).toBe('P');\n expect(getUnicodeCategory('&')).toBe('P');\n expect(getUnicodeCategory(\"'\")).toBe('P');\n expect(getUnicodeCategory('(')).toBe('P');\n expect(getUnicodeCategory(')')).toBe('P');\n expect(getUnicodeCategory('*')).toBe('P');\n expect(getUnicodeCategory('+')).toBe('P');\n expect(getUnicodeCategory(',')).toBe('P');\n expect(getUnicodeCategory('-')).toBe('P');\n expect(getUnicodeCategory('.')).toBe('P');\n expect(getUnicodeCategory('/')).toBe('P');\n });\n\n it('should identify colon/semicolon punctuation', () => {\n expect(getUnicodeCategory(':')).toBe('P');\n expect(getUnicodeCategory(';')).toBe('P');\n expect(getUnicodeCategory('<')).toBe('P');\n expect(getUnicodeCategory('=')).toBe('P');\n expect(getUnicodeCategory('>')).toBe('P');\n expect(getUnicodeCategory('?')).toBe('P');\n expect(getUnicodeCategory('@')).toBe('P');\n });\n\n it('should identify bracket punctuation', () => {\n expect(getUnicodeCategory('[')).toBe('P');\n expect(getUnicodeCategory('\\\\')).toBe('P');\n expect(getUnicodeCategory(']')).toBe('P');\n expect(getUnicodeCategory('^')).toBe('P');\n expect(getUnicodeCategory('_')).toBe('P');\n expect(getUnicodeCategory('`')).toBe('P');\n });\n\n it('should identify brace punctuation', () => {\n expect(getUnicodeCategory('{')).toBe('P');\n expect(getUnicodeCategory('|')).toBe('P');\n expect(getUnicodeCategory('}')).toBe('P');\n expect(getUnicodeCategory('~')).toBe('P');\n });\n\n it('should identify extended punctuation', () => {\n expect(getUnicodeCategory('¡')).toBe('P');\n expect(getUnicodeCategory('¿')).toBe('P');\n expect(getUnicodeCategory('«')).toBe('P');\n expect(getUnicodeCategory('»')).toBe('P');\n });\n\n it('should not identify letters as punctuation', () => {\n expect(getUnicodeCategory('a')).toBe('');\n expect(getUnicodeCategory('A')).toBe('');\n expect(getUnicodeCategory('z')).toBe('');\n expect(getUnicodeCategory('Z')).toBe('');\n });\n\n it('should not identify numbers as punctuation', () => {\n expect(getUnicodeCategory('0')).toBe('');\n expect(getUnicodeCategory('1')).toBe('');\n expect(getUnicodeCategory('9')).toBe('');\n });\n\n it('should not identify whitespace as punctuation', () => {\n expect(getUnicodeCategory(' ')).toBe('');\n expect(getUnicodeCategory('\\t')).toBe('');\n expect(getUnicodeCategory('\\n')).toBe('');\n });\n\n it('should handle empty string', () => {\n expect(getUnicodeCategory('')).toBe('');\n });\n\n it('should handle unicode characters', () => {\n expect(getUnicodeCategory('é')).toBe('');\n expect(getUnicodeCategory('ñ')).toBe('');\n expect(getUnicodeCategory('ç')).toBe('');\n });\n});\n\ndescribe('normalizeText', () => {\n describe('basic functionality', () => {\n it('should convert to lowercase', () => {\n expect(normalizeText('HELLO')).toBe('hello');\n expect(normalizeText('HeLLo')).toBe('hello');\n expect(normalizeText('WORLD')).toBe('world');\n });\n\n it('should remove basic punctuation', () => {\n expect(normalizeText('Hello!')).toBe('hello');\n expect(normalizeText('Hello?')).toBe('hello');\n expect(normalizeText('Hello.')).toBe('hello');\n expect(normalizeText('Hello,')).toBe('hello');\n });\n\n it('should preserve apostrophes', () => {\n expect(normalizeText(\"I'm happy\")).toBe(\"i'm happy\");\n expect(normalizeText(\"don't worry\")).toBe(\"don't worry\");\n expect(normalizeText(\"it's great\")).toBe(\"it's great\");\n });\n\n it('should preserve hyphens', () => {\n expect(normalizeText('well-trained')).toBe('well-trained');\n expect(normalizeText('state-of-the-art')).toBe('state-of-the-art');\n expect(normalizeText('co-worker')).toBe('co-worker');\n });\n\n it('should collapse multiple whitespace', () => {\n expect(normalizeText('hello world')).toBe('hello world');\n expect(normalizeText('multiple spaces here')).toBe('multiple spaces here');\n expect(normalizeText('tab\\t\\tspaces')).toBe('tab spaces');\n expect(normalizeText('newline\\n\\nspaces')).toBe('newline spaces');\n });\n\n it('should trim leading and trailing whitespace', () => {\n expect(normalizeText(' hello ')).toBe('hello');\n expect(normalizeText('\\t\\nhello\\t\\n')).toBe('hello');\n expect(normalizeText(' hello world ')).toBe('hello world');\n });\n });\n\n describe('comprehensive test cases', () => {\n it('should handle the basic greeting case', () => {\n expect(normalizeText('Hi, how can I help you today?')).toBe('hi how can i help you today');\n });\n\n it('should handle contractions and hyphens', () => {\n expect(normalizeText(\"I'm a well-trained assistant!\")).toBe(\"i'm a well-trained assistant\");\n });\n\n it('should remove various punctuation types', () => {\n expect(normalizeText('Hello!!! What??? Price: $19.99 (20% off).')).toBe(\n 'hello what price 1999 20 off',\n );\n });\n\n it('should handle multiple spaces', () => {\n expect(normalizeText('Multiple spaces here')).toBe('multiple spaces here');\n });\n\n it('should handle unicode characters', () => {\n expect(normalizeText('Café entrées naïve résumé')).toBe('café entrées naïve résumé');\n });\n\n it('should handle mixed punctuation and unicode', () => {\n expect(normalizeText('¿Cómo estás? ¡Muy bien!')).toBe('cómo estás muy bien');\n });\n });\n\n describe('edge cases', () => {\n it('should handle empty string', () => {\n expect(normalizeText('')).toBe('');\n });\n\n it('should handle whitespace-only string', () => {\n expect(normalizeText(' ')).toBe('');\n expect(normalizeText('\\t\\n ')).toBe('');\n });\n\n it('should handle punctuation-only string', () => {\n expect(normalizeText('!!!')).toBe('');\n expect(normalizeText('???')).toBe('');\n expect(normalizeText('...')).toBe('');\n });\n\n it('should handle mixed punctuation and preserved characters', () => {\n expect(normalizeText('!@#$%^&*()_+-={}[]|\\\\:;\"\\'<>?,./')).toBe(\"-'\");\n });\n\n it('should handle numbers with punctuation', () => {\n expect(normalizeText('$19.99')).toBe('1999');\n expect(normalizeText('(555) 123-4567')).toBe('555 123-4567');\n });\n\n it('should handle special unicode punctuation', () => {\n expect(normalizeText('Hello… world!')).toBe('hello world');\n expect(normalizeText('\"Quoted text\"')).toBe('quoted text');\n expect(normalizeText(\"'Single quotes'\")).toBe(\"'single quotes'\");\n });\n });\n\n describe('unicode normalization', () => {\n it('should apply NFKC normalization', () => {\n expect(normalizeText('café')).toBe('café');\n expect(normalizeText('naïve')).toBe('naïve');\n });\n\n it('should handle combining characters', () => {\n const eWithCombiningAcute = 'caf\\u0065\\u0301';\n const precomposedE = 'café';\n expect(normalizeText(eWithCombiningAcute)).toBe(normalizeText(precomposedE));\n });\n });\n\n describe('real-world examples', () => {\n it('should handle typical assistant responses', () => {\n expect(normalizeText('Hello! How can I assist you today?')).toBe(\n 'hello how can i assist you today',\n );\n expect(normalizeText(\"I'm here to help with any questions you might have.\")).toBe(\n \"i'm here to help with any questions you might have\",\n );\n });\n\n it('should handle typical user queries', () => {\n expect(normalizeText(\"What's the weather like?\")).toBe(\"what's the weather like\");\n expect(normalizeText('Can you help me with my order?')).toBe('can you help me with my order');\n expect(normalizeText('I need assistance, please!')).toBe('i need assistance please');\n });\n\n it('should handle incomplete sentences', () => {\n expect(normalizeText('What is the weather in')).toBe('what is the weather in');\n expect(normalizeText('I am looking for')).toBe('i am looking for');\n expect(normalizeText('Could you please')).toBe('could you please');\n });\n\n it('should handle multilingual text', () => {\n expect(normalizeText('Bonjour! Comment ça va?')).toBe('bonjour comment ça va');\n expect(normalizeText('¡Hola! ¿Cómo estás?')).toBe('hola cómo estás');\n expect(normalizeText('Guten Tag! Wie geht es Ihnen?')).toBe('guten tag wie geht es ihnen');\n });\n });\n});\n"],"mappings":"AAGA,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,oBAAoB,qBAAqB;AAElD,SAAS,sBAAsB,MAAM;AACnC,KAAG,2CAA2C,MAAM;AAClD,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AAAA,EAC1C,CAAC;AAED,KAAG,+CAA+C,MAAM;AACtD,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,CAAC,EAAE,KAAK,GAAG;AACxC,WAAO,mBAAmB,GAAG,C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AAK,SAAM;AACzC,aAAO,cAAc,UAAO,CAAC,EAAE,KAAK,UAAO;AAAA,IAC7C,CAAC;AAED,OAAG,sCAAsC,MAAM;AAC7C,YAAM,sBAAsB;AAC5B,YAAM,eAAe;AACrB,aAAO,cAAc,mBAAmB,CAAC,EAAE,KAAK,cAAc,YAAY,CAAC;AAAA,IAC7E,CAAC;AAAA,EACH,CAAC;AAED,WAAS,uBAAuB,MAAM;AACpC,OAAG,6CAA6C,MAAM;AACpD,aAAO,cAAc,oCAAoC,CAAC,EAAE;AAAA,QAC1D;AAAA,MACF;AACA,aAAO,cAAc,qDAAqD,CAAC,EAAE;AAAA,QAC3E;AAAA,MACF;AAAA,IACF,CAAC;AAED,OAAG,sCAAsC,MAAM;AAC7C,aAAO,cAAc,0BAA0B,CAAC,EAAE,KAAK,yBAAyB;AAChF,aAAO,cAAc,gCAAgC,CAAC,EAAE,KAAK,+BAA+B;AAC5F,aAAO,cAAc,4BAA4B,CAAC,EAAE,KAAK,0BAA0B;AAAA,IACrF,CAAC;AAED,OAAG,sCAAsC,MAAM;AAC7C,aAAO,cAAc,wBAAwB,CAAC,EAAE,KAAK,wBAAwB;AAC7E,aAAO,cAAc,kBAAkB,CAAC,EAAE,KAAK,kBAAkB;AACjE,aAAO,cAAc,kBAAkB,CAAC,EAAE,KAAK,kBAAkB;AAAA,IACnE,CAAC;AAED,OAAG,mCAAmC,MAAM;AAC1C,aAAO,cAAc,4BAAyB,CAAC,EAAE,KAAK,0BAAuB;AAC7E,aAAO,cAAc,iCAAqB,CAAC,EAAE,KAAK,uBAAiB;AACnE,aAAO,cAAc,+BAA+B,CAAC,EAAE,KAAK,6BAA6B;AAAA,IAC3F,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livekit/agents-plugin-livekit",
3
- "version": "0.1.2",
3
+ "version": "1.0.0-next.0",
4
4
  "description": "Additional utilities for LiveKit Node Agents",
5
5
  "main": "dist/index.js",
6
6
  "require": "dist/index.cjs",
@@ -25,21 +25,22 @@
25
25
  "README.md"
26
26
  ],
27
27
  "devDependencies": {
28
- "@livekit/agents": "^x",
28
+ "@livekit/agents": "^1.0.0-next.0",
29
29
  "@microsoft/api-extractor": "^7.35.0",
30
- "onnxruntime-common": "^1.19.2",
30
+ "onnxruntime-common": ">=1.19.0 <1.22.0",
31
31
  "tsup": "^8.3.5",
32
32
  "typescript": "^5.0.0"
33
33
  },
34
34
  "peerDependencies": {
35
- "@livekit/agents": "^0.7.7x"
35
+ "@livekit/agents": "^1.0.0-next.01.0.0-next.0"
36
36
  },
37
37
  "dependencies": {
38
+ "@huggingface/hub": "^2.4.0",
38
39
  "@huggingface/transformers": "^3.2.1",
39
- "onnxruntime-node": "^1.19.2"
40
+ "onnxruntime-node": ">=1.19.2 <1.22.0"
40
41
  },
41
42
  "scripts": {
42
- "build": "tsup --onSuccess \"pnpm build:types\" && cp src/turn_detector.onnx dist/",
43
+ "build": "tsup --onSuccess \"pnpm build:types\"",
43
44
  "build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
44
45
  "clean": "rm -rf dist",
45
46
  "clean:build": "pnpm clean && pnpm build",