@absolutejs/voice 0.0.22-beta.489 → 0.0.22-beta.490

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,12 @@
1
+ export type VoiceAgentUIState = "idle" | "listening" | "speaking" | "thinking";
2
+ export type VoiceAgentUIInput = {
3
+ hasActivePartial: boolean;
4
+ isConnected: boolean;
5
+ isPlaying: boolean;
6
+ isRecording: boolean;
7
+ lastAssistantAt?: number;
8
+ lastTranscriptAt?: number;
9
+ };
10
+ export declare const deriveVoiceAgentUIState: (input: VoiceAgentUIInput) => VoiceAgentUIState;
11
+ export declare const describeVoiceAgentUIState: (state: VoiceAgentUIState) => string;
12
+ export declare const voiceAgentUIStateOrder: ReadonlyArray<VoiceAgentUIState>;
package/dist/index.d.ts CHANGED
@@ -81,6 +81,8 @@ export { describeVoiceAssistantMode, resolveVoiceAssistantMode, } from "./assist
81
81
  export type { VoiceAssistantMode, VoiceAssistantModality, VoiceAssistantModeDescriptor, VoiceSemanticVADConfig, } from "./assistantMode";
82
82
  export { createPunctuationSemanticTurnDetector, createRegexSemanticTurnDetector, } from "./semanticTurn";
83
83
  export { VOICE_WEBHOOK_SIGNATURE_HEADER, VOICE_WEBHOOK_TIMESTAMP_HEADER, extractVoiceWebhookSignatureFromHeaders, signVoiceWebhookBody, verifyVoiceWebhookSignature, } from "./webhookVerification";
84
+ export { describeVoiceAgentUIState, deriveVoiceAgentUIState, voiceAgentUIStateOrder, } from "./agentState";
85
+ export type { VoiceAgentUIInput, VoiceAgentUIState, } from "./agentState";
84
86
  export { createVoiceBackchannelDriver } from "./backchannel";
85
87
  export type { VoiceBackchannelCue, VoiceBackchannelDriver, VoiceBackchannelDriverOptions, } from "./backchannel";
86
88
  export { createVoiceIVRSession, describeVoiceIVRPlan, evaluateVoiceIVRPlan, } from "./ivrPlan";
package/dist/index.js CHANGED
@@ -35475,6 +35475,46 @@ var extractVoiceWebhookSignatureFromHeaders = (headers) => {
35475
35475
  timestamp: get(VOICE_WEBHOOK_TIMESTAMP_HEADER)
35476
35476
  };
35477
35477
  };
35478
+ // src/agentState.ts
35479
+ var deriveVoiceAgentUIState = (input) => {
35480
+ if (!input.isConnected) {
35481
+ return "idle";
35482
+ }
35483
+ if (input.isPlaying) {
35484
+ return "speaking";
35485
+ }
35486
+ if (input.isRecording && input.hasActivePartial) {
35487
+ return "listening";
35488
+ }
35489
+ if (input.isRecording) {
35490
+ return "listening";
35491
+ }
35492
+ if (input.lastTranscriptAt && !input.lastAssistantAt) {
35493
+ return "thinking";
35494
+ }
35495
+ if (input.lastTranscriptAt && input.lastAssistantAt && input.lastTranscriptAt > input.lastAssistantAt) {
35496
+ return "thinking";
35497
+ }
35498
+ return "idle";
35499
+ };
35500
+ var describeVoiceAgentUIState = (state) => {
35501
+ switch (state) {
35502
+ case "idle":
35503
+ return "Idle";
35504
+ case "listening":
35505
+ return "Listening";
35506
+ case "speaking":
35507
+ return "Speaking";
35508
+ case "thinking":
35509
+ return "Thinking";
35510
+ }
35511
+ };
35512
+ var voiceAgentUIStateOrder = [
35513
+ "idle",
35514
+ "listening",
35515
+ "thinking",
35516
+ "speaking"
35517
+ ];
35478
35518
  // src/backchannel.ts
35479
35519
  var DEFAULT_CUES = [
35480
35520
  { text: "mm-hmm" },
@@ -46423,6 +46463,7 @@ export {
46423
46463
  voiceObservabilityExportSchemaId,
46424
46464
  voiceGuardrailPolicyPresets,
46425
46465
  voiceComplianceRedactionDefaults,
46466
+ voiceAgentUIStateOrder,
46426
46467
  voice,
46427
46468
  verifyVoiceWebhookSignature,
46428
46469
  verifyVoiceTwilioWebhookSignature,
@@ -46713,6 +46754,8 @@ export {
46713
46754
  encodePcmAsWav,
46714
46755
  describeVoiceIVRPlan,
46715
46756
  describeVoiceAssistantMode,
46757
+ describeVoiceAgentUIState,
46758
+ deriveVoiceAgentUIState,
46716
46759
  deliverVoiceTraceEventsToSinks,
46717
46760
  deliverVoiceObservabilityExport,
46718
46761
  deliverVoiceMonitorIssueNotifications,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.489",
3
+ "version": "0.0.22-beta.490",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",