@assistant-ui/react 0.5.74 → 0.5.76

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18;
2
2
 
3
3
 
4
4
 
@@ -604,20 +604,13 @@ var useActionBarReload = () => {
604
604
  // src/primitive-hooks/actionBar/useActionBarSpeak.tsx
605
605
 
606
606
  var useActionBarSpeak = () => {
607
- const messageStore = useMessageStore();
608
- const editComposerStore = useEditComposerStore();
609
607
  const messageRunime = useMessageRuntime();
610
- const messageUtilsStore = useMessageUtilsStore();
611
- const hasSpeakableContent = useCombinedStore(
612
- [messageStore, editComposerStore],
613
- (message, c) => {
614
- return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
615
- }
616
- );
617
608
  const callback = _react.useCallback.call(void 0, async () => {
618
- const utt = messageRunime.speak();
619
- messageUtilsStore.getState().addUtterance(utt);
620
- }, [messageRunime, messageUtilsStore]);
609
+ messageRunime.speak();
610
+ }, [messageRunime]);
611
+ const hasSpeakableContent = useMessage((m) => {
612
+ return (m.role !== "assistant" || m.status.type !== "running") && m.content.some((c) => c.type === "text" && c.text.length > 0);
613
+ });
621
614
  if (!hasSpeakableContent) return null;
622
615
  return callback;
623
616
  };
@@ -625,11 +618,11 @@ var useActionBarSpeak = () => {
625
618
  // src/primitive-hooks/actionBar/useActionBarStopSpeaking.tsx
626
619
 
627
620
  var useActionBarStopSpeaking = () => {
628
- const messageUtilsStore = useMessageUtilsStore();
629
- const isSpeaking = useMessageUtils((u) => u.isSpeaking);
621
+ const messageRuntime = useMessageRuntime();
622
+ const isSpeaking = useMessage((u) => u.speech != null);
630
623
  const callback = _react.useCallback.call(void 0, async () => {
631
- messageUtilsStore.getState().stopSpeaking();
632
- }, [messageUtilsStore]);
624
+ messageRuntime.stopSpeaking();
625
+ }, [messageRuntime]);
633
626
  if (!isSpeaking) return null;
634
627
  return callback;
635
628
  };
@@ -638,13 +631,9 @@ var useActionBarStopSpeaking = () => {
638
631
 
639
632
  var useActionBarFeedbackPositive = () => {
640
633
  const messageRuntime = useMessageRuntime();
641
- const messageUtilsStore = useMessageUtilsStore();
642
634
  const callback = _react.useCallback.call(void 0, () => {
643
- messageRuntime.submitFeedback({
644
- type: "positive"
645
- });
646
- messageUtilsStore.getState().setSubmittedFeedback("positive");
647
- }, [messageUtilsStore, messageRuntime]);
635
+ messageRuntime.submitFeedback({ type: "positive" });
636
+ }, [messageRuntime]);
648
637
  return callback;
649
638
  };
650
639
 
@@ -652,13 +641,9 @@ var useActionBarFeedbackPositive = () => {
652
641
 
653
642
  var useActionBarFeedbackNegative = () => {
654
643
  const messageRuntime = useMessageRuntime();
655
- const messageUtilsStore = useMessageUtilsStore();
656
644
  const callback = _react.useCallback.call(void 0, () => {
657
- messageRuntime.submitFeedback({
658
- type: "negative"
659
- });
660
- messageUtilsStore.getState().setSubmittedFeedback("negative");
661
- }, [messageUtilsStore, messageRuntime]);
645
+ messageRuntime.submitFeedback({ type: "negative" });
646
+ }, [messageRuntime]);
662
647
  return callback;
663
648
  };
664
649
 
@@ -746,23 +731,21 @@ var useComposerSend = () => {
746
731
 
747
732
  var useComposerAddAttachment = () => {
748
733
  const disabled = useComposer((c) => !c.isEditing);
749
- const threadComposerStore = useThreadComposerStore();
750
- const threadRuntimeStore = useThreadComposerStore();
734
+ const composerRuntime = useComposerRuntime();
751
735
  const callback = _react.useCallback.call(void 0, () => {
752
- const { addAttachment } = threadComposerStore.getState();
753
- const { attachmentAccept } = threadRuntimeStore.getState();
754
736
  const input = document.createElement("input");
755
737
  input.type = "file";
738
+ const attachmentAccept = composerRuntime.getAttachmentAccept();
756
739
  if (attachmentAccept !== "*") {
757
740
  input.accept = attachmentAccept;
758
741
  }
759
742
  input.onchange = (e) => {
760
743
  const file = _optionalChain([e, 'access', _7 => _7.target, 'access', _8 => _8.files, 'optionalAccess', _9 => _9[0]]);
761
744
  if (!file) return;
762
- addAttachment(file);
745
+ composerRuntime.addAttachment(file);
763
746
  };
764
747
  input.click();
765
- }, [threadComposerStore, threadRuntimeStore]);
748
+ }, [composerRuntime]);
766
749
  if (disabled) return null;
767
750
  return callback;
768
751
  };
@@ -809,7 +792,15 @@ var useMessageIf = (props) => {
809
792
  const messageUtilsStore = useMessageUtilsStore();
810
793
  return useCombinedStore(
811
794
  [messageStore, messageUtilsStore],
812
- ({ role, attachments, branchCount, isLast }, { isCopied, isHovering, isSpeaking, submittedFeedback }) => {
795
+ ({
796
+ role,
797
+ attachments,
798
+ content,
799
+ branchCount,
800
+ isLast,
801
+ speech,
802
+ submittedFeedback
803
+ }, { isCopied, isHovering }) => {
813
804
  if (props.hasBranches === true && branchCount < 2) return false;
814
805
  if (props.user && role !== "user") return false;
815
806
  if (props.assistant && role !== "assistant") return false;
@@ -817,13 +808,15 @@ var useMessageIf = (props) => {
817
808
  if (props.lastOrHover === true && !isHovering && !isLast) return false;
818
809
  if (props.copied === true && !isCopied) return false;
819
810
  if (props.copied === false && isCopied) return false;
820
- if (props.speaking === true && !isSpeaking) return false;
821
- if (props.speaking === false && isSpeaking) return false;
811
+ if (props.speaking === true && speech == null) return false;
812
+ if (props.speaking === false && speech != null) return false;
822
813
  if (props.hasAttachments === true && (role !== "user" || !attachments.length))
823
814
  return false;
824
815
  if (props.hasAttachments === false && role === "user" && !!attachments.length)
825
816
  return false;
826
- if (props.submittedFeedback !== void 0 && submittedFeedback !== props.submittedFeedback)
817
+ if (props.hasContent === true && content.length === 0) return false;
818
+ if (props.hasContent === false && content.length > 0) return false;
819
+ if (props.submittedFeedback !== void 0 && (_nullishCoalesce(_optionalChain([submittedFeedback, 'optionalAccess', _10 => _10.type]), () => ( null))) !== props.submittedFeedback)
827
820
  return false;
828
821
  return true;
829
822
  }
@@ -919,7 +912,7 @@ var useActionBarFloatStatus = ({
919
912
  const autohideEnabled = autohide === "always" || autohide === "not-last" && !m.isLast;
920
913
  if (!autohideEnabled) return "normal" /* Normal */;
921
914
  if (!mu.isHovering) return "hidden" /* Hidden */;
922
- if (autohideFloat === "always" || autohideFloat === "single-branch" && m.branches.length <= 1)
915
+ if (autohideFloat === "always" || autohideFloat === "single-branch" && m.branchCount <= 1)
923
916
  return "floating" /* Floating */;
924
917
  return "normal" /* Normal */;
925
918
  }
@@ -963,7 +956,7 @@ var ActionBarPrimitiveCopy = _react.forwardRef.call(void 0, ({ copiedDuration, o
963
956
  ref: forwardedRef,
964
957
  disabled: disabled || !callback,
965
958
  onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
966
- _optionalChain([callback, 'optionalCall', _10 => _10()]);
959
+ _optionalChain([callback, 'optionalCall', _11 => _11()]);
967
960
  })
968
961
  }
969
962
  );
@@ -995,7 +988,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
995
988
  ref: forwardedRef,
996
989
  disabled: primitiveProps.disabled || !callback,
997
990
  onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
998
- _optionalChain([callback, 'optionalCall', _11 => _11()]);
991
+ _optionalChain([callback, 'optionalCall', _12 => _12()]);
999
992
  })
1000
993
  }
1001
994
  );
@@ -1044,7 +1037,7 @@ var ActionBarPrimitiveStopSpeaking = _react.forwardRef.call(void 0, (props, ref)
1044
1037
  ...props,
1045
1038
  ref,
1046
1039
  onClick: _primitive.composeEventHandlers.call(void 0, props.onClick, () => {
1047
- _optionalChain([callback, 'optionalCall', _12 => _12()]);
1040
+ _optionalChain([callback, 'optionalCall', _13 => _13()]);
1048
1041
  })
1049
1042
  }
1050
1043
  );
@@ -1057,8 +1050,8 @@ ActionBarPrimitiveStopSpeaking.displayName = "ActionBarPrimitive.StopSpeaking";
1057
1050
 
1058
1051
 
