@pellux/goodvibes-agent 1.5.9 → 1.6.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/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/package/main.js +11310 -4960
- package/docs/README.md +1 -1
- package/docs/voice-and-live-tts.md +47 -0
- package/package.json +2 -2
- package/src/agent/memory-prompt.ts +12 -1
- package/src/agent/prompt-context-receipts.ts +71 -6
- package/src/agent/vibe-file.ts +9 -5
- package/src/audio/spoken-turn-wiring.ts +3 -2
- package/src/cli/memory-command-wire.ts +373 -0
- package/src/cli/memory-command.ts +31 -22
- package/src/runtime/bootstrap-core.ts +2 -2
- package/src/runtime/bootstrap.ts +68 -0
- package/src/runtime/memory-spine-adoption.ts +50 -0
- package/src/runtime/memory-spine-rest-transport.ts +327 -0
- package/src/runtime/services.ts +33 -0
- package/src/tools/agent-local-registry-memory.ts +42 -11
- package/src/tools/agent-local-registry-tool.ts +5 -4
- package/src/version.ts +1 -1
- package/src/audio/spoken-turn-controller.ts +0 -455
- package/src/audio/text-chunker.ts +0 -110
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
export interface TtsTextChunkerOptions {
|
|
2
|
-
readonly minBoundaryChars?: number;
|
|
3
|
-
readonly maxChunkChars?: number;
|
|
4
|
-
readonly maxLatencyMs?: number;
|
|
5
|
-
readonly now?: () => number;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class TtsTextChunker {
|
|
9
|
-
private buffer = '';
|
|
10
|
-
private firstBufferedAt: number | null = null;
|
|
11
|
-
private readonly minBoundaryChars: number;
|
|
12
|
-
private readonly maxChunkChars: number;
|
|
13
|
-
private readonly maxLatencyMs: number;
|
|
14
|
-
private readonly now: () => number;
|
|
15
|
-
|
|
16
|
-
constructor(options: TtsTextChunkerOptions = {}) {
|
|
17
|
-
this.minBoundaryChars = options.minBoundaryChars ?? 24;
|
|
18
|
-
this.maxChunkChars = options.maxChunkChars ?? 320;
|
|
19
|
-
this.maxLatencyMs = options.maxLatencyMs ?? 1_000;
|
|
20
|
-
this.now = options.now ?? (() => Date.now());
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
push(delta: string): string[] {
|
|
24
|
-
if (!delta) return [];
|
|
25
|
-
if (this.firstBufferedAt === null) this.firstBufferedAt = this.now();
|
|
26
|
-
this.buffer += delta;
|
|
27
|
-
return this.drainReady(false);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
flushDue(): string[] {
|
|
31
|
-
if (!this.buffer.trim() || this.firstBufferedAt === null) return [];
|
|
32
|
-
if (this.now() - this.firstBufferedAt < this.maxLatencyMs) return [];
|
|
33
|
-
return this.drainReady(true);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
flushAll(): string[] {
|
|
37
|
-
if (!this.buffer.trim()) {
|
|
38
|
-
this.buffer = '';
|
|
39
|
-
this.firstBufferedAt = null;
|
|
40
|
-
return [];
|
|
41
|
-
}
|
|
42
|
-
return [this.takeChunk(this.buffer.length)].filter(Boolean);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
reset(): void {
|
|
46
|
-
this.buffer = '';
|
|
47
|
-
this.firstBufferedAt = null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
private drainReady(forceLatencyFlush: boolean): string[] {
|
|
51
|
-
const chunks: string[] = [];
|
|
52
|
-
while (this.buffer.trim()) {
|
|
53
|
-
const boundary = this.findBoundary(forceLatencyFlush);
|
|
54
|
-
if (boundary <= 0) break;
|
|
55
|
-
const chunk = this.takeChunk(boundary);
|
|
56
|
-
if (chunk) chunks.push(chunk);
|
|
57
|
-
forceLatencyFlush = false;
|
|
58
|
-
}
|
|
59
|
-
return chunks;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private findBoundary(forceLatencyFlush: boolean): number {
|
|
63
|
-
const latestSentence = this.findLatestSentenceBoundary();
|
|
64
|
-
if (latestSentence >= this.minBoundaryChars) return latestSentence;
|
|
65
|
-
|
|
66
|
-
if (this.buffer.length >= this.maxChunkChars) {
|
|
67
|
-
return this.findWordBoundaryBefore(this.maxChunkChars) || this.maxChunkChars;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (forceLatencyFlush) {
|
|
71
|
-
return this.buffer.length;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return -1;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private findLatestSentenceBoundary(): number {
|
|
78
|
-
let best = -1;
|
|
79
|
-
for (let i = 0; i < this.buffer.length; i++) {
|
|
80
|
-
const char = this.buffer[i];
|
|
81
|
-
if (char !== '.' && char !== '!' && char !== '?' && char !== ';' && char !== ':' && char !== '\n') {
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
const next = this.buffer[i + 1];
|
|
85
|
-
if (i === this.buffer.length - 1 || next === undefined || /\s/.test(next)) {
|
|
86
|
-
best = i + 1;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return best;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private findWordBoundaryBefore(index: number): number {
|
|
93
|
-
const max = Math.min(index, this.buffer.length);
|
|
94
|
-
for (let i = max; i > 0; i--) {
|
|
95
|
-
if (/\s/.test(this.buffer[i - 1] ?? '')) return i;
|
|
96
|
-
}
|
|
97
|
-
return -1;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private takeChunk(end: number): string {
|
|
101
|
-
const raw = this.buffer.slice(0, end);
|
|
102
|
-
this.buffer = this.buffer.slice(end);
|
|
103
|
-
this.firstBufferedAt = this.buffer.trim() ? this.now() : null;
|
|
104
|
-
return normalizeSpeechText(raw);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function normalizeSpeechText(text: string): string {
|
|
109
|
-
return text.replace(/\s+/g, ' ').trim();
|
|
110
|
-
}
|