@absolutejs/voice 0.0.22-beta.480 → 0.0.22-beta.481
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/index.d.ts +2 -0
- package/dist/index.js +51 -4
- package/dist/redaction.d.ts +13 -0
- package/dist/testing/index.js +8 -4
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,8 @@ export { createVoiceSessionListRoutes, createVoiceSessionReplayHTMLHandler, crea
|
|
|
71
71
|
export { createVoiceAgent, createVoiceAgentSquad, createVoiceAgentTool, } from "./agent";
|
|
72
72
|
export { createAIVoiceModel } from "./aiVoiceModel";
|
|
73
73
|
export type { CreateAIVoiceModelOptions } from "./aiVoiceModel";
|
|
74
|
+
export { DEFAULT_VOICE_REDACTION_PATTERNS, createVoiceTranscriptRedactor, redactVoiceTranscript, } from "./redaction";
|
|
75
|
+
export type { CreateVoiceTranscriptRedactorOptions, VoiceRedactionPattern, VoiceTranscriptRedactor, } from "./redaction";
|
|
74
76
|
export { DEFAULT_VOICE_PRICE_BOOK, createVoiceCostAccountant, } from "./costAccounting";
|
|
75
77
|
export type { CreateVoiceCostAccountantOptions, VoiceCostAccountant, VoiceCostBreakdown, VoiceCostLLMRecord, VoiceCostSTTRecord, VoiceCostTTSRecord, VoiceCostTelephonyRecord, VoicePriceBook, VoiceProviderRates, } from "./costAccounting";
|
|
76
78
|
export { createMonologueAMDDetector } from "./amdDetector";
|
package/dist/index.js
CHANGED
|
@@ -4505,11 +4505,13 @@ var createVoiceSession = (options) => {
|
|
|
4505
4505
|
fallbackSession.on("final", ({ transcript }) => {
|
|
4506
4506
|
fallbackFinalReceived = true;
|
|
4507
4507
|
lastFallbackTranscriptAt = Date.now();
|
|
4508
|
-
|
|
4508
|
+
const next = options.redact ? options.redact(transcript) : transcript;
|
|
4509
|
+
fallbackTranscripts.push(cloneTranscript(next));
|
|
4509
4510
|
}),
|
|
4510
4511
|
fallbackSession.on("partial", ({ transcript }) => {
|
|
4511
4512
|
lastFallbackTranscriptAt = Date.now();
|
|
4512
|
-
|
|
4513
|
+
const next = options.redact ? options.redact(transcript) : transcript;
|
|
4514
|
+
fallbackTranscripts.push(cloneTranscript(next));
|
|
4513
4515
|
}),
|
|
4514
4516
|
fallbackSession.on("endOfTurn", () => {
|
|
4515
4517
|
fallbackEndOfTurnReceived = true;
|
|
@@ -4827,10 +4829,12 @@ var createVoiceSession = (options) => {
|
|
|
4827
4829
|
});
|
|
4828
4830
|
};
|
|
4829
4831
|
openedSession.on("partial", ({ transcript }) => {
|
|
4830
|
-
|
|
4832
|
+
const next = options.redact ? options.redact(transcript) : transcript;
|
|
4833
|
+
runAdapterEvent("adapter.partial", () => handlePartial(next));
|
|
4831
4834
|
});
|
|
4832
4835
|
openedSession.on("final", ({ transcript }) => {
|
|
4833
|
-
|
|
4836
|
+
const next = options.redact ? options.redact(transcript) : transcript;
|
|
4837
|
+
runAdapterEvent("adapter.final", () => handleFinal(next));
|
|
4834
4838
|
});
|
|
4835
4839
|
openedSession.on("endOfTurn", ({ reason }) => {
|
|
4836
4840
|
runAdapterEvent("adapter.endOfTurn", async () => {
|
|
@@ -34977,6 +34981,46 @@ var createAIVoiceModel = (options) => ({
|
|
|
34977
34981
|
return output;
|
|
34978
34982
|
}
|
|
34979
34983
|
});
|
|
34984
|
+
// src/redaction.ts
|
|
34985
|
+
var DEFAULT_VOICE_REDACTION_PATTERNS = [
|
|
34986
|
+
{
|
|
34987
|
+
label: "credit-card",
|
|
34988
|
+
regex: /\b(?:\d[ -]?){13,19}\b/g,
|
|
34989
|
+
replacement: "[REDACTED:CC]"
|
|
34990
|
+
},
|
|
34991
|
+
{
|
|
34992
|
+
label: "ssn",
|
|
34993
|
+
regex: /\b\d{3}-\d{2}-\d{4}\b/g,
|
|
34994
|
+
replacement: "[REDACTED:SSN]"
|
|
34995
|
+
},
|
|
34996
|
+
{
|
|
34997
|
+
label: "email",
|
|
34998
|
+
regex: /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,
|
|
34999
|
+
replacement: "[REDACTED:EMAIL]"
|
|
35000
|
+
},
|
|
35001
|
+
{
|
|
35002
|
+
label: "phone",
|
|
35003
|
+
regex: /\b(?:\+?1[ .-]?)?\(?\d{3}\)?[ .-]?\d{3}[ .-]?\d{4}\b/g,
|
|
35004
|
+
replacement: "[REDACTED:PHONE]"
|
|
35005
|
+
}
|
|
35006
|
+
];
|
|
35007
|
+
var createVoiceTranscriptRedactor = (options = {}) => {
|
|
35008
|
+
const patterns = options.patterns ?? DEFAULT_VOICE_REDACTION_PATTERNS;
|
|
35009
|
+
return (transcript) => {
|
|
35010
|
+
if (!transcript.text) {
|
|
35011
|
+
return transcript;
|
|
35012
|
+
}
|
|
35013
|
+
let redacted = transcript.text;
|
|
35014
|
+
for (const pattern of patterns) {
|
|
35015
|
+
redacted = redacted.replace(pattern.regex, pattern.replacement ?? `[REDACTED:${pattern.label.toUpperCase()}]`);
|
|
35016
|
+
}
|
|
35017
|
+
if (redacted === transcript.text) {
|
|
35018
|
+
return transcript;
|
|
35019
|
+
}
|
|
35020
|
+
return { ...transcript, text: redacted };
|
|
35021
|
+
};
|
|
35022
|
+
};
|
|
35023
|
+
var redactVoiceTranscript = (transcript, patterns = DEFAULT_VOICE_REDACTION_PATTERNS) => createVoiceTranscriptRedactor({ patterns })(transcript);
|
|
34980
35024
|
// src/costAccounting.ts
|
|
34981
35025
|
var DEFAULT_VOICE_PRICE_BOOK = {
|
|
34982
35026
|
"anthropic:claude-opus-4-5": {
|
|
@@ -45884,6 +45928,7 @@ export {
|
|
|
45884
45928
|
renderVoiceAuditHTML,
|
|
45885
45929
|
renderVoiceAuditDeliveryHTML,
|
|
45886
45930
|
renderVoiceAssistantHealthHTML,
|
|
45931
|
+
redactVoiceTranscript,
|
|
45887
45932
|
redactVoiceTraceText,
|
|
45888
45933
|
redactVoiceTraceEvents,
|
|
45889
45934
|
redactVoiceTraceEvent,
|
|
@@ -46005,6 +46050,7 @@ export {
|
|
|
46005
46050
|
createVoiceTurnLatencyJSONHandler,
|
|
46006
46051
|
createVoiceTurnLatencyHTMLHandler,
|
|
46007
46052
|
createVoiceTransferCallTool,
|
|
46053
|
+
createVoiceTranscriptRedactor,
|
|
46008
46054
|
createVoiceTraceTimelineRoutes,
|
|
46009
46055
|
createVoiceTraceSinkStore,
|
|
46010
46056
|
createVoiceTraceSinkDeliveryWorkerLoop,
|
|
@@ -46475,6 +46521,7 @@ export {
|
|
|
46475
46521
|
acknowledgeVoiceMonitorIssue,
|
|
46476
46522
|
VOICE_LIVE_OPS_ACTIONS,
|
|
46477
46523
|
TURN_PROFILE_DEFAULTS,
|
|
46524
|
+
DEFAULT_VOICE_REDACTION_PATTERNS,
|
|
46478
46525
|
DEFAULT_VOICE_PROOF_TREND_PROFILE_DEFINITIONS,
|
|
46479
46526
|
DEFAULT_VOICE_PROOF_TRENDS_MAX_AGE_MS,
|
|
46480
46527
|
DEFAULT_VOICE_PRICE_BOOK
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Transcript } from "./types";
|
|
2
|
+
export type VoiceRedactionPattern = {
|
|
3
|
+
label: string;
|
|
4
|
+
replacement?: string;
|
|
5
|
+
regex: RegExp;
|
|
6
|
+
};
|
|
7
|
+
export declare const DEFAULT_VOICE_REDACTION_PATTERNS: VoiceRedactionPattern[];
|
|
8
|
+
export type VoiceTranscriptRedactor = (transcript: Transcript) => Transcript;
|
|
9
|
+
export type CreateVoiceTranscriptRedactorOptions = {
|
|
10
|
+
patterns?: VoiceRedactionPattern[];
|
|
11
|
+
};
|
|
12
|
+
export declare const createVoiceTranscriptRedactor: (options?: CreateVoiceTranscriptRedactorOptions) => VoiceTranscriptRedactor;
|
|
13
|
+
export declare const redactVoiceTranscript: (transcript: Transcript, patterns?: VoiceRedactionPattern[]) => Transcript;
|
package/dist/testing/index.js
CHANGED
|
@@ -6473,11 +6473,13 @@ var createVoiceSession = (options) => {
|
|
|
6473
6473
|
fallbackSession.on("final", ({ transcript }) => {
|
|
6474
6474
|
fallbackFinalReceived = true;
|
|
6475
6475
|
lastFallbackTranscriptAt = Date.now();
|
|
6476
|
-
|
|
6476
|
+
const next = options.redact ? options.redact(transcript) : transcript;
|
|
6477
|
+
fallbackTranscripts.push(cloneTranscript(next));
|
|
6477
6478
|
}),
|
|
6478
6479
|
fallbackSession.on("partial", ({ transcript }) => {
|
|
6479
6480
|
lastFallbackTranscriptAt = Date.now();
|
|
6480
|
-
|
|
6481
|
+
const next = options.redact ? options.redact(transcript) : transcript;
|
|
6482
|
+
fallbackTranscripts.push(cloneTranscript(next));
|
|
6481
6483
|
}),
|
|
6482
6484
|
fallbackSession.on("endOfTurn", () => {
|
|
6483
6485
|
fallbackEndOfTurnReceived = true;
|
|
@@ -6795,10 +6797,12 @@ var createVoiceSession = (options) => {
|
|
|
6795
6797
|
});
|
|
6796
6798
|
};
|
|
6797
6799
|
openedSession.on("partial", ({ transcript }) => {
|
|
6798
|
-
|
|
6800
|
+
const next = options.redact ? options.redact(transcript) : transcript;
|
|
6801
|
+
runAdapterEvent("adapter.partial", () => handlePartial(next));
|
|
6799
6802
|
});
|
|
6800
6803
|
openedSession.on("final", ({ transcript }) => {
|
|
6801
|
-
|
|
6804
|
+
const next = options.redact ? options.redact(transcript) : transcript;
|
|
6805
|
+
runAdapterEvent("adapter.final", () => handleFinal(next));
|
|
6802
6806
|
});
|
|
6803
6807
|
openedSession.on("endOfTurn", ({ reason }) => {
|
|
6804
6808
|
runAdapterEvent("adapter.endOfTurn", async () => {
|
package/dist/types.d.ts
CHANGED
|
@@ -730,6 +730,7 @@ export type CreateVoiceSessionOptions<TContext = unknown, TSession extends Voice
|
|
|
730
730
|
costTelephony?: {
|
|
731
731
|
provider?: string;
|
|
732
732
|
};
|
|
733
|
+
redact?: import("./redaction").VoiceTranscriptRedactor;
|
|
733
734
|
reconnect: Required<VoiceReconnectConfig>;
|
|
734
735
|
phraseHints?: VoicePhraseHint[];
|
|
735
736
|
sessionMetadata?: Record<string, unknown>;
|