@assistant-ui/react 0.5.73 → 0.5.75

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -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
  };
@@ -672,12 +665,7 @@ var useBranchPickerCount = () => {
672
665
 
673
666
  var useBranchPickerNext = () => {
674
667
  const messageRuntime = useMessageRuntime();
675
- const messageStore = useMessageStore();
676
- const editComposerStore = useEditComposerStore();
677
- const disabled = useCombinedStore(
678
- [messageStore, editComposerStore],
679
- (m, c) => c.isEditing || m.branchNumber >= m.branchCount
680
- );
668
+ const disabled = useMessage((m) => m.branchNumber >= m.branchCount);
681
669
  const callback = _react.useCallback.call(void 0, () => {
682
670
  messageRuntime.switchToBranch({ position: "next" });
683
671
  }, [messageRuntime]);
@@ -695,12 +683,7 @@ var useBranchPickerNumber = () => {
695
683
 
696
684
  var useBranchPickerPrevious = () => {
697
685
  const messageRuntime = useMessageRuntime();
698
- const messageStore = useMessageStore();
699
- const editComposerStore = useEditComposerStore();
700
- const disabled = useCombinedStore(
701
- [messageStore, editComposerStore],
702
- (m, c) => c.isEditing || m.branchNumber <= 1
703
- );
686
+ const disabled = useMessage((m) => m.branchNumber <= 1);
704
687
  const callback = _react.useCallback.call(void 0, () => {
705
688
  messageRuntime.switchToBranch({ position: "previous" });
706
689
  }, [messageRuntime]);
@@ -819,7 +802,7 @@ var useMessageIf = (props) => {
819
802
  const messageUtilsStore = useMessageUtilsStore();
820
803
  return useCombinedStore(
821
804
  [messageStore, messageUtilsStore],
822
- ({ role, attachments, branchCount, isLast }, { isCopied, isHovering, isSpeaking, submittedFeedback }) => {
805
+ ({ role, attachments, branchCount, isLast, speech }, { isCopied, isHovering, submittedFeedback }) => {
823
806
  if (props.hasBranches === true && branchCount < 2) return false;
824
807
  if (props.user && role !== "user") return false;
825
808
  if (props.assistant && role !== "assistant") return false;
@@ -827,8 +810,8 @@ var useMessageIf = (props) => {
827
810
  if (props.lastOrHover === true && !isHovering && !isLast) return false;
828
811
  if (props.copied === true && !isCopied) return false;
829
812
  if (props.copied === false && isCopied) return false;
830
- if (props.speaking === true && !isSpeaking) return false;
831
- if (props.speaking === false && isSpeaking) return false;
813
+ if (props.speaking === true && speech == null) return false;
814
+ if (props.speaking === false && speech != null) return false;
832
815
  if (props.hasAttachments === true && (role !== "user" || !attachments.length))
833
816
  return false;
834
817
  if (props.hasAttachments === false && role === "user" && !!attachments.length)
@@ -1238,13 +1221,126 @@ var AssistantModalPrimitiveAnchor = _react.forwardRef.call(void 0,
1238
1221
  );
1239
1222
  AssistantModalPrimitiveAnchor.displayName = "AssistantModalPrimitive.Anchor";
1240
1223
 
1224
+ // src/primitives/attachment/index.ts
1225
+ var attachment_exports = {};
1226
+ _chunkPZ5AY32Cjs.__export.call(void 0, attachment_exports, {
1227
+ Name: () => AttachmentPrimitiveName,
1228
+ Remove: () => AttachmentPrimitiveRemove,
1229
+ Root: () => AttachmentPrimitiveRoot,
1230
+ unstable_Thumb: () => AttachmentPrimitiveThumb
1231
+ });
1232
+
1233
+ // src/primitives/attachment/AttachmentRoot.tsx
1234
+
1235
+
1236
+
1237
+ var AttachmentPrimitiveRoot = _react.forwardRef.call(void 0, (props, ref) => {
1238
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...props, ref });
1239
+ });
1240
+ AttachmentPrimitiveRoot.displayName = "AttachmentPrimitive.Root";
1241
+
1242
+ // src/primitives/attachment/AttachmentThumb.tsx
1243
+
1244
+
1245
+ // src/context/react/AttachmentContext.ts
1246
+
1247
+ var AttachmentContext = _react.createContext.call(void 0,
1248
+ null
1249
+ );
1250
+ function useAttachmentContext(options) {
1251
+ const context = _react.useContext.call(void 0, AttachmentContext);
1252
+ if (!_optionalChain([options, 'optionalAccess', _15 => _15.optional]) && !context)
1253
+ throw new Error(
1254
+ "This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
1255
+ );
1256
+ return context;
1257
+ }
1258
+ function useThreadComposerAttachmentContext(options) {
1259
+ const context = useAttachmentContext(options);
1260
+ if (!context) return null;
1261
+ if (context.source !== "thread-composer")
1262
+ throw new Error(
1263
+ "This component must be used within a thread's ComposerPrimitive.Attachments component."
1264
+ );
1265
+ return context;
1266
+ }
1267
+ function useEditComposerAttachmentContext(options) {
1268
+ const context = useAttachmentContext(options);
1269
+ if (!context) return null;
1270
+ if (context.source !== "edit-composer")
1271
+ throw new Error(
1272
+ "This component must be used within a messages's ComposerPrimitive.Attachments component."
1273
+ );
1274
+ return context;
1275
+ }
1276
+ function useMessageAttachmentContext(options) {
1277
+ const context = useAttachmentContext(options);
1278
+ if (!context) return null;
1279
+ if (context.source !== "message")
1280
+ throw new Error(
1281
+ "This component must be used within a MessagePrimitive.Attachments component."
1282
+ );
1283
+ return context;
1284
+ }
1285
+ function useAttachmentRuntime(options) {
1286
+ const attachmentRuntime = useAttachmentContext(options);
1287
+ if (!attachmentRuntime) return null;
1288
+ return attachmentRuntime.useAttachmentRuntime();
1289
+ }
1290
+ var { useAttachment } = createContextStoreHook(
1291
+ useAttachmentContext,
1292
+ "useAttachment"
1293
+ );
1294
+ var { useAttachment: useThreadComposerAttachment } = createContextStoreHook(useThreadComposerAttachmentContext, "useAttachment");
1295
+ var { useAttachment: useEditComposerAttachment } = createContextStoreHook(useEditComposerAttachmentContext, "useAttachment");
1296
+ var { useAttachment: useMessageAttachment } = createContextStoreHook(
1297
+ useMessageAttachmentContext,
1298
+ "useAttachment"
1299
+ );
1300
+
1301
+ // src/primitives/attachment/AttachmentThumb.tsx
1302
+
1303
+
1304
+ var AttachmentPrimitiveThumb = _react.forwardRef.call(void 0, () => {
1305
+ const ext = useAttachment((a) => a.name.split(".").pop());
1306
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactprimitive.Primitive.div, { children: [
1307
+ ".",
1308
+ ext
1309
+ ] });
1310
+ });
1311
+ AttachmentPrimitiveThumb.displayName = "AttachmentPrimitive.Thumb";
1312
+
1313
+ // src/primitives/attachment/AttachmentName.tsx
1314
+
1315
+ var AttachmentPrimitiveName = () => {
1316
+ const name = useAttachment((a) => a.name);
1317
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: name });
1318
+ };
1319
+ AttachmentPrimitiveName.displayName = "AttachmentPrimitive.Name";
1320
+
1321
+ // src/primitive-hooks/attachment/useAttachmentRemove.ts
1322
+
1323
+ var useAttachmentRemove = () => {
1324
+ const attachmentRuntime = useAttachmentRuntime();
1325
+ const handleRemoveAttachment = _react.useCallback.call(void 0, () => {
1326
+ attachmentRuntime.remove();
1327
+ }, [attachmentRuntime]);
1328
+ return handleRemoveAttachment;
1329
+ };
1330
+
1331
+ // src/primitives/attachment/AttachmentRemove.tsx
1332
+ var AttachmentPrimitiveRemove = createActionButton(
1333
+ "AttachmentPrimitive.Remove",
1334
+ useAttachmentRemove
1335
+ );
1336
+
1241
1337
  // src/primitives/branchPicker/index.ts
1242
1338
  var branchPicker_exports = {};
1243
1339
  _chunkPZ5AY32Cjs.__export.call(void 0, branchPicker_exports, {
1244
1340
  Count: () => BranchPickerPrimitiveCount,
1245
1341
  Next: () => BranchPickerPrimitiveNext,
1246
1342
  Number: () => BranchPickerPrimitiveNumber,
1247
- Previous: () => BranchPickerPrevious,
1343
+ Previous: () => BranchPickerPrimitivePrevious,
1248
1344
  Root: () => BranchPickerPrimitiveRoot
1249
1345
  });
1250
1346
 
@@ -1255,7 +1351,7 @@ var BranchPickerPrimitiveNext = createActionButton(
1255
1351
  );
1256
1352
 
1257
1353
  // src/primitives/branchPicker/BranchPickerPrevious.tsx
1258
- var BranchPickerPrevious = createActionButton(
1354
+ var BranchPickerPrimitivePrevious = createActionButton(
1259
1355
  "BranchPickerPrimitive.Previous",
1260
1356
  useBranchPickerPrevious
1261
1357
  );
@@ -1341,9 +1437,9 @@ var useIsHoveringRef = () => {
1341
1437
  );
1342
1438
  return useManagedRef(callbackRef);
1343
1439
  };
1344
- var MessagePrimitiveRoot = _react.forwardRef.call(void 0, (props, forwardRef33) => {
1440
+ var MessagePrimitiveRoot = _react.forwardRef.call(void 0, (props, forwardRef35) => {
1345
1441
  const isHoveringRef = useIsHoveringRef();
1346
- const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardRef33, isHoveringRef);
1442
+ const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardRef35, isHoveringRef);
1347
1443
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...props, ref });
1348
1444
  });
1349
1445
  MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
@@ -1434,7 +1530,7 @@ var withSmoothContextProvider = (Component) => {
1434
1530
  };
1435
1531
  function useSmoothContext(options) {
1436
1532
  const context = _react.useContext.call(void 0, SmoothContext);
1437
- if (!_optionalChain([options, 'optionalAccess', _15 => _15.optional]) && !context)
1533
+ if (!_optionalChain([options, 'optionalAccess', _16 => _16.optional]) && !context)
1438
1534
  throw new Error(
1439
1535
  "This component must be used within a SmoothContextProvider."
1440
1536
  );
@@ -1644,7 +1740,7 @@ var BaseSubject = (_class2 = class {constructor() { _class2.prototype.__init5.ca
1644
1740
  if (this._connection) return;
1645
1741
  this._connection = this._connect();
1646
1742
  } else {
1647
- _optionalChain([this, 'access', _16 => _16._connection, 'optionalCall', _17 => _17()]);
1743
+ _optionalChain([this, 'access', _17 => _17._connection, 'optionalCall', _18 => _18()]);
1648
1744
  this._connection = void 0;
1649
1745
  }
1650
1746
  }
@@ -1743,40 +1839,40 @@ var EMPTY_ARRAY = Object.freeze([]);
1743
1839
  var getThreadComposerState = (runtime, focus, onFocus) => {
1744
1840
  return Object.freeze({
1745
1841
  type: "thread",
1746
- isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _18 => _18.isEditing]), () => ( false)),
1747
- canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _19 => _19.canCancel]), () => ( false)),
1748
- isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _20 => _20.isEmpty]), () => ( true)),
1749
- text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _21 => _21.text]), () => ( "")),
1750
- attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _22 => _22.attachments]), () => ( EMPTY_ARRAY)),
1751
- attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _23 => _23.attachmentAccept]), () => ( "*")),
1752
- value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _24 => _24.text]), () => ( "")),
1753
- setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _25 => _25.setText, 'access', _26 => _26.bind, 'call', _27 => _27(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1754
- setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _28 => _28.setText, 'access', _29 => _29.bind, 'call', _30 => _30(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1842
+ isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _19 => _19.isEditing]), () => ( false)),
1843
+ canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _20 => _20.canCancel]), () => ( false)),
1844
+ isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _21 => _21.isEmpty]), () => ( true)),
1845
+ text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _22 => _22.text]), () => ( "")),
1846
+ attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _23 => _23.attachments]), () => ( EMPTY_ARRAY)),
1847
+ attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _24 => _24.attachmentAccept]), () => ( "*")),
1848
+ value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _25 => _25.text]), () => ( "")),
1849
+ setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _26 => _26.setText, 'access', _27 => _27.bind, 'call', _28 => _28(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1850
+ setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _29 => _29.setText, 'access', _30 => _30.bind, 'call', _31 => _31(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1755
1851
  // edit: beginEdit,
1756
- send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _31 => _31.send, 'access', _32 => _32.bind, 'call', _33 => _33(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1757
- cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _34 => _34.cancel, 'access', _35 => _35.bind, 'call', _36 => _36(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1852
+ send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _32 => _32.send, 'access', _33 => _33.bind, 'call', _34 => _34(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1853
+ cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _35 => _35.cancel, 'access', _36 => _36.bind, 'call', _37 => _37(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1758
1854
  focus,
1759
1855
  onFocus,
1760
- reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _37 => _37.reset, 'access', _38 => _38.bind, 'call', _39 => _39(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1761
- addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _40 => _40.addAttachment, 'access', _41 => _41.bind, 'call', _42 => _42(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1762
- removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _43 => _43.removeAttachment, 'access', _44 => _44.bind, 'call', _45 => _45(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1856
+ reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _38 => _38.reset, 'access', _39 => _39.bind, 'call', _40 => _40(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1857
+ addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _41 => _41.addAttachment, 'access', _42 => _42.bind, 'call', _43 => _43(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1858
+ removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _44 => _44.removeAttachment, 'access', _45 => _45.bind, 'call', _46 => _46(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1763
1859
  });
1764
1860
  };
1765
1861
  var getEditComposerState = (runtime, beginEdit) => {
1766
1862
  return Object.freeze({
1767
1863
  type: "edit",
1768
- isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _46 => _46.isEditing]), () => ( false)),
1769
- canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _47 => _47.canCancel]), () => ( false)),
1770
- isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _48 => _48.isEmpty]), () => ( true)),
1771
- text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _49 => _49.text]), () => ( "")),
1772
- attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _50 => _50.attachments]), () => ( EMPTY_ARRAY)),
1773
- attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _51 => _51.attachmentAccept]), () => ( "*")),
1774
- value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _52 => _52.text]), () => ( "")),
1775
- setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _53 => _53.setText, 'access', _54 => _54.bind, 'call', _55 => _55(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1776
- setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _56 => _56.setText, 'access', _57 => _57.bind, 'call', _58 => _58(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1864
+ isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _47 => _47.isEditing]), () => ( false)),
1865
+ canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _48 => _48.canCancel]), () => ( false)),
1866
+ isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _49 => _49.isEmpty]), () => ( true)),
1867
+ text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _50 => _50.text]), () => ( "")),
1868
+ attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _51 => _51.attachments]), () => ( EMPTY_ARRAY)),
1869
+ attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _52 => _52.attachmentAccept]), () => ( "*")),
1870
+ value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _53 => _53.text]), () => ( "")),
1871
+ setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _54 => _54.setText, 'access', _55 => _55.bind, 'call', _56 => _56(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1872
+ setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _57 => _57.setText, 'access', _58 => _58.bind, 'call', _59 => _59(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1777
1873
  edit: beginEdit,
1778
- send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _59 => _59.send, 'access', _60 => _60.bind, 'call', _61 => _61(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1779
- cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _62 => _62.cancel, 'access', _63 => _63.bind, 'call', _64 => _64(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1874
+ send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _60 => _60.send, 'access', _61 => _61.bind, 'call', _62 => _62(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
1875
+ cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _63 => _63.cancel, 'access', _64 => _64.bind, 'call', _65 => _65(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1780
1876
  });
1781
1877
  };
1782
1878
  var ComposerRuntimeImpl = class {
@@ -1889,7 +1985,7 @@ var ThreadComposerRuntimeImpl = (_class5 = class extends ComposerRuntimeImpl {
1889
1985
  this._getState = stateBinding.getState.bind(stateBinding);
1890
1986
  }
1891
1987
  get attachments() {
1892
- return _nullishCoalesce(_optionalChain([this, 'access', _65 => _65.getState, 'call', _66 => _66(), 'optionalAccess', _67 => _67.attachments]), () => ( EMPTY_ARRAY));
1988
+ return _nullishCoalesce(_optionalChain([this, 'access', _66 => _66.getState, 'call', _67 => _67(), 'optionalAccess', _68 => _68.attachments]), () => ( EMPTY_ARRAY));
1893
1989
  }
1894
1990
  getState() {
1895
1991
  return this._getState();
@@ -1991,19 +2087,19 @@ var NestedSubscriptionSubject = class extends BaseSubject {
1991
2087
  this.notifySubscribers();
1992
2088
  };
1993
2089
  let lastState = this.binding.getState();
1994
- let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess', _68 => _68.subscribe, 'call', _69 => _69(callback)]);
2090
+ let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess', _69 => _69.subscribe, 'call', _70 => _70(callback)]);
1995
2091
  const onRuntimeUpdate = () => {
1996
2092
  const newState = this.binding.getState();
1997
2093
  if (newState === lastState) return;
1998
2094
  lastState = newState;
1999
- _optionalChain([innerUnsubscribe, 'optionalCall', _70 => _70()]);
2000
- innerUnsubscribe = _optionalChain([this, 'access', _71 => _71.binding, 'access', _72 => _72.getState, 'call', _73 => _73(), 'optionalAccess', _74 => _74.subscribe, 'call', _75 => _75(callback)]);
2095
+ _optionalChain([innerUnsubscribe, 'optionalCall', _71 => _71()]);
2096
+ innerUnsubscribe = _optionalChain([this, 'access', _72 => _72.binding, 'access', _73 => _73.getState, 'call', _74 => _74(), 'optionalAccess', _75 => _75.subscribe, 'call', _76 => _76(callback)]);
2001
2097
  callback();
2002
2098
  };
2003
2099
  const outerUnsubscribe = this.binding.subscribe(onRuntimeUpdate);
2004
2100
  return () => {
2005
- _optionalChain([outerUnsubscribe, 'optionalCall', _76 => _76()]);
2006
- _optionalChain([innerUnsubscribe, 'optionalCall', _77 => _77()]);
2101
+ _optionalChain([outerUnsubscribe, 'optionalCall', _77 => _77()]);
2102
+ _optionalChain([innerUnsubscribe, 'optionalCall', _78 => _78()]);
2007
2103
  };
2008
2104
  }
2009
2105
  };
@@ -2069,6 +2165,16 @@ var MessageRuntimeImpl = (_class6 = class {
2069
2165
  if (!state) throw new Error("Message is not available");
2070
2166
  return this._threadBinding.getState().speak(state.id);
2071
2167
  }
2168
+ stopSpeaking() {
2169
+ const state = this._core.getState();
2170
+ if (!state) throw new Error("Message is not available");
2171
+ const thread = this._threadBinding.getState();
2172
+ if (_optionalChain([thread, 'access', _79 => _79.speech, 'optionalAccess', _80 => _80.messageId]) === state.id) {
2173
+ this._threadBinding.getState().stopSpeaking();
2174
+ } else {
2175
+ throw new Error("Message is not being spoken");
2176
+ }
2177
+ }
2072
2178
  submitFeedback({ type }) {
2073
2179
  const state = this._core.getState();
2074
2180
  if (!state) throw new Error("Message is not available");
@@ -2120,7 +2226,7 @@ var MessageRuntimeImpl = (_class6 = class {
2120
2226
  new ShallowMemoizeSubject({
2121
2227
  getState: () => {
2122
2228
  const attachments = this.getState().attachments;
2123
- const attachment = _optionalChain([attachments, 'optionalAccess', _78 => _78[idx]]);
2229
+ const attachment = _optionalChain([attachments, 'optionalAccess', _81 => _81[idx]]);
2124
2230
  if (!attachment) return SKIP_UPDATE;
2125
2231
  return {
2126
2232
  ...attachment,
@@ -2209,7 +2315,7 @@ var MessageContentPartImpl = ({
2209
2315
  };
2210
2316
  var MessageContentPart = _react.memo.call(void 0,
2211
2317
  MessageContentPartImpl,
2212
- (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _79 => _79.components, 'optionalAccess', _80 => _80.Text]) === _optionalChain([next, 'access', _81 => _81.components, 'optionalAccess', _82 => _82.Text]) && _optionalChain([prev, 'access', _83 => _83.components, 'optionalAccess', _84 => _84.Image]) === _optionalChain([next, 'access', _85 => _85.components, 'optionalAccess', _86 => _86.Image]) && _optionalChain([prev, 'access', _87 => _87.components, 'optionalAccess', _88 => _88.UI]) === _optionalChain([next, 'access', _89 => _89.components, 'optionalAccess', _90 => _90.UI]) && _optionalChain([prev, 'access', _91 => _91.components, 'optionalAccess', _92 => _92.tools]) === _optionalChain([next, 'access', _93 => _93.components, 'optionalAccess', _94 => _94.tools])
2318
+ (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _82 => _82.components, 'optionalAccess', _83 => _83.Text]) === _optionalChain([next, 'access', _84 => _84.components, 'optionalAccess', _85 => _85.Text]) && _optionalChain([prev, 'access', _86 => _86.components, 'optionalAccess', _87 => _87.Image]) === _optionalChain([next, 'access', _88 => _88.components, 'optionalAccess', _89 => _89.Image]) && _optionalChain([prev, 'access', _90 => _90.components, 'optionalAccess', _91 => _91.UI]) === _optionalChain([next, 'access', _92 => _92.components, 'optionalAccess', _93 => _93.UI]) && _optionalChain([prev, 'access', _94 => _94.components, 'optionalAccess', _95 => _95.tools]) === _optionalChain([next, 'access', _96 => _96.components, 'optionalAccess', _97 => _97.tools])
2213
2319
  );
2214
2320
  var MessagePrimitiveContent = ({
2215
2321
  components
@@ -2228,62 +2334,6 @@ MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
2228
2334
  // src/primitives/message/MessageAttachments.tsx
2229
2335
 
2230
2336
 
2231
- // src/context/react/AttachmentContext.ts
2232
-
2233
- var AttachmentContext = _react.createContext.call(void 0,
2234
- null
2235
- );
2236
- function useAttachmentContext(options) {
2237
- const context = _react.useContext.call(void 0, AttachmentContext);
2238
- if (!_optionalChain([options, 'optionalAccess', _95 => _95.optional]) && !context)
2239
- throw new Error(
2240
- "This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
2241
- );
2242
- return context;
2243
- }
2244
- function useThreadComposerAttachmentContext(options) {
2245
- const context = useAttachmentContext(options);
2246
- if (!context) return null;
2247
- if (context.source !== "thread-composer")
2248
- throw new Error(
2249
- "This component must be used within a thread's ComposerPrimitive.Attachments component."
2250
- );
2251
- return context;
2252
- }
2253
- function useEditComposerAttachmentContext(options) {
2254
- const context = useAttachmentContext(options);
2255
- if (!context) return null;
2256
- if (context.source !== "edit-composer")
2257
- throw new Error(
2258
- "This component must be used within a messages's ComposerPrimitive.Attachments component."
2259
- );
2260
- return context;
2261
- }
2262
- function useMessageAttachmentContext(options) {
2263
- const context = useAttachmentContext(options);
2264
- if (!context) return null;
2265
- if (context.source !== "message")
2266
- throw new Error(
2267
- "This component must be used within a MessagePrimitive.Attachments component."
2268
- );
2269
- return context;
2270
- }
2271
- function useAttachmentRuntime(options) {
2272
- const attachmentRuntime = useAttachmentContext(options);
2273
- if (!attachmentRuntime) return null;
2274
- return attachmentRuntime.useAttachmentRuntime();
2275
- }
2276
- var { useAttachment } = createContextStoreHook(
2277
- useAttachmentContext,
2278
- "useAttachment"
2279
- );
2280
- var { useAttachment: useThreadComposerAttachment } = createContextStoreHook(useThreadComposerAttachmentContext, "useAttachment");
2281
- var { useAttachment: useEditComposerAttachment } = createContextStoreHook(useEditComposerAttachmentContext, "useAttachment");
2282
- var { useAttachment: useMessageAttachment } = createContextStoreHook(
2283
- useMessageAttachmentContext,
2284
- "useAttachment"
2285
- );
2286
-
2287
2337
  // src/context/providers/AttachmentRuntimeProvider.tsx
2288
2338
 
2289
2339
 
@@ -2331,11 +2381,11 @@ var getComponent = (components, attachment) => {
2331
2381
  const type = attachment.type;
2332
2382
  switch (type) {
2333
2383
  case "image":
2334
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _96 => _96.Image]), () => ( _optionalChain([components, 'optionalAccess', _97 => _97.Attachment])));
2384
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _98 => _98.Image]), () => ( _optionalChain([components, 'optionalAccess', _99 => _99.Attachment])));
2335
2385
  case "document":
2336
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _98 => _98.Document]), () => ( _optionalChain([components, 'optionalAccess', _99 => _99.Attachment])));
2386
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _100 => _100.Document]), () => ( _optionalChain([components, 'optionalAccess', _101 => _101.Attachment])));
2337
2387
  case "file":
2338
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _100 => _100.File]), () => ( _optionalChain([components, 'optionalAccess', _101 => _101.Attachment])));
2388
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _102 => _102.File]), () => ( _optionalChain([components, 'optionalAccess', _103 => _103.Attachment])));
2339
2389
  default:
