@absolutejs/voice 0.0.22-beta.185 → 0.0.22-beta.187
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/dataControl.d.ts +3 -1
- package/dist/fileStore.d.ts +5 -2
- package/dist/incidentBundle.d.ts +50 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +140 -5
- package/package.json +1 -1
package/dist/dataControl.d.ts
CHANGED
|
@@ -2,13 +2,15 @@ import type { VoiceCampaignStore } from './campaign';
|
|
|
2
2
|
import { type VoiceAuditActor, type VoiceAuditEventStore } from './audit';
|
|
3
3
|
import type { VoiceAuditSinkDeliveryStore } from './auditSinks';
|
|
4
4
|
import type { VoiceIntegrationEventStore, VoiceOpsTaskStore } from './ops';
|
|
5
|
+
import type { VoiceIncidentBundleStore } from './incidentBundle';
|
|
5
6
|
import type { VoiceCallReviewStore } from './testing/review';
|
|
6
7
|
import type { VoiceTraceEventStore, VoiceTracePruneFilter, VoiceTraceSinkDeliveryStore } from './trace';
|
|
7
8
|
import type { VoiceSessionStore } from './types';
|
|
8
|
-
export type VoiceDataRetentionScope = 'auditDeliveries' | 'campaigns' | 'events' | 'reviews' | 'sessions' | 'tasks' | 'traceDeliveries' | 'traces';
|
|
9
|
+
export type VoiceDataRetentionScope = 'auditDeliveries' | 'campaigns' | 'events' | 'incidentBundles' | 'reviews' | 'sessions' | 'tasks' | 'traceDeliveries' | 'traces';
|
|
9
10
|
export type VoiceDataRetentionStores = {
|
|
10
11
|
campaigns?: VoiceCampaignStore;
|
|
11
12
|
events?: VoiceIntegrationEventStore;
|
|
13
|
+
incidentBundles?: VoiceIncidentBundleStore;
|
|
12
14
|
reviews?: VoiceCallReviewStore;
|
|
13
15
|
session?: VoiceSessionStore;
|
|
14
16
|
sessions?: VoiceSessionStore;
|
package/dist/fileStore.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type StoredVoiceAuditEvent, type VoiceAuditEventStore } from './audit';
|
|
|
2
2
|
import type { VoiceAuditSinkDeliveryRecord, VoiceAuditSinkDeliveryStore } from './auditSinks';
|
|
3
3
|
import type { VoiceCampaignStore } from './campaign';
|
|
4
4
|
import { type VoiceAssistantMemoryRecord, type VoiceAssistantMemoryStore } from './assistantMemory';
|
|
5
|
+
import type { StoredVoiceIncidentBundleArtifact, VoiceIncidentBundleStore } from './incidentBundle';
|
|
5
6
|
import { type StoredVoiceTraceEvent, type VoiceTraceSinkDeliveryRecord, type VoiceTraceSinkDeliveryStore, type VoiceTraceEventStore } from './trace';
|
|
6
7
|
import type { StoredVoiceIntegrationEvent, StoredVoiceExternalObjectMap, StoredVoiceOpsTask, VoiceExternalObjectMap, VoiceExternalObjectMapStore, VoiceIntegrationEvent, VoiceIntegrationEventStore, VoiceOpsTask, VoiceOpsTaskStore } from './ops';
|
|
7
8
|
import type { StoredVoiceCallReviewArtifact, VoiceCallReviewArtifact, VoiceCallReviewStore } from './testing/review';
|
|
@@ -10,12 +11,13 @@ export type VoiceFileStoreOptions = {
|
|
|
10
11
|
directory: string;
|
|
11
12
|
pretty?: boolean;
|
|
12
13
|
};
|
|
13
|
-
export type VoiceFileRuntimeStorage<TSession extends VoiceSessionRecord = VoiceSessionRecord, TReview extends StoredVoiceCallReviewArtifact = StoredVoiceCallReviewArtifact, TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask, TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent, TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap, TTrace extends StoredVoiceTraceEvent = StoredVoiceTraceEvent, TTraceDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord, TAudit extends StoredVoiceAuditEvent = StoredVoiceAuditEvent, TAuditDelivery extends VoiceAuditSinkDeliveryRecord = VoiceAuditSinkDeliveryRecord, TMemory extends VoiceAssistantMemoryRecord = VoiceAssistantMemoryRecord> = {
|
|
14
|
+
export type VoiceFileRuntimeStorage<TSession extends VoiceSessionRecord = VoiceSessionRecord, TReview extends StoredVoiceCallReviewArtifact = StoredVoiceCallReviewArtifact, TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask, TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent, TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap, TTrace extends StoredVoiceTraceEvent = StoredVoiceTraceEvent, TTraceDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord, TAudit extends StoredVoiceAuditEvent = StoredVoiceAuditEvent, TAuditDelivery extends VoiceAuditSinkDeliveryRecord = VoiceAuditSinkDeliveryRecord, TIncident extends StoredVoiceIncidentBundleArtifact = StoredVoiceIncidentBundleArtifact, TMemory extends VoiceAssistantMemoryRecord = VoiceAssistantMemoryRecord> = {
|
|
14
15
|
audit: VoiceAuditEventStore<TAudit>;
|
|
15
16
|
auditDeliveries: VoiceAuditSinkDeliveryStore<TAuditDelivery>;
|
|
16
17
|
campaigns: VoiceCampaignStore;
|
|
17
18
|
events: VoiceIntegrationEventStore<TEvent>;
|
|
18
19
|
externalObjects: VoiceExternalObjectMapStore<TMapping>;
|
|
20
|
+
incidentBundles: VoiceIncidentBundleStore<TIncident>;
|
|
19
21
|
memories: VoiceAssistantMemoryStore<TMemory>;
|
|
20
22
|
reviews: VoiceCallReviewStore<TReview>;
|
|
21
23
|
session: VoiceSessionStore<TSession>;
|
|
@@ -34,7 +36,8 @@ export declare const createVoiceFileTraceSinkDeliveryStore: <TDelivery extends V
|
|
|
34
36
|
export declare const createVoiceFileAuditEventStore: <TEvent extends StoredVoiceAuditEvent = StoredVoiceAuditEvent>(options: VoiceFileStoreOptions) => VoiceAuditEventStore<TEvent>;
|
|
35
37
|
export declare const createVoiceFileAuditSinkDeliveryStore: <TDelivery extends VoiceAuditSinkDeliveryRecord = VoiceAuditSinkDeliveryRecord>(options: VoiceFileStoreOptions) => VoiceAuditSinkDeliveryStore<TDelivery>;
|
|
36
38
|
export declare const createVoiceFileAssistantMemoryStore: <TRecord extends VoiceAssistantMemoryRecord = VoiceAssistantMemoryRecord>(options: VoiceFileStoreOptions) => VoiceAssistantMemoryStore<TRecord>;
|
|
37
|
-
export declare const
|
|
39
|
+
export declare const createVoiceFileIncidentBundleStore: <TArtifact extends StoredVoiceIncidentBundleArtifact = StoredVoiceIncidentBundleArtifact>(options: VoiceFileStoreOptions) => VoiceIncidentBundleStore<TArtifact>;
|
|
40
|
+
export declare const createVoiceFileRuntimeStorage: <TSession extends VoiceSessionRecord = VoiceSessionRecord, TReview extends StoredVoiceCallReviewArtifact = StoredVoiceCallReviewArtifact, TTask extends StoredVoiceOpsTask = StoredVoiceOpsTask, TEvent extends StoredVoiceIntegrationEvent = StoredVoiceIntegrationEvent, TMapping extends StoredVoiceExternalObjectMap = StoredVoiceExternalObjectMap, TTrace extends StoredVoiceTraceEvent = StoredVoiceTraceEvent, TTraceDelivery extends VoiceTraceSinkDeliveryRecord = VoiceTraceSinkDeliveryRecord, TAudit extends StoredVoiceAuditEvent = StoredVoiceAuditEvent, TAuditDelivery extends VoiceAuditSinkDeliveryRecord = VoiceAuditSinkDeliveryRecord, TIncident extends StoredVoiceIncidentBundleArtifact = StoredVoiceIncidentBundleArtifact, TMemory extends VoiceAssistantMemoryRecord = VoiceAssistantMemoryRecord>(options: VoiceFileStoreOptions) => VoiceFileRuntimeStorage<TSession, TReview, TTask, TEvent, TMapping, TTrace, TTraceDelivery, TAudit, TAuditDelivery, TIncident, TMemory>;
|
|
38
41
|
export declare const createStoredVoiceCallReviewArtifact: <TArtifact extends VoiceCallReviewArtifact = VoiceCallReviewArtifact>(id: string, artifact: TArtifact) => TArtifact & {
|
|
39
42
|
id: string;
|
|
40
43
|
};
|
package/dist/incidentBundle.d.ts
CHANGED
|
@@ -13,6 +13,25 @@ export type VoiceIncidentBundle = {
|
|
|
13
13
|
summary: VoiceIncidentBundleSummary;
|
|
14
14
|
traceMarkdown: string;
|
|
15
15
|
};
|
|
16
|
+
export type StoredVoiceIncidentBundleArtifact = {
|
|
17
|
+
bundle: VoiceIncidentBundle;
|
|
18
|
+
createdAt: number;
|
|
19
|
+
expiresAt?: number;
|
|
20
|
+
id: string;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
redacted: boolean;
|
|
23
|
+
sessionId: string;
|
|
24
|
+
};
|
|
25
|
+
export type VoiceIncidentBundleStoreFilter = {
|
|
26
|
+
expiredAt?: number;
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
};
|
|
29
|
+
export type VoiceIncidentBundleStore<TArtifact extends StoredVoiceIncidentBundleArtifact = StoredVoiceIncidentBundleArtifact> = {
|
|
30
|
+
get: (id: string) => Promise<TArtifact | undefined> | TArtifact | undefined;
|
|
31
|
+
list: (filter?: VoiceIncidentBundleStoreFilter) => Promise<TArtifact[]> | TArtifact[];
|
|
32
|
+
remove: (id: string) => Promise<void> | void;
|
|
33
|
+
set: (id: string, artifact: TArtifact) => Promise<void> | void;
|
|
34
|
+
};
|
|
16
35
|
export type VoiceIncidentBundleSummary = {
|
|
17
36
|
auditEvents: number;
|
|
18
37
|
durationMs?: number;
|
|
@@ -35,6 +54,37 @@ export type VoiceIncidentBundleRoutesOptions = Omit<VoiceIncidentBundleOptions,
|
|
|
35
54
|
name?: string;
|
|
36
55
|
path?: string;
|
|
37
56
|
};
|
|
57
|
+
export type VoiceIncidentBundleArtifactOptions = {
|
|
58
|
+
createdAt?: number;
|
|
59
|
+
expiresAt?: number;
|
|
60
|
+
id?: string;
|
|
61
|
+
metadata?: Record<string, unknown>;
|
|
62
|
+
ttlMs?: number;
|
|
63
|
+
};
|
|
64
|
+
export type VoiceIncidentBundleRetentionOptions = {
|
|
65
|
+
before?: number;
|
|
66
|
+
beforeOrAt?: number;
|
|
67
|
+
dryRun?: boolean;
|
|
68
|
+
expiredAt?: number;
|
|
69
|
+
keepNewest?: number;
|
|
70
|
+
limit?: number;
|
|
71
|
+
store: VoiceIncidentBundleStore;
|
|
72
|
+
};
|
|
73
|
+
export type VoiceIncidentBundleRetentionReport = {
|
|
74
|
+
deleted: StoredVoiceIncidentBundleArtifact[];
|
|
75
|
+
deletedCount: number;
|
|
76
|
+
deletedIds: string[];
|
|
77
|
+
dryRun: boolean;
|
|
78
|
+
scannedCount: number;
|
|
79
|
+
};
|
|
80
|
+
export declare const createVoiceMemoryIncidentBundleStore: <TArtifact extends StoredVoiceIncidentBundleArtifact = StoredVoiceIncidentBundleArtifact>() => VoiceIncidentBundleStore<TArtifact>;
|
|
81
|
+
export declare const createStoredVoiceIncidentBundleArtifact: (bundle: VoiceIncidentBundle, options?: VoiceIncidentBundleArtifactOptions) => StoredVoiceIncidentBundleArtifact;
|
|
82
|
+
export declare const saveVoiceIncidentBundleArtifact: (input: {
|
|
83
|
+
bundle: VoiceIncidentBundle;
|
|
84
|
+
options?: VoiceIncidentBundleArtifactOptions;
|
|
85
|
+
store: VoiceIncidentBundleStore;
|
|
86
|
+
}) => Promise<StoredVoiceIncidentBundleArtifact>;
|
|
87
|
+
export declare const pruneVoiceIncidentBundleArtifacts: (options: VoiceIncidentBundleRetentionOptions) => Promise<VoiceIncidentBundleRetentionReport>;
|
|
38
88
|
export declare const buildVoiceIncidentBundle: (options: VoiceIncidentBundleOptions) => Promise<VoiceIncidentBundle>;
|
|
39
89
|
export declare const createVoiceIncidentBundleRoutes: (options: VoiceIncidentBundleRoutesOptions) => Elysia<"", {
|
|
40
90
|
decorator: {};
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { createVoiceTurnQualityHTMLHandler, createVoiceTurnQualityJSONHandler, c
|
|
|
35
35
|
export { createVoiceOutcomeContractHTMLHandler, createVoiceOutcomeContractJSONHandler, createVoiceOutcomeContractRoutes, renderVoiceOutcomeContractHTML, runVoiceOutcomeContractSuite } from './outcomeContract';
|
|
36
36
|
export { applyVoiceTelephonyOutcome, createMemoryVoiceTelephonyWebhookIdempotencyStore, createVoiceTelephonyOutcomePolicy, createVoiceTelephonyWebhookHandler, createVoiceTelephonyWebhookRoutes, parseVoiceTelephonyWebhookEvent, resolveVoiceTelephonyOutcome, signVoiceTwilioWebhook, verifyVoiceTwilioWebhookSignature, voiceTelephonyOutcomeToRouteResult } from './telephonyOutcome';
|
|
37
37
|
export { createVoicePhoneAgent } from './phoneAgent';
|
|
38
|
-
export { createStoredVoiceCallReviewArtifact, createStoredVoiceExternalObjectMap, createStoredVoiceIntegrationEvent, createStoredVoiceOpsTask, createVoiceFileExternalObjectMapStore, createVoiceFileAssistantMemoryStore, createVoiceFileAuditEventStore, createVoiceFileAuditSinkDeliveryStore, createVoiceFileCampaignStore, createVoiceFileIntegrationEventStore, createVoiceFileReviewStore, createVoiceFileRuntimeStorage, createVoiceFileSessionStore, createVoiceFileTaskStore, createVoiceFileTraceSinkDeliveryStore, createVoiceFileTraceEventStore } from './fileStore';
|
|
38
|
+
export { createStoredVoiceCallReviewArtifact, createStoredVoiceExternalObjectMap, createStoredVoiceIntegrationEvent, createStoredVoiceOpsTask, createVoiceFileIncidentBundleStore, createVoiceFileExternalObjectMapStore, createVoiceFileAssistantMemoryStore, createVoiceFileAuditEventStore, createVoiceFileAuditSinkDeliveryStore, createVoiceFileCampaignStore, createVoiceFileIntegrationEventStore, createVoiceFileReviewStore, createVoiceFileRuntimeStorage, createVoiceFileSessionStore, createVoiceFileTaskStore, createVoiceFileTraceSinkDeliveryStore, createVoiceFileTraceEventStore } from './fileStore';
|
|
39
39
|
export { createVoiceAssistantMemoryHandle, createVoiceAssistantMemoryRecord, createVoiceMemoryAssistantMemoryStore, resolveVoiceAssistantMemoryNamespace } from './assistantMemory';
|
|
40
40
|
export { createAnthropicVoiceAssistantModel, createGeminiVoiceAssistantModel, createJSONVoiceAssistantModel, createOpenAIVoiceAssistantModel, resolveVoiceProviderRoutingPolicyPreset, createVoiceProviderRouter } from './modelAdapters';
|
|
41
41
|
export { createOpenAIRealtimeAdapter } from './openaiRealtime';
|
|
@@ -49,7 +49,7 @@ export { createVoiceReadinessProfile, recommendVoiceReadinessProfile } from './r
|
|
|
49
49
|
export { buildVoiceProviderContractMatrix, createVoiceProviderContractMatrixHTMLHandler, createVoiceProviderContractMatrixJSONHandler, createVoiceProviderContractMatrixPreset, createVoiceProviderContractMatrixRoutes, evaluateVoiceProviderStackGaps, renderVoiceProviderContractMatrixHTML, recommendVoiceProviderStack } from './providerStackRecommendations';
|
|
50
50
|
export { buildVoiceOpsConsoleReport, createVoiceOpsConsoleRoutes, renderVoiceOpsConsoleHTML } from './opsConsoleRoutes';
|
|
51
51
|
export { buildVoiceOperationsRecord, createVoiceOperationsRecordRoutes, renderVoiceOperationsRecordHTML } from './operationsRecord';
|
|
52
|
-
export { buildVoiceIncidentBundle, createVoiceIncidentBundleRoutes } from './incidentBundle';
|
|
52
|
+
export { buildVoiceIncidentBundle, createStoredVoiceIncidentBundleArtifact, createVoiceIncidentBundleRoutes, createVoiceMemoryIncidentBundleStore, pruneVoiceIncidentBundleArtifacts, saveVoiceIncidentBundleArtifact } from './incidentBundle';
|
|
53
53
|
export { summarizeVoiceOpsStatus } from './opsStatus';
|
|
54
54
|
export { createVoiceOpsStatusRoutes, renderVoiceOpsStatusHTML } from './opsStatusRoutes';
|
|
55
55
|
export { createVoiceQualityRoutes, evaluateVoiceQuality, renderVoiceQualityHTML } from './qualityRoutes';
|
|
@@ -110,7 +110,7 @@ export type { VoiceProductionReadinessAction, VoiceProductionReadinessAuditOptio
|
|
|
110
110
|
export type { VoiceReadinessProfileName, VoiceReadinessProfileOptions, VoiceReadinessProfileRecommendation, VoiceReadinessProfileRecommendationScore, VoiceReadinessProfileRoutesOptions } from './readinessProfiles';
|
|
111
111
|
export type { VoiceProviderStackChoice, VoiceProviderStackCapabilities, VoiceProviderStackCapabilityGap, VoiceProviderStackCapabilityGapInput, VoiceProviderStackCapabilityGapReport, VoiceProviderContractCheck, VoiceProviderContractCheckStatus, VoiceProviderContractDefinition, VoiceProviderContractMatrixHandlerOptions, VoiceProviderContractMatrixHTMLHandlerOptions, VoiceProviderContractMatrixInput, VoiceProviderContractMatrixPresetOptions, VoiceProviderContractMatrixReport, VoiceProviderContractMatrixRoutesOptions, VoiceProviderContractMatrixRow, VoiceProviderStackInput, VoiceProviderStackKind, VoiceProviderStackRecommendation } from './providerStackRecommendations';
|
|
112
112
|
export type { VoiceOperationsRecord, VoiceOperationsRecordAgentHandoff, VoiceOperationsRecordAuditSummary, VoiceOperationsRecordOptions, VoiceOperationsRecordOutcome, VoiceOperationsRecordRoutesOptions, VoiceOperationsRecordStatus, VoiceOperationsRecordTool } from './operationsRecord';
|
|
113
|
-
export type { VoiceIncidentBundle, VoiceIncidentBundleFormat, VoiceIncidentBundleOptions, VoiceIncidentBundleRoutesOptions, VoiceIncidentBundleSummary } from './incidentBundle';
|
|
113
|
+
export type { StoredVoiceIncidentBundleArtifact, VoiceIncidentBundle, VoiceIncidentBundleArtifactOptions, VoiceIncidentBundleFormat, VoiceIncidentBundleOptions, VoiceIncidentBundleRetentionOptions, VoiceIncidentBundleRetentionReport, VoiceIncidentBundleRoutesOptions, VoiceIncidentBundleStore, VoiceIncidentBundleStoreFilter, VoiceIncidentBundleSummary } from './incidentBundle';
|
|
114
114
|
export type { VoiceQualityLink, VoiceQualityMetric, VoiceQualityReport, VoiceQualityRoutesOptions, VoiceQualityStatus, VoiceQualityThresholds } from './qualityRoutes';
|
|
115
115
|
export type { VoiceResilienceIOSimulator, VoiceResilienceLink, VoiceResiliencePageData, VoiceResilienceRoutesOptions, VoiceResilienceSimulationProvider, VoiceRoutingKindSummary, VoiceRoutingDecisionSummary, VoiceRoutingDecisionSummaryOptions, VoiceRoutingEvent, VoiceRoutingEventKind, VoiceRoutingSessionSummary, VoiceRoutingSessionSummaryOptions } from './resilienceRoutes';
|
|
116
116
|
export type { VoiceIOProviderRouterEvent, VoiceIOProviderRouterOptions, VoiceIOProviderRouterPolicy, VoiceIOProviderRouterPolicyConfig, VoiceSTTProviderRouterOptions, VoiceTTSProviderRouterOptions } from './providerAdapters';
|
package/dist/index.js
CHANGED
|
@@ -12063,6 +12063,7 @@ var allRetentionScopes = [
|
|
|
12063
12063
|
"auditDeliveries",
|
|
12064
12064
|
"campaigns",
|
|
12065
12065
|
"events",
|
|
12066
|
+
"incidentBundles",
|
|
12066
12067
|
"reviews",
|
|
12067
12068
|
"sessions",
|
|
12068
12069
|
"tasks",
|
|
@@ -12123,6 +12124,10 @@ var getEventRetentionRecord = (record) => ({
|
|
|
12123
12124
|
at: record.createdAt,
|
|
12124
12125
|
id: record.id
|
|
12125
12126
|
});
|
|
12127
|
+
var getIncidentBundleRetentionRecord = (record) => ({
|
|
12128
|
+
at: record.expiresAt ?? record.createdAt,
|
|
12129
|
+
id: record.id
|
|
12130
|
+
});
|
|
12126
12131
|
var getReviewRetentionRecord = (record) => ({
|
|
12127
12132
|
at: record.generatedAt ?? 0,
|
|
12128
12133
|
id: record.id
|
|
@@ -12215,6 +12220,13 @@ var applyVoiceDataRetentionPolicy = async (options) => {
|
|
|
12215
12220
|
toRecord: getEventRetentionRecord
|
|
12216
12221
|
}) : reportSkippedScope(scope, dryRun, "missing-store");
|
|
12217
12222
|
}
|
|
12223
|
+
if (scope === "incidentBundles") {
|
|
12224
|
+
return options.incidentBundles ? runRetentionScope({
|
|
12225
|
+
...common,
|
|
12226
|
+
store: options.incidentBundles,
|
|
12227
|
+
toRecord: getIncidentBundleRetentionRecord
|
|
12228
|
+
}) : reportSkippedScope(scope, dryRun, "missing-store");
|
|
12229
|
+
}
|
|
12218
12230
|
if (scope === "reviews") {
|
|
12219
12231
|
return options.reviews ? runRetentionScope({
|
|
12220
12232
|
...common,
|
|
@@ -18265,6 +18277,44 @@ var createVoiceFileAssistantMemoryStore = (options) => {
|
|
|
18265
18277
|
};
|
|
18266
18278
|
return { delete: remove, get, list, set };
|
|
18267
18279
|
};
|
|
18280
|
+
var createVoiceFileIncidentBundleStore = (options) => {
|
|
18281
|
+
const get = async (id) => {
|
|
18282
|
+
const path = resolveFilePath(options.directory, id);
|
|
18283
|
+
try {
|
|
18284
|
+
return await readJsonFile(path);
|
|
18285
|
+
} catch (error) {
|
|
18286
|
+
if (error.code === "ENOENT") {
|
|
18287
|
+
return;
|
|
18288
|
+
}
|
|
18289
|
+
throw error;
|
|
18290
|
+
}
|
|
18291
|
+
};
|
|
18292
|
+
const list = async (filter = {}) => {
|
|
18293
|
+
const files = await listJsonFiles(options.directory);
|
|
18294
|
+
const artifacts = await Promise.all(files.map((file) => readJsonFile(file)));
|
|
18295
|
+
return artifacts.filter((artifact) => {
|
|
18296
|
+
if (filter.sessionId && artifact.sessionId !== filter.sessionId) {
|
|
18297
|
+
return false;
|
|
18298
|
+
}
|
|
18299
|
+
if (typeof filter.expiredAt === "number" && (artifact.expiresAt === undefined || artifact.expiresAt > filter.expiredAt)) {
|
|
18300
|
+
return false;
|
|
18301
|
+
}
|
|
18302
|
+
return true;
|
|
18303
|
+
}).sort((left, right) => right.createdAt - left.createdAt || left.id.localeCompare(right.id));
|
|
18304
|
+
};
|
|
18305
|
+
const set = async (id, artifact) => {
|
|
18306
|
+
await writeJsonFile(resolveFilePath(options.directory, id), {
|
|
18307
|
+
...artifact,
|
|
18308
|
+
id
|
|
18309
|
+
}, options);
|
|
18310
|
+
};
|
|
18311
|
+
const remove = async (id) => {
|
|
18312
|
+
await rm(resolveFilePath(options.directory, id), {
|
|
18313
|
+
force: true
|
|
18314
|
+
});
|
|
18315
|
+
};
|
|
18316
|
+
return { get, list, remove, set };
|
|
18317
|
+
};
|
|
18268
18318
|
var createVoiceFileRuntimeStorage = (options) => ({
|
|
18269
18319
|
audit: createVoiceFileAuditEventStore({
|
|
18270
18320
|
...options,
|
|
@@ -18286,6 +18336,10 @@ var createVoiceFileRuntimeStorage = (options) => ({
|
|
|
18286
18336
|
...options,
|
|
18287
18337
|
directory: join2(options.directory, "external-objects")
|
|
18288
18338
|
}),
|
|
18339
|
+
incidentBundles: createVoiceFileIncidentBundleStore({
|
|
18340
|
+
...options,
|
|
18341
|
+
directory: join2(options.directory, "incident-bundles")
|
|
18342
|
+
}),
|
|
18289
18343
|
memories: createVoiceFileAssistantMemoryStore({
|
|
18290
18344
|
...options,
|
|
18291
18345
|
directory: join2(options.directory, "memories")
|
|
@@ -22556,22 +22610,22 @@ var resolveOutcome4 = (events) => {
|
|
|
22556
22610
|
};
|
|
22557
22611
|
var buildVoiceOperationsRecord = async (options) => {
|
|
22558
22612
|
const sourceEvents = options.events ?? await options.store?.list({ sessionId: options.sessionId }) ?? [];
|
|
22559
|
-
const
|
|
22613
|
+
const rawTraceEvents = filterVoiceTraceEvents(sourceEvents, {
|
|
22560
22614
|
sessionId: options.sessionId
|
|
22561
22615
|
});
|
|
22616
|
+
const traceEvents = options.redact ? redactVoiceTraceEvents(rawTraceEvents, options.redact) : rawTraceEvents;
|
|
22562
22617
|
const timelineReport = summarizeVoiceTraceTimeline(traceEvents, {
|
|
22563
22618
|
evaluation: options.evaluation,
|
|
22564
|
-
limit: 1
|
|
22565
|
-
redact: options.redact
|
|
22619
|
+
limit: 1
|
|
22566
22620
|
});
|
|
22567
22621
|
const timelineSession = timelineReport.sessions[0];
|
|
22568
22622
|
const replay = await summarizeVoiceSessionReplay({
|
|
22569
22623
|
evaluation: options.evaluation,
|
|
22570
22624
|
events: traceEvents,
|
|
22571
|
-
redact: options.redact,
|
|
22572
22625
|
sessionId: options.sessionId
|
|
22573
22626
|
});
|
|
22574
|
-
const
|
|
22627
|
+
const rawAuditEvents = options.audit ? filterVoiceAuditEvents(await options.audit.list({ sessionId: options.sessionId })) : undefined;
|
|
22628
|
+
const auditEvents = options.redact && rawAuditEvents ? redactVoiceAuditEvents(rawAuditEvents, options.redact) : rawAuditEvents;
|
|
22575
22629
|
return {
|
|
22576
22630
|
audit: auditEvents ? {
|
|
22577
22631
|
error: countOutcome(auditEvents, "error"),
|
|
@@ -22646,6 +22700,82 @@ var createVoiceOperationsRecordRoutes = (options) => {
|
|
|
22646
22700
|
};
|
|
22647
22701
|
// src/incidentBundle.ts
|
|
22648
22702
|
import { Elysia as Elysia38 } from "elysia";
|
|
22703
|
+
var filterIncidentBundleArtifacts = (artifacts, filter = {}) => artifacts.filter((artifact) => {
|
|
22704
|
+
if (filter.sessionId && artifact.sessionId !== filter.sessionId) {
|
|
22705
|
+
return false;
|
|
22706
|
+
}
|
|
22707
|
+
if (typeof filter.expiredAt === "number" && (artifact.expiresAt === undefined || artifact.expiresAt > filter.expiredAt)) {
|
|
22708
|
+
return false;
|
|
22709
|
+
}
|
|
22710
|
+
return true;
|
|
22711
|
+
}).sort((left, right) => right.createdAt - left.createdAt || left.id.localeCompare(right.id));
|
|
22712
|
+
var createVoiceMemoryIncidentBundleStore = () => {
|
|
22713
|
+
const artifacts = new Map;
|
|
22714
|
+
return {
|
|
22715
|
+
get: (id) => artifacts.get(id),
|
|
22716
|
+
list: (filter) => filterIncidentBundleArtifacts([...artifacts.values()], filter),
|
|
22717
|
+
remove: (id) => {
|
|
22718
|
+
artifacts.delete(id);
|
|
22719
|
+
},
|
|
22720
|
+
set: (id, artifact) => {
|
|
22721
|
+
artifacts.set(id, {
|
|
22722
|
+
...artifact,
|
|
22723
|
+
id
|
|
22724
|
+
});
|
|
22725
|
+
}
|
|
22726
|
+
};
|
|
22727
|
+
};
|
|
22728
|
+
var createStoredVoiceIncidentBundleArtifact = (bundle, options = {}) => {
|
|
22729
|
+
const createdAt = options.createdAt ?? Date.now();
|
|
22730
|
+
return {
|
|
22731
|
+
bundle,
|
|
22732
|
+
createdAt,
|
|
22733
|
+
expiresAt: options.expiresAt ?? (typeof options.ttlMs === "number" ? createdAt + options.ttlMs : undefined),
|
|
22734
|
+
id: options.id ?? `voice-incident:${bundle.sessionId}:${bundle.exportedAt}:${crypto.randomUUID()}`,
|
|
22735
|
+
metadata: options.metadata,
|
|
22736
|
+
redacted: bundle.redacted,
|
|
22737
|
+
sessionId: bundle.sessionId
|
|
22738
|
+
};
|
|
22739
|
+
};
|
|
22740
|
+
var saveVoiceIncidentBundleArtifact = async (input) => {
|
|
22741
|
+
const artifact = createStoredVoiceIncidentBundleArtifact(input.bundle, input.options);
|
|
22742
|
+
await input.store.set(artifact.id, artifact);
|
|
22743
|
+
return artifact;
|
|
22744
|
+
};
|
|
22745
|
+
var retentionTimeMatch = (artifact, options) => {
|
|
22746
|
+
if (typeof options.expiredAt === "number" && (artifact.expiresAt === undefined || artifact.expiresAt > options.expiredAt)) {
|
|
22747
|
+
return false;
|
|
22748
|
+
}
|
|
22749
|
+
if (typeof options.before === "number" && artifact.createdAt >= options.before) {
|
|
22750
|
+
return false;
|
|
22751
|
+
}
|
|
22752
|
+
if (typeof options.beforeOrAt === "number" && artifact.createdAt > options.beforeOrAt) {
|
|
22753
|
+
return false;
|
|
22754
|
+
}
|
|
22755
|
+
return true;
|
|
22756
|
+
};
|
|
22757
|
+
var pruneVoiceIncidentBundleArtifacts = async (options) => {
|
|
22758
|
+
const dryRun = Boolean(options.dryRun);
|
|
22759
|
+
const artifacts = await options.store.list();
|
|
22760
|
+
let selected = artifacts.filter((artifact) => retentionTimeMatch(artifact, options)).sort((left, right) => left.createdAt - right.createdAt || left.id.localeCompare(right.id));
|
|
22761
|
+
if (typeof options.keepNewest === "number" && options.keepNewest >= 0) {
|
|
22762
|
+
const newest = new Set([...selected].sort((left, right) => right.createdAt - left.createdAt || right.id.localeCompare(left.id)).slice(0, options.keepNewest).map((artifact) => artifact.id));
|
|
22763
|
+
selected = selected.filter((artifact) => !newest.has(artifact.id));
|
|
22764
|
+
}
|
|
22765
|
+
if (typeof options.limit === "number" && options.limit >= 0) {
|
|
22766
|
+
selected = selected.slice(0, options.limit);
|
|
22767
|
+
}
|
|
22768
|
+
if (!dryRun) {
|
|
22769
|
+
await Promise.all(selected.map((artifact) => options.store.remove(artifact.id)));
|
|
22770
|
+
}
|
|
22771
|
+
return {
|
|
22772
|
+
deleted: selected,
|
|
22773
|
+
deletedCount: selected.length,
|
|
22774
|
+
deletedIds: selected.map((artifact) => artifact.id),
|
|
22775
|
+
dryRun,
|
|
22776
|
+
scannedCount: artifacts.length
|
|
22777
|
+
};
|
|
22778
|
+
};
|
|
22649
22779
|
var buildSummary = (record) => ({
|
|
22650
22780
|
auditEvents: record.audit?.total ?? 0,
|
|
22651
22781
|
durationMs: record.summary.callDurationMs,
|
|
@@ -25162,6 +25292,7 @@ export {
|
|
|
25162
25292
|
signVoicePlivoWebhook,
|
|
25163
25293
|
shapeTelephonyAssistantText,
|
|
25164
25294
|
selectVoiceTraceEventsForPrune,
|
|
25295
|
+
saveVoiceIncidentBundleArtifact,
|
|
25165
25296
|
runVoiceToolContractSuite,
|
|
25166
25297
|
runVoiceToolContract,
|
|
25167
25298
|
runVoiceSimulationSuite,
|
|
@@ -25254,6 +25385,7 @@ export {
|
|
|
25254
25385
|
recommendVoiceReadinessProfile,
|
|
25255
25386
|
recommendVoiceProviderStack,
|
|
25256
25387
|
pruneVoiceTraceEvents,
|
|
25388
|
+
pruneVoiceIncidentBundleArtifacts,
|
|
25257
25389
|
parseVoiceTelephonyWebhookEvent,
|
|
25258
25390
|
matchesVoiceOpsTaskAssignmentRule,
|
|
25259
25391
|
markVoiceOpsTaskSLABreached,
|
|
@@ -25412,6 +25544,7 @@ export {
|
|
|
25412
25544
|
createVoiceMemoryTraceSinkDeliveryStore,
|
|
25413
25545
|
createVoiceMemoryTraceEventStore,
|
|
25414
25546
|
createVoiceMemoryStore,
|
|
25547
|
+
createVoiceMemoryIncidentBundleStore,
|
|
25415
25548
|
createVoiceMemoryHandoffDeliveryStore,
|
|
25416
25549
|
createVoiceMemoryCampaignStore,
|
|
25417
25550
|
createVoiceMemoryAuditSinkDeliveryStore,
|
|
@@ -25444,6 +25577,7 @@ export {
|
|
|
25444
25577
|
createVoiceFileRuntimeStorage,
|
|
25445
25578
|
createVoiceFileReviewStore,
|
|
25446
25579
|
createVoiceFileIntegrationEventStore,
|
|
25580
|
+
createVoiceFileIncidentBundleStore,
|
|
25447
25581
|
createVoiceFileExternalObjectMapStore,
|
|
25448
25582
|
createVoiceFileEvalBaselineStore,
|
|
25449
25583
|
createVoiceFileDeliverySink,
|
|
@@ -25504,6 +25638,7 @@ export {
|
|
|
25504
25638
|
createTelnyxMediaStreamBridge,
|
|
25505
25639
|
createStoredVoiceOpsTask,
|
|
25506
25640
|
createStoredVoiceIntegrationEvent,
|
|
25641
|
+
createStoredVoiceIncidentBundleArtifact,
|
|
25507
25642
|
createStoredVoiceExternalObjectMap,
|
|
25508
25643
|
createStoredVoiceCallReviewArtifact,
|
|
25509
25644
|
createRiskyTurnCorrectionHandler,
|