@athenaintel/react 0.42.1 → 0.43.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.
Files changed (147) hide show
  1. package/README.md +46 -7
  2. package/dist/agent-runtime/src/conversation-list-groups.d.ts +74 -0
  3. package/dist/agent-runtime/src/index.d.ts +3 -2
  4. package/dist/agent-runtime/src/messages.cjs +38 -7
  5. package/dist/agent-runtime/src/messages.cjs.map +1 -1
  6. package/dist/agent-runtime/src/messages.d.ts +26 -8
  7. package/dist/agent-runtime/src/messages.js +38 -7
  8. package/dist/agent-runtime/src/messages.js.map +1 -1
  9. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs +10 -0
  10. package/dist/agent-runtime/src/quota-safe-local-storage-session.cjs.map +1 -1
  11. package/dist/agent-runtime/src/quota-safe-local-storage-session.d.ts +7 -0
  12. package/dist/agent-runtime/src/quota-safe-local-storage-session.js +10 -0
  13. package/dist/agent-runtime/src/quota-safe-local-storage-session.js.map +1 -1
  14. package/dist/agent-runtime/src/session-lane-scope.cjs +25 -0
  15. package/dist/agent-runtime/src/session-lane-scope.cjs.map +1 -0
  16. package/dist/agent-runtime/src/session-lane-scope.d.ts +59 -0
  17. package/dist/agent-runtime/src/session-lane-scope.js +25 -0
  18. package/dist/agent-runtime/src/session-lane-scope.js.map +1 -0
  19. package/dist/agent-runtime/src/subagent-transcripts.cjs +2 -2
  20. package/dist/agent-runtime/src/subagent-transcripts.cjs.map +1 -1
  21. package/dist/agent-runtime/src/subagent-transcripts.d.ts +2 -2
  22. package/dist/agent-runtime/src/subagent-transcripts.js +3 -3
  23. package/dist/agent-runtime/src/subagent-transcripts.js.map +1 -1
  24. package/dist/agent-runtime/src/tool-metadata.cjs +0 -8
  25. package/dist/agent-runtime/src/tool-metadata.cjs.map +1 -1
  26. package/dist/agent-runtime/src/tool-metadata.js +0 -8
  27. package/dist/agent-runtime/src/tool-metadata.js.map +1 -1
  28. package/dist/agent-runtime/src/tool-names.cjs +4 -0
  29. package/dist/agent-runtime/src/tool-names.cjs.map +1 -1
  30. package/dist/agent-runtime/src/tool-names.d.ts +7 -0
  31. package/dist/agent-runtime/src/tool-names.js +4 -0
  32. package/dist/agent-runtime/src/tool-names.js.map +1 -1
  33. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs +18 -1
  34. package/dist/agent-runtime/src/use-deep-agent-runtime.cjs.map +1 -1
  35. package/dist/agent-runtime/src/use-deep-agent-runtime.d.ts +19 -10
  36. package/dist/agent-runtime/src/use-deep-agent-runtime.js +19 -2
  37. package/dist/agent-runtime/src/use-deep-agent-runtime.js.map +1 -1
  38. package/dist/agent-runtime/src/use-deep-agent-thread.cjs +28 -10
  39. package/dist/agent-runtime/src/use-deep-agent-thread.cjs.map +1 -1
  40. package/dist/agent-runtime/src/use-deep-agent-thread.d.ts +35 -3
  41. package/dist/agent-runtime/src/use-deep-agent-thread.js +28 -10
  42. package/dist/agent-runtime/src/use-deep-agent-thread.js.map +1 -1
  43. package/dist/agent-runtime/src/use-deep-agent-voice.cjs +50 -15
  44. package/dist/agent-runtime/src/use-deep-agent-voice.cjs.map +1 -1
  45. package/dist/agent-runtime/src/use-deep-agent-voice.d.ts +8 -0
  46. package/dist/agent-runtime/src/use-deep-agent-voice.js +50 -15
  47. package/dist/agent-runtime/src/use-deep-agent-voice.js.map +1 -1
  48. package/dist/agent-runtime/src/voice-presentation.cjs +2 -0
  49. package/dist/agent-runtime/src/voice-presentation.cjs.map +1 -1
  50. package/dist/agent-runtime/src/voice-presentation.js +2 -0
  51. package/dist/agent-runtime/src/voice-presentation.js.map +1 -1
  52. package/dist/catalog/runtime-catalog.js +1 -1
  53. package/dist/chat/AthenaChat.cjs +125 -103
  54. package/dist/chat/AthenaChat.cjs.map +1 -1
  55. package/dist/chat/AthenaChat.d.ts +9 -0
  56. package/dist/chat/AthenaChat.js +126 -104
  57. package/dist/chat/AthenaChat.js.map +1 -1
  58. package/dist/chat/chat-voice-controls.cjs +128 -0
  59. package/dist/chat/chat-voice-controls.cjs.map +1 -0
  60. package/dist/chat/chat-voice-controls.d.ts +19 -0
  61. package/dist/chat/chat-voice-controls.js +128 -0
  62. package/dist/chat/chat-voice-controls.js.map +1 -0
  63. package/dist/chat/super-grouping/SuperGroupingCard.cjs +8 -2
  64. package/dist/chat/super-grouping/SuperGroupingCard.cjs.map +1 -1
  65. package/dist/chat/super-grouping/SuperGroupingCard.d.ts +6 -1
  66. package/dist/chat/super-grouping/SuperGroupingCard.js +8 -2
  67. package/dist/chat/super-grouping/SuperGroupingCard.js.map +1 -1
  68. package/dist/chat/super-grouping/ToolTimeline.cjs +27 -0
  69. package/dist/chat/super-grouping/ToolTimeline.cjs.map +1 -1
  70. package/dist/chat/super-grouping/ToolTimeline.d.ts +5 -1
  71. package/dist/chat/super-grouping/ToolTimeline.js +27 -0
  72. package/dist/chat/super-grouping/ToolTimeline.js.map +1 -1
  73. package/dist/chat/super-grouping/index.d.ts +1 -0
  74. package/dist/chat/super-grouping/timeline-step.cjs +61 -2
  75. package/dist/chat/super-grouping/timeline-step.cjs.map +1 -1
  76. package/dist/chat/super-grouping/timeline-step.d.ts +13 -1
  77. package/dist/chat/super-grouping/timeline-step.js +61 -2
  78. package/dist/chat/super-grouping/timeline-step.js.map +1 -1
  79. package/dist/chat/use-statewire-approval-request.js +1 -1
  80. package/dist/chat-ui/composer/tiptap-composer.cjs +42 -22
  81. package/dist/chat-ui/composer/tiptap-composer.cjs.map +1 -1
  82. package/dist/chat-ui/composer/tiptap-composer.d.ts +1 -0
  83. package/dist/chat-ui/composer/tiptap-composer.js +43 -23
  84. package/dist/chat-ui/composer/tiptap-composer.js.map +1 -1
  85. package/dist/chat-ui/mentions/mention-chip.cjs +144 -35
  86. package/dist/chat-ui/mentions/mention-chip.cjs.map +1 -1
  87. package/dist/chat-ui/mentions/mention-chip.d.ts +17 -1
  88. package/dist/chat-ui/mentions/mention-chip.js +146 -37
  89. package/dist/chat-ui/mentions/mention-chip.js.map +1 -1
  90. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs +2 -1
  91. package/dist/chat-ui/mentions/suggestions/data/api-client.cjs.map +1 -1
  92. package/dist/chat-ui/mentions/suggestions/data/api-client.d.ts +3 -1
  93. package/dist/chat-ui/mentions/suggestions/data/api-client.js +2 -1
  94. package/dist/chat-ui/mentions/suggestions/data/api-client.js.map +1 -1
  95. package/dist/chat-ui/mentions/use-account-workspace-id.cjs +29 -51
  96. package/dist/chat-ui/mentions/use-account-workspace-id.cjs.map +1 -1
  97. package/dist/chat-ui/mentions/use-account-workspace-id.d.ts +2 -2
  98. package/dist/chat-ui/mentions/use-account-workspace-id.js +30 -52
  99. package/dist/chat-ui/mentions/use-account-workspace-id.js.map +1 -1
  100. package/dist/chat-ui/mentions/use-mention-asset.cjs +140 -0
  101. package/dist/chat-ui/mentions/use-mention-asset.cjs.map +1 -0
  102. package/dist/chat-ui/mentions/use-mention-asset.d.ts +16 -0
  103. package/dist/chat-ui/mentions/use-mention-asset.js +140 -0
  104. package/dist/chat-ui/mentions/use-mention-asset.js.map +1 -0
  105. package/dist/chat-ui/rich-text/chat-link.cjs +5 -4
  106. package/dist/chat-ui/rich-text/chat-link.cjs.map +1 -1
  107. package/dist/chat-ui/rich-text/chat-link.d.ts +2 -3
  108. package/dist/chat-ui/rich-text/chat-link.js +6 -5
  109. package/dist/chat-ui/rich-text/chat-link.js.map +1 -1
  110. package/dist/chat-ui/rich-text/chat-node-views.cjs +1 -0
  111. package/dist/chat-ui/rich-text/chat-node-views.cjs.map +1 -1
  112. package/dist/chat-ui/rich-text/chat-node-views.js +1 -0
  113. package/dist/chat-ui/rich-text/chat-node-views.js.map +1 -1
  114. package/dist/chat-ui/thread/composer-send-or-stop.cjs +2 -1
  115. package/dist/chat-ui/thread/composer-send-or-stop.cjs.map +1 -1
  116. package/dist/chat-ui/thread/composer-send-or-stop.d.ts +2 -0
  117. package/dist/chat-ui/thread/composer-send-or-stop.js +2 -1
  118. package/dist/chat-ui/thread/composer-send-or-stop.js.map +1 -1
  119. package/dist/diagnostics/athena-diagnostics.cjs.map +1 -1
  120. package/dist/diagnostics/athena-diagnostics.d.ts +1 -1
  121. package/dist/diagnostics/athena-diagnostics.js.map +1 -1
  122. package/dist/index.d.ts +1 -1
  123. package/dist/react/package.json.cjs +1 -1
  124. package/dist/react/package.json.js +1 -1
  125. package/dist/references/src/tool-option-schemas.d.ts +0 -34
  126. package/dist/runtime/statewire-session-key.cjs.map +1 -1
  127. package/dist/runtime/statewire-session-key.d.ts +8 -5
  128. package/dist/runtime/statewire-session-key.js.map +1 -1
  129. package/dist/runtime/useAthenaStatewireRuntime.cjs +5 -2
  130. package/dist/runtime/useAthenaStatewireRuntime.cjs.map +1 -1
  131. package/dist/runtime/useAthenaStatewireRuntime.js +5 -2
  132. package/dist/runtime/useAthenaStatewireRuntime.js.map +1 -1
  133. package/dist/styles.css +1 -1
  134. package/dist/threads/statewire-thread-list.cjs +6 -2
  135. package/dist/threads/statewire-thread-list.cjs.map +1 -1
  136. package/dist/threads/statewire-thread-list.js +6 -2
  137. package/dist/threads/statewire-thread-list.js.map +1 -1
  138. package/dist/tools/tool-summary.cjs +0 -2
  139. package/dist/tools/tool-summary.cjs.map +1 -1
  140. package/dist/tools/tool-summary.js +0 -2
  141. package/dist/tools/tool-summary.js.map +1 -1
  142. package/dist/voice/use-chat-voice-enabled.cjs +43 -0
  143. package/dist/voice/use-chat-voice-enabled.cjs.map +1 -0
  144. package/dist/voice/use-chat-voice-enabled.d.ts +9 -0
  145. package/dist/voice/use-chat-voice-enabled.js +43 -0
  146. package/dist/voice/use-chat-voice-enabled.js.map +1 -0
  147. package/package.json +4 -8