2340
2390
  const _exhaustiveCheck = type;
2341
2391
  throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
@@ -2358,7 +2408,7 @@ var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
2358
2408
  };
2359
2409
  var MessageAttachment = _react.memo.call(void 0,
2360
2410
  MessageAttachmentImpl,
2361
- (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])
2411
+ (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _104 => _104.components, 'optionalAccess', _105 => _105.Image]) === _optionalChain([next, 'access', _106 => _106.components, 'optionalAccess', _107 => _107.Image]) && _optionalChain([prev, 'access', _108 => _108.components, 'optionalAccess', _109 => _109.Document]) === _optionalChain([next, 'access', _110 => _110.components, 'optionalAccess', _111 => _111.Document]) && _optionalChain([prev, 'access', _112 => _112.components, 'optionalAccess', _113 => _113.File]) === _optionalChain([next, 'access', _114 => _114.components, 'optionalAccess', _115 => _115.File]) && _optionalChain([prev, 'access', _116 => _116.components, 'optionalAccess', _117 => _117.Attachment]) === _optionalChain([next, 'access', _118 => _118.components, 'optionalAccess', _119 => _119.Attachment])
2362
2412
  );
2363
2413
  var MessagePrimitiveAttachments = ({ components }) => {
2364
2414
  const attachmentsCount = useMessage(({ message }) => {
@@ -2469,7 +2519,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
2469
2519
  const { isRunning } = threadStore.getState();
2470
2520
  if (!isRunning) {
2471
2521
  e.preventDefault();
2472
- _optionalChain([textareaRef, 'access', _118 => _118.current, 'optionalAccess', _119 => _119.closest, 'call', _120 => _120("form"), 'optionalAccess', _121 => _121.requestSubmit, 'call', _122 => _122()]);
2522
+ _optionalChain([textareaRef, 'access', _120 => _120.current, 'optionalAccess', _121 => _121.closest, 'call', _122 => _122("form"), 'optionalAccess', _123 => _123.requestSubmit, 'call', _124 => _124()]);
2473
2523
  }
2474
2524
  }
2475
2525
  };
@@ -2534,11 +2584,11 @@ var getComponent2 = (components, attachment) => {
2534
2584
  const type = attachment.type;
2535
2585
  switch (type) {
2536
2586
  case "image":
2537
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _123 => _123.Image]), () => ( _optionalChain([components, 'optionalAccess', _124 => _124.Attachment])));
2587
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _125 => _125.Image]), () => ( _optionalChain([components, 'optionalAccess', _126 => _126.Attachment])));
2538
2588
  case "document":