1059
1052
  var ActionBarPrimitiveFeedbackPositive = _react.forwardRef.call(void 0, ({ onClick, disabled, ...props }, forwardedRef) => {
1060
- const isSubmitted = useMessageUtils(
1061
- (u) => u.submittedFeedback === "positive"
1053
+ const isSubmitted = useMessage(
1054
+ (u) => _optionalChain([u, 'access', _14 => _14.submittedFeedback, 'optionalAccess', _15 => _15.type]) === "positive"
1062
1055
  );
1063
1056
  const callback = useActionBarFeedbackPositive();
1064
1057
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1070,7 +1063,7 @@ var ActionBarPrimitiveFeedbackPositive = _react.forwardRef.call(void 0, ({ onCli
1070
1063
  ref: forwardedRef,
1071
1064
  disabled: disabled || !callback,
1072
1065
  onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
1073
- _optionalChain([callback, 'optionalCall', _13 => _13()]);
1066
+ _optionalChain([callback, 'optionalCall', _16 => _16()]);
1074
1067
  })
1075
1068
  }
1076
1069
  );
@@ -1083,8 +1076,8 @@ ActionBarPrimitiveFeedbackPositive.displayName = "ActionBarPrimitive.FeedbackPos
1083
1076
 
1084
1077
 
1085
1078
  var ActionBarPrimitiveFeedbackNegative = _react.forwardRef.call(void 0, ({ onClick, disabled, ...props }, forwardedRef) => {
1086
- const isSubmitted = useMessageUtils(
1087
- (u) => u.submittedFeedback === "negative"
1079
+ const isSubmitted = useMessage(
1080
+ (u) => _optionalChain([u, 'access', _17 => _17.submittedFeedback, 'optionalAccess', _18 => _18.type]) === "negative"
1088
1081
  );
1089
1082
  const callback = useActionBarFeedbackNegative();
1090
1083
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
@@ -1096,7 +1089,7 @@ var ActionBarPrimitiveFeedbackNegative = _react.forwardRef.call(void 0, ({ onCli
1096
1089
  ref: forwardedRef,
1097
1090
  disabled: disabled || !callback,
1098
1091
  onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
1099
- _optionalChain([callback, 'optionalCall', _14 => _14()]);
1092
+ _optionalChain([callback, 'optionalCall', _19 => _19()]);
1100
1093
  })
1101
1094
  }
1102
1095
  );
@@ -1256,7 +1249,7 @@ var AttachmentContext = _react.createContext.call(void 0,
1256
1249
  );
1257
1250
  function useAttachmentContext(options) {
1258
1251
  const context = _react.useContext.call(void 0, AttachmentContext);
1259
- if (!_optionalChain([options, 'optionalAccess', _15 => _15.optional]) && !context)
1252
+ if (!_optionalChain([options, 'optionalAccess', _20 => _20.optional]) && !context)
1260
1253
  throw new Error(
1261
1254
  "This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
1262
1255
  );
@@ -1308,9 +1301,9 @@ var { useAttachment: useMessageAttachment } = createContextStoreHook(
1308
1301
  // src/primitives/attachment/AttachmentThumb.tsx
1309
1302
 
1310
1303
 
1311
- var AttachmentPrimitiveThumb = _react.forwardRef.call(void 0, () => {
1304
+ var AttachmentPrimitiveThumb = _react.forwardRef.call(void 0, (props, ref) => {
1312
1305
  const ext = useAttachment((a) => a.name.split(".").pop());
1313
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactprimitive.Primitive.div, { children: [
1306
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactprimitive.Primitive.div, { ...props, ref, children: [
1314
1307
  ".",
1315
1308
  ext
1316
1309
  ] });
@@ -1347,7 +1340,7 @@ _chunkPZ5AY32Cjs.__export.call(void 0, branchPicker_exports, {
1347
1340
  Count: () => BranchPickerPrimitiveCount,
1348
1341
  Next: () => BranchPickerPrimitiveNext,
1349
1342
  Number: () => BranchPickerPrimitiveNumber,
1350
- Previous: () => BranchPickerPrevious,
1343
+ Previous: () => BranchPickerPrimitivePrevious,
1351
1344
  Root: () => BranchPickerPrimitiveRoot
1352
1345
  });
1353
1346
 
@@ -1358,7 +1351,7 @@ var BranchPickerPrimitiveNext = createActionButton(
1358
1351
  );
1359
1352
 
1360
1353
  // src/primitives/branchPicker/BranchPickerPrevious.tsx
1361
- var BranchPickerPrevious = createActionButton(
1354
+ var BranchPickerPrimitivePrevious = createActionButton(
1362
1355
  "BranchPickerPrimitive.Previous",
1363
1356
  useBranchPickerPrevious
1364
1357
  );
@@ -1537,7 +1530,7 @@ var withSmoothContextProvider = (Component) => {
1537
1530
  };
1538
1531
  function useSmoothContext(options) {
1539
1532
  const context = _react.useContext.call(void 0, SmoothContext);
1540
- if (!_optionalChain([options, 'optionalAccess', _16 => _16.optional]) && !context)
1533
+ if (!_optionalChain([options, 'optionalAccess', _21 => _21.optional]) && !context)
1541
1534
  throw new Error(
1542
1535
  "This component must be used within a SmoothContextProvider."
1543
1536
  );
@@ -1747,7 +1740,7 @@ var BaseSubject = (_class2 = class {constructor() { _class2.prototype.__init5.ca
1747
1740
  if (this._connection) return;
1748
1741
  this._connection = this._connect();
1749
1742
  } else {
1750
- _optionalChain([this, 'access', _17 => _17._connection, 'optionalCall', _18 => _18()]);
1743
+ _optionalChain([this, 'access', _22 => _22._connection, 'optionalCall', _23 => _23()]);
1751
1744
  this._connection = void 0;
1752
1745
  }
1753
1746
  }
@@ -1846,40 +1839,38 @@ var EMPTY_ARRAY = Object.freeze([]);
1846
1839
  var getThreadComposerState = (runtime, focus, onFocus) => {
1847
1840
  return Object.freeze({
1848
1841
  type: "thread",
1849
- isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _19 => _19.isEditing]), () => ( false)),
1850
- canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _20 => _20.canCancel]), () => ( false)),
1851
- isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _21 => _21.isEmpty]), () => ( true)),
1852
- text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _22 => _22.text]), () => ( "")),
1853
- attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _23 => _23.attachments]), () => ( EMPTY_ARRAY)),
1854
- attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _24 => _24.attachmentAccept]), () => ( "*")),
1855
- value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _25 => _25.text]), () => ( "")),
1856
- setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _26 => _26.setText, 'access', _27 => _27.bind, 'call', _28 => _28(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1857
- setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _29 => _29.setText, 'access', _30 => _30.bind, 'call', _31 => _31(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1842
+ isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _24 => _24.isEditing]), () => ( false)),
1843
+ canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _25 => _25.canCancel]), () => ( false)),
1844
+ isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _26 => _26.isEmpty]), () => ( true)),
1845
+ text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _27 => _27.text]), () => ( "")),
1846
+ attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _28 => _28.attachments]), () => ( EMPTY_ARRAY)),
1847
+ value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _29 => _29.text]), () => ( "")),
1848
+ setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _30 => _30.setText, 'access', _31 => _31.bind, 'call', _32 => _32(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1849
+ setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _33 => _33.setText, 'access', _34 => _34.bind, 'call', _35 => _35(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1858
1850
  // edit: beginEdit,
1859
- send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _32 => _32.send, 'access', _33 => _33.bind, 'call', _34 => _34(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1860
- cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _35 => _35.cancel, 'access', _36 => _36.bind, 'call', _37 => _37(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1851
+ send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _36 => _36.send, 'access', _37 => _37.bind, 'call', _38 => _38(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1852
+ cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _39 => _39.cancel, 'access', _40 => _40.bind, 'call', _41 => _41(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1861
1853
  focus,
1862
1854
  onFocus,
1863
- reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _38 => _38.reset, 'access', _39 => _39.bind, 'call', _40 => _40(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1864
- addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _41 => _41.addAttachment, 'access', _42 => _42.bind, 'call', _43 => _43(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1865
- removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _44 => _44.removeAttachment, 'access', _45 => _45.bind, 'call', _46 => _46(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1855
+ reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _42 => _42.reset, 'access', _43 => _43.bind, 'call', _44 => _44(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1856
+ addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _45 => _45.addAttachment, 'access', _46 => _46.bind, 'call', _47 => _47(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1857
+ removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _48 => _48.removeAttachment, 'access', _49 => _49.bind, 'call', _50 => _50(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1866
1858
  });
1867
1859
  };
1868
1860
  var getEditComposerState = (runtime, beginEdit) => {
1869
1861
  return Object.freeze({
1870
1862
  type: "edit",
1871
- isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _47 => _47.isEditing]), () => ( false)),
1872
- canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _48 => _48.canCancel]), () => ( false)),
1873
- isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _49 => _49.isEmpty]), () => ( true)),
1874
- text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _50 => _50.text]), () => ( "")),
1875
- attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _51 => _51.attachments]), () => ( EMPTY_ARRAY)),
1876
- attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _52 => _52.attachmentAccept]), () => ( "*")),
1877
- value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _53 => _53.text]), () => ( "")),
1878
- setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _54 => _54.setText, 'access', _55 => _55.bind, 'call', _56 => _56(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1879
- setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _57 => _57.setText, 'access', _58 => _58.bind, 'call', _59 => _59(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1863
+ isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _51 => _51.isEditing]), () => ( false)),
1864
+ canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _52 => _52.canCancel]), () => ( false)),
1865
+ isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _53 => _53.isEmpty]), () => ( true)),
1866
+ text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _54 => _54.text]), () => ( "")),
1867
+ attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _55 => _55.attachments]), () => ( EMPTY_ARRAY)),
1868
+ value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _56 => _56.text]), () => ( "")),
1869
+ setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _57 => _57.setText, 'access', _58 => _58.bind, 'call', _59 => _59(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1870
+ setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _60 => _60.setText, 'access', _61 => _61.bind, 'call', _62 => _62(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1880
1871
  edit: beginEdit,
1881
- send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _60 => _60.send, 'access', _61 => _61.bind, 'call', _62 => _62(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1882
- cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _63 => _63.cancel, 'access', _64 => _64.bind, 'call', _65 => _65(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1872
+ send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _63 => _63.send, 'access', _64 => _64.bind, 'call', _65 => _65(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1873
+ cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _66 => _66.cancel, 'access', _67 => _67.bind, 'call', _68 => _68(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1883
1874
  });
1884
1875
  };
1885
1876
  var ComposerRuntimeImpl = class {
@@ -1910,12 +1901,6 @@ var ComposerRuntimeImpl = class {
1910
1901
  get text() {
1911
1902
  return this.getState().text;
1912
1903
  }
1913
- /**
1914
- * @deprecated Use `getState().attachmentAccept` instead. This will be removed in 0.6.0.
1915
- */
1916
- get attachmentAccept() {
1917
- return this.getState().attachmentAccept;
1918
- }
1919
1904
  /**
1920
1905
  * @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
1921
1906
  */
@@ -1970,6 +1955,11 @@ var ComposerRuntimeImpl = class {
1970
1955
  subscribe(callback) {
1971
1956
  return this._core.subscribe(callback);
1972
1957
  }
1958
+ getAttachmentAccept() {
1959
+ const core = this._core.getState();
1960
+ if (!core) throw new Error("Composer is not available");
1961
+ return core.getAttachmentAccept();
1962
+ }
1973
1963
  };
1974
1964
  var ThreadComposerRuntimeImpl = (_class5 = class extends ComposerRuntimeImpl {
1975
1965
  get type() {
@@ -1992,7 +1982,7 @@ var ThreadComposerRuntimeImpl = (_class5 = class extends ComposerRuntimeImpl {
1992
1982
  this._getState = stateBinding.getState.bind(stateBinding);
1993
1983
  }
1994
1984
  get attachments() {
1995
- return _nullishCoalesce(_optionalChain([this, 'access', _66 => _66.getState, 'call', _67 => _67(), 'optionalAccess', _68 => _68.attachments]), () => ( EMPTY_ARRAY));
1985
+ return _nullishCoalesce(_optionalChain([this, 'access', _69 => _69.getState, 'call', _70 => _70(), 'optionalAccess', _71 => _71.attachments]), () => ( EMPTY_ARRAY));
1996
1986
  }
1997
1987
  getState() {
1998
1988
  return this._getState();
@@ -2094,19 +2084,19 @@ var NestedSubscriptionSubject = class extends BaseSubject {
2094
2084
  this.notifySubscribers();
2095
2085
  };
2096
2086
  let lastState = this.binding.getState();
2097
- let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess', _69 => _69.subscribe, 'call', _70 => _70(callback)]);
2087
+ let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess', _72 => _72.subscribe, 'call', _73 => _73(callback)]);
2098
2088
  const onRuntimeUpdate = () => {
2099
2089
  const newState = this.binding.getState();
2100
2090
  if (newState === lastState) return;
2101
2091
  lastState = newState;
2102
- _optionalChain([innerUnsubscribe, 'optionalCall', _71 => _71()]);
2103
- innerUnsubscribe = _optionalChain([this, 'access', _72 => _72.binding, 'access', _73 => _73.getState, 'call', _74 => _74(), 'optionalAccess', _75 => _75.subscribe, 'call', _76 => _76(callback)]);
2092
+ _optionalChain([innerUnsubscribe, 'optionalCall', _74 => _74()]);
2093
+ innerUnsubscribe = _optionalChain([this, 'access', _75 => _75.binding, 'access', _76 => _76.getState, 'call', _77 => _77(), 'optionalAccess', _78 => _78.subscribe, 'call', _79 => _79(callback)]);
2104
2094
  callback();
2105
2095
  };
2106
2096
  const outerUnsubscribe = this.binding.subscribe(onRuntimeUpdate);
2107
2097
  return () => {
2108
- _optionalChain([outerUnsubscribe, 'optionalCall', _77 => _77()]);
2109
- _optionalChain([innerUnsubscribe, 'optionalCall', _78 => _78()]);
2098
+ _optionalChain([outerUnsubscribe, 'optionalCall', _80 => _80()]);
2099
+ _optionalChain([innerUnsubscribe, 'optionalCall', _81 => _81()]);
2110
2100
  };
2111
2101
  }
2112
2102
  };
@@ -2172,6 +2162,16 @@ var MessageRuntimeImpl = (_class6 = class {
2172
2162
  if (!state) throw new Error("Message is not available");
2173
2163
  return this._threadBinding.getState().speak(state.id);
2174
2164
  }
2165
+ stopSpeaking() {
2166
+ const state = this._core.getState();
2167
+ if (!state) throw new Error("Message is not available");
2168
+ const thread = this._threadBinding.getState();
2169
+ if (_optionalChain([thread, 'access', _82 => _82.speech, 'optionalAccess', _83 => _83.messageId]) === state.id) {
2170
+ this._threadBinding.getState().stopSpeaking();
2171
+ } else {
2172
+ throw new Error("Message is not being spoken");
2173
+ }
2174
+ }
2175
2175
  submitFeedback({ type }) {
2176
2176
  const state = this._core.getState();
2177
2177
  if (!state) throw new Error("Message is not available");
@@ -2223,7 +2223,7 @@ var MessageRuntimeImpl = (_class6 = class {
2223
2223
  new ShallowMemoizeSubject({
2224
2224
  getState: () => {
2225
2225
  const attachments = this.getState().attachments;
2226
- const attachment = _optionalChain([attachments, 'optionalAccess', _79 => _79[idx]]);
2226
+ const attachment = _optionalChain([attachments, 'optionalAccess', _84 => _84[idx]]);
2227
2227
  if (!attachment) return SKIP_UPDATE;
2228
2228
  return {
2229
2229
  ...attachment,
@@ -2312,7 +2312,7 @@ var MessageContentPartImpl = ({
2312
2312
  };
2313
2313
  var MessageContentPart = _react.memo.call(void 0,
2314
2314
  MessageContentPartImpl,
2315
- (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _80 => _80.components, 'optionalAccess', _81 => _81.Text]) === _optionalChain([next, 'access', _82 => _82.components, 'optionalAccess', _83 => _83.Text]) && _optionalChain([prev, 'access', _84 => _84.components, 'optionalAccess', _85 => _85.Image]) === _optionalChain([next, 'access', _86 => _86.components, 'optionalAccess', _87 => _87.Image]) && _optionalChain([prev, 'access', _88 => _88.components, 'optionalAccess', _89 => _89.UI]) === _optionalChain([next, 'access', _90 => _90.components, 'optionalAccess', _91 => _91.UI]) && _optionalChain([prev, 'access', _92 => _92.components, 'optionalAccess', _93 => _93.tools]) === _optionalChain([next, 'access', _94 => _94.components, 'optionalAccess', _95 => _95.tools])
2315
+ (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _85 => _85.components, 'optionalAccess', _86 => _86.Text]) === _optionalChain([next, 'access', _87 => _87.components, 'optionalAccess', _88 => _88.Text]) && _optionalChain([prev, 'access', _89 => _89.components, 'optionalAccess', _90 => _90.Image]) === _optionalChain([next, 'access', _91 => _91.components, 'optionalAccess', _92 => _92.Image]) && _optionalChain([prev, 'access', _93 => _93.components, 'optionalAccess', _94 => _94.UI]) === _optionalChain([next, 'access', _95 => _95.components, 'optionalAccess', _96 => _96.UI]) && _optionalChain([prev, 'access', _97 => _97.components, 'optionalAccess', _98 => _98.tools]) === _optionalChain([next, 'access', _99 => _99.components, 'optionalAccess', _100 => _100.tools])
2316
2316
  );
2317
2317
  var MessagePrimitiveContent = ({
2318
2318
  components
@@ -2378,11 +2378,11 @@ var getComponent = (components, attachment) => {
2378
2378
  const type = attachment.type;
2379
2379
  switch (type) {
2380
2380
  case "image":
2381
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _96 => _96.Image]), () => ( _optionalChain([components, 'optionalAccess', _97 => _97.Attachment])));
2381
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _101 => _101.Image]), () => ( _optionalChain([components, 'optionalAccess', _102 => _102.Attachment])));
2382
2382
  case "document":
2383
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _98 => _98.Document]), () => ( _optionalChain([components, 'optionalAccess', _99 => _99.Attachment])));
2383
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _103 => _103.Document]), () => ( _optionalChain([components, 'optionalAccess', _104 => _104.Attachment])));
2384
2384
  case "file":
2385
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _100 => _100.File]), () => ( _optionalChain([components, 'optionalAccess', _101 => _101.Attachment])));
2385
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _105 => _105.File]), () => ( _optionalChain([components, 'optionalAccess', _106 => _106.Attachment])));
2386
2386
  default:
2387
2387
  const _exhaustiveCheck = type;
2388
2388
  throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
@@ -2405,7 +2405,7 @@ var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
2405
2405
  };
