@absolutejs/voice 0.0.22-beta.497 → 0.0.22-beta.499
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/assistant.d.ts +1 -2
- package/dist/callQuota.d.ts +54 -0
- package/dist/client/costDashboard.d.ts +27 -0
- package/dist/client/liveCallViewer.d.ts +42 -0
- package/dist/client/replayTimeline.d.ts +26 -0
- package/dist/defineVoiceAssistant.d.ts +68 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.js +640 -37
- package/dist/midCallSummary.d.ts +27 -0
- package/dist/recordingRedaction.d.ts +18 -0
- package/dist/recordingStore.d.ts +39 -0
- package/dist/retention.d.ts +37 -0
- package/dist/routeAuth.d.ts +58 -0
- package/dist/testing/index.js +33 -0
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Transcript, VoiceSessionRecord, VoiceTurnRecord } from "./types";
|
|
2
|
+
import type { VoiceLLMJudgeCompletion } from "./llmJudge";
|
|
3
|
+
export type MidCallSummary = {
|
|
4
|
+
generatedAt: number;
|
|
5
|
+
summary: string;
|
|
6
|
+
topicalShift?: boolean;
|
|
7
|
+
turnCount: number;
|
|
8
|
+
};
|
|
9
|
+
export type CreateMidCallSummarizerOptions = {
|
|
10
|
+
completion: VoiceLLMJudgeCompletion;
|
|
11
|
+
/** Force a summary every N turns. Default 6. */
|
|
12
|
+
everyTurns?: number;
|
|
13
|
+
/** Force a summary at most every M ms. Default 60_000. */
|
|
14
|
+
minIntervalMs?: number;
|
|
15
|
+
/** Maximum chars to include in the system prompt. Default 600. */
|
|
16
|
+
summaryMaxChars?: number;
|
|
17
|
+
systemPrompt?: string;
|
|
18
|
+
};
|
|
19
|
+
export type MidCallSummarizer = {
|
|
20
|
+
evaluate: (input: {
|
|
21
|
+
session: VoiceSessionRecord;
|
|
22
|
+
turn?: VoiceTurnRecord;
|
|
23
|
+
}) => Promise<MidCallSummary | undefined>;
|
|
24
|
+
latest: () => MidCallSummary | undefined;
|
|
25
|
+
};
|
|
26
|
+
export declare const createMidCallSummarizer: (options: CreateMidCallSummarizerOptions) => MidCallSummarizer;
|
|
27
|
+
export declare const extractTranscriptText: (transcripts: Transcript[]) => string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Transcript } from "./types";
|
|
2
|
+
import { type VoiceRedactionPattern } from "./redaction";
|
|
3
|
+
export type VoiceRecordingRedactionRange = {
|
|
4
|
+
endMs: number;
|
|
5
|
+
label?: string;
|
|
6
|
+
startMs: number;
|
|
7
|
+
};
|
|
8
|
+
export type DeriveVoiceRecordingRedactionRangesInput = {
|
|
9
|
+
/** When the recording starts in epoch ms; used to convert absolute timestamps if transcripts use them. */
|
|
10
|
+
recordingStartedAtEpochMs?: number;
|
|
11
|
+
/** Optional padding around redaction ranges, in ms (default 100). */
|
|
12
|
+
paddingMs?: number;
|
|
13
|
+
/** Patterns to test against transcripts. Defaults to DEFAULT_VOICE_REDACTION_PATTERNS. */
|
|
14
|
+
patterns?: ReadonlyArray<VoiceRedactionPattern>;
|
|
15
|
+
/** Transcripts to scan. */
|
|
16
|
+
transcripts: ReadonlyArray<Transcript>;
|
|
17
|
+
};
|
|
18
|
+
export declare const deriveVoiceRecordingRedactionRanges: (input: DeriveVoiceRecordingRedactionRangesInput) => VoiceRecordingRedactionRange[];
|
package/dist/recordingStore.d.ts
CHANGED
|
@@ -11,11 +11,50 @@ export type VoiceRecordingArtifact = {
|
|
|
11
11
|
export type StoredVoiceRecordingArtifact = VoiceRecordingArtifact & {
|
|
12
12
|
recordingUrl?: string;
|
|
13
13
|
};
|
|
14
|
+
export type VoiceRecordingEncoderInput = {
|
|
15
|
+
channel: VoiceRecordingChannel;
|
|
16
|
+
format: AudioFormat;
|
|
17
|
+
pcm: Uint8Array;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
};
|
|
20
|
+
export type VoiceRecordingEncoderResult = {
|
|
21
|
+
bytes: Uint8Array;
|
|
22
|
+
contentType: string;
|
|
23
|
+
extension: string;
|
|
24
|
+
};
|
|
25
|
+
export type VoiceRecordingEncoder = {
|
|
26
|
+
encode: (input: VoiceRecordingEncoderInput) => Promise<VoiceRecordingEncoderResult> | VoiceRecordingEncoderResult;
|
|
27
|
+
kind: string;
|
|
28
|
+
};
|
|
14
29
|
export type VoiceRecordingStore = {
|
|
15
30
|
get: (sessionId: string, channel: VoiceRecordingChannel) => Promise<StoredVoiceRecordingArtifact | undefined>;
|
|
16
31
|
list: (sessionId: string) => Promise<StoredVoiceRecordingArtifact[]>;
|
|
17
32
|
put: (artifact: VoiceRecordingArtifact) => Promise<StoredVoiceRecordingArtifact>;
|
|
18
33
|
};
|
|
19
34
|
export declare const encodePcmAsWav: (pcm: Uint8Array, format: AudioFormat) => Uint8Array;
|
|
35
|
+
export type InterleavePcmInput = {
|
|
36
|
+
/** Mono PCM bytes for the left channel. */
|
|
37
|
+
left: Uint8Array;
|
|
38
|
+
/** Mono PCM bytes for the right channel. */
|
|
39
|
+
right: Uint8Array;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Interleaves two mono pcm_s16le buffers into a single stereo pcm_s16le
|
|
43
|
+
* buffer at the same sample rate. Output length is max(left, right) * 2.
|
|
44
|
+
* The shorter buffer is right-padded with silence to align frame counts.
|
|
45
|
+
*/
|
|
46
|
+
export declare const interleaveStereoPcm: (input: InterleavePcmInput) => Uint8Array;
|
|
47
|
+
export type EncodeStereoWavInput = {
|
|
48
|
+
format: AudioFormat;
|
|
49
|
+
left: Uint8Array;
|
|
50
|
+
right: Uint8Array;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Builds a stereo WAV file from two mono pcm_s16le channels. Convention:
|
|
54
|
+
* left = user track, right = assistant track. Review tools can split them
|
|
55
|
+
* back out with any DAW.
|
|
56
|
+
*/
|
|
57
|
+
export declare const encodeStereoWav: ({ format, left, right, }: EncodeStereoWavInput) => Uint8Array;
|
|
58
|
+
export declare const createVoiceWavRecordingEncoder: () => VoiceRecordingEncoder;
|
|
20
59
|
export declare const computePcmDurationMs: (pcmByteLength: number, format: AudioFormat) => number;
|
|
21
60
|
export declare const createVoiceMemoryRecordingStore: () => VoiceRecordingStore;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type VoiceRetentionPolicyOptions = {
|
|
2
|
+
/** Maximum age in milliseconds; events older than this are eligible for purge. */
|
|
3
|
+
maxAgeMs: number;
|
|
4
|
+
/** Optional override that returns the timestamp for an event. Defaults to event.at. */
|
|
5
|
+
resolveAt?: (event: unknown) => number | undefined;
|
|
6
|
+
};
|
|
7
|
+
export type VoiceRetentionStore<TRecord extends {
|
|
8
|
+
id: string;
|
|
9
|
+
}> = {
|
|
10
|
+
list: (filter?: Record<string, unknown>) => Promise<TRecord[]> | TRecord[];
|
|
11
|
+
remove: (id: string) => Promise<void> | void;
|
|
12
|
+
};
|
|
13
|
+
export type VoicePurgeReport = {
|
|
14
|
+
attempted: number;
|
|
15
|
+
failed: number;
|
|
16
|
+
purgedIds: string[];
|
|
17
|
+
reason: "expired" | "manual";
|
|
18
|
+
removed: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const purgeVoiceRetentionStore: <TRecord extends {
|
|
21
|
+
id: string;
|
|
22
|
+
}>(store: VoiceRetentionStore<TRecord>, options: VoiceRetentionPolicyOptions, now?: number) => Promise<VoicePurgeReport>;
|
|
23
|
+
export type VoiceRetentionScheduler = {
|
|
24
|
+
start: () => void;
|
|
25
|
+
stop: () => void;
|
|
26
|
+
};
|
|
27
|
+
export type CreateVoiceRetentionSchedulerOptions<TRecord extends {
|
|
28
|
+
id: string;
|
|
29
|
+
}> = {
|
|
30
|
+
intervalMs?: number;
|
|
31
|
+
onReport?: (report: VoicePurgeReport) => void;
|
|
32
|
+
policy: VoiceRetentionPolicyOptions;
|
|
33
|
+
store: VoiceRetentionStore<TRecord>;
|
|
34
|
+
};
|
|
35
|
+
export declare const createVoiceRetentionScheduler: <TRecord extends {
|
|
36
|
+
id: string;
|
|
37
|
+
}>(options: CreateVoiceRetentionSchedulerOptions<TRecord>) => VoiceRetentionScheduler;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Elysia } from "elysia";
|
|
2
|
+
export type VoiceRouteAuthDecision = {
|
|
3
|
+
allow: true;
|
|
4
|
+
} | {
|
|
5
|
+
allow: false;
|
|
6
|
+
reason: string;
|
|
7
|
+
status?: number;
|
|
8
|
+
};
|
|
9
|
+
export type VoiceRouteAuthInput = {
|
|
10
|
+
body?: string;
|
|
11
|
+
headers: Headers;
|
|
12
|
+
method: string;
|
|
13
|
+
url: string;
|
|
14
|
+
};
|
|
15
|
+
export type VoiceRouteAuthVerifier = (input: VoiceRouteAuthInput) => Promise<VoiceRouteAuthDecision> | VoiceRouteAuthDecision;
|
|
16
|
+
export type VoiceRouteAuthOptions = {
|
|
17
|
+
bypassPaths?: ReadonlyArray<string>;
|
|
18
|
+
name?: string;
|
|
19
|
+
verify: VoiceRouteAuthVerifier;
|
|
20
|
+
};
|
|
21
|
+
export declare const createVoiceBearerAuthVerifier: (input: {
|
|
22
|
+
expectedToken: string;
|
|
23
|
+
headerName?: string;
|
|
24
|
+
}) => VoiceRouteAuthVerifier;
|
|
25
|
+
export declare const createVoiceHMACAuthVerifier: (input: {
|
|
26
|
+
secret: string;
|
|
27
|
+
toleranceMs?: number;
|
|
28
|
+
}) => VoiceRouteAuthVerifier;
|
|
29
|
+
export declare const createVoiceRouteAuth: (options: VoiceRouteAuthOptions) => Elysia<"", {
|
|
30
|
+
decorator: {};
|
|
31
|
+
store: {};
|
|
32
|
+
derive: {};
|
|
33
|
+
resolve: {};
|
|
34
|
+
}, {
|
|
35
|
+
typebox: {};
|
|
36
|
+
error: {};
|
|
37
|
+
}, {
|
|
38
|
+
schema: {};
|
|
39
|
+
standaloneSchema: {};
|
|
40
|
+
macro: {};
|
|
41
|
+
macroFn: {};
|
|
42
|
+
parser: {};
|
|
43
|
+
response: {};
|
|
44
|
+
}, {}, {
|
|
45
|
+
derive: {};
|
|
46
|
+
resolve: {};
|
|
47
|
+
schema: {};
|
|
48
|
+
standaloneSchema: {};
|
|
49
|
+
response: {};
|
|
50
|
+
}, {
|
|
51
|
+
derive: {};
|
|
52
|
+
resolve: {};
|
|
53
|
+
schema: {};
|
|
54
|
+
standaloneSchema: {};
|
|
55
|
+
response: {
|
|
56
|
+
200: Response;
|
|
57
|
+
};
|
|
58
|
+
}>;
|
package/dist/testing/index.js
CHANGED
|
@@ -5381,6 +5381,39 @@ var encodePcmAsWav = (pcm, format) => {
|
|
|
5381
5381
|
output.set(pcm, 44);
|
|
5382
5382
|
return output;
|
|
5383
5383
|
};
|
|
5384
|
+
var interleaveStereoPcm = (input) => {
|
|
5385
|
+
const leftSamples = new Int16Array(input.left.buffer, input.left.byteOffset, Math.floor(input.left.byteLength / 2));
|
|
5386
|
+
const rightSamples = new Int16Array(input.right.buffer, input.right.byteOffset, Math.floor(input.right.byteLength / 2));
|
|
5387
|
+
const frameCount = Math.max(leftSamples.length, rightSamples.length);
|
|
5388
|
+
const output = new Int16Array(frameCount * 2);
|
|
5389
|
+
for (let frame = 0;frame < frameCount; frame += 1) {
|
|
5390
|
+
output[frame * 2] = leftSamples[frame] ?? 0;
|
|
5391
|
+
output[frame * 2 + 1] = rightSamples[frame] ?? 0;
|
|
5392
|
+
}
|
|
5393
|
+
return new Uint8Array(output.buffer);
|
|
5394
|
+
};
|
|
5395
|
+
var encodeStereoWav = ({
|
|
5396
|
+
format,
|
|
5397
|
+
left,
|
|
5398
|
+
right
|
|
5399
|
+
}) => {
|
|
5400
|
+
if (format.container !== "raw" || format.encoding !== "pcm_s16le") {
|
|
5401
|
+
throw new Error("encodeStereoWav requires raw pcm_s16le format on each channel");
|
|
5402
|
+
}
|
|
5403
|
+
if (format.channels !== 1) {
|
|
5404
|
+
throw new Error("encodeStereoWav expects mono input channels");
|
|
5405
|
+
}
|
|
5406
|
+
const interleaved = interleaveStereoPcm({ left, right });
|
|
5407
|
+
return encodePcmAsWav(interleaved, { ...format, channels: 2 });
|
|
5408
|
+
};
|
|
5409
|
+
var createVoiceWavRecordingEncoder = () => ({
|
|
5410
|
+
encode: ({ format, pcm }) => ({
|
|
5411
|
+
bytes: encodePcmAsWav(pcm, format),
|
|
5412
|
+
contentType: "audio/wav",
|
|
5413
|
+
extension: "wav"
|
|
5414
|
+
}),
|
|
5415
|
+
kind: "wav"
|
|
5416
|
+
});
|
|
5384
5417
|
var computePcmDurationMs = (pcmByteLength, format) => {
|
|
5385
5418
|
if (format.container !== "raw" || format.encoding !== "pcm_s16le") {
|
|
5386
5419
|
return 0;
|