2539
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _125 => _125.Document]), () => ( _optionalChain([components, 'optionalAccess', _126 => _126.Attachment])));
2589
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _127 => _127.Document]), () => ( _optionalChain([components, 'optionalAccess', _128 => _128.Attachment])));
2540
2590
  case "file":
2541
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _127 => _127.File]), () => ( _optionalChain([components, 'optionalAccess', _128 => _128.Attachment])));
2591
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _129 => _129.File]), () => ( _optionalChain([components, 'optionalAccess', _130 => _130.Attachment])));
2542
2592
  default:
2543
2593
  const _exhaustiveCheck = type;
2544
2594
  throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
@@ -2561,7 +2611,7 @@ var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
2561
2611
  };
2562
2612
  var ComposerAttachment = _react.memo.call(void 0,
2563
2613
  ComposerAttachmentImpl,
2564
- (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])
2614
+ (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _131 => _131.components, 'optionalAccess', _132 => _132.Image]) === _optionalChain([next, 'access', _133 => _133.components, 'optionalAccess', _134 => _134.Image]) && _optionalChain([prev, 'access', _135 => _135.components, 'optionalAccess', _136 => _136.Document]) === _optionalChain([next, 'access', _137 => _137.components, 'optionalAccess', _138 => _138.Document]) && _optionalChain([prev, 'access', _139 => _139.components, 'optionalAccess', _140 => _140.File]) === _optionalChain([next, 'access', _141 => _141.components, 'optionalAccess', _142 => _142.File]) && _optionalChain([prev, 'access', _143 => _143.components, 'optionalAccess', _144 => _144.Attachment]) === _optionalChain([next, 'access', _145 => _145.components, 'optionalAccess', _146 => _146.Attachment])
2565
2615
  );