2406
2406
  var MessageAttachment = _react.memo.call(void 0,
2407
2407
  MessageAttachmentImpl,
2408
- (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _102 => _102.components, 'optionalAccess', _103 => _103.Image]) === _optionalChain([next, 'access', _104 => _104.components, 'optionalAccess', _105 => _105.Image]) && _optionalChain([prev, 'access', _106 => _106.components, 'optionalAccess', _107 => _107.Document]) === _optionalChain([next, 'access', _108 => _108.components, 'optionalAccess', _109 => _109.Document]) && _optionalChain([prev, 'access', _110 => _110.components, 'optionalAccess', _111 => _111.File]) === _optionalChain([next, 'access', _112 => _112.components, 'optionalAccess', _113 => _113.File]) && _optionalChain([prev, 'access', _114 => _114.components, 'optionalAccess', _115 => _115.Attachment]) === _optionalChain([next, 'access', _116 => _116.components, 'optionalAccess', _117 => _117.Attachment])
2408
+ (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _107 => _107.components, 'optionalAccess', _108 => _108.Image]) === _optionalChain([next, 'access', _109 => _109.components, 'optionalAccess', _110 => _110.Image]) && _optionalChain([prev, 'access', _111 => _111.components, 'optionalAccess', _112 => _112.Document]) === _optionalChain([next, 'access', _113 => _113.components, 'optionalAccess', _114 => _114.Document]) && _optionalChain([prev, 'access', _115 => _115.components, 'optionalAccess', _116 => _116.File]) === _optionalChain([next, 'access', _117 => _117.components, 'optionalAccess', _118 => _118.File]) && _optionalChain([prev, 'access', _119 => _119.components, 'optionalAccess', _120 => _120.Attachment]) === _optionalChain([next, 'access', _121 => _121.components, 'optionalAccess', _122 => _122.Attachment])
2409
2409
  );
2410
2410
  var MessagePrimitiveAttachments = ({ components }) => {
2411
2411
  const attachmentsCount = useMessage(({ message }) => {
@@ -2516,7 +2516,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
2516
2516
  const { isRunning } = threadStore.getState();
2517
2517
  if (!isRunning) {
2518
2518
  e.preventDefault();
2519
- _optionalChain([textareaRef, 'access', _118 => _118.current, 'optionalAccess', _119 => _119.closest, 'call', _120 => _120("form"), 'optionalAccess', _121 => _121.requestSubmit, 'call', _122 => _122()]);
2519
+ _optionalChain([textareaRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.closest, 'call', _125 => _125("form"), 'optionalAccess', _126 => _126.requestSubmit, 'call', _127 => _127()]);
2520
2520
  }
2521
2521
  }
2522
2522
  };
@@ -2581,11 +2581,11 @@ var getComponent2 = (components, attachment) => {
2581
2581
  const type = attachment.type;
2582
2582
  switch (type) {
2583
2583
  case "image":
2584
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _123 => _123.Image]), () => ( _optionalChain([components, 'optionalAccess', _124 => _124.Attachment])));
2584
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _128 => _128.Image]), () => ( _optionalChain([components, 'optionalAccess', _129 => _129.Attachment])));
2585
2585
  case "document":
2586
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _125 => _125.Document]), () => ( _optionalChain([components, 'optionalAccess', _126 => _126.Attachment])));
2586
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _130 => _130.Document]), () => ( _optionalChain([components, 'optionalAccess', _131 => _131.Attachment])));
2587
2587
  case "file":
2588
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _127 => _127.File]), () => ( _optionalChain([components, 'optionalAccess', _128 => _128.Attachment])));
2588
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _132 => _132.File]), () => ( _optionalChain([components, 'optionalAccess', _133 => _133.Attachment])));
2589
2589
  default:
2590
2590
  const _exhaustiveCheck = type;
2591
2591
  throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
@@ -2608,7 +2608,7 @@ var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
2608
2608
  };
2609
2609
  var ComposerAttachment = _react.memo.call(void 0,
2610
2610
  ComposerAttachmentImpl,
2611
- (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _129 => _129.components, 'optionalAccess', _130 => _130.Image]) === _optionalChain([next, 'access', _131 => _131.components, 'optionalAccess', _132 => _132.Image]) && _optionalChain([prev, 'access', _133 => _133.components, 'optionalAccess', _134 => _134.Document]) === _optionalChain([next, 'access', _135 => _135.components, 'optionalAccess', _136 => _136.Document]) && _optionalChain([prev, 'access', _137 => _137.components, 'optionalAccess', _138 => _138.File]) === _optionalChain([next, 'access', _139 => _139.components, 'optionalAccess', _140 => _140.File]) && _optionalChain([prev, 'access', _141 => _141.components, 'optionalAccess', _142 => _142.Attachment]) === _optionalChain([next, 'access', _143 => _143.components, 'optionalAccess', _144 => _144.Attachment])
2611
+ (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _134 => _134.components, 'optionalAccess', _135 => _135.Image]) === _optionalChain([next, 'access', _136 => _136.components, 'optionalAccess', _137 => _137.Image]) && _optionalChain([prev, 'access', _138 => _138.components, 'optionalAccess', _139 => _139.Document]) === _optionalChain([next, 'access', _140 => _140.components, 'optionalAccess', _141 => _141.Document]) && _optionalChain([prev, 'access', _142 => _142.components, 'optionalAccess', _143 => _143.File]) === _optionalChain([next, 'access', _144 => _144.components, 'optionalAccess', _145 => _145.File]) && _optionalChain([prev, 'access', _146 => _146.components, 'optionalAccess', _147 => _147.Attachment]) === _optionalChain([next, 'access', _148 => _148.components, 'optionalAccess', _149 => _149.Attachment])
2612
2612
  );
2613
2613
  var ComposerPrimitiveAttachments = ({ components }) => {
2614
2614
  const attachmentsCount = useComposer((s) => s.attachments.length);
@@ -2816,7 +2816,6 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
2816
2816
  // src/context/stores/MessageUtils.ts
2817
2817
 
2818
2818
  var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
2819
- let utterance = null;
2820
2819
  return {
2821
2820
  isCopied: false,
2822
2821
  setIsCopied: (value) => {
@@ -2825,21 +2824,6 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
2825
2824
  isHovering: false,
2826
2825
  setIsHovering: (value) => {
2827
2826
  set({ isHovering: value });
2828
- },
2829
- isSpeaking: false,
2830
- stopSpeaking: () => {
2831
- _optionalChain([utterance, 'optionalAccess', _145 => _145.cancel, 'call', _146 => _146()]);
2832
- },
2833
- addUtterance: (utt) => {
2834
- utterance = utt;
2835
- set({ isSpeaking: true });
2836
- utt.onEnd(() => {
2837
- set({ isSpeaking: false });
2838
- });
2839
- },
2840
- submittedFeedback: null,
2841
- setSubmittedFeedback: (feedback) => {
2842
- set({ submittedFeedback: feedback });
2843
2827
  }
2844
2828
  };
2845
2829
  });
