@absolutejs/voice 0.0.22-beta.191 → 0.0.22-beta.193

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.
@@ -0,0 +1,56 @@
1
+ import type { StoredVoiceTraceEvent, VoiceTraceEventStore } from './trace';
2
+ export type VoiceLatencySLOStatus = 'empty' | 'fail' | 'pass' | 'warn';
3
+ export type VoiceLatencySLOStage = 'assistant_text_to_tts_send' | 'barge_in_stop' | 'commit_to_assistant_text' | 'final_to_commit' | 'live_latency' | 'provider_llm' | 'provider_stt' | 'provider_tts' | 'speech_to_commit' | 'tts_send_duration' | 'tts_to_first_audio';
4
+ export type VoiceLatencySLOBudget = {
5
+ failAfterMs: number;
6
+ warnAfterMs?: number;
7
+ };
8
+ export type VoiceLatencySLOMeasurement = {
9
+ at: number;
10
+ latencyMs: number;
11
+ label: string;
12
+ provider?: string;
13
+ sessionId: string;
14
+ stage: VoiceLatencySLOStage;
15
+ status: Exclude<VoiceLatencySLOStatus, 'empty'>;
16
+ turnId?: string;
17
+ };
18
+ export type VoiceLatencySLOStageSummary = {
19
+ averageMs?: number;
20
+ budget: VoiceLatencySLOBudget;
21
+ failed: number;
22
+ label: string;
23
+ maxMs?: number;
24
+ measurements: VoiceLatencySLOMeasurement[];
25
+ p50Ms?: number;
26
+ p95Ms?: number;
27
+ stage: VoiceLatencySLOStage;
28
+ status: VoiceLatencySLOStatus;
29
+ total: number;
30
+ warnings: number;
31
+ };
32
+ export type VoiceLatencySLOGateReport = {
33
+ checkedAt: number;
34
+ failed: number;
35
+ measurements: VoiceLatencySLOMeasurement[];
36
+ stages: VoiceLatencySLOStageSummary[];
37
+ status: VoiceLatencySLOStatus;
38
+ total: number;
39
+ warnings: number;
40
+ };
41
+ export type VoiceLatencySLOGateOptions = {
42
+ budgets?: Partial<Record<VoiceLatencySLOStage, VoiceLatencySLOBudget>>;
43
+ events?: StoredVoiceTraceEvent[];
44
+ failAfterMs?: number;
45
+ limit?: number;
46
+ store?: VoiceTraceEventStore;
47
+ warnAfterMs?: number;
48
+ };
49
+ export type VoiceLatencySLOGateError = Error & {
50
+ report: VoiceLatencySLOGateReport;
51
+ };
52
+ export declare const buildVoiceLatencySLOGate: (options: VoiceLatencySLOGateOptions) => Promise<VoiceLatencySLOGateReport>;
53
+ export declare const assertVoiceLatencySLOGate: (options: VoiceLatencySLOGateOptions) => Promise<VoiceLatencySLOGateReport>;
54
+ export declare const renderVoiceLatencySLOMarkdown: (report: VoiceLatencySLOGateReport, options?: {
55
+ title?: string;
56
+ }) => string;
@@ -1,6 +1,8 @@
1
1
  import { Elysia } from 'elysia';
2
2
  import { type StoredVoiceAuditEvent, type VoiceAuditEventStore } from './audit';
3
+ import type { StoredVoiceIntegrationEvent, StoredVoiceOpsTask, VoiceIntegrationEventStore, VoiceOpsTaskStore } from './ops';
3
4
  import { type VoiceSessionReplay } from './sessionReplay';
5
+ import type { StoredVoiceCallReviewArtifact, VoiceCallReviewStore } from './testing/review';
4
6
  import { type VoiceTraceTimelineEvent, type VoiceTraceTimelineProviderSummary } from './traceTimeline';