2566
2616
  var ComposerPrimitiveAttachments = ({ components }) => {
2567
2617
  const attachmentsCount = useComposer((s) => s.attachments.length);
@@ -2769,7 +2819,6 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
2769
2819
  // src/context/stores/MessageUtils.ts
2770
2820
 
2771
2821
  var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
2772
- let utterance = null;
2773
2822
  return {
2774
2823
  isCopied: false,
2775
2824
  setIsCopied: (value) => {
@@ -2779,17 +2828,6 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
2779
2828
  setIsHovering: (value) => {
2780
2829
  set({ isHovering: value });
2781
2830
  },
2782
- isSpeaking: false,
2783
- stopSpeaking: () => {
2784
- _optionalChain([utterance, 'optionalAccess', _145 => _145.cancel, 'call', _146 => _146()]);
2785
- },
2786
- addUtterance: (utt) => {
2787
- utterance = utt;
2788
- set({ isSpeaking: true });
2789
- utt.onEnd(() => {
2790
- set({ isSpeaking: false });
2791
- });
2792
- },
2793
2831
  submittedFeedback: null,
2794
2832
  setSubmittedFeedback: (feedback) => {
2795
2833
  set({ submittedFeedback: feedback });
@@ -3523,7 +3561,8 @@ var getThreadState = (runtime) => {
3523
3561
  isRunning: _optionalChain([lastMessage, 'optionalAccess', _178 => _178.role]) !== "assistant" ? false : lastMessage.status.type === "running",
3524
3562
  messages: runtime.messages,
3525
3563
  suggestions: runtime.suggestions,
3526
- extras: runtime.extras
3564
+ extras: runtime.extras,
3565
+ speech: runtime.speech
3527
3566
  });
3528
3567
  };
3529
3568
  var ThreadRuntimeImpl = (_class12 = class {
@@ -3570,6 +3609,12 @@ var ThreadRuntimeImpl = (_class12 = class {
3570
3609
  get messages() {
3571
3610
  return this._threadBinding.getState().messages;
3572
3611
  }
3612
+ /**
3613
+ * @deprecated Use `getState().speechState` instead. This will be removed in 0.6.0.
3614
+ */
3615
+ get speech() {
3616
+ return this._threadBinding.getState().speech;
3617
+ }
3573
3618
  unstable_getCore() {
3574
3619
  return this._threadBinding.getState();
3575
3620
  }
@@ -3630,15 +3675,18 @@ var ThreadRuntimeImpl = (_class12 = class {
3630
3675
  switchToBranch(branchId) {
3631
3676
  return this._threadBinding.getState().switchToBranch(branchId);
3632
3677
  }
3633
- // /**
3634
- // * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
3635
- // */
3678
+ /**
3679
+ * @deprecated Use `getMesssageById(id).speak()` instead. This will be removed in 0.6.0.
3680
+ */
3636
3681
  speak(messageId) {
3637
3682
  return this._threadBinding.getState().speak(messageId);
3638
3683
  }
3639
- // /**
3640
- // * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
3641
- // */
3684
+ stopSpeaking() {
3685
+ return this._threadBinding.getState().stopSpeaking();
3686
+ }
3687
+ /**
3688
+ * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
3689
+ */
3642
3690
  submitFeedback(options) {
3643
3691
  return this._threadBinding.getState().submitFeedback(options);
3644
3692
  }
@@ -3665,7 +3713,7 @@ var ThreadRuntimeImpl = (_class12 = class {
3665
3713
  return new MessageRuntimeImpl(
3666
3714
  new ShallowMemoizeSubject({
3667
3715
  getState: () => {
3668
- const messages2 = this.getState().messages;
3716
+ const { messages: messages2, speech: speechState } = this.getState();
3669
3717
  const message = messages2[idx];
3670
3718
  if (!message) return SKIP_UPDATE;
3671
3719
  const branches = this._threadBinding.getState().getBranches(message.id);
@@ -3676,7 +3724,8 @@ var ThreadRuntimeImpl = (_class12 = class {
3676
3724
  parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _179 => _179[idx - 1], 'optionalAccess', _180 => _180.id]), () => ( null)),
3677
3725
  branches,
3678
3726
  branchNumber: branches.indexOf(message.id) + 1,
3679
- branchCount: branches.length
3727
+ branchCount: branches.length,
3728
+ speech: _optionalChain([speechState, 'optionalAccess', _181 => _181.messageId]) === message.id ? speechState : null
3680
3729
  };
3681
3730
  },
3682
3731
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -3752,7 +3801,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
3752
3801
  });
3753
3802
  if (mergeSteps) {
3754
3803
  const previousMessage = messages2[messages2.length - 1];
3755
- if (_optionalChain([previousMessage, 'optionalAccess', _181 => _181.role]) === "assistant") {
3804
+ if (_optionalChain([previousMessage, 'optionalAccess', _182 => _182.role]) === "assistant") {
3756
3805
  previousMessage.content.push(...newContent);
3757
3806
  break;
3758
3807
  }
@@ -3765,7 +3814,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
3765
3814
  }
3766
3815
  case "tool": {
3767
3816
  const previousMessage = messages2[messages2.length - 1];
3768
- if (_optionalChain([previousMessage, 'optionalAccess', _182 => _182.role]) !== "assistant")
3817
+ if (_optionalChain([previousMessage, 'optionalAccess', _183 => _183.role]) !== "assistant")
3769
3818
  throw new Error(
3770
3819
  "A tool message must be preceded by an assistant message."
3771
3820
  );
@@ -3887,7 +3936,7 @@ function assistantDecoderStream() {
3887
3936
  }
3888
3937
  case "c" /* ToolCallDelta */: {
3889
3938
  const { toolCallId, argsTextDelta } = value;
3890
- if (_optionalChain([currentToolCall, 'optionalAccess', _183 => _183.id]) !== toolCallId) {
3939
+ if (_optionalChain([currentToolCall, 'optionalAccess', _184 => _184.id]) !== toolCallId) {
3891
3940
  throw new Error(
3892
3941
  `Received tool call delta for unknown tool call "${toolCallId}".`
3893
3942
  );
@@ -4034,7 +4083,7 @@ var useEdgeRuntime = (options) => {
4034
4083
  };
4035
4084
 
4036
4085
  // src/runtimes/local/shouldContinue.tsx
4037
- 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);
4086
+ var shouldContinue = (result) => _optionalChain([result, 'access', _185 => _185.status, 'optionalAccess', _186 => _186.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
4038
4087
 
4039
4088
  // src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
4040
4089
  var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
@@ -4075,7 +4124,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
4075
4124
 
4076
4125
  // src/runtimes/local/LocalThreadRuntimeCore.tsx
4077
4126
  var LocalThreadRuntimeCore = (_class13 = class {
4078
- 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);
4127
+ 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);_class13.prototype.__init32.call(this);
4079
4128
  this.configProvider = configProvider;
4080
4129
  this.adapter = adapter;
4081
4130
  this.threadId = generateId();
@@ -4122,18 +4171,18 @@ var LocalThreadRuntimeCore = (_class13 = class {
4122
4171
  set options({ initialMessages, ...options }) {
4123
4172
  this._options = options;
4124
4173
  let hasUpdates = false;
4125
- const canSpeak = _optionalChain([options, 'access', _186 => _186.adapters, 'optionalAccess', _187 => _187.speech]) !== void 0;
4174
+ const canSpeak = _optionalChain([options, 'access', _187 => _187.adapters, 'optionalAccess', _188 => _188.speech]) !== void 0;
4126
4175
  if (this.capabilities.speak !== canSpeak) {
4127
4176
  this.capabilities.speak = canSpeak;
4128
4177
  hasUpdates = true;
4129
4178
  }
4130
- this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _188 => _188.adapters, 'optionalAccess', _189 => _189.attachments]));
4131
- const canAttach = _optionalChain([options, 'access', _190 => _190.adapters, 'optionalAccess', _191 => _191.attachments]) !== void 0;
4179
+ this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _189 => _189.adapters, 'optionalAccess', _190 => _190.attachments]));
4180
+ const canAttach = _optionalChain([options, 'access', _191 => _191.adapters, 'optionalAccess', _192 => _192.attachments]) !== void 0;
4132
4181
  if (this.capabilities.attachments !== canAttach) {
4133
4182
  this.capabilities.attachments = canAttach;
4134
4183
  hasUpdates = true;
4135
4184
  }
4136
- const canFeedback = _optionalChain([options, 'access', _192 => _192.adapters, 'optionalAccess', _193 => _193.feedback]) !== void 0;
4185
+ const canFeedback = _optionalChain([options, 'access', _193 => _193.adapters, 'optionalAccess', _194 => _194.feedback]) !== void 0;
4137
4186
  if (this.capabilities.feedback !== canFeedback) {
4138
4187
  this.capabilities.feedback = canFeedback;
4139
4188
  hasUpdates = true;
@@ -4192,13 +4241,13 @@ var LocalThreadRuntimeCore = (_class13 = class {
4192
4241
  }
4193
4242
  async performRoundtrip(parentId, message) {
4194
4243
  const messages2 = this.repository.getMessages();
4195
- _optionalChain([this, 'access', _194 => _194.abortController, 'optionalAccess', _195 => _195.abort, 'call', _196 => _196()]);
4244
+ _optionalChain([this, 'access', _195 => _195.abortController, 'optionalAccess', _196 => _196.abort, 'call', _197 => _197()]);
4196
4245
  this.abortController = new AbortController();
4197
4246
  const initialContent = message.content;
4198
- const initialSteps = _optionalChain([message, 'access', _197 => _197.metadata, 'optionalAccess', _198 => _198.steps]);
4199
- const initalCustom = _optionalChain([message, 'access', _199 => _199.metadata, 'optionalAccess', _200 => _200.custom]);
4247
+ const initialSteps = _optionalChain([message, 'access', _198 => _198.metadata, 'optionalAccess', _199 => _199.steps]);
4248
+ const initalCustom = _optionalChain([message, 'access', _200 => _200.metadata, 'optionalAccess', _201 => _201.custom]);
4200
4249
  const updateMessage = (m) => {
4201
- const newSteps = _optionalChain([m, 'access', _201 => _201.metadata, 'optionalAccess', _202 => _202.steps]) || _optionalChain([m, 'access', _203 => _203.metadata, 'optionalAccess', _204 => _204.roundtrips]);
4250
+ const newSteps = _optionalChain([m, 'access', _202 => _202.metadata, 'optionalAccess', _203 => _203.steps]) || _optionalChain([m, 'access', _204 => _204.metadata, 'optionalAccess', _205 => _205.roundtrips]);
4202
4251
  const steps2 = newSteps ? [..._nullishCoalesce(initialSteps, () => ( [])), ...newSteps] : void 0;
4203
4252
  message = {
4204
4253
  ...message,
@@ -4210,7 +4259,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
4210
4259
  metadata: {
4211
4260
  ...message.metadata,
4212
4261
  ...steps2 ? { roundtrips: steps2, steps: steps2 } : void 0,
4213
- ..._optionalChain([m, 'access', _205 => _205.metadata, 'optionalAccess', _206 => _206.custom]) ? {
4262
+ ..._optionalChain([m, 'access', _206 => _206.metadata, 'optionalAccess', _207 => _207.custom]) ? {
4214
4263
  custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
4215
4264
  } : void 0
4216
4265
  }
@@ -4220,7 +4269,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
4220
4269
  this.notifySubscribers();
4221
4270
  };
4222
4271
  const maxSteps = this.options.maxSteps ? this.options.maxSteps : (_nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1))) + 1;
4223
- const steps = _nullishCoalesce(_optionalChain([message, 'access', _207 => _207.metadata, 'optionalAccess', _208 => _208.steps, 'optionalAccess', _209 => _209.length]), () => ( 0));
4272
+ const steps = _nullishCoalesce(_optionalChain([message, 'access', _208 => _208.metadata, 'optionalAccess', _209 => _209.steps, 'optionalAccess', _210 => _210.length]), () => ( 0));
4224
4273
  if (steps >= maxSteps) {
4225
4274
  updateMessage({
4226
4275
  status: {
@@ -4316,27 +4365,38 @@ var LocalThreadRuntimeCore = (_class13 = class {
4316
4365
  this.performRoundtrip(parentId, message);
4317
4366
  }
4318
4367
  }
4319
- // TODO lift utterance state to thread runtime
4368
+ // TODO speech runtime?
4320
4369
 
4370
+ __init32() {this.speech = null}
4321
4371
  speak(messageId) {
4322
- const adapter = _optionalChain([this, 'access', _210 => _210.options, 'access', _211 => _211.adapters, 'optionalAccess', _212 => _212.speech]);
4372
+ const adapter = _optionalChain([this, 'access', _211 => _211.options, 'access', _212 => _212.adapters, 'optionalAccess', _213 => _213.speech]);
4323
4373
  if (!adapter) throw new Error("Speech adapter not configured");
4324
4374
  const { message } = this.repository.getMessage(messageId);
4325
- if (this._utterance) {
4326
- this._utterance.cancel();
4327
- this._utterance = void 0;
4328
- }
4375
+ _optionalChain([this, 'access', _214 => _214._stopSpeaking, 'optionalCall', _215 => _215()]);
4329
4376
  const utterance = adapter.speak(message);
4330
- utterance.onEnd(() => {
4331
- if (this._utterance === utterance) {
4332
- this._utterance = void 0;
4377
+ const unsub = utterance.subscribe(() => {
4378
+ if (utterance.status.type === "ended") {
4379
+ this._stopSpeaking = void 0;
4380
+ this.speech = null;
4381
+ } else {
4382
+ this.speech = { messageId, status: utterance.status };
4333
4383
  }
4384
+ this.notifySubscribers();
4334
4385
  });
4335
- this._utterance = utterance;
4336
- return this._utterance;
4386
+ this.speech = { messageId, status: utterance.status };
4387
+ this._stopSpeaking = () => {
4388
+ utterance.cancel();
4389
+ unsub();
4390
+ this.speech = null;
4391
+ this._stopSpeaking = void 0;
4392
+ };
4393
+ }
4394
+ stopSpeaking() {
4395
+ if (!this._stopSpeaking) throw new Error("No message is being spoken");
4396
+ this._stopSpeaking();
4337
4397
  }
4338
4398
  submitFeedback({ messageId, type }) {
4339
- const adapter = _optionalChain([this, 'access', _213 => _213.options, 'access', _214 => _214.adapters, 'optionalAccess', _215 => _215.feedback]);
4399
+ const adapter = _optionalChain([this, 'access', _216 => _216.options, 'access', _217 => _217.adapters, 'optionalAccess', _218 => _218.feedback]);
4340
4400
  if (!adapter) throw new Error("Feedback adapter not configured");
4341
4401
  const { message } = this.repository.getMessage(messageId);
4342
4402
  adapter.submit({ message, type });
@@ -4383,7 +4443,7 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4383
4443
  const messages2 = fromCoreMessages(initialMessages);
4384
4444
  this.thread.import({
4385
4445
  messages: messages2.map((m, idx) => ({
4386
- parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _216 => _216[idx - 1], 'optionalAccess', _217 => _217.id]), () => ( null)),
4446
+ parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _219 => _219[idx - 1], 'optionalAccess', _220 => _220.id]), () => ( null)),
4387
4447
  message: m
4388
4448
  }))
4389
4449
  });
@@ -4419,8 +4479,8 @@ var getExternalStoreMessage = (message) => {
4419
4479
  };
4420
4480
 
4421
4481
  // src/runtimes/external-store/ThreadMessageConverter.ts
4422
- var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.__init32.call(this); }
4423
- __init32() {this.cache = /* @__PURE__ */ new WeakMap()}
4482
+ var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.__init33.call(this); }
4483
+ __init33() {this.cache = /* @__PURE__ */ new WeakMap()}
4424
4484
  convertMessages(messages2, converter) {
4425
4485
  return messages2.map((m, idx) => {
4426
4486
  const cached = this.cache.get(m);
@@ -4517,17 +4577,17 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
4517
4577
  // src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
4518
4578
  var EMPTY_ARRAY2 = Object.freeze([]);
4519
4579
  var hasUpcomingMessage = (isRunning, messages2) => {
4520
- return isRunning && _optionalChain([messages2, 'access', _218 => _218[messages2.length - 1], 'optionalAccess', _219 => _219.role]) !== "assistant";
4580
+ return isRunning && _optionalChain([messages2, 'access', _221 => _221[messages2.length - 1], 'optionalAccess', _222 => _222.role]) !== "assistant";
4521
4581
  };
4522
4582
  var ExternalStoreThreadRuntimeCore = (_class15 = class {
4523
- 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);
4583
+ constructor(configProvider, store) {;_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);_class15.prototype.__init43.call(this);_class15.prototype.__init44.call(this);
4524
4584
  this.configProvider = configProvider;
4525
4585
  this.store = store;
4526
4586
  }
4527
- __init33() {this._subscriptions = /* @__PURE__ */ new Set()}
4528
- __init34() {this.repository = new MessageRepository()}
4529
- __init35() {this.assistantOptimisticId = null}
4530
- __init36() {this._capabilities = {
4587
+ __init34() {this._subscriptions = /* @__PURE__ */ new Set()}
4588
+ __init35() {this.repository = new MessageRepository()}
4589
+ __init36() {this.assistantOptimisticId = null}
4590
+ __init37() {this._capabilities = {
4531
4591
  switchToBranch: false,
4532
4592
  edit: false,
4533
4593
  reload: false,
@@ -4543,12 +4603,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4543
4603
 
4544
4604
 
4545
4605
 
4546
- __init37() {this.suggestions = []}
4547
- __init38() {this.extras = void 0}
4548
- __init39() {this._converter = new ThreadMessageConverter()}
4606
+ __init38() {this.suggestions = []}
4607
+ __init39() {this.extras = void 0}
4608
+ __init40() {this._converter = new ThreadMessageConverter()}
4549
4609
 
4550
- __init40() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4551
- __init41() {this._editComposers = /* @__PURE__ */ new Map()}
4610
+ __init41() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4611
+ __init42() {this._editComposers = /* @__PURE__ */ new Map()}
4552
4612
  getEditComposer(messageId) {
4553
4613
  return this._editComposers.get(messageId);
4554
4614
  }
@@ -4583,12 +4643,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4583
4643
  reload: this._store.onReload !== void 0,
4584
4644
  cancel: this._store.onCancel !== void 0,
4585
4645
  speak: this._store.onSpeak !== void 0,
4586
- unstable_copy: _optionalChain([this, 'access', _223 => _223._store, 'access', _224 => _224.unstable_capabilities, 'optionalAccess', _225 => _225.copy]) !== false,
4646
+ unstable_copy: _optionalChain([this, 'access', _226 => _226._store, 'access', _227 => _227.unstable_capabilities, 'optionalAccess', _228 => _228.copy]) !== false,
4587
4647
  // default true
4588
- attachments: !!_optionalChain([this, 'access', _226 => _226.store, 'access', _227 => _227.adapters, 'optionalAccess', _228 => _228.attachments]),
4589
- feedback: !!_optionalChain([this, 'access', _229 => _229.store, 'access', _230 => _230.adapters, 'optionalAccess', _231 => _231.feedback])
4648
+ attachments: !!_optionalChain([this, 'access', _229 => _229.store, 'access', _230 => _230.adapters, 'optionalAccess', _231 => _231.attachments]),
4649
+ feedback: !!_optionalChain([this, 'access', _232 => _232.store, 'access', _233 => _233.adapters, 'optionalAccess', _234 => _234.feedback])
4590
4650
  };
4591
- this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _232 => _232._store, 'access', _233 => _233.adapters, 'optionalAccess', _234 => _234.attachments]));
4651
+ this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _235 => _235._store, 'access', _236 => _236.adapters, 'optionalAccess', _237 => _237.attachments]));
4592
4652
  if (oldStore) {
4593
4653
  if (oldStore.convertMessage !== store.convertMessage) {
4594
4654
  this._converter = new ThreadMessageConverter();
@@ -4614,7 +4674,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4614
4674
  for (let i = 0; i < messages2.length; i++) {
4615
4675
  const message = messages2[i];
4616
4676
  const parent = messages2[i - 1];
4617
- this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _235 => _235.id]), () => ( null)), message);
4677
+ this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _238 => _238.id]), () => ( null)), message);
4618
4678
  }
4619
4679
  if (this.assistantOptimisticId) {
4620
4680
  this.repository.deleteMessage(this.assistantOptimisticId);
@@ -4622,7 +4682,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4622
4682
  }
4623
4683
  if (hasUpcomingMessage(isRunning, messages2)) {
4624
4684
  this.assistantOptimisticId = this.repository.appendOptimisticMessage(
4625
- _nullishCoalesce(_optionalChain([messages2, 'access', _236 => _236.at, 'call', _237 => _237(-1), 'optionalAccess', _238 => _238.id]), () => ( null)),
4685
+ _nullishCoalesce(_optionalChain([messages2, 'access', _239 => _239.at, 'call', _240 => _240(-1), 'optionalAccess', _241 => _241.id]), () => ( null)),
4626
4686
  {
4627
4687
  role: "assistant",
4628
4688
  content: []
@@ -4630,7 +4690,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4630
4690
  );
4631
4691
  }
4632
4692
  this.repository.resetHead(
4633
- _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _239 => _239.at, 'call', _240 => _240(-1), 'optionalAccess', _241 => _241.id]))), () => ( null))
4693
+ _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _242 => _242.at, 'call', _243 => _243(-1), 'optionalAccess', _244 => _244.id]))), () => ( null))
4634
4694
  );