@@ -2975,7 +2959,7 @@ var subscribeToMainThread = (runtime, callback) => {
2975
2959
  let first = true;
2976
2960
  let cleanup;
2977
2961
  const inner = () => {
2978
- _optionalChain([cleanup, 'optionalCall', _147 => _147()]);
2962
+ _optionalChain([cleanup, 'optionalCall', _150 => _150()]);
2979
2963
  cleanup = runtime.thread.subscribe(callback);
2980
2964
  if (!first) {
2981
2965
  callback();
@@ -2986,7 +2970,7 @@ var subscribeToMainThread = (runtime, callback) => {
2986
2970
  inner();
2987
2971
  return () => {
2988
2972
  unsubscribe();
2989
- _optionalChain([cleanup, 'optionalCall', _148 => _148()]);
2973
+ _optionalChain([cleanup, 'optionalCall', _151 => _151()]);
2990
2974
  };
2991
2975
  };
2992
2976
 
@@ -3034,10 +3018,12 @@ _chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
3034
3018
 
3035
3019
  // src/runtimes/composer/BaseComposerRuntimeCore.tsx
3036
3020
  var isAttachmentComplete = (a) => a.status.type === "complete";
3037
- var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototype.__init13.call(this);_class8.prototype.__init14.call(this);_class8.prototype.__init15.call(this);_class8.prototype.__init16.call(this);_class8.prototype.__init17.call(this); }
3021
+ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototype.__init13.call(this);_class8.prototype.__init14.call(this);_class8.prototype.__init15.call(this);_class8.prototype.__init16.call(this); }
3038
3022
  __init13() {this.isEditing = true}
3039
- __init14() {this.attachmentAccept = "*"}
3040
- __init15() {this._attachments = []}
3023
+ getAttachmentAccept() {
3024
+ return _nullishCoalesce(_optionalChain([this, 'access', _152 => _152.getAttachmentAdapter, 'call', _153 => _153(), 'optionalAccess', _154 => _154.accept]), () => ( "*"));
3025
+ }
3026
+ __init14() {this._attachments = []}
3041
3027
  set attachments(value) {
3042
3028
  this._attachments = value;
3043
3029
  this.notifySubscribers();
@@ -3048,7 +3034,7 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
3048
3034
  get isEmpty() {
3049
3035
  return !this.text.trim() && !this.attachments.length;
3050
3036
  }
3051
- __init16() {this._text = ""}
3037
+ __init15() {this._text = ""}
3052
3038
  get text() {
3053
3039
  return this._text;
3054
3040
  }
@@ -3062,11 +3048,12 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
3062
3048
  this.notifySubscribers();
3063
3049
  }
3064
3050
  async send() {
3065
- const attachments = this._attachmentAdapter ? await Promise.all(
3051
+ const adapter = this.getAttachmentAdapter();
3052
+ const attachments = adapter && this.attachments.length > 0 ? await Promise.all(
3066
3053
  this.attachments.map(async (a) => {
3067
3054
  if (isAttachmentComplete(a)) return a;
3068
- const result = await this._attachmentAdapter.send(a);
3069
- if (_optionalChain([result, 'access', _149 => _149.status, 'optionalAccess', _150 => _150.type]) !== "complete") {
3055
+ const result = await adapter.send(a);
3056
+ if (_optionalChain([result, 'access', _155 => _155.status, 'optionalAccess', _156 => _156.type]) !== "complete") {
3070
3057
  result.status = { type: "complete" };
3071
3058
  }
3072
3059
  return result;
@@ -3080,19 +3067,10 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
3080
3067
  this.reset();
3081
3068
  this.handleSend(message);
3082
3069
  }
3083
-
3084
- setAttachmentAdapter(adapter) {
3085
- this._attachmentAdapter = adapter;
3086
- const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess', _151 => _151.accept]), () => ( "*"));
3087
- if (this.attachmentAccept !== accept) {
3088
- this.attachmentAccept = accept;
3089
- this.notifySubscribers();
3090
- }
3091
- }
3092
3070
  async addAttachment(file) {
3093
- if (!this._attachmentAdapter)
3094
- throw new Error("Attachments are not supported");
3095
- const attachment = await this._attachmentAdapter.add({ file });
3071
+ const adapter = this.getAttachmentAdapter();
3072
+ if (!adapter) throw new Error("Attachments are not supported");
3073
+ const attachment = await adapter.add({ file });
3096
3074
  if (attachment.status === void 0) {
3097
3075
  attachment.status = { type: "requires-action", reason: "composer-send" };
3098
3076
  }
@@ -3100,16 +3078,16 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
3100
3078
  this.notifySubscribers();
3101
3079
  }
3102
3080
  async removeAttachment(attachmentId) {
3103
- if (!this._attachmentAdapter)
3104
- throw new Error("Attachments are not supported");
3081
+ const adapter = this.getAttachmentAdapter();
3082
+ if (!adapter) throw new Error("Attachments are not supported");
3105
3083
  const index = this._attachments.findIndex((a) => a.id === attachmentId);
3106
3084
  if (index === -1) throw new Error("Attachment not found");
3107
3085
  const attachment = this._attachments[index];
3108
- await this._attachmentAdapter.remove(attachment);
3086
+ await adapter.remove(attachment);
3109
3087
  this._attachments = this._attachments.toSpliced(index, 1);
3110
3088
  this.notifySubscribers();
3111
3089
  }
3112
- __init17() {this._subscriptions = /* @__PURE__ */ new Set()}
3090
+ __init16() {this._subscriptions = /* @__PURE__ */ new Set()}
3113
3091
  notifySubscribers() {
3114
3092
  for (const callback of this._subscriptions) callback();
3115
3093
  }
@@ -3122,17 +3100,20 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
3122
3100
  // src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx
3123
3101
  var DefaultThreadComposerRuntimeCore = (_class9 = class extends BaseComposerRuntimeCore {
3124
3102
  constructor(runtime) {
3125
- super();_class9.prototype.__init18.call(this);;
3103
+ super();_class9.prototype.__init17.call(this);;
3126
3104
  this.runtime = runtime;
3127
3105
  this.connect();
3128
3106
  }
3129
- __init18() {this._canCancel = false}
3107
+ __init17() {this._canCancel = false}
3130
3108
  get canCancel() {
3131
3109
  return this._canCancel;
3132
3110
  }
3133
3111
  get attachments() {
3134
3112
  return super.attachments;
3135
3113
  }
3114
+ getAttachmentAdapter() {
3115
+ return _optionalChain([this, 'access', _157 => _157.runtime, 'access', _158 => _158.adapters, 'optionalAccess', _159 => _159.attachments]);
3116
+ }
3136
3117
  connect() {
3137
3118
  return this.runtime.subscribe(() => {
3138
3119
  if (this.canCancel !== this.runtime.capabilities.cancel) {
@@ -3144,7 +3125,7 @@ var DefaultThreadComposerRuntimeCore = (_class9 = class extends BaseComposerRunt
3144
3125
  async handleSend(message) {
3145
3126
  this.runtime.append({
3146
3127
  ...message,
3147
- parentId: _nullishCoalesce(_optionalChain([this, 'access', _152 => _152.runtime, 'access', _153 => _153.messages, 'access', _154 => _154.at, 'call', _155 => _155(-1), 'optionalAccess', _156 => _156.id]), () => ( null))
3128
+ parentId: _nullishCoalesce(_optionalChain([this, 'access', _160 => _160.runtime, 'access', _161 => _161.messages, 'access', _162 => _162.at, 'call', _163 => _163(-1), 'optionalAccess', _164 => _164.id]), () => ( null))
3148
3129
  });
3149
3130
  }
3150
3131
  async cancel() {
@@ -3153,8 +3134,8 @@ var DefaultThreadComposerRuntimeCore = (_class9 = class extends BaseComposerRunt
3153
3134
  }, _class9);
3154
3135
 
3155
3136
  // src/utils/ProxyConfigProvider.ts
3156
- var ProxyConfigProvider = (_class10 = class {constructor() { _class10.prototype.__init19.call(this); }
3157
- __init19() {this._providers = /* @__PURE__ */ new Set()}
3137
+ var ProxyConfigProvider = (_class10 = class {constructor() { _class10.prototype.__init18.call(this); }
3138
+ __init18() {this._providers = /* @__PURE__ */ new Set()}
3158
3139
  getModelConfig() {
3159
3140
  return _chunkKVXP3Q6Kjs.mergeModelConfigs.call(void 0, this._providers);
3160
3141
  }
@@ -3231,11 +3212,11 @@ var findHead = (message) => {
3231
3212
  if ("current" in message) return message;
3232
3213
  return null;
3233
3214
  };
3234
- var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__init20.call(this);_class11.prototype.__init21.call(this);_class11.prototype.__init22.call(this); }
3235
- __init20() {this.messages = /* @__PURE__ */ new Map()}
3215
+ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__init19.call(this);_class11.prototype.__init20.call(this);_class11.prototype.__init21.call(this); }
3216
+ __init19() {this.messages = /* @__PURE__ */ new Map()}
3236
3217
  // message_id -> item
3237
- __init21() {this.head = null}
3238
- __init22() {this.root = {
3218
+ __init20() {this.head = null}
3219
+ __init21() {this.root = {
3239
3220
  children: [],
3240
3221
  next: null
3241
3222
  }}
@@ -3277,7 +3258,7 @@ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__
3277
3258
  }
3278
3259
  }
3279
3260
  getMessages() {
3280
- const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access', _157 => _157.head, 'optionalAccess', _158 => _158.level]), () => ( 0)));
3261
+ const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access', _165 => _165.head, 'optionalAccess', _166 => _166.level]), () => ( 0)));
3281
3262
  for (let current = this.head; current; current = current.prev) {
3282
3263
  messages2[current.level] = current.current;
3283
3264
  }
@@ -3315,7 +3296,7 @@ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__
3315
3296
  "MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
3316
3297
  );
3317
3298
  return {
3318
- parentId: _nullishCoalesce(_optionalChain([message, 'access', _159 => _159.prev, 'optionalAccess', _160 => _160.current, 'access', _161 => _161.id]), () => ( null)),
3299
+ parentId: _nullishCoalesce(_optionalChain([message, 'access', _167 => _167.prev, 'optionalAccess', _168 => _168.current, 'access', _169 => _169.id]), () => ( null)),
3319
3300
  message: message.current
3320
3301
  };
3321
3302
  }
@@ -3399,11 +3380,11 @@ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__
3399
3380
  for (const [, message] of this.messages) {
3400
3381
  exportItems.push({
3401
3382
  message: message.current,
3402
- parentId: _nullishCoalesce(_optionalChain([message, 'access', _162 => _162.prev, 'optionalAccess', _163 => _163.current, 'access', _164 => _164.id]), () => ( null))
3383
+ parentId: _nullishCoalesce(_optionalChain([message, 'access', _170 => _170.prev, 'optionalAccess', _171 => _171.current, 'access', _172 => _172.id]), () => ( null))
3403
3384
  });
3404
3385
  }
3405
3386
  return {
3406
- headId: _nullishCoalesce(_optionalChain([this, 'access', _165 => _165.head, 'optionalAccess', _166 => _166.current, 'access', _167 => _167.id]), () => ( null)),
3387
+ headId: _nullishCoalesce(_optionalChain([this, 'access', _173 => _173.head, 'optionalAccess', _174 => _174.current, 'access', _175 => _175.id]), () => ( null)),
3407
3388
  messages: exportItems
3408
3389
  };
3409
3390
  }
@@ -3411,7 +3392,7 @@ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__
3411
3392
  for (const { message, parentId } of messages2) {
3412
3393
  this.addOrUpdateMessage(parentId, message);
3413
3394
  }
3414
- this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access', _168 => _168.at, 'call', _169 => _169(-1), 'optionalAccess', _170 => _170.message, 'access', _171 => _171.id]))), () => ( null)));
3395
+ this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access', _176 => _176.at, 'call', _177 => _177(-1), 'optionalAccess', _178 => _178.message, 'access', _179 => _179.id]))), () => ( null)));
3415
3396
  }
3416
3397
  }, _class11);
3417
3398
 
@@ -3511,41 +3492,11 @@ var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, sid
3511
3492
  });
3512
3493
  TooltipIconButton.displayName = "TooltipIconButton";
3513
3494
 
3514
- // src/api/AssistantRuntime.ts
3515
- var AssistantRuntimeImpl = class {
3516
- constructor(_core, CustomThreadRuntime) {
3517
- this._core = _core;
3518
- this.thread = new CustomThreadRuntime(
3519
- new NestedSubscriptionSubject({
3520
- getState: () => this._core.thread,
3521
- subscribe: (callback) => this._core.subscribe(callback)
3522
- })
3523
- );
3524
- }
3525
-
3526
- switchToNewThread() {
3527
- return this._core.switchToNewThread();
3528
- }
3529
- switchToThread(threadId) {
3530
- return this._core.switchToThread(threadId);
3531
- }
3532
- registerModelConfigProvider(provider) {
3533
- return this._core.registerModelConfigProvider(provider);
3534
- }
3535
- // TODO events for thread switching
3536
- /**
3537
- * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
3538
- */
3539
- subscribe(callback) {
3540
- return this._core.subscribe(callback);
3541
- }
3542
- };
3543
-
3544
3495
  // src/api/ThreadRuntime.ts
3545
3496
  var toAppendMessage = (messages2, message) => {
3546
3497
  if (typeof message === "string") {
3547
3498
  return {
3548
- parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _172 => _172.at, 'call', _173 => _173(-1), 'optionalAccess', _174 => _174.id]), () => ( null)),
3499
+ parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _180 => _180.at, 'call', _181 => _181(-1), 'optionalAccess', _182 => _182.id]), () => ( null)),
3549
3500
  role: "user",
3550
3501
  content: [{ type: "text", text: message }],
3551
3502
  attachments: []
@@ -3555,7 +3506,7 @@ var toAppendMessage = (messages2, message) => {
3555
3506
  return message;
3556
3507
  }
3557
3508
  return {
3558
- parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access', _175 => _175.at, 'call', _176 => _176(-1), 'optionalAccess', _177 => _177.id]))), () => ( null)),
3509
+ parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access', _183 => _183.at, 'call', _184 => _184(-1), 'optionalAccess', _185 => _185.id]))), () => ( null)),
3559
3510
  role: _nullishCoalesce(message.role, () => ( "user")),
3560
3511
  content: message.content,
3561
3512
  attachments: _nullishCoalesce(message.attachments, () => ( []))
@@ -3567,10 +3518,11 @@ var getThreadState = (runtime) => {
3567
3518
  threadId: runtime.threadId,
3568
3519
  capabilities: runtime.capabilities,
3569
3520
  isDisabled: runtime.isDisabled,
3570
- isRunning: _optionalChain([lastMessage, 'optionalAccess', _178 => _178.role]) !== "assistant" ? false : lastMessage.status.type === "running",
3521
+ isRunning: _optionalChain([lastMessage, 'optionalAccess', _186 => _186.role]) !== "assistant" ? false : lastMessage.status.type === "running",
3571
3522
  messages: runtime.messages,
3572
3523
  suggestions: runtime.suggestions,
3573
- extras: runtime.extras
3524
+ extras: runtime.extras,
3525
+ speech: runtime.speech
3574
3526
  });
3575
3527
  };
3576
3528
  var ThreadRuntimeImpl = (_class12 = class {
@@ -3617,11 +3569,17 @@ var ThreadRuntimeImpl = (_class12 = class {
3617
3569
  get messages() {
3618
3570
  return this._threadBinding.getState().messages;
3619
3571
  }
3572
+ /**
3573
+ * @deprecated Use `getState().speechState` instead. This will be removed in 0.6.0.
3574
+ */
3575
+ get speech() {
3576
+ return this._threadBinding.getState().speech;
3577
+ }
3620
3578
  unstable_getCore() {
3621
3579
  return this._threadBinding.getState();
3622
3580
  }
3623
3581
 
3624
- constructor(threadBinding) {;_class12.prototype.__init23.call(this);
3582
+ constructor(threadBinding) {;_class12.prototype.__init22.call(this);
3625
3583
  const stateBinding = new LazyMemoizeSubject({
3626
3584
  getState: () => getThreadState(threadBinding.getState()),
3627
3585
  subscribe: (callback) => threadBinding.subscribe(callback)
@@ -3632,7 +3590,7 @@ var ThreadRuntimeImpl = (_class12 = class {
3632
3590
  subscribe: (callback) => threadBinding.subscribe(callback)
3633
3591
  };
3634
3592
  }
3635
- __init23() {this.composer = new ThreadComposerRuntimeImpl(
3593
+ __init22() {this.composer = new ThreadComposerRuntimeImpl(
3636
3594
  new NestedSubscriptionSubject({
3637
3595
  getState: () => this._threadBinding.getState().composer,
3638
3596
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -3677,15 +3635,21 @@ var ThreadRuntimeImpl = (_class12 = class {
3677
3635
  switchToBranch(branchId) {
3678
3636
  return this._threadBinding.getState().switchToBranch(branchId);
3679
3637
  }
3680
- // /**
3681
- // * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
3682
- // */
3638
+ /**
3639
+ * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
3640
+ */
3683
3641
  speak(messageId) {
3684
3642
  return this._threadBinding.getState().speak(messageId);
3685
3643
  }
3686
- // /**
3687
- // * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
3688
- // */
3644
+ stopSpeaking() {
3645
+ return this._threadBinding.getState().stopSpeaking();
3646
+ }
3647
+ getSubmittedFeedback(messageId) {
3648
+ return this._threadBinding.getState().getSubmittedFeedback(messageId);
3649
+ }
3650
+ /**
3651
+ * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
3652
+ */
3689
3653
  submitFeedback(options) {
3690
3654
  return this._threadBinding.getState().submitFeedback(options);
3691
3655
  }
@@ -3712,18 +3676,22 @@ var ThreadRuntimeImpl = (_class12 = class {
3712
3676
  return new MessageRuntimeImpl(
3713
3677
  new ShallowMemoizeSubject({
3714
3678
  getState: () => {
3715
- const messages2 = this.getState().messages;
3679
+ const { messages: messages2, speech: speechState } = this.getState();
3716
3680
  const message = messages2[idx];
3717
3681
  if (!message) return SKIP_UPDATE;
3718
- const branches = this._threadBinding.getState().getBranches(message.id);
3682
+ const thread = this._threadBinding.getState();
3683
+ const branches = thread.getBranches(message.id);
3684
+ const submittedFeedback = thread.getSubmittedFeedback(message.id);
3719
3685
  return {
3720
3686
  ...message,
3721
3687
  message,
3722
3688
  isLast: idx === messages2.length - 1,
3723
- parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _179 => _179[idx - 1], 'optionalAccess', _180 => _180.id]), () => ( null)),
3689
+ parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _187 => _187[idx - 1], 'optionalAccess', _188 => _188.id]), () => ( null)),
3724
3690
  branches,
3725
3691
  branchNumber: branches.indexOf(message.id) + 1,
3726
- branchCount: branches.length
3692
+ branchCount: branches.length,
3693
+ speech: _optionalChain([speechState, 'optionalAccess', _189 => _189.messageId]) === message.id ? speechState : void 0,
3694
+ submittedFeedback
3727
3695
  };
3728
3696
  },
3729
3697
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -3733,6 +3701,47 @@ var ThreadRuntimeImpl = (_class12 = class {
3733
3701
  }
3734
3702
  }, _class12);
3735
3703
 
3704
+ // src/api/AssistantRuntime.ts
3705
+ var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
3706
+ constructor(_core, _thread) {
3707
+ this._core = _core;
3708
+ this._thread = _thread;
3709
+ }
3710
+ get thread() {
3711
+ return this._thread;
3712
+ }
3713
+ switchToNewThread() {
3714
+ return this._core.switchToNewThread();
3715
+ }
3716
+ switchToThread(threadId) {
3717
+ return this._core.switchToThread(threadId);
3718
+ }
3719
+ registerModelConfigProvider(provider) {
3720
+ return this._core.registerModelConfigProvider(provider);
3721
+ }
3722
+ // TODO events for thread switching
3723
+ /**
3724
+ * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
3725
+ */
3726
+ subscribe(callback) {
3727
+ return this._core.subscribe(callback);
3728
+ }
3729
+ static createThreadRuntime(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
3730
+ return new CustomThreadRuntime(
3731
+ new NestedSubscriptionSubject({
3732
+ getState: () => _core.thread,
3733
+ subscribe: (callback) => _core.subscribe(callback)
3734
+ })
3735
+ );
3736
+ }
3737
+ static create(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
3738
+ return new _AssistantRuntimeImpl(
3739
+ _core,
3740
+ _AssistantRuntimeImpl.createThreadRuntime(_core, CustomThreadRuntime)
3741
+ );
3742
+ }
3743
+ };
3744
+
3736
3745
  // src/runtimes/edge/converters/fromLanguageModelMessages.ts
3737
3746
  var fromLanguageModelMessages = (lm, { mergeSteps }) => {
3738
3747
  const messages2 = [];
@@ -3799,7 +3808,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
3799
3808
  });
3800
3809
  if (mergeSteps) {
3801
3810
  const previousMessage = messages2[messages2.length - 1];
3802
- if (_optionalChain([previousMessage, 'optionalAccess', _181 => _181.role]) === "assistant") {
3811
+ if (_optionalChain([previousMessage, 'optionalAccess', _190 => _190.role]) === "assistant") {
3803
3812
  previousMessage.content.push(...newContent);
3804
3813
  break;
3805
3814
  }
@@ -3812,7 +3821,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
3812
3821
  }
3813
3822
  case "tool": {
3814
3823
  const previousMessage = messages2[messages2.length - 1];
3815
- if (_optionalChain([previousMessage, 'optionalAccess', _182 => _182.role]) !== "assistant")
3824
+ if (_optionalChain([previousMessage, 'optionalAccess', _191 => _191.role]) !== "assistant")
3816
3825
  throw new Error(
3817
3826
  "A tool message must be preceded by an assistant message."
3818
3827
  );
@@ -3934,7 +3943,7 @@ function assistantDecoderStream() {
3934
3943
  }
3935
3944
  case "c" /* ToolCallDelta */: {
3936
3945
  const { toolCallId, argsTextDelta } = value;
3937
- if (_optionalChain([currentToolCall, 'optionalAccess', _183 => _183.id]) !== toolCallId) {
3946
+ if (_optionalChain([currentToolCall, 'optionalAccess', _192 => _192.id]) !== toolCallId) {
3938
3947
  throw new Error(
3939
3948
  `Received tool call delta for unknown tool call "${toolCallId}".`
3940
3949
  );
@@ -4081,7 +4090,7 @@ var useEdgeRuntime = (options) => {
4081
4090
  };
4082
4091
 
4083
4092
  // src/runtimes/local/shouldContinue.tsx
4084
- var shouldContinue = (result) => _optionalChain([result, 'access', _184 => _184.status, 'optionalAccess', _185 => _185.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
4093
+ var shouldContinue = (result) => _optionalChain([result, 'access', _193 => _193.status, 'optionalAccess', _194 => _194.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
4085
4094
 
4086
4095
  // src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
4087
4096
  var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
@@ -4095,10 +4104,14 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
4095
4104
  this._nonTextParts = message.content.filter(
4096
4105
  (part) => part.type !== "text" && part.type !== "ui"
4097
4106
  );
4107
+ this.attachments = _nullishCoalesce(message.attachments, () => ( []));
4098
4108
  }
4099
4109
  get canCancel() {
4100
4110
  return true;
4101
4111
  }
4112
+ getAttachmentAdapter() {
4113
+ return _optionalChain([this, 'access', _195 => _195.runtime, 'access', _196 => _196.adapters, 'optionalAccess', _197 => _197.attachments]);
4114
+ }
4102
4115
 
4103
4116
 
4104
4117
 
@@ -4120,10 +4133,107 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
4120
4133
  }
4121
4134
  };
4122
4135
 
4123
- // src/runtimes/local/LocalThreadRuntimeCore.tsx
4124
- var LocalThreadRuntimeCore = (_class13 = class {
4125
- constructor(configProvider, adapter, { initialMessages, ...options }) {;_class13.prototype.__init24.call(this);_class13.prototype.__init25.call(this);_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);_class13.prototype.__init28.call(this);_class13.prototype.__init29.call(this);_class13.prototype.__init30.call(this);_class13.prototype.__init31.call(this);
4136
+ // src/runtimes/core/BaseThreadRuntimeCore.tsx
4137
+ var BaseThreadRuntimeCore = (_class13 = class {
4138
+ constructor(configProvider) {;_class13.prototype.__init23.call(this);_class13.prototype.__init24.call(this);_class13.prototype.__init25.call(this);_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);
4126
4139
  this.configProvider = configProvider;
4140
+ }
4141
+ __init23() {this._subscriptions = /* @__PURE__ */ new Set()}
4142
+ __init24() {this.repository = new MessageRepository()}
4143
+ get messages() {
4144
+ return this.repository.getMessages();
4145
+ }
4146
+ __init25() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4147
+ getModelConfig() {
4148
+ return this.configProvider.getModelConfig();
4149
+ }
4150
+ __init26() {this._editComposers = /* @__PURE__ */ new Map()}
4151
+ getEditComposer(messageId) {
4152
+ return this._editComposers.get(messageId);
4153
+ }
4154
+ beginEdit(messageId) {
4155
+ if (this._editComposers.has(messageId))
4156
+ throw new Error("Edit already in progress");
4157
+ this._editComposers.set(
4158
+ messageId,
4159
+ new DefaultEditComposerRuntimeCore(
4160
+ this,
4161
+ () => this._editComposers.delete(messageId),
4162
+ this.repository.getMessage(messageId)
4163
+ )
4164
+ );
4165
+ this.notifySubscribers();
4166
+ }
4167
+ getBranches(messageId) {
4168
+ return this.repository.getBranches(messageId);
4169
+ }
4170
+ switchToBranch(branchId) {
4171
+ this.repository.switchToBranch(branchId);
4172
+ this.notifySubscribers();
4173
+ }
4174
+ notifySubscribers() {
4175
+ for (const callback of this._subscriptions) callback();
4176
+ }
4177
+ subscribe(callback) {
4178
+ this._subscriptions.add(callback);
4179
+ return () => this._subscriptions.delete(callback);
4180
+ }
4181
+ __init27() {this._submittedFeedback = {}}
4182
+ getSubmittedFeedback(messageId) {
4183
+ return this._submittedFeedback[messageId];
4184
+ }
4185
+ submitFeedback({ messageId, type }) {
4186
+ const adapter = _optionalChain([this, 'access', _198 => _198.adapters, 'optionalAccess', _199 => _199.feedback]);
4187
+ if (!adapter) throw new Error("Feedback adapter not configured");
4188
+ const { message } = this.repository.getMessage(messageId);
4189
+ adapter.submit({ message, type });
4190
+ this._submittedFeedback[messageId] = { type };
4191
+ this.notifySubscribers();
4192
+ }
4193
+
4194
+
4195
+ speak(messageId) {
4196
+ const adapter = _optionalChain([this, 'access', _200 => _200.adapters, 'optionalAccess', _201 => _201.speech]);
4197
+ if (!adapter) throw new Error("Speech adapter not configured");
4198
+ const { message } = this.repository.getMessage(messageId);
4199
+ _optionalChain([this, 'access', _202 => _202._stopSpeaking, 'optionalCall', _203 => _203()]);
4200
+ const utterance = adapter.speak(message);
4201
+ const unsub = utterance.subscribe(() => {
4202
+ if (utterance.status.type === "ended") {
4203
+ this._stopSpeaking = void 0;
4204
+ this.speech = void 0;
4205
+ } else {
4206
+ this.speech = { messageId, status: utterance.status };
4207
+ }
4208
+ this.notifySubscribers();
4209
+ });
4210
+ this.speech = { messageId, status: utterance.status };
4211
+ this.notifySubscribers();
4212
+ this._stopSpeaking = () => {
4213
+ utterance.cancel();
4214
+ unsub();
4215
+ this.speech = void 0;
4216
+ this._stopSpeaking = void 0;
4217
+ };
4218
+ }
4219
+ stopSpeaking() {
4220
+ if (!this._stopSpeaking) throw new Error("No message is being spoken");
4221
+ this._stopSpeaking();
4222
+ this.notifySubscribers();
4223
+ }
4224
+ export() {
4225
+ return this.repository.export();
4226
+ }
4227
+ import(data) {
4228
+ this.repository.import(data);
4229
+ this.notifySubscribers();
4230
+ }
4231
+ }, _class13);
4232
+
4233
+ // src/runtimes/local/LocalThreadRuntimeCore.tsx
4234
+ var LocalThreadRuntimeCore = (_class14 = class extends BaseThreadRuntimeCore {
4235
+ constructor(configProvider, adapter, { initialMessages, ...options }) {
4236
+ super(configProvider);_class14.prototype.__init28.call(this);_class14.prototype.__init29.call(this);_class14.prototype.__init30.call(this);_class14.prototype.__init31.call(this);;
4127
4237
  this.adapter = adapter;
4128
4238
  this.threadId = generateId();
4129
4239
  this.options = options;
@@ -4136,28 +4246,22 @@ var LocalThreadRuntimeCore = (_class13 = class {
4136
4246
  }
4137
4247
  }
4138
4248
  }
4139
- __init24() {this._subscriptions = /* @__PURE__ */ new Set()}
4140
- __init25() {this.abortController = null}
4141
- __init26() {this.repository = new MessageRepository()}
4142
- __init27() {this.capabilities = {
4249
+ __init28() {this.capabilities = {
4143
4250
  switchToBranch: true,
4144
4251
  edit: true,
4145
4252
  reload: true,
4146
4253
  cancel: true,
4147
4254
  unstable_copy: true,
4148
- speak: false,
4255
+ speech: false,
4149
4256
  attachments: false,
4150
4257
  feedback: false
4151
4258
  }}
4259
+ __init29() {this.abortController = null}
4152
4260
 
4153
- __init28() {this.isDisabled = false}
4154
- __init29() {this.suggestions = []}
4155
- get messages() {
4156
- return this.repository.getMessages();
4157
- }
4158
- __init30() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4159
- getModelConfig() {
4160
- return this.configProvider.getModelConfig();
4261
+ __init30() {this.isDisabled = false}
4262
+ __init31() {this.suggestions = []}
4263
+ get adapters() {
4264
+ return this.options.adapters;
4161
4265
  }
4162
4266
 
4163
4267
  get options() {
@@ -4169,48 +4273,23 @@ var LocalThreadRuntimeCore = (_class13 = class {
4169
4273
  set options({ initialMessages, ...options }) {
4170
4274
  this._options = options;
4171
4275
  let hasUpdates = false;
4172
- const canSpeak = _optionalChain([options, 'access', _186 => _186.adapters, 'optionalAccess', _187 => _187.speech]) !== void 0;
4173
- if (this.capabilities.speak !== canSpeak) {
4174
- this.capabilities.speak = canSpeak;
4276
+ const canSpeak = _optionalChain([options, 'access', _204 => _204.adapters, 'optionalAccess', _205 => _205.speech]) !== void 0;
4277
+ if (this.capabilities.speech !== canSpeak) {
4278
+ this.capabilities.speech = canSpeak;
4175
4279
  hasUpdates = true;
4176
4280
  }
4177
- this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _188 => _188.adapters, 'optionalAccess', _189 => _189.attachments]));
4178
- const canAttach = _optionalChain([options, 'access', _190 => _190.adapters, 'optionalAccess', _191 => _191.attachments]) !== void 0;
4281
+ const canAttach = _optionalChain([options, 'access', _206 => _206.adapters, 'optionalAccess', _207 => _207.attachments]) !== void 0;
4179
4282
  if (this.capabilities.attachments !== canAttach) {
4180
4283
  this.capabilities.attachments = canAttach;
4181
4284
  hasUpdates = true;
4182
4285
  }
4183
- const canFeedback = _optionalChain([options, 'access', _192 => _192.adapters, 'optionalAccess', _193 => _193.feedback]) !== void 0;
4286
+ const canFeedback = _optionalChain([options, 'access', _208 => _208.adapters, 'optionalAccess', _209 => _209.feedback]) !== void 0;
4184
4287
  if (this.capabilities.feedback !== canFeedback) {
4185
4288
  this.capabilities.feedback = canFeedback;
4186
4289
  hasUpdates = true;
4187
4290
  }
4188
4291
  if (hasUpdates) this.notifySubscribers();
4189
4292
  }
4190
- __init31() {this._editComposers = /* @__PURE__ */ new Map()}
4191
- getEditComposer(messageId) {
4192
- return this._editComposers.get(messageId);
4193
- }
4194
- beginEdit(messageId) {
4195
- if (this._editComposers.has(messageId))
4196
- throw new Error("Edit already in progress");
4197
- this._editComposers.set(
4198
- messageId,
4199
- new DefaultEditComposerRuntimeCore(
4200
- this,
4201
- () => this._editComposers.delete(messageId),
4202
- this.repository.getMessage(messageId)
4203
- )
4204
- );
4205
- this.notifySubscribers();
4206
- }
4207
- getBranches(messageId) {
4208
- return this.repository.getBranches(messageId);
4209
- }
4210
- switchToBranch(branchId) {
4211
- this.repository.switchToBranch(branchId);
4212
- this.notifySubscribers();
4213
- }
4214
4293
  async append(message) {
4215
4294
  const newMessage = fromCoreMessage(message, {
4216
4295
  attachments: message.attachments
@@ -4239,13 +4318,13 @@ var LocalThreadRuntimeCore = (_class13 = class {
4239
4318
  }
4240
4319
  async performRoundtrip(parentId, message) {
4241
4320
  const messages2 = this.repository.getMessages();
4242
- _optionalChain([this, 'access', _194 => _194.abortController, 'optionalAccess', _195 => _195.abort, 'call', _196 => _196()]);
4321
+ _optionalChain([this, 'access', _210 => _210.abortController, 'optionalAccess', _211 => _211.abort, 'call', _212 => _212()]);
4243
4322
  this.abortController = new AbortController();
4244
4323
  const initialContent = message.content;
4245
- const initialSteps = _optionalChain([message, 'access', _197 => _197.metadata, 'optionalAccess', _198 => _198.steps]);
4246
- const initalCustom = _optionalChain([message, 'access', _199 => _199.metadata, 'optionalAccess', _200 => _200.custom]);
4324
+ const initialSteps = _optionalChain([message, 'access', _213 => _213.metadata, 'optionalAccess', _214 => _214.steps]);
4325
+ const initalCustom = _optionalChain([message, 'access', _215 => _215.metadata, 'optionalAccess', _216 => _216.custom]);
4247
4326
  const updateMessage = (m) => {
4248
- const newSteps = _optionalChain([m, 'access', _201 => _201.metadata, 'optionalAccess', _202 => _202.steps]) || _optionalChain([m, 'access', _203 => _203.metadata, 'optionalAccess', _204 => _204.roundtrips]);
4327
+ const newSteps = _optionalChain([m, 'access', _217 => _217.metadata, 'optionalAccess', _218 => _218.steps]) || _optionalChain([m, 'access', _219 => _219.metadata, 'optionalAccess', _220 => _220.roundtrips]);
4249
4328
  const steps2 = newSteps ? [..._nullishCoalesce(initialSteps, () => ( [])), ...newSteps] : void 0;
4250
4329
  message = {
4251
4330
  ...message,
@@ -4257,7 +4336,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
4257
4336
  metadata: {
4258
4337
  ...message.metadata,
4259
4338
  ...steps2 ? { roundtrips: steps2, steps: steps2 } : void 0,
4260
- ..._optionalChain([m, 'access', _205 => _205.metadata, 'optionalAccess', _206 => _206.custom]) ? {
4339
+ ..._optionalChain([m, 'access', _221 => _221.metadata, 'optionalAccess', _222 => _222.custom]) ? {
4261
4340
  custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
4262
4341
  } : void 0
4263
4342
  }
@@ -4267,7 +4346,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
4267
4346
  this.notifySubscribers();
4268
4347
  };
4269
4348
  const maxSteps = this.options.maxSteps ? this.options.maxSteps : (_nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1))) + 1;
4270
- const steps = _nullishCoalesce(_optionalChain([message, 'access', _207 => _207.metadata, 'optionalAccess', _208 => _208.steps, 'optionalAccess', _209 => _209.length]), () => ( 0));
4349
+ const steps = _nullishCoalesce(_optionalChain([message, 'access', _223 => _223.metadata, 'optionalAccess', _224 => _224.steps, 'optionalAccess', _225 => _225.length]), () => ( 0));
4271
4350
  if (steps >= maxSteps) {
4272
4351
  updateMessage({
4273
4352
  status: {
@@ -4287,7 +4366,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
4287
4366
  const promiseOrGenerator = this.adapter.run({
4288
4367
  messages: messages2,
4289
4368
  abortSignal: this.abortController.signal,
4290
- config: this.configProvider.getModelConfig(),
4369
+ config: this.getModelConfig(),
4291
4370
  onUpdate: updateMessage
4292
4371
  });
4293
4372
  if (Symbol.asyncIterator in promiseOrGenerator) {
@@ -4319,17 +4398,9 @@ var LocalThreadRuntimeCore = (_class13 = class {
4319
4398
  return message;
4320
4399
  }
4321
4400
  cancelRun() {
4322
- if (!this.abortController) return;
4323
- this.abortController.abort();
4401
+ _optionalChain([this, 'access', _226 => _226.abortController, 'optionalAccess', _227 => _227.abort, 'call', _228 => _228()]);
4324
4402
  this.abortController = null;
4325
4403
  }
4326
- notifySubscribers() {
4327
- for (const callback of this._subscriptions) callback();
4328
- }
4329
- subscribe(callback) {
4330
- this._subscriptions.add(callback);
4331
- return () => this._subscriptions.delete(callback);
4332
- }
4333
4404
  addToolResult({
4334
4405
  messageId,
4335
4406
  toolCallId,
@@ -4363,39 +4434,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
4363
4434
  this.performRoundtrip(parentId, message);
4364
4435
  }
4365
4436
  }
4366
- // TODO lift utterance state to thread runtime
4367
-
4368
- speak(messageId) {
4369
- const adapter = _optionalChain([this, 'access', _210 => _210.options, 'access', _211 => _211.adapters, 'optionalAccess', _212 => _212.speech]);
4370
- if (!adapter) throw new Error("Speech adapter not configured");
4371
- const { message } = this.repository.getMessage(messageId);
4372
- if (this._utterance) {
4373
- this._utterance.cancel();
4374
- this._utterance = void 0;
4375
- }
4376
- const utterance = adapter.speak(message);
4377
- utterance.onEnd(() => {
4378
- if (this._utterance === utterance) {
4379
- this._utterance = void 0;
4380
- }
4381
- });
4382
- this._utterance = utterance;
4383
- return this._utterance;
4384
- }
4385
- submitFeedback({ messageId, type }) {
4386
- const adapter = _optionalChain([this, 'access', _213 => _213.options, 'access', _214 => _214.adapters, 'optionalAccess', _215 => _215.feedback]);
4387
- if (!adapter) throw new Error("Feedback adapter not configured");
4388
- const { message } = this.repository.getMessage(messageId);
4389
- adapter.submit({ message, type });
4390
- }
4391
- export() {
4392
- return this.repository.export();
4393
- }
4394
- import(data) {
4395
- this.repository.import(data);
4396
- this.notifySubscribers();
4397
- }
4398
- }, _class13);
4437
+ }, _class14);
4399
4438
 
4400
4439
  // src/runtimes/local/LocalRuntimeCore.tsx
4401
4440
  var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
@@ -4430,7 +4469,7 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4430
4469
  const messages2 = fromCoreMessages(initialMessages);
4431
4470
  this.thread.import({
4432
4471
  messages: messages2.map((m, idx) => ({
4433
- parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _216 => _216[idx - 1], 'optionalAccess', _217 => _217.id]), () => ( null)),
4472
+ parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _229 => _229[idx - 1], 'optionalAccess', _230 => _230.id]), () => ( null)),
4434
4473
  message: m
4435
4474
  }))
4436
4475
  });
@@ -4438,14 +4477,20 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4438
4477
  };
4439
4478
 
4440
4479
  // src/runtimes/local/useLocalRuntime.tsx
4441
- var LocalRuntime = class extends AssistantRuntimeImpl {
4442
- constructor(core) {
4443
- super(core, ThreadRuntimeImpl);
4480
+ var LocalRuntimeImpl = class _LocalRuntimeImpl extends AssistantRuntimeImpl {
4481
+ constructor(core, thread) {
4482
+ super(core, thread);
4444
4483
  this.core = core;
4445
4484
  }
4446
4485
  reset(options) {
4447
4486
  this.core.reset(options);
4448
4487
  }
4488
+ static create(_core) {
4489
+ return new _LocalRuntimeImpl(
4490
+ _core,
4491
+ AssistantRuntimeImpl.createThreadRuntime(_core, ThreadRuntimeImpl)
4492
+ );
4493
+ }
4449
4494
  };
4450
4495
  var useLocalRuntime = (adapter, options = {}) => {
4451
4496
  const [runtime] = _react.useState.call(void 0, () => new LocalRuntimeCore(adapter, options));
@@ -4453,7 +4498,7 @@ var useLocalRuntime = (adapter, options = {}) => {
4453
4498
  runtime.thread.adapter = adapter;
4454
4499
  runtime.thread.options = options;
4455
4500
  });
4456
- return _react.useMemo.call(void 0, () => new LocalRuntime(runtime), [runtime]);
4501
+ return _react.useMemo.call(void 0, () => LocalRuntimeImpl.create(runtime), [runtime]);
4457
4502
  };
4458
4503
 
4459
4504
  // src/runtimes/external-store/useExternalStoreRuntime.tsx
@@ -4466,7 +4511,7 @@ var getExternalStoreMessage = (message) => {
4466
4511
  };
4467
4512
 
4468
4513
  // src/runtimes/external-store/ThreadMessageConverter.ts
4469
- var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.__init32.call(this); }
4514
+ var ThreadMessageConverter = (_class15 = class {constructor() { _class15.prototype.__init32.call(this); }
4470
4515
  __init32() {this.cache = /* @__PURE__ */ new WeakMap()}
4471
4516
  convertMessages(messages2, converter) {
4472
4517
  return messages2.map((m, idx) => {
@@ -4476,7 +4521,7 @@ var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototy
4476
4521
  return newMessage;
4477
4522
  });
4478
4523
  }
4479
- }, _class14);
4524
+ }, _class15);
4480
4525
 
4481
4526
  // src/runtimes/external-store/auto-status.tsx
4482
4527
  var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
@@ -4564,23 +4609,17 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
4564
4609
  // src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
4565
4610
  var EMPTY_ARRAY2 = Object.freeze([]);
4566
4611
  var hasUpcomingMessage = (isRunning, messages2) => {
4567
- return isRunning && _optionalChain([messages2, 'access', _218 => _218[messages2.length - 1], 'optionalAccess', _219 => _219.role]) !== "assistant";
4612
+ return isRunning && _optionalChain([messages2, 'access', _231 => _231[messages2.length - 1], 'optionalAccess', _232 => _232.role]) !== "assistant";
4568
4613
  };
4569
- var ExternalStoreThreadRuntimeCore = (_class15 = class {
4570
- constructor(configProvider, store) {;_class15.prototype.__init33.call(this);_class15.prototype.__init34.call(this);_class15.prototype.__init35.call(this);_class15.prototype.__init36.call(this);_class15.prototype.__init37.call(this);_class15.prototype.__init38.call(this);_class15.prototype.__init39.call(this);_class15.prototype.__init40.call(this);_class15.prototype.__init41.call(this);_class15.prototype.__init42.call(this);
4571
- this.configProvider = configProvider;
4572
- this.store = store;
4573
- }
4574
- __init33() {this._subscriptions = /* @__PURE__ */ new Set()}
4575
- __init34() {this.repository = new MessageRepository()}
4576
- __init35() {this.assistantOptimisticId = null}
4577
- __init36() {this._capabilities = {
4614
+ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntimeCore {
4615
+ __init33() {this.assistantOptimisticId = null}
4616
+ __init34() {this._capabilities = {
4578
4617
  switchToBranch: false,
4579
4618
  edit: false,
4580
4619
  reload: false,
4581
4620
  cancel: false,
4582
4621
  unstable_copy: false,
4583
- speak: false,
4622
+ speech: false,
4584
4623
  attachments: false,
4585
4624
  feedback: false
4586
4625
  }}
@@ -4590,27 +4629,24 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4590
4629
 
4591
4630
 
4592
4631
 
4593
- __init37() {this.suggestions = []}
4594
- __init38() {this.extras = void 0}
4595
- __init39() {this._converter = new ThreadMessageConverter()}
4596
-
4597
- __init40() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4598
- __init41() {this._editComposers = /* @__PURE__ */ new Map()}
4599
- getEditComposer(messageId) {
4600
- return this._editComposers.get(messageId);
4632
+ get messages() {
4633
+ return this._messages;
4634
+ }
4635
+ get adapters() {
4636
+ return this._store.adapters;
4601
4637
  }
4638
+ __init35() {this.suggestions = []}
4639
+ __init36() {this.extras = void 0}
4640
+ __init37() {this._converter = new ThreadMessageConverter()}
4641
+
4602
4642
  beginEdit(messageId) {
4603
- if (this._editComposers.has(messageId))
4604
- throw new Error("Edit already in progress");
4605
- this._editComposers.set(
4606
- messageId,
4607
- new DefaultEditComposerRuntimeCore(
4608
- this,
4609
- () => this._editComposers.delete(messageId),
4610
- this.repository.getMessage(messageId)
4611
- )
4612
- );
4613
- this.notifySubscribers();
4643
+ if (!this.store.onEdit)
4644
+ throw new Error("Runtime does not support editing.");
4645
+ super.beginEdit(messageId);
4646
+ }
4647
+ constructor(configProvider, store) {
4648
+ super(configProvider);_class16.prototype.__init33.call(this);_class16.prototype.__init34.call(this);_class16.prototype.__init35.call(this);_class16.prototype.__init36.call(this);_class16.prototype.__init37.call(this);_class16.prototype.__init38.call(this);;
4649
+ this.store = store;
4614
4650
  }
4615
4651
  get store() {
4616
4652
  return this._store;
@@ -4629,13 +4665,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4629
4665
  edit: this._store.onEdit !== void 0,
4630
4666
  reload: this._store.onReload !== void 0,
4631
4667
  cancel: this._store.onCancel !== void 0,
4632
- speak: this._store.onSpeak !== void 0,
4633
- unstable_copy: _optionalChain([this, 'access', _223 => _223._store, 'access', _224 => _224.unstable_capabilities, 'optionalAccess', _225 => _225.copy]) !== false,
4668
+ speech: _optionalChain([this, 'access', _236 => _236._store, 'access', _237 => _237.adapters, 'optionalAccess', _238 => _238.speech]) !== void 0,
4669
+ unstable_copy: _optionalChain([this, 'access', _239 => _239._store, 'access', _240 => _240.unstable_capabilities, 'optionalAccess', _241 => _241.copy]) !== false,
4634
4670
  // default true
4635
- attachments: !!_optionalChain([this, 'access', _226 => _226.store, 'access', _227 => _227.adapters, 'optionalAccess', _228 => _228.attachments]),
4636
- feedback: !!_optionalChain([this, 'access', _229 => _229.store, 'access', _230 => _230.adapters, 'optionalAccess', _231 => _231.feedback])
4671
+ attachments: !!_optionalChain([this, 'access', _242 => _242.store, 'access', _243 => _243.adapters, 'optionalAccess', _244 => _244.attachments]),
4672
+ feedback: !!_optionalChain([this, 'access', _245 => _245.store, 'access', _246 => _246.adapters, 'optionalAccess', _247 => _247.feedback])
4637
4673
  };
4638
- this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _232 => _232._store, 'access', _233 => _233.adapters, 'optionalAccess', _234 => _234.attachments]));
4639
4674
  if (oldStore) {
4640
4675
  if (oldStore.convertMessage !== store.convertMessage) {
4641
4676
  this._converter = new ThreadMessageConverter();
@@ -4661,7 +4696,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4661
4696
  for (let i = 0; i < messages2.length; i++) {
4662
4697
  const message = messages2[i];
4663
4698
  const parent = messages2[i - 1];
4664
- this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _235 => _235.id]), () => ( null)), message);
4699
+ this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _248 => _248.id]), () => ( null)), message);
4665
4700
  }
4666
4701
  if (this.assistantOptimisticId) {
4667
4702
  this.repository.deleteMessage(this.assistantOptimisticId);
@@ -4669,7 +4704,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4669
4704
  }
4670
4705
  if (hasUpcomingMessage(isRunning, messages2)) {
4671
4706
  this.assistantOptimisticId = this.repository.appendOptimisticMessage(
4672
- _nullishCoalesce(_optionalChain([messages2, 'access', _236 => _236.at, 'call', _237 => _237(-1), 'optionalAccess', _238 => _238.id]), () => ( null)),
4707
+ _nullishCoalesce(_optionalChain([messages2, 'access', _249 => _249.at, 'call', _250 => _250(-1), 'optionalAccess', _251 => _251.id]), () => ( null)),
4673
4708
  {
4674
4709
  role: "assistant",
4675
4710
  content: []
@@ -4677,20 +4712,11 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4677
4712
  );
4678
4713
  }
4679
4714
  this.repository.resetHead(
4680
- _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _239 => _239.at, 'call', _240 => _240(-1), 'optionalAccess', _241 => _241.id]))), () => ( null))
4715
+ _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _252 => _252.at, 'call', _253 => _253(-1), 'optionalAccess', _254 => _254.id]))), () => ( null))
4681
4716
  );
4682
- this.messages = this.repository.getMessages();
4717
+ this._messages = this.repository.getMessages();
4683
4718
  this.notifySubscribers();
4684
4719
  }
4685
- getModelConfig() {
4686
- return this.configProvider.getModelConfig();
4687
- }
4688
- notifySubscribers() {
4689
- for (const callback of this._subscriptions) callback();
4690
- }
4691
- getBranches(messageId) {
4692
- return this.repository.getBranches(messageId);
4693
- }
4694
4720
  switchToBranch(branchId) {
4695
4721
  if (!this._store.setMessages)
4696
4722
  throw new Error("Runtime does not support switching branches.");
@@ -4698,7 +4724,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4698
4724
  this.updateMessages(this.repository.getMessages());
4699
4725
  }
4700
4726
  async append(message) {
4701
- if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _242 => _242.messages, 'access', _243 => _243.at, 'call', _244 => _244(-1), 'optionalAccess', _245 => _245.id]), () => ( null)))) {
4727
+ if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _255 => _255.messages, 'access', _256 => _256.at, 'call', _257 => _257(-1), 'optionalAccess', _258 => _258.id]), () => ( null)))) {
4702
4728
  if (!this._store.onEdit)
4703
4729
  throw new Error("Runtime does not support editing messages.");
4704
4730
  await this._store.onEdit(message);
@@ -4721,7 +4747,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4721
4747
  }
4722
4748
  let messages2 = this.repository.getMessages();
4723
4749
  const previousMessage = messages2[messages2.length - 1];
4724
- if (_optionalChain([previousMessage, 'optionalAccess', _246 => _246.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _247 => _247.at, 'call', _248 => _248(-1), 'optionalAccess', _249 => _249.id])) {
4750
+ if (_optionalChain([previousMessage, 'optionalAccess', _259 => _259.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _260 => _260.at, 'call', _261 => _261(-1), 'optionalAccess', _262 => _262.id])) {
4725
4751
  this.repository.deleteMessage(previousMessage.id);
4726
4752
  if (!this.composer.text.trim()) {
4727
4753
  this.composer.setText(getThreadMessageText(previousMessage));
@@ -4739,34 +4765,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4739
4765
  throw new Error("Runtime does not support tool results.");
4740
4766
  this._store.onAddToolResult(options);
4741
4767
  }
4742
- speak(messageId) {
4743
- if (!this._store.onSpeak)
4744
- throw new Error("Runtime does not support speaking.");
4745
- const { message } = this.repository.getMessage(messageId);
4746
- return this._store.onSpeak(message);
4747
- }
4748
- submitFeedback({ messageId, type }) {
4749
- const adapter = _optionalChain([this, 'access', _250 => _250._store, 'access', _251 => _251.adapters, 'optionalAccess', _252 => _252.feedback]);
4750
- if (!adapter) throw new Error("Feedback adapter not configured");
4751
- const { message } = this.repository.getMessage(messageId);
4752
- adapter.submit({ message, type });
4753
- }
4754
- subscribe(callback) {
4755
- this._subscriptions.add(callback);
4756
- return () => this._subscriptions.delete(callback);
4757
- }
4758
- __init42() {this.updateMessages = (messages2) => {
4759
- _optionalChain([this, 'access', _253 => _253._store, 'access', _254 => _254.setMessages, 'optionalCall', _255 => _255(
4768
+ __init38() {this.updateMessages = (messages2) => {
4769
+ _optionalChain([this, 'access', _263 => _263._store, 'access', _264 => _264.setMessages, 'optionalCall', _265 => _265(
4760
4770
  messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
4761
4771
  )]);
4762
4772
  }}
4763
- import(repository) {
4764
- this.repository.import(repository);
4765
- }
4766
- export() {
4767
- return this.repository.export();
4768
- }
4769
- }, _class15);
4773
+ }, _class16);
4770
4774
 
4771
4775
  // src/runtimes/external-store/ExternalStoreRuntimeCore.tsx
4772
4776
  var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
@@ -4820,7 +4824,7 @@ var useExternalStoreRuntime = (store) => {
4820
4824
  runtime.thread.store = store;
4821
4825
  });
4822
4826
  return _react.useMemo.call(void 0,
4823
- () => new AssistantRuntimeImpl(runtime, ThreadRuntimeImpl),
4827
+ () => AssistantRuntimeImpl.create(runtime, ThreadRuntimeImpl),
4824
4828
  [runtime]
4825
4829
  );
4826
4830
  };
@@ -5010,11 +5014,11 @@ var WebSpeechSynthesisAdapter = class {
5010
5014
  speak(message) {
5011
5015
  const text = getThreadMessageText(message);
5012
5016
  const utterance = new SpeechSynthesisUtterance(text);
5013
- const endHandlers = /* @__PURE__ */ new Set();
5017
+ const subscribers = /* @__PURE__ */ new Set();
5014
5018
  const handleEnd = (reason, error) => {
5015
5019
  if (res.status.type === "ended") return;
5016
5020
  res.status = { type: "ended", reason, error };
5017
- endHandlers.forEach((handler) => handler());
5021
+ subscribers.forEach((handler) => handler());
5018
5022
  };
5019
5023
  utterance.addEventListener("end", () => handleEnd("finished"));
5020
5024
  utterance.addEventListener("error", (e) => handleEnd("error", e.error));
@@ -5025,7 +5029,7 @@ var WebSpeechSynthesisAdapter = class {
5025
5029
  window.speechSynthesis.cancel();
5026
5030
  handleEnd("cancelled");
5027
5031
  },
5028
- onEnd: (callback) => {
5032
+ subscribe: (callback) => {
5029
5033
  if (res.status.type === "ended") {
5030
5034
  let cancelled = false;
5031
5035
  queueMicrotask(() => {
@@ -5035,9 +5039,9 @@ var WebSpeechSynthesisAdapter = class {
5035
5039
  cancelled = true;
5036
5040
  };
5037
5041
  } else {
5038
- endHandlers.add(callback);
5042
+ subscribers.add(callback);
5039
5043
  return () => {
5040
- endHandlers.delete(callback);
5044
+ subscribers.delete(callback);
5041
5045
  };
5042
5046
  }
5043
5047
  }
@@ -5047,8 +5051,8 @@ var WebSpeechSynthesisAdapter = class {
5047
5051
  };
5048
5052
 
5049
5053
  // src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
5050
- var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init43.call(this); }
5051
- __init43() {this.accept = "image/*"}
5054
+ var SimpleImageAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init39.call(this); }
5055
+ __init39() {this.accept = "image/*"}
5052
5056
  async add(state) {
5053
5057
  return {
5054
5058
  id: state.file.name,
@@ -5073,7 +5077,7 @@ var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.p
5073
5077
  }
5074
5078
  async remove() {
5075
5079
  }
5076
- }, _class16);
5080
+ }, _class17);
5077
5081
  var getFileDataURL = (file) => new Promise((resolve, reject) => {
5078
5082
  const reader = new FileReader();
5079
5083
  reader.onload = () => resolve(reader.result);
@@ -5082,8 +5086,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
5082
5086
  });
5083
5087
 
5084
5088
  // src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
5085
- var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init44.call(this); }
5086
- __init44() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
5089
+ var SimpleTextAttachmentAdapter = (_class18 = class {constructor() { _class18.prototype.__init40.call(this); }
5090
+ __init40() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
5087
5091
  async add(state) {
5088
5092
  return {
5089
5093
  id: state.file.name,
@@ -5110,7 +5114,7 @@ ${await getFileText(attachment.file)}
5110
5114
  }
5111
5115
  async remove() {
5112
5116
  }
5113
- }, _class17);
5117
+ }, _class18);
5114
5118
  var getFileText = (file) => new Promise((resolve, reject) => {
5115
5119
  const reader = new FileReader();
5116
5120
  reader.onload = () => resolve(reader.result);
@@ -5211,7 +5215,7 @@ var ThreadConfigProvider = ({
5211
5215
  }) => {
5212
5216
  const hasAssistant = !!useAssistantRuntime({ optional: true });
5213
5217
  const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
5214
- if (!_optionalChain([config, 'optionalAccess', _256 => _256.runtime])) return configProvider;
5218
+ if (!_optionalChain([config, 'optionalAccess', _266 => _266.runtime])) return configProvider;
5215
5219
  if (hasAssistant) {
5216
5220
  throw new Error(
5217
5221
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
@@ -5240,8 +5244,8 @@ var useAllowCopy = (ensureCapability = false) => {
5240
5244
  };
5241
5245
  var useAllowSpeak = (ensureCapability = false) => {
5242
5246
  const { assistantMessage: { allowSpeak = true } = {} } = useThreadConfig();
5243
- const speakSupported = useThread((t) => t.capabilities.speak);
5244
- return allowSpeak && (!ensureCapability || speakSupported);
5247
+ const speechSupported = useThread((t) => t.capabilities.speech);
5248
+ return allowSpeak && (!ensureCapability || speechSupported);
5245
5249
  };
5246
5250
  var useAllowReload = (ensureCapability = false) => {
5247
5251
  const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();
@@ -5287,13 +5291,13 @@ var AssistantActionBarRoot = withDefaults(actionBar_exports.Root, {
5287
5291
  className: "aui-assistant-action-bar-root"
5288
5292
  });
5289
5293
  AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
5290
- var AssistantActionBarCopy = _react.forwardRef.call(void 0, (props, ref) => {
5294
+ var AssistantActionBarCopy = _react.forwardRef.call(void 0, ({ copiedDuration, ...props }, ref) => {
5291
5295
  const {
5292
5296
  strings: {
5293
5297
  assistantMessage: { copy: { tooltip = "Copy" } = {} } = {}
5294
5298
  } = {}
5295
5299
  } = useThreadConfig();
5296
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
5300
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Copy, { copiedDuration, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
5297
5301
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { copied: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CheckIcon, {}) }),
5298
5302
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { copied: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CopyIcon, {}) })
5299
5303
  ] }))) }) });
@@ -5408,7 +5412,7 @@ var BranchPicker = () => {
5408
5412
  const allowBranchPicker = useAllowBranchPicker(true);
5409
5413
  if (!allowBranchPicker) return null;
5410
5414
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, BranchPickerRoot, { hideWhenSingleBranch: true, children: [
5411
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerPrevious2, {}),
5415
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerPrevious, {}),
5412
5416
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerState, {}),
5413
5417
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerNext, {})
5414
5418
  ] });
