@absolutejs/voice 0.0.22-beta.355 → 0.0.22-beta.356
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/audit.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type VoiceAuditEventType = 'handoff' | 'operator.action' | 'provider.call' | 'retention.policy' | 'tool.call';
|
|
1
|
+
export type VoiceAuditEventType = 'handoff' | 'operator.action' | 'profile.switch' | 'provider.call' | 'retention.policy' | 'tool.call';
|
|
2
2
|
export type VoiceAuditActor = {
|
|
3
3
|
id: string;
|
|
4
4
|
kind: 'agent' | 'operator' | 'system' | 'worker';
|
package/dist/index.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export { assertVoiceCompetitiveCoverage, buildVoiceCompetitiveCoverageReport, cr
|
|
|
31
31
|
export type { VoiceCompetitiveCoverageAssertionInput, VoiceCompetitiveCoverageAssertionReport, VoiceCompetitiveCoverageIssue, VoiceCompetitiveCoverageLevel, VoiceCompetitiveCoverageReport, VoiceCompetitiveCoverageReportInput, VoiceCompetitiveCoverageRoutesOptions, VoiceCompetitiveCoverageStatus, VoiceCompetitiveCoverageSummary, VoiceCompetitiveDepthLevel, VoiceCompetitiveEvidence, VoiceCompetitiveSurface } from './competitiveCoverage';
|
|
32
32
|
export type { VoicePlatformCoverageAssertionInput, VoicePlatformCoverageAssertionReport, VoicePlatformCoverageEvidence, VoicePlatformCoverageRoutesOptions, VoicePlatformCoverageStatus, VoicePlatformCoverageSummary, VoicePlatformCoverageSummaryInput, VoicePlatformCoverageSurface } from './platformCoverage';
|
|
33
33
|
export { assertVoiceProofTrendEvidence, buildEmptyVoiceProofTrendReport, buildVoiceProofTrendProfileSummaries, buildVoiceProofTrendRecommendationReport, buildVoiceProofTrendReportFromRealCallProfiles, buildVoiceProofTrendReport, buildVoiceRealCallProfileDefaults, buildVoiceRealCallProfileHistoryReport, createVoiceProofTrendRecommendationRoutes, createVoiceProofTrendRoutes, createVoiceRealCallProfileHistoryRoutes, DEFAULT_VOICE_PROOF_TREND_PROFILE_DEFINITIONS, DEFAULT_VOICE_PROOF_TRENDS_MAX_AGE_MS, evaluateVoiceProofTrendEvidence, formatVoiceProofTrendAge, normalizeVoiceProofTrendReport, readVoiceProofTrendReportFile, renderVoiceProofTrendRecommendationHTML, renderVoiceProofTrendRecommendationMarkdown, renderVoiceRealCallProfileHistoryHTML, renderVoiceRealCallProfileHistoryMarkdown, resolveVoiceRealCallProfileProviderRoute } from './proofTrends';
|
|
34
|
-
export { recommendVoiceProfileSwitch } from './profileSwitchRecommendation';
|
|
35
|
-
export type { VoiceProfileSwitchObservedSignals, VoiceProfileSwitchRecommendation, VoiceProfileSwitchRecommendationOptions } from './profileSwitchRecommendation';
|
|
34
|
+
export { applyVoiceProfileSwitchGuard, recommendVoiceProfileSwitch } from './profileSwitchRecommendation';
|
|
35
|
+
export type { VoiceProfileSwitchGuardAction, VoiceProfileSwitchGuardDecision, VoiceProfileSwitchGuardMode, VoiceProfileSwitchGuardOptions, VoiceProfileSwitchObservedSignals, VoiceProfileSwitchRecommendation, VoiceProfileSwitchRecommendationOptions } from './profileSwitchRecommendation';
|
|
36
36
|
export { buildVoiceProviderDecisionTraceReport, createVoiceProviderDecisionTraceEvent, createVoiceProviderDecisionTraceRoutes, listVoiceProviderDecisionTraces, renderVoiceProviderDecisionTraceHTML, renderVoiceProviderDecisionTraceMarkdown } from './providerDecisionTraces';
|
|
37
37
|
export type { VoiceProviderDecisionStatus, VoiceProviderDecisionSurfaceReport, VoiceProviderDecisionTrace, VoiceProviderDecisionTraceInput, VoiceProviderDecisionTraceIssue, VoiceProviderDecisionTraceReport, VoiceProviderDecisionTraceReportOptions, VoiceProviderDecisionTraceRoutesOptions } from './providerDecisionTraces';
|
|
38
38
|
export type { VoiceProofTrendAssertionInput, VoiceProofTrendAssertionReport, VoiceProofTrendCycle, VoiceProofTrendProfileDefinition, VoiceProofTrendProfileRecommendation, VoiceProofTrendProfileSummaryOptions, VoiceProofTrendProfileSummary, VoiceProofTrendProviderRecommendation, VoiceProofTrendProviderSummary, VoiceProofTrendRecommendation, VoiceProofTrendRecommendationOptions, VoiceProofTrendRecommendationReport, VoiceProofTrendRecommendationRoutesOptions, VoiceProofTrendRecommendationStatus, VoiceProofTrendRecommendationSurface, VoiceProofTrendRealCallProfileEvidence, VoiceProofTrendRealCallProfileReportOptions, VoiceProofTrendReport, VoiceProofTrendReportInput, VoiceProofTrendRoutesOptions, VoiceProofTrendRuntimeChannelSummary, VoiceProofTrendStatus, VoiceProofTrendSummary, VoiceRealCallProfileDefault, VoiceRealCallProfileDefaultsOptions, VoiceRealCallProfileDefaultsReport, VoiceRealCallProfileHistoryOptions, VoiceRealCallProfileHistoryReport, VoiceRealCallProfileHistoryRoutesOptions, VoiceRealCallProfileProviderRouteOptions } from './proofTrends';
|
package/dist/index.js
CHANGED
|
@@ -15707,6 +15707,32 @@ var scoreProfile = (profile, observed) => {
|
|
|
15707
15707
|
const noisyBonus = (observed.fallbackUsed || (observed.turnWarnings ?? 0) > 0) && /noisy|phone/i.test(`${profile.profileId} ${profile.label ?? ""}`) ? -1000 : 0;
|
|
15708
15708
|
return live + provider + turn + statusPenalty + noisyBonus;
|
|
15709
15709
|
};
|
|
15710
|
+
var clampConfidence = (value) => Math.max(0, Math.min(0.99, Number(value.toFixed(2))));
|
|
15711
|
+
var estimateSwitchConfidence = (recommendation) => {
|
|
15712
|
+
if (!recommendation.ok || recommendation.status !== "switch") {
|
|
15713
|
+
return recommendation.status === "stay" && recommendation.ok ? 0.99 : 0;
|
|
15714
|
+
}
|
|
15715
|
+
const observed = recommendation.observed;
|
|
15716
|
+
const currentStatus = recommendation.currentProfile?.status;
|
|
15717
|
+
const recommendedStatus = recommendation.recommendedProfile?.status;
|
|
15718
|
+
let confidence = 0.58;
|
|
15719
|
+
if (currentStatus && currentStatus !== "pass") {
|
|
15720
|
+
confidence += 0.12;
|
|
15721
|
+
}
|
|
15722
|
+
if (recommendedStatus === "pass") {
|
|
15723
|
+
confidence += 0.1;
|
|
15724
|
+
}
|
|
15725
|
+
if (observed.fallbackUsed) {
|
|
15726
|
+
confidence += 0.08;
|
|
15727
|
+
}
|
|
15728
|
+
if ((observed.turnWarnings ?? 0) > 0) {
|
|
15729
|
+
confidence += 0.08;
|
|
15730
|
+
}
|
|
15731
|
+
if (recommendation.reasons.some((reason) => /budget|strongest measured fit/i.test(reason))) {
|
|
15732
|
+
confidence += 0.08;
|
|
15733
|
+
}
|
|
15734
|
+
return clampConfidence(confidence);
|
|
15735
|
+
};
|
|
15710
15736
|
var recommendVoiceProfileSwitch = (options) => {
|
|
15711
15737
|
const defaults = readDefaults(options.defaults);
|
|
15712
15738
|
const observed = options.observed ?? {};
|
|
@@ -15760,6 +15786,62 @@ var recommendVoiceProfileSwitch = (options) => {
|
|
|
15760
15786
|
status: issues.length > 0 ? "warn" : shouldSwitch ? "switch" : "stay"
|
|
15761
15787
|
};
|
|
15762
15788
|
};
|
|
15789
|
+
var applyVoiceProfileSwitchGuard = async (options) => {
|
|
15790
|
+
const mode = options.mode ?? "recommend";
|
|
15791
|
+
const minConfidence = options.minConfidence ?? 0.75;
|
|
15792
|
+
const recommendation = recommendVoiceProfileSwitch(options);
|
|
15793
|
+
const confidence = estimateSwitchConfidence(recommendation);
|
|
15794
|
+
const previousProfileId = recommendation.currentProfile?.profileId;
|
|
15795
|
+
const recommendedProfileId = recommendation.recommendedProfile?.profileId;
|
|
15796
|
+
const canSwitch = recommendation.status === "switch" && recommendation.ok && Boolean(recommendedProfileId) && confidence >= minConfidence;
|
|
15797
|
+
const action = recommendation.status === "stay" ? "stay" : canSwitch ? mode === "auto" ? "switch" : "recommend" : "blocked";
|
|
15798
|
+
const selectedProfileId = action === "switch" ? recommendedProfileId : previousProfileId ?? recommendedProfileId;
|
|
15799
|
+
const reason = action === "switch" ? `Auto-switched from ${previousProfileId ?? "unknown"} to ${recommendedProfileId}.` : action === "recommend" ? `Recommended ${recommendedProfileId} but left selection unchanged because mode is recommend.` : action === "blocked" ? `Blocked profile switch because confidence ${confidence} is below ${minConfidence} or evidence is incomplete.` : "Kept current profile because measured evidence does not require a switch.";
|
|
15800
|
+
const decision = {
|
|
15801
|
+
action,
|
|
15802
|
+
autoApplied: action === "switch",
|
|
15803
|
+
confidence,
|
|
15804
|
+
minConfidence,
|
|
15805
|
+
mode,
|
|
15806
|
+
previousProfileId,
|
|
15807
|
+
reason,
|
|
15808
|
+
recommendation,
|
|
15809
|
+
recommendedProfileId,
|
|
15810
|
+
selectedProfileId
|
|
15811
|
+
};
|
|
15812
|
+
if (options.audit) {
|
|
15813
|
+
const auditEvent = await options.audit.append(createVoiceAuditEvent({
|
|
15814
|
+
action: `profile.switch.${action}`,
|
|
15815
|
+
actor: options.actor ?? {
|
|
15816
|
+
id: "absolutejs-voice-profile-switch-guard",
|
|
15817
|
+
kind: "system",
|
|
15818
|
+
name: "AbsoluteJS Voice Profile Switch Guard"
|
|
15819
|
+
},
|
|
15820
|
+
metadata: options.metadata,
|
|
15821
|
+
outcome: action === "blocked" ? "skipped" : "success",
|
|
15822
|
+
payload: {
|
|
15823
|
+
autoApplied: decision.autoApplied,
|
|
15824
|
+
confidence,
|
|
15825
|
+
minConfidence,
|
|
15826
|
+
mode,
|
|
15827
|
+
previousProfileId,
|
|
15828
|
+
reasons: recommendation.reasons,
|
|
15829
|
+
recommendedProfileId,
|
|
15830
|
+
selectedProfileId,
|
|
15831
|
+
status: recommendation.status
|
|
15832
|
+
},
|
|
15833
|
+
resource: {
|
|
15834
|
+
id: selectedProfileId,
|
|
15835
|
+
type: "voice-profile"
|
|
15836
|
+
},
|
|
15837
|
+
sessionId: options.sessionId,
|
|
15838
|
+
traceId: options.traceId,
|
|
15839
|
+
type: "profile.switch"
|
|
15840
|
+
}));
|
|
15841
|
+
decision.auditEvent = auditEvent;
|
|
15842
|
+
}
|
|
15843
|
+
return decision;
|
|
15844
|
+
};
|
|
15763
15845
|
// src/providerDecisionTraces.ts
|
|
15764
15846
|
import { Elysia as Elysia23 } from "elysia";
|
|
15765
15847
|
|
|
@@ -37846,6 +37928,7 @@ export {
|
|
|
37846
37928
|
assertVoiceAgentSquadContractEvidence,
|
|
37847
37929
|
assertVoiceAgentSquadContract,
|
|
37848
37930
|
applyVoiceTelephonyOutcome,
|
|
37931
|
+
applyVoiceProfileSwitchGuard,
|
|
37849
37932
|
applyVoiceOpsTaskPolicy,
|
|
37850
37933
|
applyVoiceOpsTaskAssignmentRule,
|
|
37851
37934
|
applyVoiceHandoffDeliveryResult,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { VoiceRealCallProfileDefault, VoiceRealCallProfileDefaultsReport, VoiceRealCallProfileHistoryReport } from './proofTrends';
|
|
2
|
+
import { type StoredVoiceAuditEvent, type VoiceAuditActor, type VoiceAuditEventStore } from './audit';
|
|
2
3
|
export type VoiceProfileSwitchObservedSignals = {
|
|
3
4
|
currentProfileId?: string;
|
|
4
5
|
fallbackUsed?: boolean;
|
|
@@ -35,4 +36,29 @@ export type VoiceProfileSwitchRecommendationOptions = {
|
|
|
35
36
|
minImprovementMs?: number;
|
|
36
37
|
observed?: VoiceProfileSwitchObservedSignals;
|
|
37
38
|
};
|
|
39
|
+
export type VoiceProfileSwitchGuardMode = 'auto' | 'recommend';
|
|
40
|
+
export type VoiceProfileSwitchGuardAction = 'blocked' | 'recommend' | 'stay' | 'switch';
|
|
41
|
+
export type VoiceProfileSwitchGuardDecision = {
|
|
42
|
+
action: VoiceProfileSwitchGuardAction;
|
|
43
|
+
auditEvent?: StoredVoiceAuditEvent;
|
|
44
|
+
autoApplied: boolean;
|
|
45
|
+
confidence: number;
|
|
46
|
+
minConfidence: number;
|
|
47
|
+
mode: VoiceProfileSwitchGuardMode;
|
|
48
|
+
previousProfileId?: string;
|
|
49
|
+
reason: string;
|
|
50
|
+
recommendation: VoiceProfileSwitchRecommendation;
|
|
51
|
+
recommendedProfileId?: string;
|
|
52
|
+
selectedProfileId?: string;
|
|
53
|
+
};
|
|
54
|
+
export type VoiceProfileSwitchGuardOptions = VoiceProfileSwitchRecommendationOptions & {
|
|
55
|
+
actor?: VoiceAuditActor;
|
|
56
|
+
audit?: VoiceAuditEventStore;
|
|
57
|
+
metadata?: Record<string, unknown>;
|
|
58
|
+
minConfidence?: number;
|
|
59
|
+
mode?: VoiceProfileSwitchGuardMode;
|
|
60
|
+
sessionId?: string;
|
|
61
|
+
traceId?: string;
|
|
62
|
+
};
|
|
38
63
|
export declare const recommendVoiceProfileSwitch: (options: VoiceProfileSwitchRecommendationOptions) => VoiceProfileSwitchRecommendation;
|
|
64
|
+
export declare const applyVoiceProfileSwitchGuard: (options: VoiceProfileSwitchGuardOptions) => Promise<VoiceProfileSwitchGuardDecision>;
|
|
@@ -146,6 +146,7 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
|
|
|
146
146
|
readonly present: {
|
|
147
147
|
readonly "operator.action": number;
|
|
148
148
|
readonly handoff: number;
|
|
149
|
+
readonly "profile.switch": number;
|
|
149
150
|
readonly "provider.call": number;
|
|
150
151
|
readonly "retention.policy": number;
|
|
151
152
|
readonly "tool.call": number;
|
|
@@ -578,6 +579,7 @@ export declare const useVoiceReadinessFailures: (path?: string, options?: VoiceR
|
|
|
578
579
|
readonly present: {
|
|
579
580
|
readonly "operator.action": number;
|
|
580
581
|
readonly handoff: number;
|
|
582
|
+
readonly "profile.switch": number;
|
|
581
583
|
readonly "provider.call": number;
|
|
582
584
|
readonly "retention.policy": number;
|
|
583
585
|
readonly "tool.call": number;
|