@kuralle-syrinx/core 4.2.0 → 4.3.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.
- package/package.json +2 -2
- package/src/audio/alaw.ts +56 -0
- package/src/audio/g722.ts +329 -0
- package/src/audio/index.ts +12 -0
- package/src/audio/loudness.ts +87 -0
- package/src/idle-timeout.ts +1 -0
- package/src/index.ts +63 -3
- package/src/interaction-policy.ts +12 -0
- package/src/observability-observer.ts +8 -4
- package/src/observability.ts +30 -1
- package/src/packet-factories.ts +110 -2
- package/src/packets.ts +116 -1
- package/src/plugin-contract.ts +41 -0
- package/src/policies/rule-based.ts +17 -2
- package/src/pricing.ts +137 -0
- package/src/primary-speaker-gate.ts +23 -3
- package/src/reasoner.ts +28 -1
- package/src/spend-cap.ts +52 -0
- package/src/turn-arbiter.ts +34 -2
- package/src/voice-agent-session.ts +453 -34
- package/src/voice-text.ts +69 -0
- package/src/audio/audio.test.ts +0 -285
- package/src/audio-envelope.test.ts +0 -167
- package/src/confidence-to-wait.test.ts +0 -21
- package/src/error-handler.test.ts +0 -56
- package/src/hedge-throwing-backend.test.ts +0 -46
- package/src/interaction-coordinator.test.ts +0 -425
- package/src/iu-ledger.test.ts +0 -276
- package/src/latency-filler.test.ts +0 -62
- package/src/observability-observer.test.ts +0 -245
- package/src/observability.test.ts +0 -85
- package/src/packet-factories.test.ts +0 -53
- package/src/pipeline-bus.g10.test.ts +0 -145
- package/src/pipeline-bus.test.ts +0 -211
- package/src/policies/defer.test.ts +0 -86
- package/src/policies/rule-based.test.ts +0 -269
- package/src/primary-speaker-gate.test.ts +0 -150
- package/src/provider-fallback.test.ts +0 -87
- package/src/reasoner-hedge.test.ts +0 -361
- package/src/reasoner-route.test.ts +0 -248
- package/src/reasoner.test.ts +0 -69
- package/src/retry.test.ts +0 -83
- package/src/route-throwing-spec.test.ts +0 -44
- package/src/tts-playout-clock.test.ts +0 -125
- package/src/turn-arbiter.characterization.test.ts +0 -477
- package/src/turn-arbiter.test.ts +0 -567
- package/src/voice-agent-session.test.ts +0 -3316
- package/src/voice-text.test.ts +0 -94
- package/tsconfig.json +0 -21
package/src/voice-text.test.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
import { describe, expect, it } from "vitest";
|
|
4
|
-
import { takeCompleteVoiceText, isCompleteVoiceText, appendVoiceText } from "./voice-text.js";
|
|
5
|
-
|
|
6
|
-
describe("isCompleteVoiceText", () => {
|
|
7
|
-
it("treats terminal punctuation as complete", () => {
|
|
8
|
-
expect(isCompleteVoiceText("Hello there.")).toBe(true);
|
|
9
|
-
expect(isCompleteVoiceText("Really?!")).toBe(true);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("treats an unterminated fragment as incomplete", () => {
|
|
13
|
-
expect(isCompleteVoiceText("Hello there")).toBe(false);
|
|
14
|
-
expect(isCompleteVoiceText("and then we")).toBe(false);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("looks past trailing closing quotes/brackets to the terminator", () => {
|
|
18
|
-
expect(isCompleteVoiceText('She said "hi."')).toBe(true);
|
|
19
|
-
expect(isCompleteVoiceText("(a complete aside.)")).toBe(true);
|
|
20
|
-
expect(isCompleteVoiceText('an open quote "')).toBe(false);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("recognizes non-English terminal punctuation", () => {
|
|
24
|
-
expect(isCompleteVoiceText("こんにちは。")).toBe(true); // Japanese full stop
|
|
25
|
-
expect(isCompleteVoiceText("مرحبا؟")).toBe(true); // Arabic question mark
|
|
26
|
-
expect(isCompleteVoiceText("नमस्ते।")).toBe(true); // Devanagari danda
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("does not treat abbreviation or decimal dots as sentence ends", () => {
|
|
30
|
-
// These would otherwise be voiced with a falling intonation and split from
|
|
31
|
-
// their continuation ("Dr." | "Smith", "twelve." | "fifty").
|
|
32
|
-
expect(isCompleteVoiceText("Dr.")).toBe(false);
|
|
33
|
-
expect(isCompleteVoiceText("e.g.")).toBe(false);
|
|
34
|
-
expect(isCompleteVoiceText("The total is $12.")).toBe(false);
|
|
35
|
-
expect(isCompleteVoiceText("Meet at 3 p.m.")).toBe(false);
|
|
36
|
-
expect(isCompleteVoiceText("His name is J.")).toBe(false);
|
|
37
|
-
// But a real sentence end after an abbreviation earlier in the text is fine.
|
|
38
|
-
expect(isCompleteVoiceText("Dr. Smith will see you now.")).toBe(true);
|
|
39
|
-
expect(isCompleteVoiceText("The total is $12.50 today.")).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe("takeCompleteVoiceText", () => {
|
|
44
|
-
it("splits leading complete sentences from the incomplete remainder", () => {
|
|
45
|
-
const { text, remaining } = takeCompleteVoiceText("One. Two. Thre");
|
|
46
|
-
expect(text).toBe("One. Two.");
|
|
47
|
-
expect(remaining).toBe("Thre");
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("returns no text when nothing is complete yet", () => {
|
|
51
|
-
const { text, remaining } = takeCompleteVoiceText("still going");
|
|
52
|
-
expect(text).toBe("");
|
|
53
|
-
expect(remaining).toBe("still going");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("emits multiple complete sentences and buffers only the trailing fragment", () => {
|
|
57
|
-
const { text, remaining } = takeCompleteVoiceText("Done. And more.");
|
|
58
|
-
expect(text).toBe("Done. And more.");
|
|
59
|
-
expect(remaining).toBe("");
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("buffers the trailing incomplete fragment after a complete sentence", () => {
|
|
63
|
-
// Capitalized continuation so the locale-aware segmenter treats it as a new
|
|
64
|
-
// (still-incomplete) sentence rather than one run-on.
|
|
65
|
-
const { text, remaining } = takeCompleteVoiceText("Done. And more");
|
|
66
|
-
expect(text).toBe("Done.");
|
|
67
|
-
expect(remaining).toBe("And more");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
describe("appendVoiceText", () => {
|
|
72
|
-
it("seeds from empty and trims", () => {
|
|
73
|
-
expect(appendVoiceText("", " hi ")).toBe("hi");
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it("joins with a single space when neither side has whitespace at the seam", () => {
|
|
77
|
-
expect(appendVoiceText("Hello", "there")).toBe("Hello there");
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it("does not double-space when the existing side already ends in whitespace", () => {
|
|
81
|
-
expect(appendVoiceText("Hello ", "there")).toBe("Hello there");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("trims a whitespace-led next fragment (the seam's space collapses)", () => {
|
|
85
|
-
// Current behavior: a leading-whitespace `next` is trimmed and concatenated
|
|
86
|
-
// directly. Reachable inputs (trimmed segment text) never hit this path; the
|
|
87
|
-
// test pins the documented behavior rather than the intuitive one.
|
|
88
|
-
expect(appendVoiceText("Hello", " there")).toBe("Hellothere");
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("returns the existing text unchanged when the next fragment is blank", () => {
|
|
92
|
-
expect(appendVoiceText("Hello", " ")).toBe("Hello");
|
|
93
|
-
});
|
|
94
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"lib": ["ES2022"],
|
|
7
|
-
"strict": true,
|
|
8
|
-
"noUncheckedIndexedAccess": true,
|
|
9
|
-
"noImplicitReturns": true,
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"declarationMap": true,
|
|
12
|
-
"sourceMap": true,
|
|
13
|
-
"outDir": "./dist",
|
|
14
|
-
"rootDir": "./src",
|
|
15
|
-
"esModuleInterop": true,
|
|
16
|
-
"skipLibCheck": true,
|
|
17
|
-
"forceConsistentCasingInFileNames": true
|
|
18
|
-
},
|
|
19
|
-
"include": ["src/**/*.ts"],
|
|
20
|
-
"exclude": ["node_modules", "dist"]
|
|
21
|
-
}
|