@@ -5418,7 +5422,7 @@ var BranchPickerRoot = withDefaults(branchPicker_exports.Root, {
5418
5422
  className: "aui-branch-picker-root"
5419
5423
  });
5420
5424
  BranchPickerRoot.displayName = "BranchPickerRoot";
5421
- var BranchPickerPrevious2 = _react.forwardRef.call(void 0, (props, ref) => {
5425
+ var BranchPickerPrevious = _react.forwardRef.call(void 0, (props, ref) => {
5422
5426
  const {
5423
5427
  strings: {
5424
5428
  branchPicker: { previous: { tooltip = "Previous" } = {} } = {}
@@ -5427,7 +5431,7 @@ var BranchPickerPrevious2 = _react.forwardRef.call(void 0, (props, ref) => {
5427
5431
  const allowBranchPicker = useAllowBranchPicker();
5428
5432
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Previous, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon, {}))) }) });
5429
5433
  });
5430
- BranchPickerPrevious2.displayName = "BranchPickerPrevious";
5434
+ BranchPickerPrevious.displayName = "BranchPickerPrevious";
5431
5435
  var BranchPickerStateWrapper = withDefaults("span", {
5432
5436
  className: "aui-branch-picker-state"
5433
5437
  });
@@ -5449,7 +5453,7 @@ var BranchPickerNext = _react.forwardRef.call(void 0, (props, ref) => {
5449
5453
  BranchPickerNext.displayName = "BranchPickerNext";
5450
5454
  var exports2 = {
5451
5455
  Root: BranchPickerRoot,
5452
- Previous: BranchPickerPrevious2,
5456
+ Previous: BranchPickerPrevious,
5453
5457
  Next: BranchPickerNext
5454
5458
  };
5455
5459
  var branch_picker_default = Object.assign(BranchPicker, exports2);
@@ -5539,7 +5543,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
5539
5543
  {
5540
5544
  components: {
5541
5545
  ...componentsProp,
5542
- Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _257 => _257.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
5546
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _267 => _267.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
5543
5547
  tools: toolsComponents
5544
5548
  }
5545
5549
  }
@@ -5590,12 +5594,30 @@ CircleStopIcon.displayName = "CircleStopIcon";
5590
5594
 
5591
5595
 
5592
5596
  var ComposerAttachmentRoot = withDefaults(attachment_exports.Root, {
5593
- className: "aui-composer-attachment-root"
5597
+ className: "aui-attachment-root"
5594
5598
  });
5595
5599
  ComposerAttachmentRoot.displayName = "ComposerAttachmentRoot";
5596
5600
  var ComposerAttachment2 = () => {
5601
+ const typeLabel = useAttachment((a) => {
5602
+ const type = a.type;
5603
+ switch (type) {
5604
+ case "image":
5605
+ return "Image";
5606
+ case "document":
5607
+ return "Document";
5608
+ case "file":
5609
+ return "File";
5610
+ default:
5611
+ const _exhaustiveCheck = type;
5612
+ throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
5613
+ }
5614
+ });
5597
5615
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerAttachmentRoot, { children: [
5598
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, {}),
5616
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, { className: "aui-attachment-thumb" }),
5617
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "aui-attachment-text", children: [
5618
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "aui-attachment-name", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.Name, {}) }),
5619
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "aui-attachment-type", children: typeLabel })
5620
+ ] }),
5599
5621
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAttachmentRemove, {})
5600
5622
  ] });