5
7
  import { type StoredVoiceTraceEvent, type VoiceTraceEvaluationOptions, type VoiceTraceEventStore, type VoiceTraceRedactionConfig, type VoiceTraceSummary } from './trace';
6
8
  export type VoiceOperationsRecordStatus = 'failed' | 'healthy' | 'warning';
@@ -38,16 +40,41 @@ export type VoiceOperationsRecordAuditSummary = {
38
40
  success: number;
39
41
  total: number;
40
42
  };
43
+ export type VoiceOperationsRecordReviewSummary = {
44
+ failed: number;
45
+ reviews: StoredVoiceCallReviewArtifact[];
46
+ total: number;
47
+ };
48
+ export type VoiceOperationsRecordTaskSummary = {
49
+ done: number;
50
+ inProgress: number;
51
+ open: number;
52
+ overdue: number;
53
+ tasks: StoredVoiceOpsTask[];
54
+ total: number;
55
+ };
56
+ export type VoiceOperationsRecordIntegrationEventSummary = {
57
+ delivered: number;
58
+ events: StoredVoiceIntegrationEvent[];
59
+ failed: number;
60
+ pending: number;
61
+ sinkDeliveries: number;
62
+ skipped: number;
63
+ total: number;
64
+ };
41
65
  export type VoiceOperationsRecord = {
42
66
  audit?: VoiceOperationsRecordAuditSummary;
43
67
  checkedAt: number;
44
68
  handoffs: VoiceOperationsRecordAgentHandoff[];
69
+ integrationEvents?: VoiceOperationsRecordIntegrationEventSummary;
45
70
  outcome: VoiceOperationsRecordOutcome;
46
71
  providers: VoiceTraceTimelineProviderSummary[];
47
72
  replay: VoiceSessionReplay;
73
+ reviews?: VoiceOperationsRecordReviewSummary;
48
74
  sessionId: string;
49
75
  status: VoiceOperationsRecordStatus;
50
76
  summary: VoiceTraceSummary;
77
+ tasks?: VoiceOperationsRecordTaskSummary;
51
78
  timeline: VoiceTraceTimelineEvent[];
52
79
  tools: VoiceOperationsRecordTool[];
53
80
  traceEvents: StoredVoiceTraceEvent[];
@@ -56,9 +83,12 @@ export type VoiceOperationsRecordOptions = {
56
83
  audit?: VoiceAuditEventStore;
57
84
  evaluation?: VoiceTraceEvaluationOptions;
58
85
  events?: StoredVoiceTraceEvent[];
86
+ integrationEvents?: VoiceIntegrationEventStore;
59
87
  redact?: VoiceTraceRedactionConfig;
88
+ reviews?: VoiceCallReviewStore;
60
89
  sessionId: string;
61
90
  store?: VoiceTraceEventStore;
91
+ tasks?: VoiceOpsTaskStore;
62
92
  };
63
93
  export type VoiceOperationsRecordRoutesOptions = Omit<VoiceOperationsRecordOptions, 'sessionId'> & {
64
94
  headers?: HeadersInit;
@@ -12,6 +12,7 @@ import type { VoiceReconnectContractReport } from './reconnectContract';
12
12
  import type { VoiceAuditEventStore, VoiceAuditEventType, VoiceAuditOutcome } from './audit';
13
13
  import { type VoiceAuditSinkDeliveryStore } from './auditSinks';
14
14
  import type { VoiceProviderContractMatrixReport, VoiceProviderStackCapabilityGapReport } from './providerStackRecommendations';
15
+ import type { VoiceCampaignReadinessProofReport } from './campaign';
15
16
  export type VoiceProductionReadinessStatus = 'fail' | 'pass' | 'warn';
16
17
  export type VoiceProductionReadinessAction = {
17
18
  description?: string;
@@ -81,6 +82,7 @@ export type VoiceProductionReadinessReport = {
81
82
  audit?: string;
82
83
  auditDeliveries?: string;
83
84
  bargeIn?: string;
85
+ campaignReadiness?: string;
84
86
  carriers?: string;
85
87
  deliveryRuntime?: string;
86
88
  handoffs?: string;
@@ -117,6 +119,12 @@ export type VoiceProductionReadinessReport = {
117
119
  total: number;
118
120
  warnings: number;
119
121
  };
122
+ campaignReadiness?: {
123
+ failed: number;
124
+ passed: number;
125
+ status: VoiceProductionReadinessStatus;
126
+ total: number;
127
+ };
120
128
  carriers?: {
121
129
  failing: number;
122
130
  providers: number;
@@ -294,6 +302,10 @@ export type VoiceProductionReadinessRoutesOptions = {
294
302
  query: Record<string, unknown>;
295
303
  request: Request;
296
304
  }) => Promise<readonly VoiceTelephonyCarrierMatrixInput[]> | readonly VoiceTelephonyCarrierMatrixInput[]);
305
+ campaignReadiness?: false | VoiceCampaignReadinessProofReport | ((input: {
306
+ query: Record<string, unknown>;
307
+ request: Request;
308
+ }) => Promise<VoiceCampaignReadinessProofReport> | VoiceCampaignReadinessProofReport);
297
309
  deliveryRuntime?: false | VoiceDeliveryRuntime | VoiceDeliveryRuntimeSummary | ((input: {
298
310
  query: Record<string, unknown>;
299
311
  request: Request;
@@ -4,6 +4,7 @@ export type VoiceReadinessProfileOptions = {
4
4
  audit?: VoiceProductionReadinessAuditOptions;
5
5
  auditDeliveries?: VoiceProductionReadinessAuditDeliveryOptions;
6
6
  bargeInReports?: VoiceProductionReadinessRoutesOptions['bargeInReports'];
7
+ campaignReadiness?: VoiceProductionReadinessRoutesOptions['campaignReadiness'];
7
8
  carriers?: VoiceProductionReadinessRoutesOptions['carriers'];
8
9
  deliveryRuntime?: VoiceProductionReadinessRoutesOptions['deliveryRuntime'];
9
10
  explain?: boolean;
@@ -6401,9 +6401,32 @@ var createVoiceSession = (options) => {
6401
6401
  });
6402
6402
  };
6403
6403
  const completeTurn = async (session, turn) => {
6404
+ const liveOpsControl = await options.liveOps?.getControl(options.id);
6405
+ if (liveOpsControl?.assistantPaused || liveOpsControl?.operatorTakeover) {
6406
+ await appendTrace({
6407
+ metadata: {
6408
+ source: "voice-live-ops"
6409
+ },
6410
+ payload: {
6411
+ action: "turn.skipped",
6412
+ control: liveOpsControl,
6413
+ reason: liveOpsControl.operatorTakeover ? "operator-takeover" : "assistant-paused",
6414
+ status: "skipped"
6415
+ },
6416
+ session,
6417
+ turnId: turn.id,
6418
+ type: "operator.action"
6419
+ });
6420
+ return;
6421
+ }
6422
+ const injectedInstruction = liveOpsControl?.injectedInstruction?.trim();
6404
6423
  const committedOutput = await options.route.onTurn({
6405
6424
  api,
6406
6425
  context: options.context,
6426
+ liveOps: liveOpsControl ? {
6427
+ control: liveOpsControl,
6428
+ injectedInstruction
6429
+ } : undefined,
6407
6430
  session,
6408
6431
  turn
6409
6432
  });
package/dist/types.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { VoiceOpsDispositionTaskPolicies, VoiceOpsTaskAssignmentRule, Voice
3
3
  import type { VoiceIntegrationSink } from './opsSinks';
4
4
  import type { StoredVoiceCallReviewArtifact, VoiceCallReviewArtifact, VoiceCallReviewStore } from './testing/review';
5
5
  import type { VoiceTraceEventStore } from './trace';
6
+ import type { VoiceLiveOpsControlState } from './liveOps';
6
7
  export type AudioFormat = {
7
8
  container: 'raw';
8
9
  encoding: 'alaw' | 'mulaw' | 'pcm_s16le';
@@ -484,6 +485,10 @@ export type VoiceLexiconResolver<TContext = unknown> = (input: {
484
485
  }) => Promise<VoiceLexiconEntry[] | void> | VoiceLexiconEntry[] | void;
485
486
  export type VoiceOnTurnObjectHandler<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = (input: {
486
487
  context: TContext;
488
+ liveOps?: {
489
+ control: VoiceLiveOpsControlState;
490
+ injectedInstruction?: string;
491
+ };
487
492
  session: TSession;
488
493
  turn: VoiceTurnRecord;
489
494
  api: VoiceSessionHandle<TContext, TSession, TResult>;
@@ -605,6 +610,9 @@ export type VoiceRuntimeOpsConfig<TContext = unknown, TSession extends VoiceSess
605
610
  tasks?: VoiceOpsTaskStore;
606
611
  webhook?: VoiceIntegrationWebhookConfig;
607
612
  };
613
+ export type VoiceLiveOpsRuntimeConfig = {
614
+ getControl: (sessionId: string) => Promise<VoiceLiveOpsControlState | null | undefined> | VoiceLiveOpsControlState | null | undefined;
615
+ };
608
616
  export type VoiceNormalizedRouteConfig<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = Omit<VoiceRouteConfig<TContext, TSession, TResult>, 'onTurn'> & {
609
617
  onTurn: VoiceOnTurnObjectHandler<TContext, TSession, TResult>;
610
618
  };
@@ -639,6 +647,7 @@ export type VoicePluginConfig<TContext = unknown, TSession extends VoiceSessionR
639
647
  htmx?: boolean | VoiceHTMXConfig<TSession, NoInfer<TResult>>;
640
648
  handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
641
649
  ops?: VoiceRuntimeOpsConfig<TContext, TSession, TResult>;
650
+ liveOps?: VoiceLiveOpsRuntimeConfig;
642
651
  trace?: VoiceTraceEventStore;
643
652
  } & VoiceRouteConfig<TContext, TSession, TResult>;
644
653
  export type CreateVoiceSessionOptions<TContext = unknown, TSession extends VoiceSessionRecord = VoiceSessionRecord, TResult = unknown> = {
@@ -662,6 +671,7 @@ export type CreateVoiceSessionOptions<TContext = unknown, TSession extends Voice
662
671
  turnDetection: VoiceResolvedTurnDetectionConfig;
663
672
  audioConditioning?: VoiceResolvedAudioConditioningConfig;
664
673
  handoff?: VoiceHandoffConfig<TContext, TSession, TResult>;
674
+ liveOps?: VoiceLiveOpsRuntimeConfig;
665
675
  route: VoiceNormalizedRouteConfig<TContext, TSession, TResult>;
666
676
  logger?: VoiceLogger;
667
677
  };
@@ -4,6 +4,6 @@ export declare function useVoiceLiveOps(options?: VoiceLiveOpsClientOptions): {
4
4
  isRunning: import("vue").Ref<boolean, boolean>;
5
5
  lastResult: import("vue").ShallowRef<VoiceLiveOpsActionResult | undefined, VoiceLiveOpsActionResult | undefined>;
6
6
  run: (input: import("..").VoiceLiveOpsActionInput) => Promise<VoiceLiveOpsActionResult | undefined>;
7
- runningAction: import("vue").Ref<"escalate" | "assign" | "create-task" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined, "escalate" | "assign" | "create-task" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined>;
7
+ runningAction: import("vue").Ref<"assign" | "create-task" | "escalate" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined, "assign" | "create-task" | "escalate" | "force-handoff" | "inject-instruction" | "operator-takeover" | "pause-assistant" | "resume-assistant" | "tag" | undefined>;
8
8
  updatedAt: import("vue").Ref<number | undefined, number | undefined>;
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.191",
3
+ "version": "0.0.22-beta.193",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",