4635
4695
  this.messages = this.repository.getMessages();
4636
4696
  this.notifySubscribers();
@@ -4651,7 +4711,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4651
4711
  this.updateMessages(this.repository.getMessages());
4652
4712
  }
4653
4713
  async append(message) {
4654
- if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _242 => _242.messages, 'access', _243 => _243.at, 'call', _244 => _244(-1), 'optionalAccess', _245 => _245.id]), () => ( null)))) {
4714
+ if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _245 => _245.messages, 'access', _246 => _246.at, 'call', _247 => _247(-1), 'optionalAccess', _248 => _248.id]), () => ( null)))) {
4655
4715
  if (!this._store.onEdit)
4656
4716
  throw new Error("Runtime does not support editing messages.");
4657
4717
  await this._store.onEdit(message);
@@ -4674,7 +4734,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4674
4734
  }
4675
4735
  let messages2 = this.repository.getMessages();
4676
4736
  const previousMessage = messages2[messages2.length - 1];
4677
- if (_optionalChain([previousMessage, 'optionalAccess', _246 => _246.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _247 => _247.at, 'call', _248 => _248(-1), 'optionalAccess', _249 => _249.id])) {
4737
+ if (_optionalChain([previousMessage, 'optionalAccess', _249 => _249.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _250 => _250.at, 'call', _251 => _251(-1), 'optionalAccess', _252 => _252.id])) {
4678
4738
  this.repository.deleteMessage(previousMessage.id);
4679
4739
  if (!this.composer.text.trim()) {
4680
4740
  this.composer.setText(getThreadMessageText(previousMessage));
@@ -4692,14 +4752,41 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4692
4752
  throw new Error("Runtime does not support tool results.");
4693
4753
  this._store.onAddToolResult(options);
4694
4754
  }
4755
+ // TODO speech runtime?
4756
+
4757
+ __init43() {this.speech = null}
4695
4758
  speak(messageId) {
4696
- if (!this._store.onSpeak)
4697
- throw new Error("Runtime does not support speaking.");
4759
+ let adapter = _optionalChain([this, 'access', _253 => _253.store, 'access', _254 => _254.adapters, 'optionalAccess', _255 => _255.speech]);
4760
+ if (!adapter && this.store.onSpeak) {
4761
+ adapter = { speak: this.store.onSpeak };
4762
+ }
4763
+ if (!adapter) throw new Error("Speech adapter not configured");
4698
4764
  const { message } = this.repository.getMessage(messageId);
4699
- return this._store.onSpeak(message);
4765
+ _optionalChain([this, 'access', _256 => _256._stopSpeaking, 'optionalCall', _257 => _257()]);
4766
+ const utterance = adapter.speak(message);
4767
+ const unsub = utterance.subscribe(() => {
4768
+ if (utterance.status.type === "ended") {
4769
+ this._stopSpeaking = void 0;
4770
+ this.speech = null;
4771
+ } else {
4772
+ this.speech = { messageId, status: utterance.status };
4773
+ }
4774
+ this.notifySubscribers();
4775
+ });
4776
+ this.speech = { messageId, status: utterance.status };
4777
+ this._stopSpeaking = () => {
4778
+ utterance.cancel();
4779
+ unsub();
4780
+ this.speech = null;
4781
+ this._stopSpeaking = void 0;
4782
+ };
4783
+ }
4784
+ stopSpeaking() {
4785
+ if (!this._stopSpeaking) throw new Error("No message is being spoken");
4786
+ this._stopSpeaking();
4700
4787
  }
4701
4788
  submitFeedback({ messageId, type }) {
4702
- const adapter = _optionalChain([this, 'access', _250 => _250._store, 'access', _251 => _251.adapters, 'optionalAccess', _252 => _252.feedback]);
4789
+ const adapter = _optionalChain([this, 'access', _258 => _258._store, 'access', _259 => _259.adapters, 'optionalAccess', _260 => _260.feedback]);
4703
4790
  if (!adapter) throw new Error("Feedback adapter not configured");
4704
4791
  const { message } = this.repository.getMessage(messageId);
4705
4792
  adapter.submit({ message, type });
@@ -4708,8 +4795,8 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4708
4795
  this._subscriptions.add(callback);
4709
4796
  return () => this._subscriptions.delete(callback);
4710
4797
  }
4711
- __init42() {this.updateMessages = (messages2) => {
4712
- _optionalChain([this, 'access', _253 => _253._store, 'access', _254 => _254.setMessages, 'optionalCall', _255 => _255(
4798
+ __init44() {this.updateMessages = (messages2) => {
4799
+ _optionalChain([this, 'access', _261 => _261._store, 'access', _262 => _262.setMessages, 'optionalCall', _263 => _263(
4713
4800
  messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
4714
4801
  )]);
4715
4802
  }}
@@ -4963,11 +5050,11 @@ var WebSpeechSynthesisAdapter = class {
4963
5050
  speak(message) {
4964
5051
  const text = getThreadMessageText(message);
4965
5052
  const utterance = new SpeechSynthesisUtterance(text);
4966
- const endHandlers = /* @__PURE__ */ new Set();
5053
+ const subscribers = /* @__PURE__ */ new Set();
4967
5054
  const handleEnd = (reason, error) => {
4968
5055
  if (res.status.type === "ended") return;
4969
5056
  res.status = { type: "ended", reason, error };
4970
- endHandlers.forEach((handler) => handler());
5057
+ subscribers.forEach((handler) => handler());
4971
5058
  };
4972
5059
  utterance.addEventListener("end", () => handleEnd("finished"));
4973
5060
  utterance.addEventListener("error", (e) => handleEnd("error", e.error));
@@ -4978,7 +5065,7 @@ var WebSpeechSynthesisAdapter = class {
4978
5065
  window.speechSynthesis.cancel();
4979
5066
  handleEnd("cancelled");
4980
5067
  },
4981
- onEnd: (callback) => {
5068
+ subscribe: (callback) => {
4982
5069
  if (res.status.type === "ended") {
4983
5070
  let cancelled = false;
4984
5071
  queueMicrotask(() => {
@@ -4988,9 +5075,9 @@ var WebSpeechSynthesisAdapter = class {
4988
5075
  cancelled = true;
4989
5076
  };
4990
5077
  } else {
4991
- endHandlers.add(callback);
5078
+ subscribers.add(callback);
4992
5079
  return () => {
4993
- endHandlers.delete(callback);
5080
+ subscribers.delete(callback);
4994
5081
  };
4995
5082
  }
4996
5083
  }
@@ -5000,8 +5087,8 @@ var WebSpeechSynthesisAdapter = class {
5000
5087
  };
5001
5088
 
5002
5089
  // src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
5003
- var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init43.call(this); }
5004
- __init43() {this.accept = "image/*"}
5090
+ var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init45.call(this); }
5091
+ __init45() {this.accept = "image/*"}
5005
5092
  async add(state) {
5006
5093
  return {
5007
5094
  id: state.file.name,
@@ -5035,8 +5122,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
5035
5122
  });
5036
5123
 
5037
5124
  // src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
5038
- var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init44.call(this); }
5039
- __init44() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
5125
+ var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init46.call(this); }
5126
+ __init46() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
5040
5127
  async add(state) {
5041
5128
  return {
5042
5129
  id: state.file.name,
@@ -5164,7 +5251,7 @@ var ThreadConfigProvider = ({
5164
5251
  }) => {
5165
5252
  const hasAssistant = !!useAssistantRuntime({ optional: true });
5166
5253
  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 });
5167
- if (!_optionalChain([config, 'optionalAccess', _256 => _256.runtime])) return configProvider;
5254
+ if (!_optionalChain([config, 'optionalAccess', _264 => _264.runtime])) return configProvider;
5168
5255
  if (hasAssistant) {
5169
5256
  throw new Error(
5170
5257
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
@@ -5240,13 +5327,13 @@ var AssistantActionBarRoot = withDefaults(actionBar_exports.Root, {
5240
5327
  className: "aui-assistant-action-bar-root"
5241
5328
  });
5242
5329
  AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
5243
- var AssistantActionBarCopy = _react.forwardRef.call(void 0, (props, ref) => {
5330
+ var AssistantActionBarCopy = _react.forwardRef.call(void 0, ({ copiedDuration, ...props }, ref) => {
5244
5331
  const {
5245
5332
  strings: {
5246
5333
  assistantMessage: { copy: { tooltip = "Copy" } = {} } = {}
5247
5334
  } = {}
5248
5335
  } = useThreadConfig();
5249
- 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: [
5336
+ 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: [
5250
5337
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { copied: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CheckIcon, {}) }),
5251
5338
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { copied: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CopyIcon, {}) })
5252
5339
  ] }))) }) });
@@ -5361,7 +5448,7 @@ var BranchPicker = () => {
5361
5448
  const allowBranchPicker = useAllowBranchPicker(true);
5362
5449
  if (!allowBranchPicker) return null;
5363
5450
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, BranchPickerRoot, { hideWhenSingleBranch: true, children: [
5364
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerPrevious2, {}),
5451
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerPrevious, {}),
5365
5452
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerState, {}),
5366
5453
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerNext, {})
5367
5454
  ] });