5601
5623
  };
@@ -5674,7 +5696,7 @@ var ComposerAttachments = ({ components }) => {
5674
5696
  {
5675
5697
  components: {
5676
5698
  ...components,
5677
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _258 => _258.Attachment]), () => ( composer_attachment_default))
5699
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _268 => _268.Attachment]), () => ( composer_attachment_default))
5678
5700
  }
5679
5701
  }
5680
5702
  ) });
@@ -5719,23 +5741,27 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
5719
5741
  variant: "default",
5720
5742
  className: "aui-composer-send"
5721
5743
  });
5722
- var ComposerSend = _react.forwardRef.call(void 0, (props, ref) => {
5723
- const {
5724
- strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
5725
- } = useThreadConfig();
5726
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Send, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerSendButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.SendHorizontalIcon, {}))) }) });
5727
- });
5744
+ var ComposerSend = _react.forwardRef.call(void 0,
5745
+ (props, ref) => {
5746
+ const {
5747
+ strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
5748
+ } = useThreadConfig();
5749
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Send, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerSendButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.SendHorizontalIcon, {}))) }) });
5750
+ }
5751
+ );
5728
5752
  ComposerSend.displayName = "ComposerSend";
5729
5753
  var ComposerCancelButton = withDefaults(TooltipIconButton, {
5730
5754
  variant: "default",
5731
5755
  className: "aui-composer-cancel"
5732
5756
  });