@@ -188,7 +188,25 @@ const RELAY_CAPTURE_FRAME_SAMPLES = 1024;
188
188
  const RELAY_PLAYBACK_LEAD_SECONDS = 0.02;
189
189
  const MEDIA_DISCONNECT_GRACE_MS = 5e3;
190
190
  const END_BEFORE_RESTART_TIMEOUT_MS = 3e3;
191
- const mintVoiceTextId = () => `voicetext_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 12)}`;
191
+ const mintVoiceId = ({ kind }) => `voice${kind}_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 12)}`;
192
+ const formatVoiceElapsed = (sinceMs, nowMs = Date.now()) => {
193
+ const total = Math.max(0, Math.floor((nowMs - sinceMs) / 1e3));
194
+ const hours = Math.floor(total / 3600);
195
+ const minutes = Math.floor(total % 3600 / 60);
196
+ const seconds = total % 60;
197
+ const mmss = `${minutes}:${String(seconds).padStart(2, "0")}`;
198
+ return hours > 0 ? `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}` : mmss;
199
+ };
200
+ const useVoiceElapsed = (since) => {
201
+ const [now, setNow] = useState(() => Date.now());
202
+ useEffect(() => {
203
+ if (since === null) return;
204
+ setNow(Date.now());
205
+ const timer = setInterval(() => setNow(Date.now()), 1e3);
206
+ return () => clearInterval(timer);
207
+ }, [since]);
208
+ return since === null ? null : formatVoiceElapsed(since, now);
209
+ };
192
210
  const REQUEST_LABELS = {
193
211
  "session.commentary.append": "a result for the voice conversation",
194
212
  "session.thinking.append": "a context update",
@@ -288,6 +306,15 @@ const useDeepAgentVoice = (options = {}) => {
288
306
  const livekitRef = useRef(null);
289
307
  const livekitAbortRef = useRef(null);
290
308
  const attemptRef = useRef(0);
309
+ const callAttemptIdRef = useRef("");
310
+ const observedAttempt = useStatewireState((s) => {
311
+ if (!isDeepAgentStateHydrated(s)) return void 0;
312
+ const values = readDeepAgentStreamValues(s);
313
+ const value = values.voiceStartFence ?? values.voiceAttemptId;
314
+ return typeof value === "string" ? value : null;
315
+ });
316
+ const observedAttemptRef = useRef(void 0);
317
+ if (observedAttempt !== void 0) observedAttemptRef.current = observedAttempt ?? void 0;
291
318
  const startingRef = useRef(false);
292
319
  const startPromiseRef = useRef(null);
293
320
  const autoRestartedRef = useRef(false);
@@ -454,6 +481,9 @@ const useDeepAgentVoice = (options = {}) => {
454
481
  const runStartSession = useCallback(async () => {
455
482
  var _a, _b, _c;
456
483
  const attempt = attemptRef.current += 1;
484
+ const attemptId = mintVoiceId({ kind: "attempt" });
485
+ const previousAttemptId = observedAttemptRef.current;
486
+ callAttemptIdRef.current = attemptId;
457
487
  startingRef.current = true;
458
488
  attemptStartedAtRef.current = Date.now();
459
489
  setFailure(null);
@@ -513,6 +543,8 @@ const useDeepAgentVoice = (options = {}) => {
513
543
  const sendVoiceStart = (offer2) => sendCommand({
514
544
  type: "voice/start",
515
545
  offer: offer2,
546
+ attemptId,
547
+ ...previousAttemptId !== void 0 && { previousAttemptId },
516
548
  ...model2 !== void 0 && { model: model2 }
517
549
  });
518
550
  const negotiateStart = async (offer2) => {
@@ -520,11 +552,12 @@ const useDeepAgentVoice = (options = {}) => {
520
552
  const negotiationStartedAt = Date.now();
521
553
  const commandPromise = sendVoiceStart(offer2).catch((commandError) => {
522
554
  if (!isRecoveredCommandAuthRejection(commandError)) throw commandError;
555
+ if (attemptRef.current !== attempt) throw commandError;
523
556
  return sendVoiceStart(offer2);
524
557
  });
525
558
  void commandPromise.then(() => {
526
559
  if (attemptRef.current !== attempt)
527
- void sendCommand({ type: "voice/end" }).catch(() => void 0);
560
+ void sendCommand({ type: "voice/end", attemptId }).catch(() => void 0);
528
561
  }).catch(() => void 0);
529
562
  let answerTimer = null;
530
563
  let result;
@@ -587,12 +620,12 @@ const useDeepAgentVoice = (options = {}) => {
587
620
  report("room-joined", attempt, { roomName: room.roomName });
588
621
  } catch (roomError) {
589
622
  if (attemptRef.current === attempt)
590
- void sendCommand({ type: "voice/end" }).catch(() => void 0);
623
+ void sendCommand({ type: "voice/end", attemptId }).catch(() => void 0);
591
624
  throw roomError;
592
625
  }
593
626
  report("live", attempt, { transport, ...model2 !== void 0 && { model: model2 } });
594
627
  if (micMutedRef.current) {
595
- void sendCommand({ type: "voice/set-mic", paused: true }).catch(() => void 0);
628
+ void sendCommand({ type: "voice/set-mic", paused: true, attemptId }).catch(() => void 0);
596
629
  }
597
630
  setPhase("live");
598
631
  setLiveSince(Date.now());
@@ -666,7 +699,7 @@ const useDeepAgentVoice = (options = {}) => {
666
699
  });
667
700
  report("live", attempt, { transport });
668
701
  if (micMutedRef.current) {
669
- void sendCommand({ type: "voice/set-mic", paused: true }).catch(() => void 0);
702
+ void sendCommand({ type: "voice/set-mic", paused: true, attemptId }).catch(() => void 0);
670
703
  }
671
704
  setPhase("live");
672
705
  setLiveSince(Date.now());
@@ -686,7 +719,7 @@ const useDeepAgentVoice = (options = {}) => {
686
719
  await ((_a2 = onRemoteStreamRef.current) == null ? void 0 : _a2.call(onRemoteStreamRef, remote));
687
720
  } catch (playError) {
688
721
  if (attemptRef.current !== attempt) return;
689
- void sendCommand({ type: "voice/end" }).catch(() => void 0);
722
+ void sendCommand({ type: "voice/end", attemptId }).catch(() => void 0);
690
723
  fail({
691
724
  kind: "playback_failed",
692
725
  stage: "playback",
@@ -733,7 +766,7 @@ const useDeepAgentVoice = (options = {}) => {
733
766
  }
734
767
  report("live", attempt, { transport });
735
768
  if (micMutedRef.current) {
736
- void sendCommand({ type: "voice/set-mic", paused: true }).catch(() => void 0);
769
+ void sendCommand({ type: "voice/set-mic", paused: true, attemptId }).catch(() => void 0);
737
770
  }
738
771
  setPhase("live");
739
772
  setLiveSince(Date.now());
@@ -767,7 +800,7 @@ const useDeepAgentVoice = (options = {}) => {
767
800
  restartBudgetLeft: !autoRestartedRef.current
768
801
  });
769
802
  if (lastActiveTaskRef.current) setHandoffTask(lastActiveTaskRef.current);
770
- const ending = sendCommand({ type: "voice/end" }).catch(() => void 0);
803
+ const ending = sendCommand({ type: "voice/end", attemptId: callAttemptIdRef.current }).catch(() => void 0);
771
804
  teardown();
772
805
  const recovery = attemptRef.current;
773
806
  setPhase("idle");
@@ -821,7 +854,7 @@ const useDeepAgentVoice = (options = {}) => {
821
854
  const end = useCallback(() => {
822
855
  if (phase === "connecting" || phase === "live") {
823
856
  report("end", attemptRef.current, { source: "user", phase });
824
- void sendCommand({ type: "voice/end" }).catch(() => void 0);
857
+ void sendCommand({ type: "voice/end", attemptId: callAttemptIdRef.current }).catch(() => void 0);
825
858
  if (lastActiveTaskRef.current) setHandoffTask(lastActiveTaskRef.current);
826
859
  }
827
860
  teardown();
@@ -843,7 +876,7 @@ const useDeepAgentVoice = (options = {}) => {
843
876
  if (room) releaseSafely(() => room.setMicrophoneEnabled(!value));
844
877
  };
845
878
  applyLocal(muted);
846
- void sendCommand({ type: "voice/set-mic", paused: muted }).catch(() => {
879
+ void sendCommand({ type: "voice/set-mic", paused: muted, attemptId: callAttemptIdRef.current }).catch(() => {
847
880
  if (!muted && attemptRef.current === attempt && micChangeRef.current === change) {
848
881
  applyLocal(true);
849
882
  }
@@ -877,7 +910,7 @@ const useDeepAgentVoice = (options = {}) => {
877
910
  source: "unmount",
878
911
  phase: phaseAtUnmount
879
912
  });
880
- void sendCommand({ type: "voice/end" }).catch(() => void 0);
913
+ void sendCommand({ type: "voice/end", attemptId: callAttemptIdRef.current }).catch(() => void 0);
881
914
  }
882
915
  teardown();
883
916
  },
@@ -918,22 +951,22 @@ const useDeepAgentVoice = (options = {}) => {
918
951
  }, [wireModelOptions]);
919
952
  const syncProfile = useCallback(() => {
920
953
  if (phase !== "connecting" && phase !== "live") return;
921
- void sendCommand({ type: "voice/profile-sync" }).catch(() => void 0);
954
+ void sendCommand({ type: "voice/profile-sync", attemptId: callAttemptIdRef.current }).catch(() => void 0);
922
955
  }, [phase, sendCommand]);
923
956
  const sendContext = useCallback(
924
957
  (text) => {
925
958
  const trimmed = text.trim();
926
959
  if (phase !== "live" || !trimmed) return;
927
- void sendCommand({ type: "voice/context", text: trimmed }).catch(() => void 0);
960
+ void sendCommand({ type: "voice/context", text: trimmed, attemptId: callAttemptIdRef.current }).catch(() => void 0);
928
961
  },
929
962
  [phase, sendCommand]
930
963
  );
931
964
  const sendUserText = useCallback(
932
965
  async (text) => {
933
966
  if (phase !== "live" || !text.trim()) return false;
934
- const messageId = mintVoiceTextId();
967
+ const messageId = mintVoiceId({ kind: "text" });
935
968
  try {
936
- await sendCommand({ type: "voice/user-text", text, messageId });
969
+ await sendCommand({ type: "voice/user-text", text, messageId, attemptId: callAttemptIdRef.current });
937
970
  return true;
938
971
  } catch {
939
972
  return false;
@@ -990,10 +1023,12 @@ export {
990
1023
  describeVoiceFailure,
991
1024
  describeVoiceWireError,
992
1025
  float32FromPcm16,
1026
+ formatVoiceElapsed,
993
1027
  parseVoiceLiveKitAnswer,
994
1028
  parseVoiceModelOptions,
995
1029
  pcm16FromFloat32,
996
1030
  useDeepAgentVoice,
1031
+ useVoiceElapsed,
997
1032
  voiceRelayUrl
998
1033
  };
999
1034
  //# sourceMappingURL=use-deep-agent-voice.js.map