@@ -5371,7 +5458,7 @@ var BranchPickerRoot = withDefaults(branchPicker_exports.Root, {
5371
5458
  className: "aui-branch-picker-root"
5372
5459
  });
5373
5460
  BranchPickerRoot.displayName = "BranchPickerRoot";
5374
- var BranchPickerPrevious2 = _react.forwardRef.call(void 0, (props, ref) => {
5461
+ var BranchPickerPrevious = _react.forwardRef.call(void 0, (props, ref) => {
5375
5462
  const {
5376
5463
  strings: {
5377
5464
  branchPicker: { previous: { tooltip = "Previous" } = {} } = {}
@@ -5380,7 +5467,7 @@ var BranchPickerPrevious2 = _react.forwardRef.call(void 0, (props, ref) => {
5380
5467
  const allowBranchPicker = useAllowBranchPicker();
5381
5468
  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, {}))) }) });
5382
5469
  });
5383
- BranchPickerPrevious2.displayName = "BranchPickerPrevious";
5470
+ BranchPickerPrevious.displayName = "BranchPickerPrevious";
5384
5471
  var BranchPickerStateWrapper = withDefaults("span", {
5385
5472
  className: "aui-branch-picker-state"
5386
5473
  });
@@ -5402,7 +5489,7 @@ var BranchPickerNext = _react.forwardRef.call(void 0, (props, ref) => {
5402
5489
  BranchPickerNext.displayName = "BranchPickerNext";
5403
5490
  var exports2 = {
5404
5491
  Root: BranchPickerRoot,
5405
- Previous: BranchPickerPrevious2,
5492
+ Previous: BranchPickerPrevious,
5406
5493
  Next: BranchPickerNext
5407
5494
  };
5408
5495
  var branch_picker_default = Object.assign(BranchPicker, exports2);
@@ -5492,7 +5579,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
5492
5579
  {
5493
5580
  components: {
5494
5581
  ...componentsProp,
5495
- Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _257 => _257.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
5582
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _265 => _265.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
5496
5583
  tools: toolsComponents
5497
5584
  }
5498
5585
  }
@@ -5542,15 +5629,13 @@ CircleStopIcon.displayName = "CircleStopIcon";
5542
5629
 
5543
5630
 
5544
5631
 
5545
- var ComposerAttachmentRoot = withDefaults("div", {
5632
+ var ComposerAttachmentRoot = withDefaults(attachment_exports.Root, {
5546
5633
  className: "aui-composer-attachment-root"
5547
5634
  });
5548
5635
  ComposerAttachmentRoot.displayName = "ComposerAttachmentRoot";
5549
5636
  var ComposerAttachment2 = () => {
5550
- const attachment = useThreadComposerAttachment((a) => a.attachment);
5551
5637
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerAttachmentRoot, { children: [
5552
- ".",
5553
- attachment.name.split(".").pop(),
5638
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, {}),
5554
5639
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAttachmentRemove, {})
5555
5640
  ] });
5556
5641
  };
@@ -5561,22 +5646,17 @@ var ComposerAttachmentRemove = _react.forwardRef.call(void 0, (props, ref) => {
5561
5646
  composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
5562
5647
  } = {}
5563
5648
  } = useThreadConfig();
5564
- const attachmentRuntime = useAttachmentRuntime();
5565
- const handleRemoveAttachment = () => {
5566
- attachmentRuntime.remove();
5567
- };
5568
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5649
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.Remove, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5569
5650
  TooltipIconButton,
5570
5651
  {
5571
5652
  tooltip,
5572
5653
  className: "aui-composer-attachment-remove",
5573
5654
  side: "top",
5574
5655
  ...props,
5575
- onClick: handleRemoveAttachment,
5576
5656
  ref,
5577
5657
  children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CircleXIcon, {})))