5733
- var ComposerCancel = _react.forwardRef.call(void 0, (props, ref) => {
5734
- const {
5735
- strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
5736
- } = useThreadConfig();
5737
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerCancelButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleStopIcon, {}))) }) });
5738
- });
5757
+ var ComposerCancel = _react.forwardRef.call(void 0,
5758
+ (props, ref) => {
5759
+ const {
5760
+ strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
5761
+ } = useThreadConfig();
5762
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerCancelButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleStopIcon, {}))) }) });
5763
+ }
5764
+ );
5739
5765
  ComposerCancel.displayName = "ComposerCancel";
5740
5766
  var exports6 = {
5741
5767
  Root: ComposerRoot,
@@ -5767,11 +5793,9 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
5767
5793
  var ThreadWelcomeCenter = withDefaults("div", {
5768
5794
  className: "aui-thread-welcome-center"
5769
5795
  });
5770
- var ThreadWelcomeRoot = _react.forwardRef.call(void 0,
5771
- (props, ref) => {
5772
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.Empty, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeRootStyled, { ...props, ref }) });
5773
- }
5774
- );
5796
+ var ThreadWelcomeRoot = _react.forwardRef.call(void 0, (props, ref) => {
5797
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.Empty, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeRootStyled, { ...props, ref }) });
5798
+ });
5775
5799
  ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
