@chatterfly/widget 0.4.0 → 0.5.0

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/index.d.mts CHANGED
@@ -272,12 +272,18 @@ type RunEvent = {
272
272
  type: "message.sent";
273
273
  content: string;
274
274
  participant_role: string;
275
+ } | {
276
+ type: "run_complete";
277
+ state?: Record<string, unknown>;
275
278
  } | {
276
279
  type: "run.completed";
277
280
  state?: Record<string, unknown>;
278
281
  } | {
279
282
  type: "run.cancelled";
280
283
  state?: Record<string, unknown>;
284
+ } | {
285
+ type: "run_error";
286
+ error?: string;
281
287
  } | {
282
288
  type: "run.failed";
283
289
  error: string;
@@ -523,6 +529,8 @@ declare const ChatAdapter: react.ForwardRefExoticComponent<ChatAdapterProps & re
523
529
  type VoiceOrbState = "idle" | "listening" | "speaking" | "processing" | "confirming" | "error";
524
530
  interface VoiceOrbProps {
525
531
  state: VoiceOrbState;
532
+ /** Smoothed microphone energy in the range 0..1. */
533
+ inputLevel?: number;
526
534
  onPress?: () => void;
527
535
  onRelease?: () => void;
528
536
  disabled?: boolean;
@@ -538,7 +546,7 @@ interface VoiceOrbProps {
538
546
  * - confirming: pop + success color
539
547
  * - error: shake + red flash
540
548
  */
541
- declare function VoiceOrb({ state, onPress, onRelease, disabled, }: VoiceOrbProps): react_jsx_runtime.JSX.Element;
549
+ declare function VoiceOrb({ state, inputLevel, onPress, onRelease, disabled, }: VoiceOrbProps): react_jsx_runtime.JSX.Element;
542
550
 
543
551
  interface VoicePromptCardProps {
544
552
  field: FieldSpec;
@@ -643,12 +651,16 @@ interface VoiceLiveRendererProps {
643
651
  participantToken: string;
644
652
  /** HITL session id; the proxy resolves field, channel, and tokens from it. */
645
653
  sessionId: string;
654
+ /** Current field's HITL session, distinct from the first session pinned for the socket. */
655
+ fieldSessionId: string;
646
656
  /** Resolved widget/voice live tunables (config.style "live"). May be empty — defaults are server-side. */
647
657
  liveConfig?: SurfaceConfig;
648
658
  onValue: (value: unknown) => void;
659
+ onPlaybackComplete?: () => void;
660
+ onFieldRevealed?: (sessionId: string) => void;
649
661
  disabled?: boolean;
650
662
  }
651
- declare function VoiceLiveRenderer({ field, apiBase, participantToken, sessionId, liveConfig, onValue, disabled, }: VoiceLiveRendererProps): react_jsx_runtime.JSX.Element;
663
+ declare function VoiceLiveRenderer({ field, apiBase, participantToken, sessionId, fieldSessionId, liveConfig, onValue, onPlaybackComplete, onFieldRevealed, disabled, }: VoiceLiveRendererProps): react_jsx_runtime.JSX.Element;
652
664
 
653
665
  interface RequiredConnection {
654
666
  slug: string;
@@ -711,7 +723,9 @@ declare function ConnectionOnboarding({ connections, appBase, participantToken,
711
723
  * Live model, so the widget only manages the audio pipes and surfaces
712
724
  * transparency events to the UI.
713
725
  */
714
- type LiveVoiceState = "idle" | "connecting" | "listening" | "speaking" | "muted" | "completed" | "error";
726
+ type LiveVoiceState = "idle" | "connecting" | "listening"
727
+ /** Transcript arrived; answer/tool/workflow/model turn is advancing. */
728
+ | "processing" | "speaking" | "muted" | "completed" | "error";
715
729
  interface LiveTranscript {
716
730
  /** "user" for input transcription, "assistant" for output transcription. */
717
731
  who: "user" | "assistant";
@@ -735,8 +749,18 @@ interface LiveSessionResult {
735
749
  assistantText: string;
736
750
  /** Latest field id reported by the proxy via field_change. */
737
751
  activeFieldId: string | null;
752
+ /**
753
+ * The most recent field whose audio has finished PLAYING. The engine opens a
754
+ * field (and sends field_change) seconds before the spoken question ends, so
755
+ * renderers should gate field UI on this, not on activeFieldId.
756
+ */
757
+ askedFieldId: string | null;
758
+ /** True once the terminal socket has closed and all received PCM has played. */
759
+ playbackComplete: boolean;
738
760
  /** The committed value, set when the proxy emits a value envelope. */
739
761
  lastValue: unknown;
762
+ /** Smoothed microphone energy in the range 0..1; visual feedback only. */
763
+ inputLevel: number;
740
764
  isMuted: boolean;
741
765
  toggleMute: () => void;
742
766
  error: string | null;
package/dist/index.d.ts CHANGED
@@ -272,12 +272,18 @@ type RunEvent = {
272
272
  type: "message.sent";
273
273
  content: string;
274
274
  participant_role: string;
275
+ } | {
276
+ type: "run_complete";
277
+ state?: Record<string, unknown>;
275
278
  } | {
276
279
  type: "run.completed";
277
280
  state?: Record<string, unknown>;
278
281
  } | {
279
282
  type: "run.cancelled";
280
283
  state?: Record<string, unknown>;
284
+ } | {
285
+ type: "run_error";
286
+ error?: string;
281
287
  } | {
282
288
  type: "run.failed";
283
289
  error: string;
@@ -523,6 +529,8 @@ declare const ChatAdapter: react.ForwardRefExoticComponent<ChatAdapterProps & re
523
529
  type VoiceOrbState = "idle" | "listening" | "speaking" | "processing" | "confirming" | "error";
524
530
  interface VoiceOrbProps {
525
531
  state: VoiceOrbState;
532
+ /** Smoothed microphone energy in the range 0..1. */
533
+ inputLevel?: number;
526
534
  onPress?: () => void;
527
535
  onRelease?: () => void;
528
536
  disabled?: boolean;
@@ -538,7 +546,7 @@ interface VoiceOrbProps {
538
546
  * - confirming: pop + success color
539
547
  * - error: shake + red flash
540
548
  */
541
- declare function VoiceOrb({ state, onPress, onRelease, disabled, }: VoiceOrbProps): react_jsx_runtime.JSX.Element;
549
+ declare function VoiceOrb({ state, inputLevel, onPress, onRelease, disabled, }: VoiceOrbProps): react_jsx_runtime.JSX.Element;
542
550
 
543
551
  interface VoicePromptCardProps {
544
552
  field: FieldSpec;
@@ -643,12 +651,16 @@ interface VoiceLiveRendererProps {
643
651
  participantToken: string;
644
652
  /** HITL session id; the proxy resolves field, channel, and tokens from it. */
645
653
  sessionId: string;
654
+ /** Current field's HITL session, distinct from the first session pinned for the socket. */
655
+ fieldSessionId: string;
646
656
  /** Resolved widget/voice live tunables (config.style "live"). May be empty — defaults are server-side. */
647
657
  liveConfig?: SurfaceConfig;
648
658
  onValue: (value: unknown) => void;
659
+ onPlaybackComplete?: () => void;
660
+ onFieldRevealed?: (sessionId: string) => void;
649
661
  disabled?: boolean;
650
662
  }
651
- declare function VoiceLiveRenderer({ field, apiBase, participantToken, sessionId, liveConfig, onValue, disabled, }: VoiceLiveRendererProps): react_jsx_runtime.JSX.Element;
663
+ declare function VoiceLiveRenderer({ field, apiBase, participantToken, sessionId, fieldSessionId, liveConfig, onValue, onPlaybackComplete, onFieldRevealed, disabled, }: VoiceLiveRendererProps): react_jsx_runtime.JSX.Element;
652
664
 
653
665
  interface RequiredConnection {
654
666
  slug: string;
@@ -711,7 +723,9 @@ declare function ConnectionOnboarding({ connections, appBase, participantToken,
711
723
  * Live model, so the widget only manages the audio pipes and surfaces
712
724
  * transparency events to the UI.
713
725
  */
714
- type LiveVoiceState = "idle" | "connecting" | "listening" | "speaking" | "muted" | "completed" | "error";
726
+ type LiveVoiceState = "idle" | "connecting" | "listening"
727
+ /** Transcript arrived; answer/tool/workflow/model turn is advancing. */
728
+ | "processing" | "speaking" | "muted" | "completed" | "error";
715
729
  interface LiveTranscript {
716
730
  /** "user" for input transcription, "assistant" for output transcription. */
717
731
  who: "user" | "assistant";
@@ -735,8 +749,18 @@ interface LiveSessionResult {
735
749
  assistantText: string;
736
750
  /** Latest field id reported by the proxy via field_change. */
737
751
  activeFieldId: string | null;
752
+ /**
753
+ * The most recent field whose audio has finished PLAYING. The engine opens a
754
+ * field (and sends field_change) seconds before the spoken question ends, so
755
+ * renderers should gate field UI on this, not on activeFieldId.
756
+ */
757
+ askedFieldId: string | null;
758
+ /** True once the terminal socket has closed and all received PCM has played. */
759
+ playbackComplete: boolean;
738
760
  /** The committed value, set when the proxy emits a value envelope. */
739
761
  lastValue: unknown;
762
+ /** Smoothed microphone energy in the range 0..1; visual feedback only. */
763
+ inputLevel: number;
740
764
  isMuted: boolean;
741
765
  toggleMute: () => void;
742
766
  error: string | null;