5578
5658
  }
5579
- );
5659
+ ) });
5580
5660
  });
5581
5661
  ComposerAttachmentRemove.displayName = "ComposerAttachmentRemove";
5582
5662
  var exports5 = {
@@ -5634,7 +5714,7 @@ var ComposerAttachments = ({ components }) => {
5634
5714
  {
5635
5715
  components: {
5636
5716
  ...components,
5637
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _258 => _258.Attachment]), () => ( composer_attachment_default))
5717
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _266 => _266.Attachment]), () => ( composer_attachment_default))
5638
5718
  }
5639
5719
  }
5640
5720
  ) });
@@ -5679,23 +5759,27 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
5679
5759
  variant: "default",
5680
5760
  className: "aui-composer-send"
5681
5761
  });
5682
- var ComposerSend = _react.forwardRef.call(void 0, (props, ref) => {
5683
- const {
5684
- strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
5685
- } = useThreadConfig();
5686
- 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, {}))) }) });
5687
- });
5762
+ var ComposerSend = _react.forwardRef.call(void 0,
5763
+ (props, ref) => {
5764
+ const {
5765
+ strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
5766
+ } = useThreadConfig();
5767
+ 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, {}))) }) });
5768
+ }
5769
+ );
5688
5770
  ComposerSend.displayName = "ComposerSend";
5689
5771
  var ComposerCancelButton = withDefaults(TooltipIconButton, {
5690
5772
  variant: "default",
5691
5773
  className: "aui-composer-cancel"
5692
5774
  });
5693
- var ComposerCancel = _react.forwardRef.call(void 0, (props, ref) => {
5694
- const {
5695
- strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
5696
- } = useThreadConfig();
5697
- 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, {}))) }) });
5698
- });
5775
+ var ComposerCancel = _react.forwardRef.call(void 0,
5776
+ (props, ref) => {
5777
+ const {
5778
+ strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
5779
+ } = useThreadConfig();
5780
+ 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, {}))) }) });
5781
+ }
5782
+ );
5699
5783
  ComposerCancel.displayName = "ComposerCancel";
5700
5784
  var exports6 = {
5701
5785
  Root: ComposerRoot,
@@ -5727,11 +5811,9 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
5727
5811
  var ThreadWelcomeCenter = withDefaults("div", {
5728
5812
  className: "aui-thread-welcome-center"
5729
5813
  });
5730
- var ThreadWelcomeRoot = _react.forwardRef.call(void 0,
5731
- (props, ref) => {
5732
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.Empty, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeRootStyled, { ...props, ref }) });
5733
- }
5734
- );
5814
+ var ThreadWelcomeRoot = _react.forwardRef.call(void 0, (props, ref) => {
5815
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.Empty, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeRootStyled, { ...props, ref }) });
5816
+ });
5735
5817
  ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
5736
5818
  var ThreadWelcomeAvatar = () => {
5737
5819
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
@@ -5760,7 +5842,7 @@ var ThreadWelcomeSuggestions = () => {
5760
5842
  const suggestions2 = useThread((t) => t.suggestions);
5761
5843
  const { welcome: { suggestions } = {} } = useThreadConfig();
5762
5844
  const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
5763
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _259 => _259.map, 'call', _260 => _260((suggestion, idx) => {
5845
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _267 => _267.map, 'call', _268 => _268((suggestion, idx) => {
5764
5846
  const key = `${suggestion.prompt}-${idx}`;
5765
5847
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
5766
5848
  })]) });