5776
5800
  var ThreadWelcomeAvatar = () => {
5777
5801
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
@@ -5800,7 +5824,7 @@ var ThreadWelcomeSuggestions = () => {
5800
5824
  const suggestions2 = useThread((t) => t.suggestions);
5801
5825
  const { welcome: { suggestions } = {} } = useThreadConfig();
5802
5826
  const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
5803
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _259 => _259.map, 'call', _260 => _260((suggestion, idx) => {
5827
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _269 => _269.map, 'call', _270 => _270((suggestion, idx) => {
5804
5828
  const key = `${suggestion.prompt}-${idx}`;
5805
5829
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
5806
5830
  })]) });
@@ -5855,11 +5879,31 @@ var user_action_bar_default = Object.assign(UserActionBar, exports8);
5855
5879
  // src/ui/user-message-attachment.tsx
5856
5880
 
5857
5881
  var UserMessageAttachmentRoot = withDefaults(attachment_exports.Root, {
5858
- className: "aui-user-message-attachment-root"
5882
+ className: "aui-attachment-root"
5859
5883
  });
5860
5884
  UserMessageAttachmentRoot.displayName = "UserMessageAttachmentRoot";
5861
5885
  var UserMessageAttachment = () => {
5862
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageAttachmentRoot, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, {}) });
5886
+ const typeLabel = useAttachment((a) => {
5887
+ const type = a.type;
5888
+ switch (type) {
5889
+ case "image":
5890
+ return "Image";
5891
+ case "document":
5892
+ return "Document";
5893
+ case "file":
5894
+ return "File";
5895
+ default:
5896
+ const _exhaustiveCheck = type;
5897
+ throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
5898
+ }
5899
+ });
5900
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageAttachmentRoot, { children: [
5901
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, { className: "aui-attachment-thumb" }),
5902
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "aui-attachment-text", children: [
5903
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "aui-attachment-name", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.Name, {}) }),
5904
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "aui-attachment-type", children: typeLabel })
5905
+ ] })
5906
+ ] });
5863
5907
  };
5864
5908
  UserMessageAttachment.displayName = "UserMessageAttachment";
5865
5909
  var exports9 = {
@@ -5875,8 +5919,10 @@ var user_message_attachment_default = Object.assign(
5875
5919
  var UserMessage = () => {
5876
5920
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageRoot, { children: [
5877
5921
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageAttachments, {}),
5878
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, user_action_bar_default, {}),
5879
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContent, {}),
5922
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, message_exports.If, { hasContent: true, children: [
5923
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, user_action_bar_default, {}),
5924
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContent, {})
5925
+ ] }),
5880
5926
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branch_picker_default, {})
5881
5927
  ] });
5882
5928
  };
@@ -5888,19 +5934,17 @@ UserMessageRoot.displayName = "UserMessageRoot";
5888
5934
  var UserMessageContentWrapper = withDefaults("div", {
5889
5935
  className: "aui-user-message-content"
5890
5936
  });
5891
- var UserMessageContent = _react.forwardRef.call(void 0,
5892
- ({ components, ...props }, ref) => {
5893
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5894
- message_exports.Content,
5895
- {
5896
- components: {
5897
- ...components,
5898
- Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _261 => _261.Text]), () => ( content_part_default.Text))
5899
- }
5937
+ var UserMessageContent = _react.forwardRef.call(void 0, ({ components, ...props }, ref) => {
5938
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5939
+ message_exports.Content,
5940
+ {
5941
+ components: {
5942
+ ...components,
5943
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _271 => _271.Text]), () => ( content_part_default.Text))
5900
5944
  }
5901
- ) });
5902
- }
5903
- );
5945
+ }
5946
+ ) });
5947
+ });
5904
5948
  UserMessageContent.displayName = "UserMessageContent";
5905
5949
  var UserMessageAttachmentsContainer = withDefaults("div", {
5906
5950
  className: "aui-user-message-attachments"
@@ -5913,7 +5957,7 @@ var UserMessageAttachments = ({
5913
5957
  {
5914
5958
  components: {
5915
5959
  ...components,
5916
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _262 => _262.Attachment]), () => ( user_message_attachment_default))
5960
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _272 => _272.Attachment]), () => ( user_message_attachment_default))
5917
5961
  }
5918
5962
  }
5919
5963
  ) }) });
@@ -5950,25 +5994,19 @@ var EditComposerFooter = withDefaults("div", {
5950
5994
  className: "aui-edit-composer-footer"
5951
5995
  });
5952
5996
  EditComposerFooter.displayName = "EditComposerFooter";
5953
- var EditComposerCancel = _react.forwardRef.call(void 0,
5954
- (props, ref) => {
5955
- const {
5956
- strings: {
5957
- editComposer: { cancel: { label = "Cancel" } = {} } = {}
5958
- } = {}
5959
- } = useThreadConfig();
5960
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { variant: "ghost", ...props, ref, children: _nullishCoalesce(props.children, () => ( label)) }) });
5961
- }
5962
- );
5997
+ var EditComposerCancel = _react.forwardRef.call(void 0, (props, ref) => {
5998
+ const {
5999
+ strings: { editComposer: { cancel: { label = "Cancel" } = {} } = {} } = {}
6000
+ } = useThreadConfig();
6001
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { variant: "ghost", ...props, ref, children: _nullishCoalesce(props.children, () => ( label)) }) });
6002
+ });
5963
6003
  EditComposerCancel.displayName = "EditComposerCancel";
5964
- var EditComposerSend = _react.forwardRef.call(void 0,
5965
- (props, ref) => {
5966
- const {
5967
- strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
5968
- } = useThreadConfig();
5969
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Send, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { ...props, ref, children: _nullishCoalesce(props.children, () => ( label)) }) });
5970
- }
5971
- );
6004
+ var EditComposerSend = _react.forwardRef.call(void 0, (props, ref) => {
6005
+ const {
6006
+ strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
6007
+ } = useThreadConfig();
6008
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Send, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { ...props, ref, children: _nullishCoalesce(props.children, () => ( label)) }) });
6009
+ });
5972
6010
  EditComposerSend.displayName = "EditComposerSend";
5973
6011
  var exports11 = {
5974
6012
  Root: EditComposerRoot,
@@ -6022,10 +6060,10 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
6022
6060
  thread_exports.Messages,
6023
6061
  {
6024
6062
  components: {
6025
- UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _263 => _263.UserMessage]), () => ( user_message_default)),
6026
- EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _264 => _264.EditComposer]), () => ( edit_composer_default)),
6027
- AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _265 => _265.AssistantMessage]), () => ( assistant_message_default)),
6028
- SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _266 => _266.SystemMessage]), () => ( SystemMessage))
6063
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _273 => _273.UserMessage]), () => ( user_message_default)),
6064
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _274 => _274.EditComposer]), () => ( edit_composer_default)),
6065
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _275 => _275.AssistantMessage]), () => ( assistant_message_default)),
6066
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _276 => _276.SystemMessage]), () => ( SystemMessage))
6029
6067
  },
6030
6068
  ...rest
6031
6069
  }
@@ -6036,7 +6074,7 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
6036
6074
  ThreadMessages.displayName = "ThreadMessages";
6037
6075
  var ThreadFollowupSuggestions = () => {
6038
6076
  const suggestions = useThread((t) => t.suggestions);
6039
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _267 => _267.map, 'call', _268 => _268((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6077
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _277 => _277.map, 'call', _278 => _278((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6040
6078
  thread_exports.Suggestion,
6041
6079
  {
6042
6080
  className: "aui-thread-followup-suggestion",
@@ -6080,7 +6118,10 @@ var AssistantModal = (config) => {
6080
6118
  ] });
6081
6119
  };
6082
6120
  AssistantModal.displayName = "AssistantModal";
6083
- var AssistantModalRoot = ({ config, ...props }) => {
6121
+ var AssistantModalRoot = ({
6122
+ config,
6123
+ ...props
6124
+ }) => {
6084
6125
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, assistantModal_exports.Root, { ...props }) });
6085
6126
  };
6086
6127
  AssistantModalRoot.displayName = "AssistantModalRoot";