@framers/agentos 0.13.3 → 0.13.4
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/dist/cognition/emergent/EffectsStore.d.ts +6 -1
- package/dist/cognition/emergent/EffectsStore.d.ts.map +1 -1
- package/dist/cognition/emergent/EffectsStore.js.map +1 -1
- package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts +8 -0
- package/dist/cognition/emergent/EmergentCapabilityEngine.d.ts.map +1 -1
- package/dist/cognition/emergent/EmergentCapabilityEngine.js +84 -9
- package/dist/cognition/emergent/EmergentCapabilityEngine.js.map +1 -1
- package/dist/cognition/emergent/EmergentJudge.d.ts.map +1 -1
- package/dist/cognition/emergent/EmergentJudge.js +8 -1
- package/dist/cognition/emergent/EmergentJudge.js.map +1 -1
- package/dist/cognition/emergent/ForgeToolMetaTool.d.ts +2 -1
- package/dist/cognition/emergent/ForgeToolMetaTool.d.ts.map +1 -1
- package/dist/cognition/emergent/ForgeToolMetaTool.js +27 -4
- package/dist/cognition/emergent/ForgeToolMetaTool.js.map +1 -1
- package/dist/cognition/emergent/SandboxedToolForge.d.ts +7 -3
- package/dist/cognition/emergent/SandboxedToolForge.d.ts.map +1 -1
- package/dist/cognition/emergent/SandboxedToolForge.js +21 -8
- package/dist/cognition/emergent/SandboxedToolForge.js.map +1 -1
- package/dist/cognition/emergent/broker/CapabilityBroker.d.ts +56 -18
- package/dist/cognition/emergent/broker/CapabilityBroker.d.ts.map +1 -1
- package/dist/cognition/emergent/broker/CapabilityBroker.js +309 -47
- package/dist/cognition/emergent/broker/CapabilityBroker.js.map +1 -1
- package/dist/cognition/emergent/broker/dry-run.d.ts +39 -0
- package/dist/cognition/emergent/broker/dry-run.d.ts.map +1 -0
- package/dist/cognition/emergent/broker/dry-run.js +88 -0
- package/dist/cognition/emergent/broker/dry-run.js.map +1 -0
- package/dist/cognition/emergent/broker/fetch.d.ts +30 -7
- package/dist/cognition/emergent/broker/fetch.d.ts.map +1 -1
- package/dist/cognition/emergent/broker/fetch.js +69 -9
- package/dist/cognition/emergent/broker/fetch.js.map +1 -1
- package/dist/cognition/emergent/broker/fs-write.d.ts +73 -0
- package/dist/cognition/emergent/broker/fs-write.d.ts.map +1 -0
- package/dist/cognition/emergent/broker/fs-write.js +268 -0
- package/dist/cognition/emergent/broker/fs-write.js.map +1 -0
- package/dist/cognition/emergent/broker/protected.d.ts +19 -0
- package/dist/cognition/emergent/broker/protected.d.ts.map +1 -0
- package/dist/cognition/emergent/broker/protected.js +89 -0
- package/dist/cognition/emergent/broker/protected.js.map +1 -0
- package/dist/cognition/emergent/capabilities.d.ts +2 -0
- package/dist/cognition/emergent/capabilities.d.ts.map +1 -1
- package/dist/cognition/emergent/capabilities.js +12 -2
- package/dist/cognition/emergent/capabilities.js.map +1 -1
- package/dist/cognition/emergent/ceiling.d.ts +38 -3
- package/dist/cognition/emergent/ceiling.d.ts.map +1 -1
- package/dist/cognition/emergent/ceiling.js +119 -2
- package/dist/cognition/emergent/ceiling.js.map +1 -1
- package/dist/cognition/emergent/executor/QuickJSExecutor.d.ts +1 -1
- package/dist/cognition/emergent/executor/QuickJSExecutor.d.ts.map +1 -1
- package/dist/cognition/emergent/executor/QuickJSExecutor.js +45 -15
- package/dist/cognition/emergent/executor/QuickJSExecutor.js.map +1 -1
- package/dist/cognition/emergent/executor/guest-prelude.d.ts.map +1 -1
- package/dist/cognition/emergent/executor/guest-prelude.js +48 -17
- package/dist/cognition/emergent/executor/guest-prelude.js.map +1 -1
- package/dist/cognition/emergent/executor/guest-surface.d.ts.map +1 -1
- package/dist/cognition/emergent/executor/guest-surface.js +18 -5
- package/dist/cognition/emergent/executor/guest-surface.js.map +1 -1
- package/dist/cognition/emergent/persisted-source.d.ts.map +1 -1
- package/dist/cognition/emergent/persisted-source.js +7 -1
- package/dist/cognition/emergent/persisted-source.js.map +1 -1
- package/dist/cognition/emergent/types.d.ts +117 -6
- package/dist/cognition/emergent/types.d.ts.map +1 -1
- package/dist/cognition/emergent/types.js.map +1 -1
- package/dist/core/tools/ITool.d.ts +12 -2
- package/dist/core/tools/ITool.d.ts.map +1 -1
- package/dist/io/hearing/LiveKitTranscriptionOutput.d.ts +95 -0
- package/dist/io/hearing/LiveKitTranscriptionOutput.d.ts.map +1 -0
- package/dist/io/hearing/LiveKitTranscriptionOutput.js +108 -0
- package/dist/io/hearing/LiveKitTranscriptionOutput.js.map +1 -0
- package/dist/io/hearing/livekit.d.ts +15 -0
- package/dist/io/hearing/livekit.d.ts.map +1 -0
- package/dist/io/hearing/livekit.js +15 -0
- package/dist/io/hearing/livekit.js.map +1 -0
- package/dist/io/voice-pipeline/browser.d.ts +19 -0
- package/dist/io/voice-pipeline/browser.d.ts.map +1 -0
- package/dist/io/voice-pipeline/browser.js +20 -0
- package/dist/io/voice-pipeline/browser.js.map +1 -0
- package/dist/io/voice-pipeline/index.d.ts +1 -0
- package/dist/io/voice-pipeline/index.d.ts.map +1 -1
- package/dist/io/voice-pipeline/index.js +1 -0
- package/dist/io/voice-pipeline/index.js.map +1 -1
- package/dist/io/voice-pipeline/transcriptLedger.d.ts +139 -0
- package/dist/io/voice-pipeline/transcriptLedger.d.ts.map +1 -0
- package/dist/io/voice-pipeline/transcriptLedger.js +192 -0
- package/dist/io/voice-pipeline/transcriptLedger.js.map +1 -0
- package/dist/io/voice-pipeline/types.d.ts +27 -0
- package/dist/io/voice-pipeline/types.d.ts.map +1 -1
- package/package.json +11 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module hearing/LiveKitTranscriptionOutput
|
|
3
|
+
* Writes a speech-to-text session's transcripts into a LiveKit room the way
|
|
4
|
+
* LiveKit's own transcription output does, so a page's standard handler of the
|
|
5
|
+
* `lk.transcription` topic shows them: each interim and each final as a text
|
|
6
|
+
* stream holding the line's whole text, with `lk.segment_id` (the transcript's
|
|
7
|
+
* `itemId`), `lk.transcription_final` and `lk.transcribed_track_id`. Writes go
|
|
8
|
+
* out in the order they were asked for. The finals are kept in a
|
|
9
|
+
* {@link TranscriptLedger}, so a participant that reconnects can be sent again
|
|
10
|
+
* the finals after the last line it holds, a line taken back among them.
|
|
11
|
+
*
|
|
12
|
+
* The room is described by a structural type, so this module and its typings
|
|
13
|
+
* carry no dependency on `@livekit/rtc-node`; a connected rtc-node `Room` is
|
|
14
|
+
* passed as it is.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const output = new LiveKitTranscriptionOutput({ room, trackSid: () => heardTrack?.sid });
|
|
19
|
+
* sttSession.on('transcript', (event) => {
|
|
20
|
+
* output.write(event).catch((error) => console.warn('transcript not sent', error));
|
|
21
|
+
* });
|
|
22
|
+
* // when the page says the last line it holds:
|
|
23
|
+
* await output.replayAfter(lastItemId, participantIdentity);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import { LIVEKIT_TRANSCRIPTION_ATTRIBUTES, LIVEKIT_TRANSCRIPTION_TOPIC, TRANSCRIPTION_FAILED_ATTRIBUTE, TranscriptLedger, } from '../voice-pipeline/transcriptLedger.js';
|
|
27
|
+
/** Transcripts written into a LiveKit room as transcription text streams. */
|
|
28
|
+
export class LiveKitTranscriptionOutput {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.chain = Promise.resolve();
|
|
32
|
+
this.ledger = options.ledger ?? new TranscriptLedger();
|
|
33
|
+
this.topic = options.topic ?? LIVEKIT_TRANSCRIPTION_TOPIC;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Writes one transcript to every participant. Resolves `true` once it is
|
|
37
|
+
* sent, `false` when the ledger already held it (a repeated final, or an
|
|
38
|
+
* interim after the final), which sends nothing.
|
|
39
|
+
*
|
|
40
|
+
* The ledger takes the line before it is sent, so a send that fails leaves
|
|
41
|
+
* the line there: writing the same transcript again sends nothing, and
|
|
42
|
+
* {@link LiveKitTranscriptionOutput.replayAfter} sends a final again to a
|
|
43
|
+
* participant, as it does for one that rejoins.
|
|
44
|
+
*
|
|
45
|
+
* @param extra - `itemId` when the transcript carries none; `failed`, a short
|
|
46
|
+
* reason, for a line the provider could not transcribe.
|
|
47
|
+
* @throws {RangeError} When neither the transcript nor `extra` gives a line id.
|
|
48
|
+
* @throws {Error} When the room has no local participant, or the send fails.
|
|
49
|
+
*/
|
|
50
|
+
write(event, extra = {}) {
|
|
51
|
+
const itemId = extra.itemId ?? event.itemId;
|
|
52
|
+
if (!itemId) {
|
|
53
|
+
return Promise.reject(new RangeError('LiveKitTranscriptionOutput: the transcript has no itemId; pass one in the second argument'));
|
|
54
|
+
}
|
|
55
|
+
const changed = this.ledger.apply({
|
|
56
|
+
itemId,
|
|
57
|
+
text: event.text,
|
|
58
|
+
isFinal: event.isFinal,
|
|
59
|
+
...(event.startMs !== undefined ? { startMs: event.startMs } : {}),
|
|
60
|
+
...(event.endMs !== undefined ? { endMs: event.endMs } : {}),
|
|
61
|
+
...(event.language !== undefined ? { language: event.language } : {}),
|
|
62
|
+
...(extra.failed !== undefined ? { failed: extra.failed } : {}),
|
|
63
|
+
});
|
|
64
|
+
if (!changed)
|
|
65
|
+
return Promise.resolve(false);
|
|
66
|
+
const line = this.ledger.get(itemId);
|
|
67
|
+
return this.enqueue(() => this.send(line, undefined)).then(() => true);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Sends again, to one participant, the final lines after the line with the
|
|
71
|
+
* id, in order, a line taken back among them as its empty final, so a page
|
|
72
|
+
* that missed the retraction drops the line; every one of them when the id
|
|
73
|
+
* is `undefined` or unknown. Resolves how many were sent.
|
|
74
|
+
*/
|
|
75
|
+
replayAfter(itemId, participantIdentity) {
|
|
76
|
+
const finals = this.ledger.finalsAfter(itemId, { takenBack: true });
|
|
77
|
+
return this.enqueue(async () => {
|
|
78
|
+
for (const line of finals)
|
|
79
|
+
await this.send(line, [participantIdentity]);
|
|
80
|
+
return finals.length;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
enqueue(work) {
|
|
84
|
+
const next = this.chain.then(work, work);
|
|
85
|
+
this.chain = next.catch(() => undefined);
|
|
86
|
+
return next;
|
|
87
|
+
}
|
|
88
|
+
async send(line, destinationIdentities) {
|
|
89
|
+
const local = this.options.room.localParticipant;
|
|
90
|
+
if (!local)
|
|
91
|
+
throw new Error('LiveKitTranscriptionOutput: the room has no local participant; connect it first');
|
|
92
|
+
const attributes = {
|
|
93
|
+
[LIVEKIT_TRANSCRIPTION_ATTRIBUTES.segmentId]: line.itemId,
|
|
94
|
+
[LIVEKIT_TRANSCRIPTION_ATTRIBUTES.final]: line.isFinal ? 'true' : 'false',
|
|
95
|
+
};
|
|
96
|
+
const sid = this.options.trackSid?.();
|
|
97
|
+
if (sid)
|
|
98
|
+
attributes[LIVEKIT_TRANSCRIPTION_ATTRIBUTES.trackId] = sid;
|
|
99
|
+
if (line.failed)
|
|
100
|
+
attributes[TRANSCRIPTION_FAILED_ATTRIBUTE] = line.failed;
|
|
101
|
+
await local.sendText(line.text, {
|
|
102
|
+
topic: this.topic,
|
|
103
|
+
attributes,
|
|
104
|
+
...(destinationIdentities ? { destinationIdentities } : {}),
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=LiveKitTranscriptionOutput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveKitTranscriptionOutput.js","sourceRoot":"","sources":["../../../src/io/hearing/LiveKitTranscriptionOutput.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EACL,gCAAgC,EAChC,2BAA2B,EAC3B,8BAA8B,EAC9B,gBAAgB,GAEjB,MAAM,uCAAuC,CAAC;AAkC/C,6EAA6E;AAC7E,MAAM,OAAO,0BAA0B;IAMrC,YAA6B,OAA0C;QAA1C,YAAO,GAAP,OAAO,CAAmC;QAF/D,UAAK,GAAqB,OAAO,CAAC,OAAO,EAAE,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AAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;SAC1E,CAAC;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;QACtC,IAAI,GAAG;YAAE,UAAU,CAAC,gCAAgC,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC;QACpE,IAAI,IAAI,CAAC,MAAM;YAAE,UAAU,CAAC,8BAA8B,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1E,MAAM,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU;YACV,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module hearing/livekit
|
|
3
|
+
*
|
|
4
|
+
* LiveKit for the hearing layer: transcripts written into a LiveKit room as
|
|
5
|
+
* LiveKit's own transcription text streams, by an agent that joined the room
|
|
6
|
+
* as a participant. It takes the host's connected `@livekit/rtc-node` `Room`,
|
|
7
|
+
* described by a structural type, so this entry imports no LiveKit package.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { LiveKitTranscriptionOutput } from './livekit.js';
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export { LiveKitTranscriptionOutput, type LiveKitTranscriptionOutputOptions, type LiveKitTranscriptionRoomLike, } from './LiveKitTranscriptionOutput.js';
|
|
15
|
+
//# sourceMappingURL=livekit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"livekit.d.ts","sourceRoot":"","sources":["../../../src/io/hearing/livekit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,0BAA0B,EAC1B,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,GAClC,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module hearing/livekit
|
|
3
|
+
*
|
|
4
|
+
* LiveKit for the hearing layer: transcripts written into a LiveKit room as
|
|
5
|
+
* LiveKit's own transcription text streams, by an agent that joined the room
|
|
6
|
+
* as a participant. It takes the host's connected `@livekit/rtc-node` `Room`,
|
|
7
|
+
* described by a structural type, so this entry imports no LiveKit package.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { LiveKitTranscriptionOutput } from './livekit.js';
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export { LiveKitTranscriptionOutput, } from './LiveKitTranscriptionOutput.js';
|
|
15
|
+
//# sourceMappingURL=livekit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"livekit.js","sourceRoot":"","sources":["../../../src/io/hearing/livekit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,0BAA0B,GAG3B,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @framers/agentos/io/voice-pipeline/browser
|
|
3
|
+
*
|
|
4
|
+
* The voice pipeline's browser entry: modules that import no Node built-in and
|
|
5
|
+
* no package, so a browser bundle can take them. The Node entry,
|
|
6
|
+
* `@framers/agentos/io/voice-pipeline`, carries all of this as well, with the
|
|
7
|
+
* providers, transports and orchestrator that run on a server.
|
|
8
|
+
*
|
|
9
|
+
* A test walks this entry's built module graph and fails on any import that
|
|
10
|
+
* is not one of the library's own modules, so a module added here keeps to
|
|
11
|
+
* that.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { TranscriptLedger, transcriptEventFromLiveKit } from './browser.js';
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { LIVEKIT_TRANSCRIPTION_ATTRIBUTES, LIVEKIT_TRANSCRIPTION_TOPIC, TRANSCRIPTION_FAILED_ATTRIBUTE, TranscriptLedger, transcriptEventFromLiveKit, type LedgerEvent, type LedgerItem, type TranscriptLedgerOptions, } from './transcriptLedger.js';
|
|
19
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/io/voice-pipeline/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EACL,gCAAgC,EAChC,2BAA2B,EAC3B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,EAC1B,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @framers/agentos/io/voice-pipeline/browser
|
|
3
|
+
*
|
|
4
|
+
* The voice pipeline's browser entry: modules that import no Node built-in and
|
|
5
|
+
* no package, so a browser bundle can take them. The Node entry,
|
|
6
|
+
* `@framers/agentos/io/voice-pipeline`, carries all of this as well, with the
|
|
7
|
+
* providers, transports and orchestrator that run on a server.
|
|
8
|
+
*
|
|
9
|
+
* A test walks this entry's built module graph and fails on any import that
|
|
10
|
+
* is not one of the library's own modules, so a module added here keeps to
|
|
11
|
+
* that.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { TranscriptLedger, transcriptEventFromLiveKit } from './browser.js';
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
// A live transcript as lines keyed by item id, and LiveKit's transcription streams read into it.
|
|
19
|
+
export { LIVEKIT_TRANSCRIPTION_ATTRIBUTES, LIVEKIT_TRANSCRIPTION_TOPIC, TRANSCRIPTION_FAILED_ATTRIBUTE, TranscriptLedger, transcriptEventFromLiveKit, } from './transcriptLedger.js';
|
|
20
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/io/voice-pipeline/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,iGAAiG;AACjG,OAAO,EACL,gCAAgC,EAChC,2BAA2B,EAC3B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,GAI3B,MAAM,uBAAuB,CAAC"}
|
|
@@ -112,6 +112,7 @@ export { type HealthyProvider, type ProviderCapabilities, type HealthCheckResult
|
|
|
112
112
|
export { CircuitBreaker, type BreakerState, type CircuitBreakerOptions, type StateChangeEvent, } from './CircuitBreaker.js';
|
|
113
113
|
export { AudioRingBuffer, type AudioRingBufferOptions } from './AudioRingBuffer.js';
|
|
114
114
|
export { TranscriptDedupe, type TranscriptObservation, type DedupeResult, } from './TranscriptDedupe.js';
|
|
115
|
+
export { LIVEKIT_TRANSCRIPTION_ATTRIBUTES, LIVEKIT_TRANSCRIPTION_TOPIC, TRANSCRIPTION_FAILED_ATTRIBUTE, TranscriptLedger, transcriptEventFromLiveKit, type LedgerEvent, type LedgerItem, type TranscriptLedgerOptions, } from './transcriptLedger.js';
|
|
115
116
|
export { VoiceMetricsReporter, type VoiceMetricEvent, type VoiceMetricListener, } from './VoiceMetricsReporter.js';
|
|
116
117
|
export { createVoiceProvidersFromEnv, NoVoiceProvidersAvailableError, type VoiceProviderEnvConfig, type VoiceProviderBundle, } from './env-constructor.js';
|
|
117
118
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/io/voice-pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,EAChC,2BAA2B,EAC3B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,EAC1B,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,uBAAuB,GAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,GACzB,MAAM,sBAAsB,CAAC"}
|
|
@@ -124,6 +124,7 @@ export { defaultCapabilities, supportsLanguage, } from './HealthyProvider.js';
|
|
|
124
124
|
export { CircuitBreaker, } from './CircuitBreaker.js';
|
|
125
125
|
export { AudioRingBuffer } from './AudioRingBuffer.js';
|
|
126
126
|
export { TranscriptDedupe, } from './TranscriptDedupe.js';
|
|
127
|
+
export { LIVEKIT_TRANSCRIPTION_ATTRIBUTES, LIVEKIT_TRANSCRIPTION_TOPIC, TRANSCRIPTION_FAILED_ATTRIBUTE, TranscriptLedger, transcriptEventFromLiveKit, } from './transcriptLedger.js';
|
|
127
128
|
export { VoiceMetricsReporter, } from './VoiceMetricsReporter.js';
|
|
128
129
|
export { createVoiceProvidersFromEnv, NoVoiceProvidersAvailableError, } from './env-constructor.js';
|
|
129
130
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/io/voice-pipeline/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGG;AAEH,wDAAwD;AACxD,8EAA8E;AAC9E,cAAc,YAAY,CAAC;AAE3B,+DAA+D;AAC/D,OAAO,EAAE,iBAAiB,EAA0B,MAAM,sBAAsB,CAAC;AAEjF,4CAA4C;AA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IL,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,cAAc,GAIf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAA+B,MAAM,sBAAsB,CAAC;AACpF,OAAO,EACL,gBAAgB,GAGjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,gCAAgC,EAChC,2BAA2B,EAC3B,8BAA8B,EAC9B,gBAAgB,EAChB,0BAA0B,GAI3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,GAGrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,GAG/B,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module voice-pipeline/transcriptLedger
|
|
3
|
+
* A live transcript as lines keyed by their item id. An interim replaces the
|
|
4
|
+
* line's earlier interim, a final closes the line, and a final that arrives
|
|
5
|
+
* again (a replay after a reconnect) or an interim after its final changes
|
|
6
|
+
* nothing; lines keep the order they were first seen in. An empty final with
|
|
7
|
+
* no failure takes a line back, and the ledger hides it. LiveKit carries
|
|
8
|
+
* transcripts as text streams on its `lk.transcription` topic with the
|
|
9
|
+
* attributes its own transcription output sets: `transcriptEventFromLiveKit()`
|
|
10
|
+
* reads one, and `LiveKitTranscriptionOutput`
|
|
11
|
+
* (`@framers/agentos/io/hearing/livekit`) writes them. The module imports
|
|
12
|
+
* nothing, its types included, so a browser bundle takes it from
|
|
13
|
+
* `@framers/agentos/io/voice-pipeline/browser` and a type check of it needs no
|
|
14
|
+
* Node types.
|
|
15
|
+
*/
|
|
16
|
+
/** LiveKit's topic for transcription text streams. */
|
|
17
|
+
export declare const LIVEKIT_TRANSCRIPTION_TOPIC = "lk.transcription";
|
|
18
|
+
/** The attributes LiveKit's own transcription output sets on each stream. */
|
|
19
|
+
export declare const LIVEKIT_TRANSCRIPTION_ATTRIBUTES: {
|
|
20
|
+
/** The line's id; this library writes the transcript's `itemId` here. */
|
|
21
|
+
readonly segmentId: "lk.segment_id";
|
|
22
|
+
/** `'true'` on the line's final stream, `'false'` on an interim. */
|
|
23
|
+
readonly final: "lk.transcription_final";
|
|
24
|
+
/** The SID of the audio track the line was heard on. */
|
|
25
|
+
readonly trackId: "lk.transcribed_track_id";
|
|
26
|
+
};
|
|
27
|
+
/** The attribute this library adds to a line the provider could not transcribe, holding a short reason. */
|
|
28
|
+
export declare const TRANSCRIPTION_FAILED_ATTRIBUTE = "agentos.transcription_failed";
|
|
29
|
+
/** One line of a ledger. */
|
|
30
|
+
export interface LedgerItem {
|
|
31
|
+
/** The line's id: the provider's item id. */
|
|
32
|
+
readonly itemId: string;
|
|
33
|
+
/** The line's text: the newest interim, or the final. */
|
|
34
|
+
readonly text: string;
|
|
35
|
+
/** `true` once the final arrived; the line no longer changes. */
|
|
36
|
+
readonly isFinal: boolean;
|
|
37
|
+
/** Start of the line on the session's audio clock, when the provider gives it. */
|
|
38
|
+
readonly startMs?: number;
|
|
39
|
+
/** End of the line on the session's audio clock, when the provider gives it. */
|
|
40
|
+
readonly endMs?: number;
|
|
41
|
+
/** The line's language, when the provider gives it. */
|
|
42
|
+
readonly language?: string;
|
|
43
|
+
/** Why the provider could not transcribe the line; its text is then empty. */
|
|
44
|
+
readonly failed?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* What a ledger takes: a transcript's text, finality and id, with the optional
|
|
48
|
+
* timing, language and failure. A `TranscriptEvent` fits it as it is; the shape
|
|
49
|
+
* is declared here so the browser entry's typings import nothing.
|
|
50
|
+
*/
|
|
51
|
+
export interface LedgerEvent {
|
|
52
|
+
/** The line's id: the provider's item id. An event without one changes nothing. */
|
|
53
|
+
itemId?: string;
|
|
54
|
+
/** The line's text: an interim's text so far, or the final text. */
|
|
55
|
+
text: string;
|
|
56
|
+
/** `true` on the line's final, `false` on an interim. */
|
|
57
|
+
isFinal: boolean;
|
|
58
|
+
/** Start of the line on the session's audio clock, when the provider gives it. */
|
|
59
|
+
startMs?: number;
|
|
60
|
+
/** End of the line on the session's audio clock, when the provider gives it. */
|
|
61
|
+
endMs?: number;
|
|
62
|
+
/** The line's language, when the provider gives it. */
|
|
63
|
+
language?: string;
|
|
64
|
+
/** Why the provider could not transcribe the line; its text is then empty. An empty reason counts as none. */
|
|
65
|
+
failed?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Options of {@link TranscriptLedger}. */
|
|
68
|
+
export interface TranscriptLedgerOptions {
|
|
69
|
+
/**
|
|
70
|
+
* The most lines held, a line taken back among them (it stays, hidden, so a
|
|
71
|
+
* later event for its id changes nothing and a replay carries it); beyond it
|
|
72
|
+
* the oldest final lines are dropped, never the line just applied nor a line
|
|
73
|
+
* still being heard, so while more lines than that are open the ledger holds
|
|
74
|
+
* them all.
|
|
75
|
+
* @defaultValue 20000
|
|
76
|
+
*/
|
|
77
|
+
maxItems?: number;
|
|
78
|
+
}
|
|
79
|
+
/** A live transcript's lines keyed by item id, in the order first seen. */
|
|
80
|
+
export declare class TranscriptLedger {
|
|
81
|
+
private readonly lines;
|
|
82
|
+
private readonly retracted;
|
|
83
|
+
private readonly maxItems;
|
|
84
|
+
/** @throws {RangeError} When `maxItems` is below 1. */
|
|
85
|
+
constructor(options?: TranscriptLedgerOptions);
|
|
86
|
+
/** How many lines the ledger shows. */
|
|
87
|
+
get size(): number;
|
|
88
|
+
/**
|
|
89
|
+
* Applies one transcript. Answers `true` when the ledger changed: a new
|
|
90
|
+
* line, a new interim text, the final, or a line taken back. An empty final
|
|
91
|
+
* with no failure takes back the text a line showed so far (a device
|
|
92
|
+
* session's retraction when it closes), and the line is hidden from then on.
|
|
93
|
+
* An event with no item id, a final for a line already final, an interim
|
|
94
|
+
* after the final, an interim with the same text and the retraction of a
|
|
95
|
+
* line never shown change nothing.
|
|
96
|
+
*/
|
|
97
|
+
apply(event: LedgerEvent): boolean;
|
|
98
|
+
/** The line with the id (a line taken back answers its empty final), or `undefined`. */
|
|
99
|
+
get(itemId: string): LedgerItem | undefined;
|
|
100
|
+
/** Every line shown, in the order first seen; a line taken back is left out. */
|
|
101
|
+
items(): LedgerItem[];
|
|
102
|
+
/** The id of the last final line shown, or `undefined` when none is final. */
|
|
103
|
+
lastFinalId(): string | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* The id a page that rejoins sends, so it is given every final it may lack: the last final line before the first
|
|
106
|
+
* line not yet final (a final that arrived out of order while the page was away comes after it), the last final
|
|
107
|
+
* when every line is final, `undefined` when none is. A final the page already holds comes again and is dropped.
|
|
108
|
+
*/
|
|
109
|
+
resumeAfterId(): string | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* The final lines shown after the line with the id, in order; every one of
|
|
112
|
+
* them when the id is `undefined` or unknown. With `takenBack`, a line taken
|
|
113
|
+
* back comes too, as its empty final in its place: what a participant that
|
|
114
|
+
* rejoins is sent again, so a page that missed the retraction drops the line.
|
|
115
|
+
*/
|
|
116
|
+
finalsAfter(itemId: string | undefined, options?: {
|
|
117
|
+
takenBack?: boolean;
|
|
118
|
+
}): LedgerItem[];
|
|
119
|
+
/** The ledger as plain JSON. */
|
|
120
|
+
toJSON(): {
|
|
121
|
+
v: 1;
|
|
122
|
+
items: LedgerItem[];
|
|
123
|
+
};
|
|
124
|
+
/** A ledger from {@link TranscriptLedger.toJSON}'s output; a malformed line is skipped. */
|
|
125
|
+
static fromJSON(value: unknown, options?: TranscriptLedgerOptions): TranscriptLedger;
|
|
126
|
+
/**
|
|
127
|
+
* Drops the oldest final lines while the ledger is over its size, never the
|
|
128
|
+
* line just applied nor a line still being heard: a later final or
|
|
129
|
+
* retraction of an open line must find it, so open lines are held over the
|
|
130
|
+
* size until they close.
|
|
131
|
+
*/
|
|
132
|
+
private trim;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Reads one LiveKit transcription stream (its text and attributes) as a
|
|
136
|
+
* {@link LedgerEvent}, or `null` when it carries no segment id.
|
|
137
|
+
*/
|
|
138
|
+
export declare function transcriptEventFromLiveKit(text: string, attributes: Readonly<Record<string, string>> | undefined): LedgerEvent | null;
|
|
139
|
+
//# sourceMappingURL=transcriptLedger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcriptLedger.d.ts","sourceRoot":"","sources":["../../../src/io/voice-pipeline/transcriptLedger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,sDAAsD;AACtD,eAAO,MAAM,2BAA2B,qBAAqB,CAAC;AAE9D,6EAA6E;AAC7E,eAAO,MAAM,gCAAgC;IAC3C,yEAAyE;;IAEzE,oEAAoE;;IAEpE,wDAAwD;;CAEhD,CAAC;AAEX,2GAA2G;AAC3G,eAAO,MAAM,8BAA8B,iCAAiC,CAAC;AAE7E,4BAA4B;AAC5B,MAAM,WAAW,UAAU;IACzB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yDAAyD;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,kFAAkF;IAClF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,gFAAgF;IAChF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gFAAgF;IAChF,KAAK,CA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CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,GAAG,WAAW,GAAG,IAAI,CAQrI"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module voice-pipeline/transcriptLedger
|
|
3
|
+
* A live transcript as lines keyed by their item id. An interim replaces the
|
|
4
|
+
* line's earlier interim, a final closes the line, and a final that arrives
|
|
5
|
+
* again (a replay after a reconnect) or an interim after its final changes
|
|
6
|
+
* nothing; lines keep the order they were first seen in. An empty final with
|
|
7
|
+
* no failure takes a line back, and the ledger hides it. LiveKit carries
|
|
8
|
+
* transcripts as text streams on its `lk.transcription` topic with the
|
|
9
|
+
* attributes its own transcription output sets: `transcriptEventFromLiveKit()`
|
|
10
|
+
* reads one, and `LiveKitTranscriptionOutput`
|
|
11
|
+
* (`@framers/agentos/io/hearing/livekit`) writes them. The module imports
|
|
12
|
+
* nothing, its types included, so a browser bundle takes it from
|
|
13
|
+
* `@framers/agentos/io/voice-pipeline/browser` and a type check of it needs no
|
|
14
|
+
* Node types.
|
|
15
|
+
*/
|
|
16
|
+
/** LiveKit's topic for transcription text streams. */
|
|
17
|
+
export const LIVEKIT_TRANSCRIPTION_TOPIC = 'lk.transcription';
|
|
18
|
+
/** The attributes LiveKit's own transcription output sets on each stream. */
|
|
19
|
+
export const LIVEKIT_TRANSCRIPTION_ATTRIBUTES = {
|
|
20
|
+
/** The line's id; this library writes the transcript's `itemId` here. */
|
|
21
|
+
segmentId: 'lk.segment_id',
|
|
22
|
+
/** `'true'` on the line's final stream, `'false'` on an interim. */
|
|
23
|
+
final: 'lk.transcription_final',
|
|
24
|
+
/** The SID of the audio track the line was heard on. */
|
|
25
|
+
trackId: 'lk.transcribed_track_id',
|
|
26
|
+
};
|
|
27
|
+
/** The attribute this library adds to a line the provider could not transcribe, holding a short reason. */
|
|
28
|
+
export const TRANSCRIPTION_FAILED_ATTRIBUTE = 'agentos.transcription_failed';
|
|
29
|
+
/** A live transcript's lines keyed by item id, in the order first seen. */
|
|
30
|
+
export class TranscriptLedger {
|
|
31
|
+
/** @throws {RangeError} When `maxItems` is below 1. */
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
this.lines = new Map();
|
|
34
|
+
this.retracted = new Set();
|
|
35
|
+
this.maxItems = options.maxItems ?? 20000;
|
|
36
|
+
if (!(this.maxItems >= 1))
|
|
37
|
+
throw new RangeError('TranscriptLedger: maxItems must be at least 1');
|
|
38
|
+
}
|
|
39
|
+
/** How many lines the ledger shows. */
|
|
40
|
+
get size() {
|
|
41
|
+
return this.lines.size - this.retracted.size;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Applies one transcript. Answers `true` when the ledger changed: a new
|
|
45
|
+
* line, a new interim text, the final, or a line taken back. An empty final
|
|
46
|
+
* with no failure takes back the text a line showed so far (a device
|
|
47
|
+
* session's retraction when it closes), and the line is hidden from then on.
|
|
48
|
+
* An event with no item id, a final for a line already final, an interim
|
|
49
|
+
* after the final, an interim with the same text and the retraction of a
|
|
50
|
+
* line never shown change nothing.
|
|
51
|
+
*/
|
|
52
|
+
apply(event) {
|
|
53
|
+
const itemId = event.itemId;
|
|
54
|
+
if (!itemId)
|
|
55
|
+
return false;
|
|
56
|
+
const held = this.lines.get(itemId);
|
|
57
|
+
if (held?.isFinal)
|
|
58
|
+
return false;
|
|
59
|
+
// An empty reason is no reason: the LiveKit stream carries none, so a reader takes such a line back.
|
|
60
|
+
const failed = event.failed || undefined;
|
|
61
|
+
if (event.isFinal && event.text === '' && failed === undefined) {
|
|
62
|
+
if (held === undefined)
|
|
63
|
+
return false;
|
|
64
|
+
this.retracted.add(itemId);
|
|
65
|
+
this.lines.set(itemId, { itemId, text: '', isFinal: true });
|
|
66
|
+
this.trim(itemId);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
if (!event.isFinal && held !== undefined && held.text === event.text)
|
|
70
|
+
return false;
|
|
71
|
+
const line = { itemId, text: event.text, isFinal: event.isFinal };
|
|
72
|
+
if (event.startMs !== undefined)
|
|
73
|
+
line.startMs = event.startMs;
|
|
74
|
+
if (event.endMs !== undefined)
|
|
75
|
+
line.endMs = event.endMs;
|
|
76
|
+
if (event.language !== undefined)
|
|
77
|
+
line.language = event.language;
|
|
78
|
+
if (failed !== undefined)
|
|
79
|
+
line.failed = failed;
|
|
80
|
+
// Setting a key a Map already holds keeps its place, so a line stays where it was first seen.
|
|
81
|
+
this.lines.set(itemId, line);
|
|
82
|
+
this.trim(itemId);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
/** The line with the id (a line taken back answers its empty final), or `undefined`. */
|
|
86
|
+
get(itemId) {
|
|
87
|
+
return this.lines.get(itemId);
|
|
88
|
+
}
|
|
89
|
+
/** Every line shown, in the order first seen; a line taken back is left out. */
|
|
90
|
+
items() {
|
|
91
|
+
return [...this.lines.values()].filter((line) => !this.retracted.has(line.itemId));
|
|
92
|
+
}
|
|
93
|
+
/** The id of the last final line shown, or `undefined` when none is final. */
|
|
94
|
+
lastFinalId() {
|
|
95
|
+
let last;
|
|
96
|
+
for (const line of this.items())
|
|
97
|
+
if (line.isFinal)
|
|
98
|
+
last = line.itemId;
|
|
99
|
+
return last;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The id a page that rejoins sends, so it is given every final it may lack: the last final line before the first
|
|
103
|
+
* line not yet final (a final that arrived out of order while the page was away comes after it), the last final
|
|
104
|
+
* when every line is final, `undefined` when none is. A final the page already holds comes again and is dropped.
|
|
105
|
+
*/
|
|
106
|
+
resumeAfterId() {
|
|
107
|
+
let last;
|
|
108
|
+
for (const line of this.items()) {
|
|
109
|
+
if (!line.isFinal)
|
|
110
|
+
return last;
|
|
111
|
+
last = line.itemId;
|
|
112
|
+
}
|
|
113
|
+
return last;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The final lines shown after the line with the id, in order; every one of
|
|
117
|
+
* them when the id is `undefined` or unknown. With `takenBack`, a line taken
|
|
118
|
+
* back comes too, as its empty final in its place: what a participant that
|
|
119
|
+
* rejoins is sent again, so a page that missed the retraction drops the line.
|
|
120
|
+
*/
|
|
121
|
+
finalsAfter(itemId, options = {}) {
|
|
122
|
+
const lines = options.takenBack ? [...this.lines.values()] : this.items();
|
|
123
|
+
const index = itemId === undefined ? -1 : lines.findIndex((line) => line.itemId === itemId);
|
|
124
|
+
return lines.slice(index + 1).filter((line) => line.isFinal);
|
|
125
|
+
}
|
|
126
|
+
/** The ledger as plain JSON. */
|
|
127
|
+
toJSON() {
|
|
128
|
+
return { v: 1, items: this.items() };
|
|
129
|
+
}
|
|
130
|
+
/** A ledger from {@link TranscriptLedger.toJSON}'s output; a malformed line is skipped. */
|
|
131
|
+
static fromJSON(value, options = {}) {
|
|
132
|
+
const ledger = new TranscriptLedger(options);
|
|
133
|
+
const items = value?.items;
|
|
134
|
+
if (!Array.isArray(items))
|
|
135
|
+
return ledger;
|
|
136
|
+
for (const item of items) {
|
|
137
|
+
if (typeof item !== 'object' || item === null)
|
|
138
|
+
continue;
|
|
139
|
+
const line = item;
|
|
140
|
+
if (typeof line.itemId !== 'string' || typeof line.text !== 'string' || typeof line.isFinal !== 'boolean')
|
|
141
|
+
continue;
|
|
142
|
+
ledger.apply({
|
|
143
|
+
itemId: line.itemId,
|
|
144
|
+
text: line.text,
|
|
145
|
+
isFinal: line.isFinal,
|
|
146
|
+
...(typeof line.startMs === 'number' ? { startMs: line.startMs } : {}),
|
|
147
|
+
...(typeof line.endMs === 'number' ? { endMs: line.endMs } : {}),
|
|
148
|
+
...(typeof line.language === 'string' ? { language: line.language } : {}),
|
|
149
|
+
...(typeof line.failed === 'string' ? { failed: line.failed } : {}),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return ledger;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Drops the oldest final lines while the ledger is over its size, never the
|
|
156
|
+
* line just applied nor a line still being heard: a later final or
|
|
157
|
+
* retraction of an open line must find it, so open lines are held over the
|
|
158
|
+
* size until they close.
|
|
159
|
+
*/
|
|
160
|
+
trim(keep) {
|
|
161
|
+
while (this.lines.size > this.maxItems) {
|
|
162
|
+
let drop;
|
|
163
|
+
for (const line of this.lines.values()) {
|
|
164
|
+
if (line.isFinal && line.itemId !== keep) {
|
|
165
|
+
drop = line.itemId;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (drop === undefined)
|
|
170
|
+
return;
|
|
171
|
+
this.lines.delete(drop);
|
|
172
|
+
this.retracted.delete(drop);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Reads one LiveKit transcription stream (its text and attributes) as a
|
|
178
|
+
* {@link LedgerEvent}, or `null` when it carries no segment id.
|
|
179
|
+
*/
|
|
180
|
+
export function transcriptEventFromLiveKit(text, attributes) {
|
|
181
|
+
if (attributes === undefined)
|
|
182
|
+
return null;
|
|
183
|
+
const itemId = attributes[LIVEKIT_TRANSCRIPTION_ATTRIBUTES.segmentId];
|
|
184
|
+
if (!itemId)
|
|
185
|
+
return null;
|
|
186
|
+
const event = { itemId, text, isFinal: attributes[LIVEKIT_TRANSCRIPTION_ATTRIBUTES.final] === 'true' };
|
|
187
|
+
const failed = attributes[TRANSCRIPTION_FAILED_ATTRIBUTE];
|
|
188
|
+
if (failed)
|
|
189
|
+
event.failed = failed;
|
|
190
|
+
return event;
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=transcriptLedger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcriptLedger.js","sourceRoot":"","sources":["../../../src/io/voice-pipeline/transcriptLedger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,sDAAsD;AACtD,MAAM,CAAC,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AAE9D,6EAA6E;AAC7E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U,CAAC,8BAA8B,CAAC,CAAC;IAC1D,IAAI,MAAM;QAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAClC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -352,6 +352,33 @@ export interface TranscriptEvent {
|
|
|
352
352
|
/** Confidence score in [0, 1]. */
|
|
353
353
|
confidence: number;
|
|
354
354
|
};
|
|
355
|
+
/**
|
|
356
|
+
* Identifier of the provider's input item this hypothesis belongs to, when
|
|
357
|
+
* the provider keys its results (OpenAI Realtime's `item_id`). Every interim
|
|
358
|
+
* and the final of one utterance carry the same `itemId`, so a consumer that
|
|
359
|
+
* shows interim text replaces it by key, and the results of two utterances
|
|
360
|
+
* whose events interleave never mix. Providers without item keys leave it
|
|
361
|
+
* undefined.
|
|
362
|
+
*/
|
|
363
|
+
itemId?: string;
|
|
364
|
+
/**
|
|
365
|
+
* Start of the utterance's audio, in milliseconds counted from the first
|
|
366
|
+
* frame pushed into the session, when the provider reports speech
|
|
367
|
+
* boundaries.
|
|
368
|
+
*/
|
|
369
|
+
startMs?: number;
|
|
370
|
+
/**
|
|
371
|
+
* End of the utterance's audio, in milliseconds counted from the first
|
|
372
|
+
* frame pushed into the session, when the provider reports speech
|
|
373
|
+
* boundaries.
|
|
374
|
+
*/
|
|
375
|
+
endMs?: number;
|
|
376
|
+
/**
|
|
377
|
+
* Language of `text`: the code the provider detected, or the language the
|
|
378
|
+
* session was configured with (for example `'en'`). Undefined when neither
|
|
379
|
+
* is known.
|
|
380
|
+
*/
|
|
381
|
+
language?: string;
|
|
355
382
|
}
|
|
356
383
|
/**
|
|
357
384
|
* An active streaming speech-to-text session. Audio frames are pushed in
|