@@ -5814,16 +5896,12 @@ var user_action_bar_default = Object.assign(UserActionBar, exports8);
5814
5896
 
5815
5897
  // src/ui/user-message-attachment.tsx
5816
5898
 
5817
- var UserMessageAttachmentRoot = withDefaults("div", {
5899
+ var UserMessageAttachmentRoot = withDefaults(attachment_exports.Root, {
5818
5900
  className: "aui-user-message-attachment-root"
5819
5901
  });
5820
5902
  UserMessageAttachmentRoot.displayName = "UserMessageAttachmentRoot";
5821
5903
  var UserMessageAttachment = () => {
5822
- const attachment = useAttachment((a) => a.attachment);
5823
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageAttachmentRoot, { children: [
5824
- ".",
5825
- attachment.name.split(".").pop()
5826
- ] });
5904
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageAttachmentRoot, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, {}) });
5827
5905
  };
5828
5906
  UserMessageAttachment.displayName = "UserMessageAttachment";
5829
5907
  var exports9 = {
@@ -5852,19 +5930,17 @@ UserMessageRoot.displayName = "UserMessageRoot";
5852
5930
  var UserMessageContentWrapper = withDefaults("div", {
5853
5931
  className: "aui-user-message-content"
5854
5932
  });
5855
- var UserMessageContent = _react.forwardRef.call(void 0,
5856
- ({ components, ...props }, ref) => {
5857
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5858
- message_exports.Content,
5859
- {
5860
- components: {
5861
- ...components,
5862
- Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _261 => _261.Text]), () => ( content_part_default.Text))
5863
- }
5933
+ var UserMessageContent = _react.forwardRef.call(void 0, ({ components, ...props }, ref) => {
5934
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5935
+ message_exports.Content,
5936
+ {
5937
+ components: {
5938
+ ...components,
5939
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _269 => _269.Text]), () => ( content_part_default.Text))
5864
5940
  }
5865
- ) });
5866
- }
5867
- );
5941
+ }
5942
+ ) });
5943
+ });
5868
5944
  UserMessageContent.displayName = "UserMessageContent";
5869
5945
  var UserMessageAttachmentsContainer = withDefaults("div", {
5870
5946
  className: "aui-user-message-attachments"
@@ -5877,7 +5953,7 @@ var UserMessageAttachments = ({
5877
5953
  {
5878
5954
  components: {
5879
5955
  ...components,
5880
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _262 => _262.Attachment]), () => ( user_message_attachment_default))
5956
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _270 => _270.Attachment]), () => ( user_message_attachment_default))
5881
5957
  }
5882
5958
  }
5883
5959
  ) }) });
@@ -5914,25 +5990,19 @@ var EditComposerFooter = withDefaults("div", {
5914
5990
  className: "aui-edit-composer-footer"
5915
5991
  });
5916
5992
  EditComposerFooter.displayName = "EditComposerFooter";
5917
- var EditComposerCancel = _react.forwardRef.call(void 0,
5918
- (props, ref) => {
5919
- const {
5920
- strings: {
5921
- editComposer: { cancel: { label = "Cancel" } = {} } = {}
5922
- } = {}
5923
- } = useThreadConfig();
5924
- 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)) }) });
5925
- }
5926
- );
5993
+ var EditComposerCancel = _react.forwardRef.call(void 0, (props, ref) => {
5994
+ const {
5995
+ strings: { editComposer: { cancel: { label = "Cancel" } = {} } = {} } = {}
5996
+ } = useThreadConfig();
5997
+ 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)) }) });
5998
+ });
5927
5999
  EditComposerCancel.displayName = "EditComposerCancel";
5928
- var EditComposerSend = _react.forwardRef.call(void 0,
5929
- (props, ref) => {
5930
- const {
5931
- strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
5932
- } = useThreadConfig();
5933
- 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)) }) });
5934
- }
5935
- );
6000
+ var EditComposerSend = _react.forwardRef.call(void 0, (props, ref) => {
6001
+ const {
6002
+ strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
6003
+ } = useThreadConfig();
6004
+ 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)) }) });
6005
+ });
5936
6006
  EditComposerSend.displayName = "EditComposerSend";
5937
6007
  var exports11 = {
5938
6008
  Root: EditComposerRoot,
@@ -5986,10 +6056,10 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
5986
6056
  thread_exports.Messages,
5987
6057
  {
5988
6058
  components: {
5989
- UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _263 => _263.UserMessage]), () => ( user_message_default)),
5990
- EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _264 => _264.EditComposer]), () => ( edit_composer_default)),
5991
- AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _265 => _265.AssistantMessage]), () => ( assistant_message_default)),
5992
- SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _266 => _266.SystemMessage]), () => ( SystemMessage))
6059
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _271 => _271.UserMessage]), () => ( user_message_default)),
6060
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _272 => _272.EditComposer]), () => ( edit_composer_default)),
6061
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _273 => _273.AssistantMessage]), () => ( assistant_message_default)),
6062
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _274 => _274.SystemMessage]), () => ( SystemMessage))
5993
6063
  },
5994
6064
  ...rest
5995
6065
  }
@@ -6000,7 +6070,7 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
6000
6070
  ThreadMessages.displayName = "ThreadMessages";
6001
6071
  var ThreadFollowupSuggestions = () => {
6002
6072
  const suggestions = useThread((t) => t.suggestions);
6003
- 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,
6073
+ 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', _275 => _275.map, 'call', _276 => _276((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6004
6074
  thread_exports.Suggestion,
6005
6075
  {
6006
6076
  className: "aui-thread-followup-suggestion",
@@ -6044,7 +6114,10 @@ var AssistantModal = (config) => {
6044
6114
  ] });
6045
6115
  };
6046
6116
  AssistantModal.displayName = "AssistantModal";
6047
- var AssistantModalRoot = ({ config, ...props }) => {
6117
+ var AssistantModalRoot = ({
6118
+ config,
6119
+ ...props
6120
+ }) => {
6048
6121
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, assistantModal_exports.Root, { ...props }) });
6049
6122
  };
6050
6123
  AssistantModalRoot.displayName = "AssistantModalRoot";
@@ -6228,5 +6301,6 @@ var assistant_modal_default = Object.assign(AssistantModal, exports13);
6228
6301
 
6229
6302
 
6230
6303
 
6231
- exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkKVXP3Q6Kjs.toCoreMessage; exports.toCoreMessages = _chunkKVXP3Q6Kjs.toCoreMessages; exports.toLanguageModelMessages = _chunkKVXP3Q6Kjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkKVXP3Q6Kjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarFeedbackNegative = useActionBarFeedbackNegative; exports.useActionBarFeedbackPositive = useActionBarFeedbackPositive; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantActions = useAssistantActions; exports.useAssistantActionsStore = useAssistantActionsStore; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantRuntime = useAssistantRuntime; exports.useAssistantRuntimeStore = useAssistantRuntimeStore; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposer = useComposer; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerRuntime = useComposerRuntime; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartRuntime = useContentPartRuntime; exports.useContentPartStore = useContentPartStore; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useEditComposer = useEditComposer; exports.useEditComposerStore = useEditComposerStore; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessage = useMessage; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useMessageRuntime = useMessageRuntime; exports.useMessageStore = useMessageStore; exports.useMessageUtils = useMessageUtils; exports.useMessageUtilsStore = useMessageUtilsStore; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThread = useThread; exports.useThreadActions = useThreadActions; exports.useThreadActionsStore = useThreadActionsStore; exports.useThreadComposer = useThreadComposer; exports.useThreadComposerStore = useThreadComposerStore; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadRuntime = useThreadRuntime; exports.useThreadRuntimeStore = useThreadRuntimeStore; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadStore = useThreadStore; exports.useThreadSuggestion = useThreadSuggestion; exports.useThreadViewport = useThreadViewport; exports.useThreadViewportStore = useThreadViewportStore; exports.useToolUIs = useToolUIs; exports.useToolUIsStore = useToolUIsStore;
6304
+
6305
+ exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.AttachmentPrimitive = attachment_exports; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkKVXP3Q6Kjs.toCoreMessage; exports.toCoreMessages = _chunkKVXP3Q6Kjs.toCoreMessages; exports.toLanguageModelMessages = _chunkKVXP3Q6Kjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkKVXP3Q6Kjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarFeedbackNegative = useActionBarFeedbackNegative; exports.useActionBarFeedbackPositive = useActionBarFeedbackPositive; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantActions = useAssistantActions; exports.useAssistantActionsStore = useAssistantActionsStore; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantRuntime = useAssistantRuntime; exports.useAssistantRuntimeStore = useAssistantRuntimeStore; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposer = useComposer; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerRuntime = useComposerRuntime; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartRuntime = useContentPartRuntime; exports.useContentPartStore = useContentPartStore; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useEditComposer = useEditComposer; exports.useEditComposerStore = useEditComposerStore; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessage = useMessage; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useMessageRuntime = useMessageRuntime; exports.useMessageStore = useMessageStore; exports.useMessageUtils = useMessageUtils; exports.useMessageUtilsStore = useMessageUtilsStore; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThread = useThread; exports.useThreadActions = useThreadActions; exports.useThreadActionsStore = useThreadActionsStore; exports.useThreadComposer = useThreadComposer; exports.useThreadComposerStore = useThreadComposerStore; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadRuntime = useThreadRuntime; exports.useThreadRuntimeStore = useThreadRuntimeStore; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadStore = useThreadStore; exports.useThreadSuggestion = useThreadSuggestion; exports.useThreadViewport = useThreadViewport; exports.useThreadViewportStore = useThreadViewportStore; exports.useToolUIs = useToolUIs; exports.useToolUIsStore = useToolUIsStore;
6232
6306
  //# sourceMappingURL=index.js.map