@assistant-ui/react 0.5.67 → 0.5.69

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -184,7 +184,7 @@ var writableStore = (store) => {
184
184
 
185
185
  // src/context/providers/ThreadRuntimeProvider.tsx
186
186
  import { create as create3 } from "zustand";
187
- import { jsx, jsxs } from "react/jsx-runtime";
187
+ import { jsx } from "react/jsx-runtime";
188
188
  var useThreadRuntimeStore2 = (runtime) => {
189
189
  const [store] = useState(() => create3(() => runtime));
190
190
  useEffect(() => {
@@ -235,13 +235,7 @@ var ThreadRuntimeProvider = ({ children, runtime }) => {
235
235
  useViewport
236
236
  };
237
237
  }, [useThread2, useThreadRuntime2, useThreadMessages2, useThreadComposer2]);
238
- const Synchronizer = context.useThread(
239
- (t) => t.unstable_synchronizer
240
- );
241
- return /* @__PURE__ */ jsxs(ThreadContext.Provider, { value: context, children: [
242
- Synchronizer && /* @__PURE__ */ jsx(Synchronizer, {}),
243
- children
244
- ] });
238
+ return /* @__PURE__ */ jsx(ThreadContext.Provider, { value: context, children });
245
239
  };
246
240
 
247
241
  // src/context/providers/AssistantRuntimeProvider.tsx
@@ -577,11 +571,11 @@ var useActionBarCopy = ({
577
571
  // src/primitive-hooks/actionBar/useActionBarEdit.tsx
578
572
  import { useCallback as useCallback4 } from "react";
579
573
  var useActionBarEdit = () => {
580
- const composerRuntime = useComposerRuntime();
581
- const disabled = useComposer((c) => c.isEditing);
574
+ const messageRuntime = useMessageRuntime();
575
+ const disabled = useEditComposer((c) => c.isEditing);
582
576
  const callback = useCallback4(() => {
583
- composerRuntime.beginEdit();
584
- }, [composerRuntime]);
577
+ messageRuntime.composer.beginEdit();
578
+ }, [messageRuntime]);
585
579
  if (disabled) return null;
586
580
  return callback;
587
581
  };
@@ -1590,14 +1584,165 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
1590
1584
  };
1591
1585
  ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
1592
1586
 
1587
+ // src/api/AttachmentRuntime.ts
1588
+ var AttachmentRuntime = class {
1589
+ constructor(_core) {
1590
+ this._core = _core;
1591
+ }
1592
+ getState() {
1593
+ return this._core.getState();
1594
+ }
1595
+ subscribe(callback) {
1596
+ return this._core.subscribe(callback);
1597
+ }
1598
+ };
1599
+ var ComposerAttachmentRuntime = class extends AttachmentRuntime {
1600
+ constructor(core, _composerApi) {
1601
+ super(core);
1602
+ this._composerApi = _composerApi;
1603
+ }
1604
+ remove() {
1605
+ const core = this._composerApi.getState();
1606
+ if (!core) throw new Error("Composer is not available");
1607
+ return core.removeAttachment(this.getState().id);
1608
+ }
1609
+ };
1610
+ var ThreadComposerAttachmentRuntime = class extends ComposerAttachmentRuntime {
1611
+ get source() {
1612
+ return "thread-composer";
1613
+ }
1614
+ };
1615
+ var EditComposerAttachmentRuntime = class extends ComposerAttachmentRuntime {
1616
+ get source() {
1617
+ return "edit-composer";
1618
+ }
1619
+ };
1620
+ var MessageAttachmentRuntime = class extends AttachmentRuntime {
1621
+ get source() {
1622
+ return "message";
1623
+ }
1624
+ constructor(core) {
1625
+ super(core);
1626
+ }
1627
+ remove() {
1628
+ throw new Error("Message attachments cannot be removed");
1629
+ }
1630
+ };
1631
+
1632
+ // src/api/subscribable/BaseSubject.ts
1633
+ var BaseSubject = class {
1634
+ _subscriptions = /* @__PURE__ */ new Set();
1635
+ _connection;
1636
+ get isConnected() {
1637
+ return !!this._connection;
1638
+ }
1639
+ notifySubscribers() {
1640
+ for (const callback of this._subscriptions) callback();
1641
+ }
1642
+ _updateConnection() {
1643
+ if (this._subscriptions.size > 0) {
1644
+ if (this._connection) return;
1645
+ this._connection = this._connect();
1646
+ } else {
1647
+ this._connection?.();
1648
+ this._connection = void 0;
1649
+ }
1650
+ }
1651
+ subscribe(callback) {
1652
+ this._subscriptions.add(callback);
1653
+ this._updateConnection();
1654
+ return () => {
1655
+ this._subscriptions.delete(callback);
1656
+ this._updateConnection();
1657
+ };
1658
+ }
1659
+ };
1660
+
1661
+ // src/api/subscribable/SKIP_UPDATE.ts
1662
+ var SKIP_UPDATE = Symbol("skip-update");
1663
+
1664
+ // src/api/subscribable/LazyMemoizeSubject.ts
1665
+ var LazyMemoizeSubject = class extends BaseSubject {
1666
+ constructor(binding) {
1667
+ super();
1668
+ this.binding = binding;
1669
+ }
1670
+ _previousStateDirty = true;
1671
+ _previousState;
1672
+ getState = () => {
1673
+ if (!this.isConnected || this._previousStateDirty) {
1674
+ const newState = this.binding.getState();
1675
+ if (newState !== SKIP_UPDATE) {
1676
+ this._previousState = newState;
1677
+ }
1678
+ this._previousStateDirty = false;
1679
+ }
1680
+ if (this._previousState === void 0)
1681
+ throw new Error("Entry not available in the store");
1682
+ return this._previousState;
1683
+ };
1684
+ _connect() {
1685
+ const callback = () => {
1686
+ this._previousStateDirty = true;
1687
+ this.notifySubscribers();
1688
+ };
1689
+ return this.binding.subscribe(callback);
1690
+ }
1691
+ };
1692
+
1693
+ // src/api/subscribable/shallowEqual.ts
1694
+ function shallowEqual(objA, objB) {
1695
+ if (objA === void 0 && objB === void 0) return true;
1696
+ if (objA === void 0) return false;
1697
+ if (objB === void 0) return false;
1698
+ for (const key of Object.keys(objA)) {
1699
+ const valueA = objA[key];
1700
+ const valueB = objB[key];
1701
+ if (!Object.is(valueA, valueB)) return false;
1702
+ }
1703
+ return true;
1704
+ }
1705
+
1706
+ // src/api/subscribable/ShallowMemoizeSubject.ts
1707
+ var ShallowMemoizeSubject = class extends BaseSubject {
1708
+ constructor(binding) {
1709
+ super();
1710
+ this.binding = binding;
1711
+ const state = binding.getState();
1712
+ if (state === SKIP_UPDATE)
1713
+ throw new Error("Entry not available in the store");
1714
+ this._previousState = state;
1715
+ }
1716
+ _previousState;
1717
+ getState = () => {
1718
+ if (!this.isConnected) this._syncState();
1719
+ return this._previousState;
1720
+ };
1721
+ _syncState() {
1722
+ const state = this.binding.getState();
1723
+ if (state === SKIP_UPDATE) return false;
1724
+ if (shallowEqual(state, this._previousState)) return false;
1725
+ this._previousState = state;
1726
+ return true;
1727
+ }
1728
+ _connect() {
1729
+ const callback = () => {
1730
+ if (this._syncState()) {
1731
+ this.notifySubscribers();
1732
+ }
1733
+ };
1734
+ return this.binding.subscribe(callback);
1735
+ }
1736
+ };
1737
+
1593
1738
  // src/api/ComposerRuntime.ts
1594
1739
  var METHOD_NOT_SUPPORTED = () => {
1595
1740
  throw new Error("Composer is not available");
1596
1741
  };
1597
1742
  var EMPTY_ARRAY = Object.freeze([]);
1598
- var getThreadComposerState = (type, runtime, beginEdit, focus, onFocus) => {
1743
+ var getThreadComposerState = (runtime, focus, onFocus) => {
1599
1744
  return Object.freeze({
1600
- type,
1745
+ type: "thread",
1601
1746
  isEditing: runtime?.isEditing ?? false,
1602
1747
  canCancel: runtime?.canCancel ?? false,
1603
1748
  isEmpty: runtime?.isEmpty ?? true,
@@ -1607,23 +1752,36 @@ var getThreadComposerState = (type, runtime, beginEdit, focus, onFocus) => {
1607
1752
  value: runtime?.text ?? "",
1608
1753
  setValue: runtime?.setText.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1609
1754
  setText: runtime?.setText.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1610
- edit: beginEdit,
1755
+ // edit: beginEdit,
1611
1756
  send: runtime?.send.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1612
1757
  cancel: runtime?.cancel.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1613
- focus: focus ?? METHOD_NOT_SUPPORTED,
1614
- onFocus: onFocus ?? METHOD_NOT_SUPPORTED,
1758
+ focus,
1759
+ onFocus,
1615
1760
  reset: runtime?.reset.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1616
1761
  addAttachment: runtime?.addAttachment.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1617
1762
  removeAttachment: runtime?.removeAttachment.bind(runtime) ?? METHOD_NOT_SUPPORTED
1618
1763
  });
1619
1764
  };
1765
+ var getEditComposerState = (runtime, beginEdit) => {
1766
+ return Object.freeze({
1767
+ type: "edit",
1768
+ isEditing: runtime?.isEditing ?? false,
1769
+ canCancel: runtime?.canCancel ?? false,
1770
+ isEmpty: runtime?.isEmpty ?? true,
1771
+ text: runtime?.text ?? "",
1772
+ attachments: runtime?.attachments ?? EMPTY_ARRAY,
1773
+ attachmentAccept: runtime?.attachmentAccept ?? "*",
1774
+ value: runtime?.text ?? "",
1775
+ setValue: runtime?.setText.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1776
+ setText: runtime?.setText.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1777
+ edit: beginEdit,
1778
+ send: runtime?.send.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1779
+ cancel: runtime?.cancel.bind(runtime) ?? METHOD_NOT_SUPPORTED
1780
+ });
1781
+ };
1620
1782
  var ComposerRuntime = class {
1621
- constructor(_core, _beginEdit) {
1783
+ constructor(_core) {
1622
1784
  this._core = _core;
1623
- this._beginEdit = _beginEdit;
1624
- }
1625
- get type() {
1626
- return this._beginEdit ? "edit" : "thread";
1627
1785
  }
1628
1786
  /**
1629
1787
  * @deprecated Use `getState().isEditing` instead. This will be removed in 0.6.0.
@@ -1655,7 +1813,6 @@ var ComposerRuntime = class {
1655
1813
  get attachmentAccept() {
1656
1814
  return this.getState().attachmentAccept;
1657
1815
  }
1658
- // TODO should this instead return getAttachmentByIndex([idx]) instead?
1659
1816
  /**
1660
1817
  * @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
1661
1818
  */
@@ -1668,15 +1825,6 @@ var ComposerRuntime = class {
1668
1825
  get value() {
1669
1826
  return this.text;
1670
1827
  }
1671
- getState() {
1672
- return getThreadComposerState(
1673
- this.type,
1674
- this._core.getState(),
1675
- this._beginEdit?.bind(this) ?? METHOD_NOT_SUPPORTED,
1676
- this.focus.bind(this),
1677
- this.onFocus.bind(this)
1678
- );
1679
- }
1680
1828
  setText(text) {
1681
1829
  const core = this._core.getState();
1682
1830
  if (!core) throw new Error("Composer is not available");
@@ -1716,18 +1864,37 @@ var ComposerRuntime = class {
1716
1864
  if (!core) throw new Error("Composer is not available");
1717
1865
  core.cancel();
1718
1866
  }
1719
- beginEdit() {
1720
- this._beginEdit?.();
1721
- }
1722
- /**
1723
- * @deprecated Use `beginEdit()` instead. This will be removed in 0.6.0.
1724
- */
1725
- edit() {
1726
- this.beginEdit();
1727
- }
1728
1867
  subscribe(callback) {
1729
1868
  return this._core.subscribe(callback);
1730
1869
  }
1870
+ };
1871
+ var ThreadComposerRuntime = class extends ComposerRuntime {
1872
+ get type() {
1873
+ return "thread";
1874
+ }
1875
+ _getState;
1876
+ constructor(core) {
1877
+ const stateBinding = new LazyMemoizeSubject({
1878
+ getState: () => getThreadComposerState(
1879
+ core.getState(),
1880
+ this.focus.bind(this),
1881
+ this.onFocus.bind(this)
1882
+ ),
1883
+ subscribe: (callback) => core.subscribe(callback)
1884
+ });
1885
+ super({
1886
+ getState: () => core.getState(),
1887
+ subscribe: (callback) => stateBinding.subscribe(callback)
1888
+ });
1889
+ this._getState = stateBinding.getState.bind(stateBinding);
1890
+ }
1891
+ get attachments() {
1892
+ return this.getState()?.attachments ?? EMPTY_ARRAY;
1893
+ }
1894
+ getState() {
1895
+ return this._getState();
1896
+ }
1897
+ // TODO replace with events
1731
1898
  _focusListeners = /* @__PURE__ */ new Set();
1732
1899
  focus() {
1733
1900
  this._focusListeners.forEach((callback) => callback());
@@ -1736,34 +1903,71 @@ var ComposerRuntime = class {
1736
1903
  this._focusListeners.add(callback);
1737
1904
  return () => this._focusListeners.delete(callback);
1738
1905
  }
1906
+ unstable_getAttachmentByIndex(idx) {
1907
+ return new ThreadComposerAttachmentRuntime(
1908
+ new ShallowMemoizeSubject({
1909
+ getState: () => {
1910
+ const attachments = this.getState().attachments;
1911
+ const attachment = attachments[idx];
1912
+ if (!attachment) return SKIP_UPDATE;
1913
+ return {
1914
+ ...attachment,
1915
+ attachment,
1916
+ source: "thread-composer"
1917
+ };
1918
+ },
1919
+ subscribe: (callback) => this._core.subscribe(callback)
1920
+ }),
1921
+ this._core
1922
+ );
1923
+ }
1739
1924
  };
1740
-
1741
- // src/api/subscribable/BaseSubject.ts
1742
- var BaseSubject = class {
1743
- _subscriptions = /* @__PURE__ */ new Set();
1744
- _connection;
1745
- get isConnected() {
1746
- return !!this._connection;
1925
+ var EditComposerRuntime = class extends ComposerRuntime {
1926
+ constructor(core, _beginEdit) {
1927
+ const stateBinding = new LazyMemoizeSubject({
1928
+ getState: () => getEditComposerState(core.getState(), this._beginEdit),
1929
+ subscribe: (callback) => core.subscribe(callback)
1930
+ });
1931
+ super({
1932
+ getState: () => core.getState(),
1933
+ subscribe: (callback) => stateBinding.subscribe(callback)
1934
+ });
1935
+ this._beginEdit = _beginEdit;
1936
+ this._getState = stateBinding.getState.bind(stateBinding);
1747
1937
  }
1748
- notifySubscribers() {
1749
- for (const callback of this._subscriptions) callback();
1938
+ get type() {
1939
+ return "edit";
1750
1940
  }
1751
- _updateConnection() {
1752
- if (this._subscriptions.size > 0) {
1753
- if (this._connection) return;
1754
- this._connection = this._connect();
1755
- } else {
1756
- this._connection?.();
1757
- this._connection = void 0;
1758
- }
1941
+ _getState;
1942
+ getState() {
1943
+ return this._getState();
1759
1944
  }
1760
- subscribe(callback) {
1761
- this._subscriptions.add(callback);
1762
- this._updateConnection();
1763
- return () => {
1764
- this._subscriptions.delete(callback);
1765
- this._updateConnection();
1766
- };
1945
+ beginEdit() {
1946
+ this._beginEdit();
1947
+ }
1948
+ /**
1949
+ * @deprecated Use `beginEdit()` instead. This will be removed in 0.6.0.
1950
+ */
1951
+ edit() {
1952
+ this.beginEdit();
1953
+ }
1954
+ unstable_getAttachmentByIndex(idx) {
1955
+ return new EditComposerAttachmentRuntime(
1956
+ new ShallowMemoizeSubject({
1957
+ getState: () => {
1958
+ const attachments = this.getState().attachments;
1959
+ const attachment = attachments[idx];
1960
+ if (!attachment) return SKIP_UPDATE;
1961
+ return {
1962
+ ...attachment,
1963
+ attachment,
1964
+ source: "edit-composer"
1965
+ };
1966
+ },
1967
+ subscribe: (callback) => this._core.subscribe(callback)
1968
+ }),
1969
+ this._core
1970
+ );
1767
1971
  }
1768
1972
  };
1769
1973
 
@@ -1798,51 +2002,6 @@ var NestedSubscriptionSubject = class extends BaseSubject {
1798
2002
  }
1799
2003
  };
1800
2004
 
1801
- // src/api/subscribable/shallowEqual.ts
1802
- function shallowEqual(objA, objB) {
1803
- if (objA === void 0 && objB === void 0) return true;
1804
- if (objA === void 0) return false;
1805
- if (objB === void 0) return false;
1806
- for (const key of Object.keys(objA)) {
1807
- const valueA = objA[key];
1808
- const valueB = objB[key];
1809
- if (!Object.is(valueA, valueB)) return false;
1810
- }
1811
- return true;
1812
- }
1813
-
1814
- // src/api/subscribable/ShallowMemoizeSubject.ts
1815
- var ShallowMemoizeSubject = class extends BaseSubject {
1816
- constructor(binding) {
1817
- super();
1818
- this.binding = binding;
1819
- const state = binding.getState();
1820
- if (state === void 0)
1821
- throw new Error("Entry not available in the store");
1822
- this._previousState = state;
1823
- }
1824
- _previousState;
1825
- getState = () => {
1826
- if (!this.isConnected) this._syncState();
1827
- return this._previousState;
1828
- };
1829
- _syncState() {
1830
- const state = this.binding.getState();
1831
- if (state === void 0) return false;
1832
- if (shallowEqual(state, this._previousState)) return false;
1833
- this._previousState = state;
1834
- return true;
1835
- }
1836
- _connect() {
1837
- const callback = () => {
1838
- if (this._syncState()) {
1839
- this.notifySubscribers();
1840
- }
1841
- };
1842
- return this.binding.subscribe(callback);
1843
- }
1844
- };
1845
-
1846
2005
  // src/api/MessageRuntime.ts
1847
2006
  var COMPLETE_STATUS2 = {
1848
2007
  type: "complete"
@@ -1869,7 +2028,7 @@ var getContentPartState = (message, partIndex) => {
1869
2028
  if (message.content.length === 0 && partIndex === 0) {
1870
2029
  part = EMPTY_CONTENT;
1871
2030
  } else {
1872
- return void 0;
2031
+ return SKIP_UPDATE;
1873
2032
  }
1874
2033
  } else if (message.content.length === 1 && part.type === "text" && part.text.length === 0) {
1875
2034
  part = EMPTY_CONTENT;
@@ -1882,7 +2041,7 @@ var MessageRuntime = class {
1882
2041
  this._core = _core;
1883
2042
  this._threadBinding = _threadBinding;
1884
2043
  }
1885
- composer = new ComposerRuntime(
2044
+ composer = new EditComposerRuntime(
1886
2045
  new NestedSubscriptionSubject({
1887
2046
  getState: () => this._threadBinding.getState().getEditComposer(this._core.getState().id),
1888
2047
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -1959,10 +2118,27 @@ var MessageRuntime = class {
1959
2118
  this._threadBinding
1960
2119
  );
1961
2120
  }
2121
+ unstable_getAttachmentByIndex(idx) {
2122
+ return new MessageAttachmentRuntime(
2123
+ new ShallowMemoizeSubject({
2124
+ getState: () => {
2125
+ const attachments = this.getState().attachments;
2126
+ const attachment = attachments?.[idx];
2127
+ if (!attachment) return SKIP_UPDATE;
2128
+ return {
2129
+ ...attachment,
2130
+ attachment,
2131
+ source: "message"
2132
+ };
2133
+ },
2134
+ subscribe: (callback) => this._core.subscribe(callback)
2135
+ })
2136
+ );
2137
+ }
1962
2138
  };
1963
2139
 
1964
2140
  // src/primitives/message/MessageContent.tsx
1965
- import { jsx as jsx21, jsxs as jsxs2 } from "react/jsx-runtime";
2141
+ import { jsx as jsx21, jsxs } from "react/jsx-runtime";
1966
2142
  var ToolUIDisplay = ({
1967
2143
  UI,
1968
2144
  ...props
@@ -1972,7 +2148,7 @@ var ToolUIDisplay = ({
1972
2148
  return /* @__PURE__ */ jsx21(Render, { ...props });
1973
2149
  };
1974
2150
  var defaultComponents = {
1975
- Text: () => /* @__PURE__ */ jsxs2("p", { style: { whiteSpace: "pre-line" }, children: [
2151
+ Text: () => /* @__PURE__ */ jsxs("p", { style: { whiteSpace: "pre-line" }, children: [
1976
2152
  /* @__PURE__ */ jsx21(ContentPartPrimitiveText, {}),
1977
2153
  /* @__PURE__ */ jsx21(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ jsx21("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
1978
2154
  ] }),
@@ -2053,7 +2229,7 @@ var MessagePrimitiveInProgress = () => {
2053
2229
  MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
2054
2230
 
2055
2231
  // src/primitives/message/MessageAttachments.tsx
2056
- import { memo as memo3 } from "react";
2232
+ import { memo as memo3, useMemo as useMemo8 } from "react";
2057
2233
 
2058
2234
  // src/context/react/AttachmentContext.ts
2059
2235
  import { createContext as createContext6, useContext as useContext3 } from "react";
@@ -2068,80 +2244,87 @@ function useAttachmentContext(options) {
2068
2244
  );
2069
2245
  return context;
2070
2246
  }
2071
- function useComposerAttachmentContext(options) {
2247
+ function useThreadComposerAttachmentContext(options) {
2248
+ const context = useAttachmentContext(options);
2249
+ if (!context) return null;
2250
+ if (context.source !== "thread-composer")
2251
+ throw new Error(
2252
+ "This component must be used within a thread's ComposerPrimitive.Attachments component."
2253
+ );
2254
+ return context;
2255
+ }
2256
+ function useEditComposerAttachmentContext(options) {
2072
2257
  const context = useAttachmentContext(options);
2073
2258
  if (!context) return null;
2074
- if (context.type !== "composer")
2259
+ if (context.source !== "edit-composer")
2075
2260
  throw new Error(
2076
- "This component must be used within a ComposerPrimitive.Attachments component."
2261
+ "This component must be used within a messages's ComposerPrimitive.Attachments component."
2077
2262
  );
2078
2263
  return context;
2079
2264
  }
2080
2265
  function useMessageAttachmentContext(options) {
2081
2266
  const context = useAttachmentContext(options);
2082
2267
  if (!context) return null;
2083
- if (context.type !== "message")
2268
+ if (context.source !== "message")
2084
2269
  throw new Error(
2085
2270
  "This component must be used within a MessagePrimitive.Attachments component."
2086
2271
  );
2087
2272
  return context;
2088
2273
  }
2089
- var { useAttachment, useAttachmentStore } = createContextStoreHook(
2274
+ function useAttachmentRuntime(options) {
2275
+ const attachmentRuntime = useAttachmentContext(options);
2276
+ if (!attachmentRuntime) return null;
2277
+ return attachmentRuntime.useAttachmentRuntime();
2278
+ }
2279
+ var { useAttachment } = createContextStoreHook(
2090
2280
  useAttachmentContext,
2091
2281
  "useAttachment"
2092
2282
  );
2093
- var {
2094
- useAttachment: useComposerAttachment,
2095
- useAttachmentStore: useComposerAttachmentStore
2096
- } = createContextStoreHook(useComposerAttachmentContext, "useAttachment");
2097
- var {
2098
- useAttachment: useMessageAttachment,
2099
- useAttachmentStore: useMessageAttachmentStore
2100
- } = createContextStoreHook(useMessageAttachmentContext, "useAttachment");
2283
+ var { useAttachment: useThreadComposerAttachment } = createContextStoreHook(useThreadComposerAttachmentContext, "useAttachment");
2284
+ var { useAttachment: useEditComposerAttachment } = createContextStoreHook(useEditComposerAttachmentContext, "useAttachment");
2285
+ var { useAttachment: useMessageAttachment } = createContextStoreHook(
2286
+ useMessageAttachmentContext,
2287
+ "useAttachment"
2288
+ );
2101
2289
 
2102
- // src/context/providers/MessageAttachmentProvider.tsx
2103
- import { useEffect as useEffect10, useState as useState8 } from "react";
2290
+ // src/context/providers/AttachmentRuntimeProvider.tsx
2291
+ import {
2292
+ useEffect as useEffect10,
2293
+ useMemo as useMemo7,
2294
+ useState as useState8
2295
+ } from "react";
2104
2296
  import { create as create8 } from "zustand";
2105
2297
  import { jsx as jsx22 } from "react/jsx-runtime";
2106
- var getAttachment = (message, useAttachment2, partIndex) => {
2107
- if (message.role !== "user") return null;
2108
- const attachments = message.attachments;
2109
- const attachment = attachments[partIndex];
2110
- if (!attachment) return null;
2111
- const currentState = useAttachment2?.getState();
2112
- if (currentState && currentState.attachment === attachment) return null;
2113
- return Object.freeze({ attachment });
2114
- };
2115
- var useMessageAttachmentContext2 = (partIndex) => {
2116
- const messageStore = useMessageStore();
2117
- const [context] = useState8(
2118
- () => {
2119
- const useAttachment2 = create8(
2120
- () => getAttachment(messageStore.getState(), void 0, partIndex)
2121
- );
2122
- return { type: "message", useAttachment: useAttachment2 };
2123
- }
2124
- );
2298
+ var useAttachmentRuntimeStore = (runtime) => {
2299
+ const [store] = useState8(() => create8(() => runtime));
2125
2300
  useEffect10(() => {
2126
- const syncAttachment = (messageState) => {
2127
- const newState = getAttachment(
2128
- messageState,
2129
- context.useAttachment,
2130
- partIndex
2131
- );
2132
- if (!newState) return;
2133
- writableStore(context.useAttachment).setState(newState, true);
2134
- };
2135
- syncAttachment(messageStore.getState());
2136
- return messageStore.subscribe(syncAttachment);
2137
- }, [context, messageStore, partIndex]);
2138
- return context;
2301
+ writableStore(store).setState(runtime, true);
2302
+ }, [runtime, store]);
2303
+ return store;
2304
+ };
2305
+ var useAttachmentStore = (runtime) => {
2306
+ const [store] = useState8(() => create8(() => runtime.getState()));
2307
+ useEffect10(() => {
2308
+ const updateState = () => writableStore(store).setState(runtime.getState(), true);
2309
+ updateState();
2310
+ return runtime.subscribe(updateState);
2311
+ }, [runtime, store]);
2312
+ return store;
2139
2313
  };
2140
- var MessageAttachmentProvider = ({
2141
- attachmentIndex: partIndex,
2314
+ var AttachmentRuntimeProvider = ({
2315
+ runtime,
2142
2316
  children
2143
2317
  }) => {
2144
- const context = useMessageAttachmentContext2(partIndex);
2318
+ const useAttachmentRuntime2 = useAttachmentRuntimeStore(runtime);
2319
+ const useAttachment2 = useAttachmentStore(runtime);
2320
+ const source = useAttachment2((s) => s.source);
2321
+ const context = useMemo7(() => {
2322
+ return {
2323
+ source,
2324
+ useAttachmentRuntime: useAttachmentRuntime2,
2325
+ useAttachment: useAttachment2
2326
+ };
2327
+ }, [useAttachmentRuntime2, useAttachment2]);
2145
2328
  return /* @__PURE__ */ jsx22(AttachmentContext.Provider, { value: context, children });
2146
2329
  };
2147
2330
 
@@ -2169,7 +2352,12 @@ var AttachmentComponent = ({ components }) => {
2169
2352
  return /* @__PURE__ */ jsx23(Component, {});
2170
2353
  };
2171
2354
  var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
2172
- return /* @__PURE__ */ jsx23(MessageAttachmentProvider, { attachmentIndex, children: /* @__PURE__ */ jsx23(AttachmentComponent, { components }) });
2355
+ const messageRuntime = useMessageRuntime();
2356
+ const runtime = useMemo8(
2357
+ () => messageRuntime.unstable_getAttachmentByIndex(attachmentIndex),
2358
+ [messageRuntime, attachmentIndex]
2359
+ );
2360
+ return /* @__PURE__ */ jsx23(AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx23(AttachmentComponent, { components }) });
2173
2361
  };
2174
2362
  var MessageAttachment = memo3(
2175
2363
  MessageAttachmentImpl,
@@ -2343,51 +2531,8 @@ var ComposerPrimitiveAddAttachment = createActionButton(
2343
2531
  );
2344
2532
 
2345
2533
  // src/primitives/composer/ComposerAttachments.tsx
2346
- import { memo as memo4 } from "react";
2347
-
2348
- // src/context/providers/ComposerAttachmentProvider.tsx
2349
- import { useEffect as useEffect12, useState as useState9 } from "react";
2350
- import { create as create9 } from "zustand";
2534
+ import { memo as memo4, useMemo as useMemo9 } from "react";
2351
2535
  import { jsx as jsx27 } from "react/jsx-runtime";
2352
- var getAttachment2 = ({ attachments }, useAttachment2, partIndex) => {
2353
- const attachment = attachments[partIndex];
2354
- if (!attachment) return null;
2355
- const currentState = useAttachment2?.getState();
2356
- if (currentState && currentState.attachment === attachment) return null;
2357
- return Object.freeze({ attachment });
2358
- };
2359
- var useComposerAttachmentContext2 = (partIndex) => {
2360
- const threadComposerStore = useThreadComposerStore();
2361
- const [context] = useState9(
2362
- () => {
2363
- const useAttachment2 = create9(
2364
- () => getAttachment2(threadComposerStore.getState(), void 0, partIndex)
2365
- );
2366
- return { type: "composer", useAttachment: useAttachment2 };
2367
- }
2368
- );
2369
- useEffect12(() => {
2370
- const syncAttachment = (composer) => {
2371
- const newState = getAttachment2(
2372
- composer,
2373
- context.useAttachment,
2374
- partIndex
2375
- );
2376
- if (!newState) return;
2377
- writableStore(context.useAttachment).setState(newState, true);
2378
- };
2379
- syncAttachment(threadComposerStore.getState());
2380
- return threadComposerStore.subscribe(syncAttachment);
2381
- }, [context, threadComposerStore, partIndex]);
2382
- return context;
2383
- };
2384
- var ComposerAttachmentProvider = ({ attachmentIndex: partIndex, children }) => {
2385
- const context = useComposerAttachmentContext2(partIndex);
2386
- return /* @__PURE__ */ jsx27(AttachmentContext.Provider, { value: context, children });
2387
- };
2388
-
2389
- // src/primitives/composer/ComposerAttachments.tsx
2390
- import { jsx as jsx28 } from "react/jsx-runtime";
2391
2536
  var getComponent2 = (components, attachment) => {
2392
2537
  const type = attachment.type;
2393
2538
  switch (type) {
@@ -2403,22 +2548,27 @@ var getComponent2 = (components, attachment) => {
2403
2548
  }
2404
2549
  };
2405
2550
  var AttachmentComponent2 = ({ components }) => {
2406
- const Component = useComposerAttachment(
2407
- (a) => getComponent2(components, a.attachment)
2551
+ const Component = useThreadComposerAttachment(
2552
+ (a) => getComponent2(components, a)
2408
2553
  );
2409
2554
  if (!Component) return null;
2410
- return /* @__PURE__ */ jsx28(Component, {});
2555
+ return /* @__PURE__ */ jsx27(Component, {});
2411
2556
  };
2412
2557
  var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
2413
- return /* @__PURE__ */ jsx28(ComposerAttachmentProvider, { attachmentIndex, children: /* @__PURE__ */ jsx28(AttachmentComponent2, { components }) });
2558
+ const composerRuntime = useComposerRuntime();
2559
+ const runtime = useMemo9(
2560
+ () => composerRuntime.unstable_getAttachmentByIndex(attachmentIndex),
2561
+ [composerRuntime, attachmentIndex]
2562
+ );
2563
+ return /* @__PURE__ */ jsx27(AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx27(AttachmentComponent2, { components }) });
2414
2564
  };
2415
2565
  var ComposerAttachment = memo4(
2416
2566
  ComposerAttachmentImpl,
2417
2567
  (prev, next) => prev.attachmentIndex === next.attachmentIndex && prev.components?.Image === next.components?.Image && prev.components?.Document === next.components?.Document && prev.components?.File === next.components?.File && prev.components?.Attachment === next.components?.Attachment
2418
2568
  );
2419
2569
  var ComposerPrimitiveAttachments = ({ components }) => {
2420
- const attachmentsCount = useThreadComposer((s) => s.attachments.length);
2421
- return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */ jsx28(
2570
+ const attachmentsCount = useComposer((s) => s.attachments.length);
2571
+ return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */ jsx27(
2422
2572
  ComposerAttachment,
2423
2573
  {
2424
2574
  attachmentIndex: index,
@@ -2463,9 +2613,9 @@ __export(thread_exports, {
2463
2613
  // src/primitives/thread/ThreadRoot.tsx
2464
2614
  import { Primitive as Primitive11 } from "@radix-ui/react-primitive";
2465
2615
  import { forwardRef as forwardRef17 } from "react";
2466
- import { jsx as jsx29 } from "react/jsx-runtime";
2616
+ import { jsx as jsx28 } from "react/jsx-runtime";
2467
2617
  var ThreadPrimitiveRoot = forwardRef17((props, ref) => {
2468
- return /* @__PURE__ */ jsx29(Primitive11.div, { ...props, ref });
2618
+ return /* @__PURE__ */ jsx28(Primitive11.div, { ...props, ref });
2469
2619
  });
2470
2620
  ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
2471
2621
 
@@ -2539,11 +2689,11 @@ var useOnResizeContent = (callback) => {
2539
2689
 
2540
2690
  // src/utils/hooks/useOnScrollToBottom.tsx
2541
2691
  import { useCallbackRef as useCallbackRef4 } from "@radix-ui/react-use-callback-ref";
2542
- import { useEffect as useEffect13 } from "react";
2692
+ import { useEffect as useEffect12 } from "react";
2543
2693
  var useOnScrollToBottom = (callback) => {
2544
2694
  const callbackRef = useCallbackRef4(callback);
2545
2695
  const threadViewportStore = useThreadViewportStore();
2546
- useEffect13(() => {
2696
+ useEffect12(() => {
2547
2697
  return threadViewportStore.getState().onScrollToBottom(() => {
2548
2698
  callbackRef();
2549
2699
  });
@@ -2602,26 +2752,26 @@ var useThreadViewportAutoScroll = ({
2602
2752
  };
2603
2753
 
2604
2754
  // src/primitives/thread/ThreadViewport.tsx
2605
- import { jsx as jsx30 } from "react/jsx-runtime";
2755
+ import { jsx as jsx29 } from "react/jsx-runtime";
2606
2756
  var ThreadPrimitiveViewport = forwardRef18(({ autoScroll, children, ...rest }, forwardedRef) => {
2607
2757
  const autoScrollRef = useThreadViewportAutoScroll({
2608
2758
  autoScroll
2609
2759
  });
2610
2760
  const ref = useComposedRefs4(forwardedRef, autoScrollRef);
2611
- return /* @__PURE__ */ jsx30(Primitive12.div, { ...rest, ref, children });
2761
+ return /* @__PURE__ */ jsx29(Primitive12.div, { ...rest, ref, children });
2612
2762
  });
2613
2763
  ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
2614
2764
 
2615
2765
  // src/primitives/thread/ThreadMessages.tsx
2616
- import { memo as memo5, useMemo as useMemo7 } from "react";
2766
+ import { memo as memo5, useMemo as useMemo10 } from "react";
2617
2767
 
2618
2768
  // src/context/providers/MessageRuntimeProvider.tsx
2619
- import { useEffect as useEffect14, useState as useState10 } from "react";
2620
- import { create as create11 } from "zustand";
2769
+ import { useEffect as useEffect13, useState as useState9 } from "react";
2770
+ import { create as create10 } from "zustand";
2621
2771
 
2622
2772
  // src/context/stores/MessageUtils.ts
2623
- import { create as create10 } from "zustand";
2624
- var makeMessageUtilsStore = () => create10((set) => {
2773
+ import { create as create9 } from "zustand";
2774
+ var makeMessageUtilsStore = () => create9((set) => {
2625
2775
  let utterance = null;
2626
2776
  return {
2627
2777
  isCopied: false,
@@ -2651,17 +2801,17 @@ var makeMessageUtilsStore = () => create10((set) => {
2651
2801
  });
2652
2802
 
2653
2803
  // src/context/providers/MessageRuntimeProvider.tsx
2654
- import { jsx as jsx31 } from "react/jsx-runtime";
2804
+ import { jsx as jsx30 } from "react/jsx-runtime";
2655
2805
  var useMessageRuntimeStore = (runtime) => {
2656
- const [store] = useState10(() => create11(() => runtime));
2657
- useEffect14(() => {
2806
+ const [store] = useState9(() => create10(() => runtime));
2807
+ useEffect13(() => {
2658
2808
  writableStore(store).setState(runtime, true);
2659
2809
  }, [runtime, store]);
2660
2810
  return store;
2661
2811
  };
2662
2812
  var useMessageStore2 = (runtime) => {
2663
- const [store] = useState10(() => create11(() => runtime.getState()));
2664
- useEffect14(() => {
2813
+ const [store] = useState9(() => create10(() => runtime.getState()));
2814
+ useEffect13(() => {
2665
2815
  const updateState = () => writableStore(store).setState(runtime.getState(), true);
2666
2816
  updateState();
2667
2817
  return runtime.subscribe(updateState);
@@ -2669,13 +2819,13 @@ var useMessageStore2 = (runtime) => {
2669
2819
  return store;
2670
2820
  };
2671
2821
  var useMessageUtilsStore2 = () => {
2672
- const [store] = useState10(() => makeMessageUtilsStore());
2822
+ const [store] = useState9(() => makeMessageUtilsStore());
2673
2823
  return store;
2674
2824
  };
2675
2825
  var useEditComposerStore2 = (useMessageRuntime2) => {
2676
2826
  const runtime = useMessageRuntime2.getState().composer;
2677
- const [store] = useState10(() => create11(() => runtime.getState()));
2678
- useEffect14(() => {
2827
+ const [store] = useState9(() => create10(() => runtime.getState()));
2828
+ useEffect13(() => {
2679
2829
  const updateState = () => writableStore(store).setState(runtime.getState());
2680
2830
  updateState();
2681
2831
  return runtime.subscribe(updateState);
@@ -2690,14 +2840,14 @@ var MessageRuntimeProvider = ({
2690
2840
  const useMessage2 = useMessageStore2(runtime);
2691
2841
  const useMessageUtils2 = useMessageUtilsStore2();
2692
2842
  const useEditComposer2 = useEditComposerStore2(useMessageRuntime2);
2693
- const [context] = useState10(() => {
2843
+ const [context] = useState9(() => {
2694
2844
  return { useMessageRuntime: useMessageRuntime2, useMessage: useMessage2, useMessageUtils: useMessageUtils2, useEditComposer: useEditComposer2 };
2695
2845
  });
2696
- return /* @__PURE__ */ jsx31(MessageContext.Provider, { value: context, children });
2846
+ return /* @__PURE__ */ jsx30(MessageContext.Provider, { value: context, children });
2697
2847
  };
2698
2848
 
2699
2849
  // src/primitives/thread/ThreadMessages.tsx
2700
- import { jsx as jsx32 } from "react/jsx-runtime";
2850
+ import { jsx as jsx31 } from "react/jsx-runtime";
2701
2851
  var isComponentsSame = (prev, next) => {
2702
2852
  return prev.Message === next.Message && prev.EditComposer === next.EditComposer && prev.UserEditComposer === next.UserEditComposer && prev.AssistantEditComposer === next.AssistantEditComposer && prev.SystemEditComposer === next.SystemEditComposer && prev.UserMessage === next.UserMessage && prev.AssistantMessage === next.AssistantMessage && prev.SystemMessage === next.SystemMessage;
2703
2853
  };
@@ -2733,18 +2883,18 @@ var ThreadMessageComponent = ({
2733
2883
  const role = useMessage((m) => m.role);
2734
2884
  const isEditing = useEditComposer((c) => c.isEditing);
2735
2885
  const Component = getComponent3(components, role, isEditing);
2736
- return /* @__PURE__ */ jsx32(Component, {});
2886
+ return /* @__PURE__ */ jsx31(Component, {});
2737
2887
  };
2738
2888
  var ThreadMessageImpl = ({
2739
2889
  messageIndex,
2740
2890
  components
2741
2891
  }) => {
2742
2892
  const threadRuntime = useThreadRuntime();
2743
- const runtime = useMemo7(
2893
+ const runtime = useMemo10(
2744
2894
  () => threadRuntime.unstable_getMesssageByIndex(messageIndex),
2745
2895
  [threadRuntime, messageIndex]
2746
2896
  );
2747
- return /* @__PURE__ */ jsx32(MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx32(ThreadMessageComponent, { components }) });
2897
+ return /* @__PURE__ */ jsx31(MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx31(ThreadMessageComponent, { components }) });
2748
2898
  };
2749
2899
  var ThreadMessage = memo5(
2750
2900
  ThreadMessageImpl,
@@ -2755,7 +2905,7 @@ var ThreadPrimitiveMessagesImpl = ({
2755
2905
  }) => {
2756
2906
  const messagesLength = useThread((t) => t.messages.length);
2757
2907
  if (messagesLength === 0) return null;
2758
- return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */ jsx32(ThreadMessage, { messageIndex: index, components }, index));
2908
+ return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */ jsx31(ThreadMessage, { messageIndex: index, components }, index));
2759
2909
  };
2760
2910
  ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
2761
2911
  var ThreadPrimitiveMessages = memo5(
@@ -2797,7 +2947,7 @@ var subscribeToMainThread = (runtime, callback) => {
2797
2947
  };
2798
2948
 
2799
2949
  // src/runtimes/local/useLocalRuntime.tsx
2800
- import { useInsertionEffect, useMemo as useMemo8, useState as useState12 } from "react";
2950
+ import { useInsertionEffect, useMemo as useMemo11, useState as useState11 } from "react";
2801
2951
 
2802
2952
  // src/runtimes/core/BaseAssistantRuntimeCore.tsx
2803
2953
  var BaseAssistantRuntimeCore = class {
@@ -2839,6 +2989,7 @@ __export(internal_exports, {
2839
2989
  });
2840
2990
 
2841
2991
  // src/runtimes/composer/BaseComposerRuntimeCore.tsx
2992
+ var isAttachmentComplete = (a) => a.status.type === "complete";
2842
2993
  var BaseComposerRuntimeCore = class {
2843
2994
  isEditing = true;
2844
2995
  attachmentAccept = "*";
@@ -2868,9 +3019,14 @@ var BaseComposerRuntimeCore = class {
2868
3019
  }
2869
3020
  async send() {
2870
3021
  const attachments = this._attachmentAdapter ? await Promise.all(
2871
- this.attachments.map(
2872
- async (a) => await this._attachmentAdapter.send(a)
2873
- )
3022
+ this.attachments.map(async (a) => {
3023
+ if (isAttachmentComplete(a)) return a;
3024
+ const result = await this._attachmentAdapter.send(a);
3025
+ if (result.status?.type !== "complete") {
3026
+ result.status = { type: "complete" };
3027
+ }
3028
+ return result;
3029
+ })
2874
3030
  ) : [];
2875
3031
  const message = {
2876
3032
  role: "user",
@@ -2893,6 +3049,9 @@ var BaseComposerRuntimeCore = class {
2893
3049
  if (!this._attachmentAdapter)
2894
3050
  throw new Error("Attachments are not supported");
2895
3051
  const attachment = await this._attachmentAdapter.add({ file });
3052
+ if (attachment.status === void 0) {
3053
+ attachment.status = { type: "requires-action", reason: "composer-send" };
3054
+ }
2896
3055
  this._attachments = [...this._attachments, attachment];
2897
3056
  this.notifySubscribers();
2898
3057
  }
@@ -2927,6 +3086,9 @@ var DefaultThreadComposerRuntimeCore = class extends BaseComposerRuntimeCore {
2927
3086
  get canCancel() {
2928
3087
  return this._canCancel;
2929
3088
  }
3089
+ get attachments() {
3090
+ return super.attachments;
3091
+ }
2930
3092
  connect() {
2931
3093
  return this.runtime.subscribe(() => {
2932
3094
  if (this.canCancel !== this.runtime.capabilities.cancel) {
@@ -3220,7 +3382,7 @@ import {
3220
3382
  forwardRef as forwardRef19
3221
3383
  } from "react";
3222
3384
  import classNames from "classnames";
3223
- import { jsx as jsx33 } from "react/jsx-runtime";
3385
+ import { jsx as jsx32 } from "react/jsx-runtime";
3224
3386
  var withDefaultProps = ({
3225
3387
  className,
3226
3388
  ...defaultProps
@@ -3236,7 +3398,7 @@ var withDefaults = (Component, defaultProps) => {
3236
3398
  const WithDefaults = forwardRef19(
3237
3399
  (props, ref) => {
3238
3400
  const ComponentAsAny = Component;
3239
- return /* @__PURE__ */ jsx33(ComponentAsAny, { ...getProps(props), ref });
3401
+ return /* @__PURE__ */ jsx32(ComponentAsAny, { ...getProps(props), ref });
3240
3402
  }
3241
3403
  );
3242
3404
  WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
@@ -3244,9 +3406,9 @@ var withDefaults = (Component, defaultProps) => {
3244
3406
  };
3245
3407
 
3246
3408
  // src/ui/base/tooltip.tsx
3247
- import { jsx as jsx34 } from "react/jsx-runtime";
3409
+ import { jsx as jsx33 } from "react/jsx-runtime";
3248
3410
  var Tooltip = (props) => {
3249
- return /* @__PURE__ */ jsx34(TooltipPrimitive.Provider, { children: /* @__PURE__ */ jsx34(TooltipPrimitive.Root, { ...props }) });
3411
+ return /* @__PURE__ */ jsx33(TooltipPrimitive.Provider, { children: /* @__PURE__ */ jsx33(TooltipPrimitive.Root, { ...props }) });
3250
3412
  };
3251
3413
  Tooltip.displayName = "Tooltip";
3252
3414
  var TooltipTrigger = TooltipPrimitive.Trigger;
@@ -3260,7 +3422,7 @@ TooltipContent.displayName = "TooltipContent";
3260
3422
  import { cva } from "class-variance-authority";
3261
3423
  import { Primitive as Primitive13 } from "@radix-ui/react-primitive";
3262
3424
  import { forwardRef as forwardRef20 } from "react";
3263
- import { jsx as jsx35 } from "react/jsx-runtime";
3425
+ import { jsx as jsx34 } from "react/jsx-runtime";
3264
3426
  var buttonVariants = cva("aui-button", {
3265
3427
  variants: {
3266
3428
  variant: {
@@ -3280,7 +3442,7 @@ var buttonVariants = cva("aui-button", {
3280
3442
  });
3281
3443
  var Button = forwardRef20(
3282
3444
  ({ className, variant, size, ...props }, ref) => {
3283
- return /* @__PURE__ */ jsx35(
3445
+ return /* @__PURE__ */ jsx34(
3284
3446
  Primitive13.button,
3285
3447
  {
3286
3448
  className: buttonVariants({ variant, size, className }),
@@ -3293,14 +3455,14 @@ var Button = forwardRef20(
3293
3455
  Button.displayName = "Button";
3294
3456
 
3295
3457
  // src/ui/base/tooltip-icon-button.tsx
3296
- import { jsx as jsx36, jsxs as jsxs3 } from "react/jsx-runtime";
3458
+ import { jsx as jsx35, jsxs as jsxs2 } from "react/jsx-runtime";
3297
3459
  var TooltipIconButton = forwardRef21(({ children, tooltip, side = "bottom", ...rest }, ref) => {
3298
- return /* @__PURE__ */ jsxs3(Tooltip, { children: [
3299
- /* @__PURE__ */ jsx36(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs3(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
3460
+ return /* @__PURE__ */ jsxs2(Tooltip, { children: [
3461
+ /* @__PURE__ */ jsx35(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs2(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
3300
3462
  children,
3301
- /* @__PURE__ */ jsx36("span", { className: "aui-sr-only", children: tooltip })
3463
+ /* @__PURE__ */ jsx35("span", { className: "aui-sr-only", children: tooltip })
3302
3464
  ] }) }),
3303
- /* @__PURE__ */ jsx36(TooltipContent, { side, children: tooltip })
3465
+ /* @__PURE__ */ jsx35(TooltipContent, { side, children: tooltip })
3304
3466
  ] });
3305
3467
  });
3306
3468
  TooltipIconButton.displayName = "TooltipIconButton";
@@ -3335,37 +3497,6 @@ var AssistantRuntime = class {
3335
3497
  }
3336
3498
  };
3337
3499
 
3338
- // src/api/subscribable/LazyMemoizeSubject.ts
3339
- var LazyMemoizeSubject = class extends BaseSubject {
3340
- constructor(binding) {
3341
- super();
3342
- this.binding = binding;
3343
- const state = binding.getState();
3344
- if (state === void 0)
3345
- throw new Error("Entry not available in the store");
3346
- this._previousState = state;
3347
- }
3348
- _previousStateDirty = true;
3349
- _previousState;
3350
- getState = () => {
3351
- if (!this.isConnected || this._previousStateDirty) {
3352
- const newState = this.binding.getState();
3353
- if (newState !== void 0) {
3354
- this._previousState = newState;
3355
- }
3356
- this._previousStateDirty = false;
3357
- }
3358
- return this._previousState;
3359
- };
3360
- _connect() {
3361
- const callback = () => {
3362
- this._previousStateDirty = true;
3363
- this.notifySubscribers();
3364
- };
3365
- return this.binding.subscribe(callback);
3366
- }
3367
- };
3368
-
3369
3500
  // src/api/ThreadRuntime.ts
3370
3501
  var toAppendMessage = (messages2, message) => {
3371
3502
  if (typeof message === "string") {
@@ -3393,8 +3524,7 @@ var getThreadState = (runtime) => {
3393
3524
  capabilities: runtime.capabilities,
3394
3525
  isDisabled: runtime.isDisabled,
3395
3526
  isRunning: lastMessage?.role !== "assistant" ? false : lastMessage.status.type === "running",
3396
- messages: runtime.messages,
3397
- unstable_synchronizer: runtime.unstable_synchronizer
3527
+ messages: runtime.messages
3398
3528
  });
3399
3529
  };
3400
3530
  var ThreadRuntime = class {
@@ -3444,7 +3574,7 @@ var ThreadRuntime = class {
3444
3574
  subscribe: (callback) => threadBinding.subscribe(callback)
3445
3575
  };
3446
3576
  }
3447
- composer = new ComposerRuntime(
3577
+ composer = new ThreadComposerRuntime(
3448
3578
  new NestedSubscriptionSubject({
3449
3579
  getState: () => this._threadBinding.getState().composer,
3450
3580
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -3501,13 +3631,13 @@ var ThreadRuntime = class {
3501
3631
  return this._threadBinding.getState().submitFeedback(options);
3502
3632
  }
3503
3633
  /**
3504
- * @deprecated This is a temporary API. This will be removed in 0.6.0.
3634
+ * @deprecated Use `getMesssageById(id).unstable_getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
3505
3635
  */
3506
3636
  getEditComposer(messageId) {
3507
3637
  return this._threadBinding.getState().getEditComposer(messageId);
3508
3638
  }
3509
3639
  /**
3510
- * @deprecated This is a temporary API. This will be removed in 0.6.0.
3640
+ * @deprecated Use `getMesssageById(id).unstable_getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
3511
3641
  */
3512
3642
  beginEdit(messageId) {
3513
3643
  return this._threadBinding.getState().beginEdit(messageId);
@@ -3523,9 +3653,9 @@ var ThreadRuntime = class {
3523
3653
  return new MessageRuntime(
3524
3654
  new ShallowMemoizeSubject({
3525
3655
  getState: () => {
3526
- const messages2 = this.messages;
3656
+ const messages2 = this.getState().messages;
3527
3657
  const message = messages2[idx];
3528
- if (!message) return void 0;
3658
+ if (!message) return SKIP_UPDATE;
3529
3659
  const branches = this._threadBinding.getState().getBranches(message.id);
3530
3660
  return {
3531
3661
  ...message,
@@ -3583,6 +3713,9 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
3583
3713
  }
3584
3714
  throw new Error("Only images with URL data are supported");
3585
3715
  }
3716
+ case "file": {
3717
+ throw new Error("File content parts are not supported");
3718
+ }
3586
3719
  default: {
3587
3720
  const unhandledType = type;
3588
3721
  throw new Error(`Unknown content part type: ${unhandledType}`);
@@ -3708,7 +3841,7 @@ var streamUtils = {
3708
3841
  };
3709
3842
 
3710
3843
  // src/runtimes/edge/useEdgeRuntime.ts
3711
- import { useState as useState11 } from "react";
3844
+ import { useState as useState10 } from "react";
3712
3845
 
3713
3846
  // src/runtimes/edge/streams/assistantDecoderStream.ts
3714
3847
  function assistantDecoderStream() {
@@ -3840,7 +3973,7 @@ var useEdgeRuntime = ({
3840
3973
  adapters,
3841
3974
  ...options
3842
3975
  }) => {
3843
- const [adapter] = useState11(() => new EdgeChatAdapter(options));
3976
+ const [adapter] = useState10(() => new EdgeChatAdapter(options));
3844
3977
  return useLocalRuntime(adapter, {
3845
3978
  initialMessages,
3846
3979
  maxToolRoundtrips,
@@ -4220,16 +4353,16 @@ var LocalRuntime = class extends AssistantRuntime {
4220
4353
  }
4221
4354
  };
4222
4355
  var useLocalRuntime = (adapter, options = {}) => {
4223
- const [runtime] = useState12(() => new LocalRuntimeCore(adapter, options));
4356
+ const [runtime] = useState11(() => new LocalRuntimeCore(adapter, options));
4224
4357
  useInsertionEffect(() => {
4225
4358
  runtime.thread.adapter = adapter;
4226
4359
  runtime.thread.options = options;
4227
4360
  });
4228
- return useMemo8(() => new LocalRuntime(runtime), [runtime]);
4361
+ return useMemo11(() => new LocalRuntime(runtime), [runtime]);
4229
4362
  };
4230
4363
 
4231
4364
  // src/runtimes/external-store/useExternalStoreRuntime.tsx
4232
- import { useEffect as useEffect15, useMemo as useMemo9, useState as useState13 } from "react";
4365
+ import { useEffect as useEffect14, useMemo as useMemo12, useState as useState12 } from "react";
4233
4366
 
4234
4367
  // src/runtimes/external-store/getExternalStoreMessage.tsx
4235
4368
  var symbolInnerMessage = Symbol("innerMessage");
@@ -4582,15 +4715,15 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
4582
4715
 
4583
4716
  // src/runtimes/external-store/useExternalStoreRuntime.tsx
4584
4717
  var useExternalStoreRuntime = (store) => {
4585
- const [runtime] = useState13(() => new ExternalStoreRuntimeCore(store));
4586
- useEffect15(() => {
4718
+ const [runtime] = useState12(() => new ExternalStoreRuntimeCore(store));
4719
+ useEffect14(() => {
4587
4720
  runtime.thread.store = store;
4588
4721
  });
4589
- return useMemo9(() => new AssistantRuntime(runtime, ThreadRuntime), [runtime]);
4722
+ return useMemo12(() => new AssistantRuntime(runtime, ThreadRuntime), [runtime]);
4590
4723
  };
4591
4724
 
4592
4725
  // src/runtimes/external-store/external-message-converter.tsx
4593
- import { useMemo as useMemo10 } from "react";
4726
+ import { useMemo as useMemo13 } from "react";
4594
4727
  var joinExternalMessages = (messages2) => {
4595
4728
  const assistantMessage = {
4596
4729
  role: "assistant",
@@ -4676,7 +4809,7 @@ var useExternalMessageConverter = ({
4676
4809
  messages: messages2,
4677
4810
  isRunning
4678
4811
  }) => {
4679
- const state = useMemo10(
4812
+ const state = useMemo13(
4680
4813
  () => ({
4681
4814
  callback,
4682
4815
  callbackCache: /* @__PURE__ */ new WeakMap(),
@@ -4685,7 +4818,7 @@ var useExternalMessageConverter = ({
4685
4818
  }),
4686
4819
  [callback]
4687
4820
  );
4688
- return useMemo10(() => {
4821
+ return useMemo13(() => {
4689
4822
  const callbackResults = [];
4690
4823
  for (const message of messages2) {
4691
4824
  let result = state.callbackCache.get(message);
@@ -4736,7 +4869,7 @@ var shallowArrayEqual = (a, b) => {
4736
4869
  };
4737
4870
 
4738
4871
  // src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
4739
- import { useState as useState14 } from "react";
4872
+ import { useState as useState13 } from "react";
4740
4873
 
4741
4874
  // src/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.ts
4742
4875
  var DangerousInBrowserAdapter = class {
@@ -4767,7 +4900,7 @@ var useDangerousInBrowserRuntime = ({
4767
4900
  initialMessages,
4768
4901
  ...options
4769
4902
  }) => {
4770
- const [adapter] = useState14(() => new DangerousInBrowserAdapter(options));
4903
+ const [adapter] = useState13(() => new DangerousInBrowserAdapter(options));
4771
4904
  return useLocalRuntime(adapter, { initialMessages });
4772
4905
  };
4773
4906
 
@@ -4820,12 +4953,15 @@ var SimpleImageAttachmentAdapter = class {
4820
4953
  id: state.file.name,
4821
4954
  type: "image",
4822
4955
  name: state.file.name,
4823
- file: state.file
4956
+ contentType: state.file.type,
4957
+ file: state.file,
4958
+ status: { type: "requires-action", reason: "composer-send" }
4824
4959
  };
4825
4960
  }
4826
4961
  async send(attachment) {
4827
4962
  return {
4828
4963
  ...attachment,
4964
+ status: { type: "complete" },
4829
4965
  content: [
4830
4966
  {
4831
4967
  type: "image",
@@ -4852,12 +4988,15 @@ var SimpleTextAttachmentAdapter = class {
4852
4988
  id: state.file.name,
4853
4989
  type: "document",
4854
4990
  name: state.file.name,
4855
- file: state.file
4991
+ contentType: state.file.type,
4992
+ file: state.file,
4993
+ status: { type: "requires-action", reason: "composer-send" }
4856
4994
  };
4857
4995
  }
4858
4996
  async send(attachment) {
4859
4997
  return {
4860
4998
  ...attachment,
4999
+ status: { type: "complete" },
4861
5000
  content: [
4862
5001
  {
4863
5002
  type: "text",
@@ -4940,7 +5079,14 @@ var CompositeAttachmentAdapter = class {
4940
5079
  async remove(attachment) {
4941
5080
  const adapters = this._adapters.slice();
4942
5081
  for (const adapter of adapters) {
4943
- if (fileMatchesAccept(attachment.file, adapter.accept)) {
5082
+ if (fileMatchesAccept(
5083
+ {
5084
+ name: attachment.name,
5085
+ type: attachment.contentType ?? "unknown/unknown"
5086
+ // TODO remove after 0.6.0
5087
+ },
5088
+ adapter.accept
5089
+ )) {
4944
5090
  return adapter.remove(attachment);
4945
5091
  }
4946
5092
  }
@@ -4953,7 +5099,7 @@ import {
4953
5099
  createContext as createContext7,
4954
5100
  useContext as useContext4
4955
5101
  } from "react";
4956
- import { Fragment as Fragment3, jsx as jsx37 } from "react/jsx-runtime";
5102
+ import { Fragment as Fragment3, jsx as jsx36 } from "react/jsx-runtime";
4957
5103
  var ThreadConfigContext = createContext7({});
4958
5104
  var useThreadConfig = () => {
4959
5105
  return useContext4(ThreadConfigContext);
@@ -4963,14 +5109,14 @@ var ThreadConfigProvider = ({
4963
5109
  config
4964
5110
  }) => {
4965
5111
  const hasAssistant = !!useAssistantRuntime({ optional: true });
4966
- const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */ jsx37(ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ jsx37(Fragment3, { children });
5112
+ const configProvider = config && Object.keys(config ?? {}).length > 0 ? /* @__PURE__ */ jsx36(ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ jsx36(Fragment3, { children });
4967
5113
  if (!config?.runtime) return configProvider;
4968
5114
  if (hasAssistant) {
4969
5115
  throw new Error(
4970
5116
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
4971
5117
  );
4972
5118
  }
4973
- return /* @__PURE__ */ jsx37(AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
5119
+ return /* @__PURE__ */ jsx36(AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
4974
5120
  };
4975
5121
  ThreadConfigProvider.displayName = "ThreadConfigProvider";
4976
5122
 
@@ -4985,7 +5131,7 @@ import {
4985
5131
  ThumbsDownIcon,
4986
5132
  ThumbsUpIcon
4987
5133
  } from "lucide-react";
4988
- import { Fragment as Fragment4, jsx as jsx38, jsxs as jsxs4 } from "react/jsx-runtime";
5134
+ import { Fragment as Fragment4, jsx as jsx37, jsxs as jsxs3 } from "react/jsx-runtime";
4989
5135
  var useAllowCopy = (ensureCapability = false) => {
4990
5136
  const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
4991
5137
  const copySupported = useThread((t) => t.capabilities.unstable_copy);
@@ -5019,18 +5165,18 @@ var AssistantActionBar = () => {
5019
5165
  const allowFeedbackNegative = useAllowFeedbackNegative(true);
5020
5166
  if (!allowCopy && !allowReload && !allowSpeak && !allowFeedbackPositive && !allowFeedbackNegative)
5021
5167
  return null;
5022
- return /* @__PURE__ */ jsxs4(
5168
+ return /* @__PURE__ */ jsxs3(
5023
5169
  AssistantActionBarRoot,
5024
5170
  {
5025
5171
  hideWhenRunning: true,
5026
5172
  autohide: "not-last",
5027
5173
  autohideFloat: "single-branch",
5028
5174
  children: [
5029
- allowSpeak && /* @__PURE__ */ jsx38(AssistantActionBarSpeechControl, {}),
5030
- allowCopy && /* @__PURE__ */ jsx38(AssistantActionBarCopy, {}),
5031
- allowReload && /* @__PURE__ */ jsx38(AssistantActionBarReload, {}),
5032
- allowFeedbackPositive && /* @__PURE__ */ jsx38(AssistantActionBarFeedbackPositive, {}),
5033
- allowFeedbackNegative && /* @__PURE__ */ jsx38(AssistantActionBarFeedbackNegative, {})
5175
+ allowSpeak && /* @__PURE__ */ jsx37(AssistantActionBarSpeechControl, {}),
5176
+ allowCopy && /* @__PURE__ */ jsx37(AssistantActionBarCopy, {}),
5177
+ allowReload && /* @__PURE__ */ jsx37(AssistantActionBarReload, {}),
5178
+ allowFeedbackPositive && /* @__PURE__ */ jsx37(AssistantActionBarFeedbackPositive, {}),
5179
+ allowFeedbackNegative && /* @__PURE__ */ jsx37(AssistantActionBarFeedbackNegative, {})
5034
5180
  ]
5035
5181
  }
5036
5182
  );
@@ -5046,16 +5192,16 @@ var AssistantActionBarCopy = forwardRef22((props, ref) => {
5046
5192
  assistantMessage: { copy: { tooltip = "Copy" } = {} } = {}
5047
5193
  } = {}
5048
5194
  } = useThreadConfig();
5049
- return /* @__PURE__ */ jsx38(actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsxs4(Fragment4, { children: [
5050
- /* @__PURE__ */ jsx38(message_exports.If, { copied: true, children: /* @__PURE__ */ jsx38(CheckIcon, {}) }),
5051
- /* @__PURE__ */ jsx38(message_exports.If, { copied: false, children: /* @__PURE__ */ jsx38(CopyIcon, {}) })
5195
+ return /* @__PURE__ */ jsx37(actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ jsx37(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsxs3(Fragment4, { children: [
5196
+ /* @__PURE__ */ jsx37(message_exports.If, { copied: true, children: /* @__PURE__ */ jsx37(CheckIcon, {}) }),
5197
+ /* @__PURE__ */ jsx37(message_exports.If, { copied: false, children: /* @__PURE__ */ jsx37(CopyIcon, {}) })
5052
5198
  ] }) }) });
5053
5199
  });
5054
5200
  AssistantActionBarCopy.displayName = "AssistantActionBarCopy";
5055
5201
  var AssistantActionBarSpeechControl = () => {
5056
- return /* @__PURE__ */ jsxs4(Fragment4, { children: [
5057
- /* @__PURE__ */ jsx38(message_exports.If, { speaking: false, children: /* @__PURE__ */ jsx38(AssistantActionBarSpeak, {}) }),
5058
- /* @__PURE__ */ jsx38(message_exports.If, { speaking: true, children: /* @__PURE__ */ jsx38(AssistantActionBarStopSpeaking, {}) })
5202
+ return /* @__PURE__ */ jsxs3(Fragment4, { children: [
5203
+ /* @__PURE__ */ jsx37(message_exports.If, { speaking: false, children: /* @__PURE__ */ jsx37(AssistantActionBarSpeak, {}) }),
5204
+ /* @__PURE__ */ jsx37(message_exports.If, { speaking: true, children: /* @__PURE__ */ jsx37(AssistantActionBarStopSpeaking, {}) })
5059
5205
  ] });
5060
5206
  };
5061
5207
  var AssistantActionBarSpeak = forwardRef22((props, ref) => {
@@ -5065,7 +5211,7 @@ var AssistantActionBarSpeak = forwardRef22((props, ref) => {
5065
5211
  } = {}
5066
5212
  } = useThreadConfig();
5067
5213
  const allowSpeak = useAllowSpeak();
5068
- return /* @__PURE__ */ jsx38(actionBar_exports.Speak, { disabled: !allowSpeak, asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(AudioLinesIcon, {}) }) });
5214
+ return /* @__PURE__ */ jsx37(actionBar_exports.Speak, { disabled: !allowSpeak, asChild: true, children: /* @__PURE__ */ jsx37(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(AudioLinesIcon, {}) }) });
5069
5215
  });
5070
5216
  AssistantActionBarSpeak.displayName = "AssistantActionBarSpeak";
5071
5217
  var AssistantActionBarStopSpeaking = forwardRef22((props, ref) => {
@@ -5077,7 +5223,7 @@ var AssistantActionBarStopSpeaking = forwardRef22((props, ref) => {
5077
5223
  } = {}
5078
5224
  } = useThreadConfig();
5079
5225
  const allowSpeak = useAllowSpeak();
5080
- return /* @__PURE__ */ jsx38(actionBar_exports.StopSpeaking, { disabled: !allowSpeak, asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip: stopTooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(StopCircleIcon, {}) }) });
5226
+ return /* @__PURE__ */ jsx37(actionBar_exports.StopSpeaking, { disabled: !allowSpeak, asChild: true, children: /* @__PURE__ */ jsx37(TooltipIconButton, { tooltip: stopTooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(StopCircleIcon, {}) }) });
5081
5227
  });
5082
5228
  AssistantActionBarStopSpeaking.displayName = "AssistantActionBarStopSpeaking";
5083
5229
  var AssistantActionBarReload = forwardRef22((props, ref) => {
@@ -5087,7 +5233,7 @@ var AssistantActionBarReload = forwardRef22((props, ref) => {
5087
5233
  } = {}
5088
5234
  } = useThreadConfig();
5089
5235
  const allowReload = useAllowReload();
5090
- return /* @__PURE__ */ jsx38(actionBar_exports.Reload, { disabled: !allowReload, asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(RefreshCwIcon, {}) }) });
5236
+ return /* @__PURE__ */ jsx37(actionBar_exports.Reload, { disabled: !allowReload, asChild: true, children: /* @__PURE__ */ jsx37(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(RefreshCwIcon, {}) }) });
5091
5237
  });
5092
5238
  AssistantActionBarReload.displayName = "AssistantActionBarReload";
5093
5239
  var AssistantActionBarFeedbackPositive = forwardRef22((props, ref) => {
@@ -5099,13 +5245,13 @@ var AssistantActionBarFeedbackPositive = forwardRef22((props, ref) => {
5099
5245
  } = {}
5100
5246
  } = useThreadConfig();
5101
5247
  const allowFeedbackPositive = useAllowFeedbackPositive();
5102
- return /* @__PURE__ */ jsx38(
5248
+ return /* @__PURE__ */ jsx37(
5103
5249
  actionBar_exports.FeedbackPositive,
5104
5250
  {
5105
5251
  disabled: !allowFeedbackPositive,
5106
5252
  className: "aui-assistant-action-bar-feedback-positive",
5107
5253
  asChild: true,
5108
- children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(ThumbsUpIcon, {}) })
5254
+ children: /* @__PURE__ */ jsx37(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(ThumbsUpIcon, {}) })
5109
5255
  }
5110
5256
  );
5111
5257
  });
@@ -5119,13 +5265,13 @@ var AssistantActionBarFeedbackNegative = forwardRef22((props, ref) => {
5119
5265
  } = {}
5120
5266
  } = useThreadConfig();
5121
5267
  const allowFeedbackNegative = useAllowFeedbackNegative();
5122
- return /* @__PURE__ */ jsx38(
5268
+ return /* @__PURE__ */ jsx37(
5123
5269
  actionBar_exports.FeedbackNegative,
5124
5270
  {
5125
5271
  disabled: !allowFeedbackNegative,
5126
5272
  className: "aui-assistant-action-bar-feedback-negative",
5127
5273
  asChild: true,
5128
- children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(ThumbsDownIcon, {}) })
5274
+ children: /* @__PURE__ */ jsx37(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx37(ThumbsDownIcon, {}) })
5129
5275
  }
5130
5276
  );
5131
5277
  });
@@ -5146,24 +5292,24 @@ var assistant_action_bar_default = Object.assign(
5146
5292
  );
5147
5293
 
5148
5294
  // src/ui/assistant-message.tsx
5149
- import { forwardRef as forwardRef24, useMemo as useMemo11 } from "react";
5295
+ import { forwardRef as forwardRef24, useMemo as useMemo14 } from "react";
5150
5296
 
5151
5297
  // src/ui/branch-picker.tsx
5152
5298
  import { forwardRef as forwardRef23 } from "react";
5153
5299
  import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
5154
- import { jsx as jsx39, jsxs as jsxs5 } from "react/jsx-runtime";
5300
+ import { jsx as jsx38, jsxs as jsxs4 } from "react/jsx-runtime";
5155
5301
  var useAllowBranchPicker = (ensureCapability = false) => {
5156
5302
  const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
5157
5303
  const branchPickerSupported = useThread((t) => t.capabilities.edit);
5158
5304
  return allowBranchPicker && (!ensureCapability || branchPickerSupported);
5159
5305
  };
5160
5306
  var BranchPicker = () => {
5161
- const allowBranchPicker = useAllowBranchPicker();
5307
+ const allowBranchPicker = useAllowBranchPicker(true);
5162
5308
  if (!allowBranchPicker) return null;
5163
- return /* @__PURE__ */ jsxs5(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
5164
- /* @__PURE__ */ jsx39(BranchPickerPrevious2, {}),
5165
- /* @__PURE__ */ jsx39(BranchPickerState, {}),
5166
- /* @__PURE__ */ jsx39(BranchPickerNext, {})
5309
+ return /* @__PURE__ */ jsxs4(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
5310
+ /* @__PURE__ */ jsx38(BranchPickerPrevious2, {}),
5311
+ /* @__PURE__ */ jsx38(BranchPickerState, {}),
5312
+ /* @__PURE__ */ jsx38(BranchPickerNext, {})
5167
5313
  ] });
5168
5314
  };
5169
5315
  BranchPicker.displayName = "BranchPicker";
@@ -5178,17 +5324,17 @@ var BranchPickerPrevious2 = forwardRef23((props, ref) => {
5178
5324
  } = {}
5179
5325
  } = useThreadConfig();
5180
5326
  const allowBranchPicker = useAllowBranchPicker();
5181
- return /* @__PURE__ */ jsx39(branchPicker_exports.Previous, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ jsx39(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx39(ChevronLeftIcon, {}) }) });
5327
+ return /* @__PURE__ */ jsx38(branchPicker_exports.Previous, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(ChevronLeftIcon, {}) }) });
5182
5328
  });
5183
5329
  BranchPickerPrevious2.displayName = "BranchPickerPrevious";
5184
5330
  var BranchPickerStateWrapper = withDefaults("span", {
5185
5331
  className: "aui-branch-picker-state"
5186
5332
  });
5187
5333
  var BranchPickerState = forwardRef23((props, ref) => {
5188
- return /* @__PURE__ */ jsxs5(BranchPickerStateWrapper, { ...props, ref, children: [
5189
- /* @__PURE__ */ jsx39(branchPicker_exports.Number, {}),
5334
+ return /* @__PURE__ */ jsxs4(BranchPickerStateWrapper, { ...props, ref, children: [
5335
+ /* @__PURE__ */ jsx38(branchPicker_exports.Number, {}),
5190
5336
  " / ",
5191
- /* @__PURE__ */ jsx39(branchPicker_exports.Count, {})
5337
+ /* @__PURE__ */ jsx38(branchPicker_exports.Count, {})
5192
5338
  ] });
5193
5339
  });
5194
5340
  BranchPickerState.displayName = "BranchPickerState";
@@ -5197,7 +5343,7 @@ var BranchPickerNext = forwardRef23((props, ref) => {
5197
5343
  strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {}
5198
5344
  } = useThreadConfig();
5199
5345
  const allowBranchPicker = useAllowBranchPicker();
5200
- return /* @__PURE__ */ jsx39(branchPicker_exports.Next, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ jsx39(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx39(ChevronRightIcon, {}) }) });
5346
+ return /* @__PURE__ */ jsx38(branchPicker_exports.Next, { disabled: !allowBranchPicker, asChild: true, children: /* @__PURE__ */ jsx38(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx38(ChevronRightIcon, {}) }) });
5201
5347
  });
5202
5348
  BranchPickerNext.displayName = "BranchPickerNext";
5203
5349
  var exports2 = {
@@ -5209,12 +5355,12 @@ var branch_picker_default = Object.assign(BranchPicker, exports2);
5209
5355
 
5210
5356
  // src/ui/base/avatar.tsx
5211
5357
  import * as AvatarPrimitive from "@radix-ui/react-avatar";
5212
- import { jsx as jsx40, jsxs as jsxs6 } from "react/jsx-runtime";
5358
+ import { jsx as jsx39, jsxs as jsxs5 } from "react/jsx-runtime";
5213
5359
  var Avatar = ({ src, alt, fallback }) => {
5214
5360
  if (src == null && fallback == null) return null;
5215
- return /* @__PURE__ */ jsxs6(AvatarRoot, { children: [
5216
- src != null && /* @__PURE__ */ jsx40(AvatarImage, { src, alt }),
5217
- fallback != null && /* @__PURE__ */ jsx40(AvatarFallback, { children: fallback })
5361
+ return /* @__PURE__ */ jsxs5(AvatarRoot, { children: [
5362
+ src != null && /* @__PURE__ */ jsx39(AvatarImage, { src, alt }),
5363
+ fallback != null && /* @__PURE__ */ jsx39(AvatarFallback, { children: fallback })
5218
5364
  ] });
5219
5365
  };
5220
5366
  Avatar.displayName = "Avatar";
@@ -5233,10 +5379,10 @@ AvatarFallback.displayName = "AvatarFallback";
5233
5379
 
5234
5380
  // src/ui/content-part.tsx
5235
5381
  import classNames2 from "classnames";
5236
- import { jsx as jsx41 } from "react/jsx-runtime";
5382
+ import { jsx as jsx40 } from "react/jsx-runtime";
5237
5383
  var Text = () => {
5238
5384
  const status = useSmoothStatus();
5239
- return /* @__PURE__ */ jsx41(
5385
+ return /* @__PURE__ */ jsx40(
5240
5386
  contentPart_exports.Text,
5241
5387
  {
5242
5388
  className: classNames2(
@@ -5251,19 +5397,19 @@ var exports3 = { Text: withSmoothContextProvider(Text) };
5251
5397
  var content_part_default = exports3;
5252
5398
 
5253
5399
  // src/ui/assistant-message.tsx
5254
- import { jsx as jsx42, jsxs as jsxs7 } from "react/jsx-runtime";
5400
+ import { jsx as jsx41, jsxs as jsxs6 } from "react/jsx-runtime";
5255
5401
  var AssistantMessage = () => {
5256
- return /* @__PURE__ */ jsxs7(AssistantMessageRoot, { children: [
5257
- /* @__PURE__ */ jsx42(AssistantMessageAvatar, {}),
5258
- /* @__PURE__ */ jsx42(AssistantMessageContent, {}),
5259
- /* @__PURE__ */ jsx42(branch_picker_default, {}),
5260
- /* @__PURE__ */ jsx42(assistant_action_bar_default, {})
5402
+ return /* @__PURE__ */ jsxs6(AssistantMessageRoot, { children: [
5403
+ /* @__PURE__ */ jsx41(AssistantMessageAvatar, {}),
5404
+ /* @__PURE__ */ jsx41(AssistantMessageContent, {}),
5405
+ /* @__PURE__ */ jsx41(branch_picker_default, {}),
5406
+ /* @__PURE__ */ jsx41(assistant_action_bar_default, {})
5261
5407
  ] });
5262
5408
  };
5263
5409
  AssistantMessage.displayName = "AssistantMessage";
5264
5410
  var AssistantMessageAvatar = () => {
5265
5411
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
5266
- return /* @__PURE__ */ jsx42(Avatar, { ...avatar });
5412
+ return /* @__PURE__ */ jsx41(Avatar, { ...avatar });
5267
5413
  };
5268
5414
  var AssistantMessageRoot = withDefaults(message_exports.Root, {
5269
5415
  className: "aui-assistant-message-root"
@@ -5274,7 +5420,7 @@ var AssistantMessageContentWrapper = withDefaults("div", {
5274
5420
  });
5275
5421
  var AssistantMessageContent = forwardRef24(({ components: componentsProp, ...rest }, ref) => {
5276
5422
  const { tools, assistantMessage: { components = {} } = {} } = useThreadConfig();
5277
- const toolsComponents = useMemo11(
5423
+ const toolsComponents = useMemo14(
5278
5424
  () => ({
5279
5425
  by_name: !tools ? void 0 : Object.fromEntries(
5280
5426
  tools.map((t) => [
@@ -5287,7 +5433,7 @@ var AssistantMessageContent = forwardRef24(({ components: componentsProp, ...res
5287
5433
  // eslint-disable-next-line react-hooks/exhaustive-deps
5288
5434
  [...tools ?? [], components.ToolFallback]
5289
5435
  );
5290
- return /* @__PURE__ */ jsx42(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ jsx42(
5436
+ return /* @__PURE__ */ jsx41(AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ jsx41(
5291
5437
  message_exports.Content,
5292
5438
  {
5293
5439
  components: {
@@ -5322,9 +5468,9 @@ import { forwardRef as forwardRef26 } from "react";
5322
5468
  import { PaperclipIcon, SendHorizontalIcon } from "lucide-react";
5323
5469
 
5324
5470
  // src/ui/base/CircleStopIcon.tsx
5325
- import { jsx as jsx43 } from "react/jsx-runtime";
5471
+ import { jsx as jsx42 } from "react/jsx-runtime";
5326
5472
  var CircleStopIcon = () => {
5327
- return /* @__PURE__ */ jsx43(
5473
+ return /* @__PURE__ */ jsx42(
5328
5474
  "svg",
5329
5475
  {
5330
5476
  xmlns: "http://www.w3.org/2000/svg",
@@ -5332,7 +5478,7 @@ var CircleStopIcon = () => {
5332
5478
  fill: "currentColor",
5333
5479
  width: "16",
5334
5480
  height: "16",
5335
- children: /* @__PURE__ */ jsx43("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
5481
+ children: /* @__PURE__ */ jsx42("rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
5336
5482
  }
5337
5483
  );
5338
5484
  };
@@ -5341,17 +5487,17 @@ CircleStopIcon.displayName = "CircleStopIcon";
5341
5487
  // src/ui/composer-attachment.tsx
5342
5488
  import { forwardRef as forwardRef25 } from "react";
5343
5489
  import { CircleXIcon } from "lucide-react";
5344
- import { jsx as jsx44, jsxs as jsxs8 } from "react/jsx-runtime";
5490
+ import { jsx as jsx43, jsxs as jsxs7 } from "react/jsx-runtime";
5345
5491
  var ComposerAttachmentRoot = withDefaults("div", {
5346
5492
  className: "aui-composer-attachment-root"
5347
5493
  });
5348
5494
  ComposerAttachmentRoot.displayName = "ComposerAttachmentRoot";
5349
5495
  var ComposerAttachment2 = () => {
5350
- const attachment = useComposerAttachment((a) => a.attachment);
5351
- return /* @__PURE__ */ jsxs8(ComposerAttachmentRoot, { children: [
5496
+ const attachment = useThreadComposerAttachment((a) => a.attachment);
5497
+ return /* @__PURE__ */ jsxs7(ComposerAttachmentRoot, { children: [
5352
5498
  ".",
5353
5499
  attachment.name.split(".").pop(),
5354
- /* @__PURE__ */ jsx44(ComposerAttachmentRemove, {})
5500
+ /* @__PURE__ */ jsx43(ComposerAttachmentRemove, {})
5355
5501
  ] });
5356
5502
  };
5357
5503
  ComposerAttachment2.displayName = "ComposerAttachment";
@@ -5361,12 +5507,11 @@ var ComposerAttachmentRemove = forwardRef25((props, ref) => {
5361
5507
  composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
5362
5508
  } = {}
5363
5509
  } = useThreadConfig();
5364
- const composerStore = useThreadComposerStore();
5365
- const attachmentStore = useAttachmentStore();
5510
+ const attachmentRuntime = useAttachmentRuntime();
5366
5511
  const handleRemoveAttachment = () => {
5367
- composerStore.getState().removeAttachment(attachmentStore.getState().attachment.id);
5512
+ attachmentRuntime.remove();
5368
5513
  };
5369
- return /* @__PURE__ */ jsx44(
5514
+ return /* @__PURE__ */ jsx43(
5370
5515
  TooltipIconButton,
5371
5516
  {
5372
5517
  tooltip,
@@ -5375,7 +5520,7 @@ var ComposerAttachmentRemove = forwardRef25((props, ref) => {
5375
5520
  ...props,
5376
5521
  onClick: handleRemoveAttachment,
5377
5522
  ref,
5378
- children: props.children ?? /* @__PURE__ */ jsx44(CircleXIcon, {})
5523
+ children: props.children ?? /* @__PURE__ */ jsx43(CircleXIcon, {})
5379
5524
  }
5380
5525
  );
5381
5526
  });
@@ -5390,7 +5535,7 @@ var composer_attachment_default = Object.assign(
5390
5535
  );
5391
5536
 
5392
5537
  // src/ui/composer.tsx
5393
- import { Fragment as Fragment5, jsx as jsx45, jsxs as jsxs9 } from "react/jsx-runtime";
5538
+ import { Fragment as Fragment5, jsx as jsx44, jsxs as jsxs8 } from "react/jsx-runtime";
5394
5539
  var useAllowAttachments = (ensureCapability = false) => {
5395
5540
  const { composer: { allowAttachments = true } = {} } = useThreadConfig();
5396
5541
  const attachmentsSupported = useThread((t) => t.capabilities.attachments);
@@ -5398,11 +5543,11 @@ var useAllowAttachments = (ensureCapability = false) => {
5398
5543
  };
5399
5544
  var Composer = () => {
5400
5545
  const allowAttachments = useAllowAttachments(true);
5401
- return /* @__PURE__ */ jsxs9(ComposerRoot, { children: [
5402
- allowAttachments && /* @__PURE__ */ jsx45(ComposerAttachments, {}),
5403
- allowAttachments && /* @__PURE__ */ jsx45(ComposerAddAttachment, {}),
5404
- /* @__PURE__ */ jsx45(ComposerInput, { autoFocus: true }),
5405
- /* @__PURE__ */ jsx45(ComposerAction, {})
5546
+ return /* @__PURE__ */ jsxs8(ComposerRoot, { children: [
5547
+ allowAttachments && /* @__PURE__ */ jsx44(ComposerAttachments, {}),
5548
+ allowAttachments && /* @__PURE__ */ jsx44(ComposerAddAttachment, {}),
5549
+ /* @__PURE__ */ jsx44(ComposerInput, { autoFocus: true }),
5550
+ /* @__PURE__ */ jsx44(ComposerAction, {})
5406
5551
  ] });
5407
5552
  };
5408
5553
  Composer.displayName = "Composer";
@@ -5422,7 +5567,7 @@ var ComposerInput = forwardRef26(
5422
5567
  composer: { input: { placeholder = "Write a message..." } = {} } = {}
5423
5568
  } = {}
5424
5569
  } = useThreadConfig();
5425
- return /* @__PURE__ */ jsx45(ComposerInputStyled, { placeholder, ...props, ref });
5570
+ return /* @__PURE__ */ jsx44(ComposerInputStyled, { placeholder, ...props, ref });
5426
5571
  }
5427
5572
  );
5428
5573
  ComposerInput.displayName = "ComposerInput";
@@ -5430,7 +5575,7 @@ var ComposerAttachmentsContainer = withDefaults("div", {
5430
5575
  className: "aui-composer-attachments"
5431
5576
  });
5432
5577
  var ComposerAttachments = ({ components }) => {
5433
- return /* @__PURE__ */ jsx45(ComposerAttachmentsContainer, { children: /* @__PURE__ */ jsx45(
5578
+ return /* @__PURE__ */ jsx44(ComposerAttachmentsContainer, { children: /* @__PURE__ */ jsx44(
5434
5579
  composer_exports.Attachments,
5435
5580
  {
5436
5581
  components: {
@@ -5451,14 +5596,14 @@ var ComposerAddAttachment = forwardRef26((props, ref) => {
5451
5596
  } = {}
5452
5597
  } = useThreadConfig();
5453
5598
  const allowAttachments = useAllowAttachments();
5454
- return /* @__PURE__ */ jsx45(composer_exports.AddAttachment, { disabled: !allowAttachments, asChild: true, children: /* @__PURE__ */ jsx45(
5599
+ return /* @__PURE__ */ jsx44(composer_exports.AddAttachment, { disabled: !allowAttachments, asChild: true, children: /* @__PURE__ */ jsx44(
5455
5600
  ComposerAttachButton,
5456
5601
  {
5457
5602
  tooltip,
5458
5603
  variant: "ghost",
5459
5604
  ...props,
5460
5605
  ref,
5461
- children: props.children ?? /* @__PURE__ */ jsx45(PaperclipIcon, {})
5606
+ children: props.children ?? /* @__PURE__ */ jsx44(PaperclipIcon, {})
5462
5607
  }
5463
5608
  ) });
5464
5609
  });
@@ -5469,10 +5614,10 @@ var useAllowCancel = () => {
5469
5614
  };
5470
5615
  var ComposerAction = () => {
5471
5616
  const allowCancel = useAllowCancel();
5472
- if (!allowCancel) return /* @__PURE__ */ jsx45(ComposerSend, {});
5473
- return /* @__PURE__ */ jsxs9(Fragment5, { children: [
5474
- /* @__PURE__ */ jsx45(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx45(ComposerSend, {}) }),
5475
- /* @__PURE__ */ jsx45(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx45(ComposerCancel, {}) })
5617
+ if (!allowCancel) return /* @__PURE__ */ jsx44(ComposerSend, {});
5618
+ return /* @__PURE__ */ jsxs8(Fragment5, { children: [
5619
+ /* @__PURE__ */ jsx44(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx44(ComposerSend, {}) }),
5620
+ /* @__PURE__ */ jsx44(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx44(ComposerCancel, {}) })
5476
5621
  ] });
5477
5622
  };
5478
5623
  ComposerAction.displayName = "ComposerAction";
@@ -5484,7 +5629,7 @@ var ComposerSend = forwardRef26((props, ref) => {
5484
5629
  const {
5485
5630
  strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
5486
5631
  } = useThreadConfig();
5487
- return /* @__PURE__ */ jsx45(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx45(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx45(SendHorizontalIcon, {}) }) });
5632
+ return /* @__PURE__ */ jsx44(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx44(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx44(SendHorizontalIcon, {}) }) });
5488
5633
  });
5489
5634
  ComposerSend.displayName = "ComposerSend";
5490
5635
  var ComposerCancelButton = withDefaults(TooltipIconButton, {
@@ -5495,7 +5640,7 @@ var ComposerCancel = forwardRef26((props, ref) => {
5495
5640
  const {
5496
5641
  strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
5497
5642
  } = useThreadConfig();
5498
- return /* @__PURE__ */ jsx45(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx45(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx45(CircleStopIcon, {}) }) });
5643
+ return /* @__PURE__ */ jsx44(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx44(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx44(CircleStopIcon, {}) }) });
5499
5644
  });
5500
5645
  ComposerCancel.displayName = "ComposerCancel";
5501
5646
  var exports6 = {
@@ -5511,14 +5656,14 @@ var composer_default = Object.assign(Composer, exports6);
5511
5656
 
5512
5657
  // src/ui/thread-welcome.tsx
5513
5658
  import { forwardRef as forwardRef27 } from "react";
5514
- import { jsx as jsx46, jsxs as jsxs10 } from "react/jsx-runtime";
5659
+ import { jsx as jsx45, jsxs as jsxs9 } from "react/jsx-runtime";
5515
5660
  var ThreadWelcome = () => {
5516
- return /* @__PURE__ */ jsxs10(ThreadWelcomeRoot, { children: [
5517
- /* @__PURE__ */ jsxs10(ThreadWelcomeCenter, { children: [
5518
- /* @__PURE__ */ jsx46(ThreadWelcomeAvatar, {}),
5519
- /* @__PURE__ */ jsx46(ThreadWelcomeMessage, {})
5661
+ return /* @__PURE__ */ jsxs9(ThreadWelcomeRoot, { children: [
5662
+ /* @__PURE__ */ jsxs9(ThreadWelcomeCenter, { children: [
5663
+ /* @__PURE__ */ jsx45(ThreadWelcomeAvatar, {}),
5664
+ /* @__PURE__ */ jsx45(ThreadWelcomeMessage, {})
5520
5665
  ] }),
5521
- /* @__PURE__ */ jsx46(ThreadWelcomeSuggestions, {})
5666
+ /* @__PURE__ */ jsx45(ThreadWelcomeSuggestions, {})
5522
5667
  ] });
5523
5668
  };
5524
5669
  ThreadWelcome.displayName = "ThreadWelcome";
@@ -5530,20 +5675,20 @@ var ThreadWelcomeCenter = withDefaults("div", {
5530
5675
  });
5531
5676
  var ThreadWelcomeRoot = forwardRef27(
5532
5677
  (props, ref) => {
5533
- return /* @__PURE__ */ jsx46(thread_exports.Empty, { children: /* @__PURE__ */ jsx46(ThreadWelcomeRootStyled, { ...props, ref }) });
5678
+ return /* @__PURE__ */ jsx45(thread_exports.Empty, { children: /* @__PURE__ */ jsx45(ThreadWelcomeRootStyled, { ...props, ref }) });
5534
5679
  }
5535
5680
  );
5536
5681
  ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
5537
5682
  var ThreadWelcomeAvatar = () => {
5538
5683
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
5539
- return /* @__PURE__ */ jsx46(Avatar, { ...avatar });
5684
+ return /* @__PURE__ */ jsx45(Avatar, { ...avatar });
5540
5685
  };
5541
5686
  var ThreadWelcomeMessageStyled = withDefaults("p", {
5542
5687
  className: "aui-thread-welcome-message"
5543
5688
  });
5544
5689
  var ThreadWelcomeMessage = forwardRef27(({ message: messageProp, ...rest }, ref) => {
5545
5690
  const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
5546
- return /* @__PURE__ */ jsx46(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
5691
+ return /* @__PURE__ */ jsx45(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
5547
5692
  });
5548
5693
  ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
5549
5694
  var ThreadWelcomeSuggestionContainer = withDefaults("div", {
@@ -5555,21 +5700,21 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
5555
5700
  var ThreadWelcomeSuggestion = ({
5556
5701
  suggestion: { text, prompt }
5557
5702
  }) => {
5558
- return /* @__PURE__ */ jsx46(
5703
+ return /* @__PURE__ */ jsx45(
5559
5704
  ThreadWelcomeSuggestionStyled,
5560
5705
  {
5561
5706
  prompt,
5562
5707
  method: "replace",
5563
5708
  autoSend: true,
5564
- children: /* @__PURE__ */ jsx46("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
5709
+ children: /* @__PURE__ */ jsx45("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
5565
5710
  }
5566
5711
  );
5567
5712
  };
5568
5713
  var ThreadWelcomeSuggestions = () => {
5569
5714
  const { welcome: { suggestions } = {} } = useThreadConfig();
5570
- return /* @__PURE__ */ jsx46(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
5715
+ return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
5571
5716
  const key = `${suggestion.prompt}-${idx}`;
5572
- return /* @__PURE__ */ jsx46(ThreadWelcomeSuggestion, { suggestion }, key);
5717
+ return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestion, { suggestion }, key);
5573
5718
  }) });
5574
5719
  };
5575
5720
  ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
@@ -5589,7 +5734,7 @@ import { forwardRef as forwardRef29 } from "react";
5589
5734
  // src/ui/user-action-bar.tsx
5590
5735
  import { forwardRef as forwardRef28 } from "react";
5591
5736
  import { PencilIcon } from "lucide-react";
5592
- import { jsx as jsx47 } from "react/jsx-runtime";
5737
+ import { jsx as jsx46 } from "react/jsx-runtime";
5593
5738
  var useAllowEdit = (ensureCapability = false) => {
5594
5739
  const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
5595
5740
  const editSupported = useThread((t) => t.capabilities.edit);
@@ -5598,7 +5743,7 @@ var useAllowEdit = (ensureCapability = false) => {
5598
5743
  var UserActionBar = () => {
5599
5744
  const allowEdit = useAllowEdit(true);
5600
5745
  if (!allowEdit) return null;
5601
- return /* @__PURE__ */ jsx47(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx47(UserActionBarEdit, {}) });
5746
+ return /* @__PURE__ */ jsx46(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx46(UserActionBarEdit, {}) });
5602
5747
  };
5603
5748
  UserActionBar.displayName = "UserActionBar";
5604
5749
  var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
@@ -5610,7 +5755,7 @@ var UserActionBarEdit = forwardRef28((props, ref) => {
5610
5755
  strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
5611
5756
  } = useThreadConfig();
5612
5757
  const allowEdit = useAllowEdit();
5613
- return /* @__PURE__ */ jsx47(actionBar_exports.Edit, { disabled: !allowEdit, asChild: true, children: /* @__PURE__ */ jsx47(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx47(PencilIcon, {}) }) });
5758
+ return /* @__PURE__ */ jsx46(actionBar_exports.Edit, { disabled: !allowEdit, asChild: true, children: /* @__PURE__ */ jsx46(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx46(PencilIcon, {}) }) });
5614
5759
  });
5615
5760
  UserActionBarEdit.displayName = "UserActionBarEdit";
5616
5761
  var exports8 = {
@@ -5620,14 +5765,14 @@ var exports8 = {
5620
5765
  var user_action_bar_default = Object.assign(UserActionBar, exports8);
5621
5766
 
5622
5767
  // src/ui/user-message-attachment.tsx
5623
- import { jsxs as jsxs11 } from "react/jsx-runtime";
5768
+ import { jsxs as jsxs10 } from "react/jsx-runtime";
5624
5769
  var UserMessageAttachmentRoot = withDefaults("div", {
5625
5770
  className: "aui-user-message-attachment-root"
5626
5771
  });
5627
5772
  UserMessageAttachmentRoot.displayName = "UserMessageAttachmentRoot";
5628
5773
  var UserMessageAttachment = () => {
5629
5774
  const attachment = useAttachment((a) => a.attachment);
5630
- return /* @__PURE__ */ jsxs11(UserMessageAttachmentRoot, { children: [
5775
+ return /* @__PURE__ */ jsxs10(UserMessageAttachmentRoot, { children: [
5631
5776
  ".",
5632
5777
  attachment.name.split(".").pop()
5633
5778
  ] });
@@ -5642,13 +5787,13 @@ var user_message_attachment_default = Object.assign(
5642
5787
  );
5643
5788
 
5644
5789
  // src/ui/user-message.tsx
5645
- import { jsx as jsx48, jsxs as jsxs12 } from "react/jsx-runtime";
5790
+ import { jsx as jsx47, jsxs as jsxs11 } from "react/jsx-runtime";
5646
5791
  var UserMessage = () => {
5647
- return /* @__PURE__ */ jsxs12(UserMessageRoot, { children: [
5648
- /* @__PURE__ */ jsx48(UserMessageAttachments, {}),
5649
- /* @__PURE__ */ jsx48(user_action_bar_default, {}),
5650
- /* @__PURE__ */ jsx48(UserMessageContent, {}),
5651
- /* @__PURE__ */ jsx48(branch_picker_default, {})
5792
+ return /* @__PURE__ */ jsxs11(UserMessageRoot, { children: [
5793
+ /* @__PURE__ */ jsx47(UserMessageAttachments, {}),
5794
+ /* @__PURE__ */ jsx47(user_action_bar_default, {}),
5795
+ /* @__PURE__ */ jsx47(UserMessageContent, {}),
5796
+ /* @__PURE__ */ jsx47(branch_picker_default, {})
5652
5797
  ] });
5653
5798
  };
5654
5799
  UserMessage.displayName = "UserMessage";
@@ -5661,7 +5806,7 @@ var UserMessageContentWrapper = withDefaults("div", {
5661
5806
  });
5662
5807
  var UserMessageContent = forwardRef29(
5663
5808
  ({ components, ...props }, ref) => {
5664
- return /* @__PURE__ */ jsx48(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx48(
5809
+ return /* @__PURE__ */ jsx47(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx47(
5665
5810
  message_exports.Content,
5666
5811
  {
5667
5812
  components: {
@@ -5679,7 +5824,7 @@ var UserMessageAttachmentsContainer = withDefaults("div", {
5679
5824
  var UserMessageAttachments = ({
5680
5825
  components
5681
5826
  }) => {
5682
- return /* @__PURE__ */ jsx48(message_exports.If, { hasAttachments: true, children: /* @__PURE__ */ jsx48(UserMessageAttachmentsContainer, { children: /* @__PURE__ */ jsx48(
5827
+ return /* @__PURE__ */ jsx47(message_exports.If, { hasAttachments: true, children: /* @__PURE__ */ jsx47(UserMessageAttachmentsContainer, { children: /* @__PURE__ */ jsx47(
5683
5828
  message_exports.Attachments,
5684
5829
  {
5685
5830
  components: {
@@ -5698,13 +5843,13 @@ var user_message_default = Object.assign(UserMessage, exports10);
5698
5843
 
5699
5844
  // src/ui/edit-composer.tsx
5700
5845
  import { forwardRef as forwardRef30 } from "react";
5701
- import { jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
5846
+ import { jsx as jsx48, jsxs as jsxs12 } from "react/jsx-runtime";
5702
5847
  var EditComposer = () => {
5703
- return /* @__PURE__ */ jsxs13(EditComposerRoot, { children: [
5704
- /* @__PURE__ */ jsx49(EditComposerInput, {}),
5705
- /* @__PURE__ */ jsxs13(EditComposerFooter, { children: [
5706
- /* @__PURE__ */ jsx49(EditComposerCancel, {}),
5707
- /* @__PURE__ */ jsx49(EditComposerSend, {})
5848
+ return /* @__PURE__ */ jsxs12(EditComposerRoot, { children: [
5849
+ /* @__PURE__ */ jsx48(EditComposerInput, {}),
5850
+ /* @__PURE__ */ jsxs12(EditComposerFooter, { children: [
5851
+ /* @__PURE__ */ jsx48(EditComposerCancel, {}),
5852
+ /* @__PURE__ */ jsx48(EditComposerSend, {})
5708
5853
  ] })
5709
5854
  ] });
5710
5855
  };
@@ -5728,7 +5873,7 @@ var EditComposerCancel = forwardRef30(
5728
5873
  editComposer: { cancel: { label = "Cancel" } = {} } = {}
5729
5874
  } = {}
5730
5875
  } = useThreadConfig();
5731
- return /* @__PURE__ */ jsx49(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx49(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
5876
+ return /* @__PURE__ */ jsx48(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx48(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
5732
5877
  }
5733
5878
  );
5734
5879
  EditComposerCancel.displayName = "EditComposerCancel";
@@ -5737,7 +5882,7 @@ var EditComposerSend = forwardRef30(
5737
5882
  const {
5738
5883
  strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
5739
5884
  } = useThreadConfig();
5740
- return /* @__PURE__ */ jsx49(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx49(Button, { ...props, ref, children: props.children ?? label }) });
5885
+ return /* @__PURE__ */ jsx48(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx48(Button, { ...props, ref, children: props.children ?? label }) });
5741
5886
  }
5742
5887
  );
5743
5888
  EditComposerSend.displayName = "EditComposerSend";
@@ -5751,14 +5896,14 @@ var exports11 = {
5751
5896
  var edit_composer_default = Object.assign(EditComposer, exports11);
5752
5897
 
5753
5898
  // src/ui/thread.tsx
5754
- import { jsx as jsx50, jsxs as jsxs14 } from "react/jsx-runtime";
5899
+ import { jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
5755
5900
  var Thread = (config) => {
5756
- return /* @__PURE__ */ jsx50(ThreadRoot, { config, children: /* @__PURE__ */ jsxs14(ThreadViewport, { children: [
5757
- /* @__PURE__ */ jsx50(thread_welcome_default, {}),
5758
- /* @__PURE__ */ jsx50(ThreadMessages, {}),
5759
- /* @__PURE__ */ jsxs14(ThreadViewportFooter, { children: [
5760
- /* @__PURE__ */ jsx50(ThreadScrollToBottom, {}),
5761
- /* @__PURE__ */ jsx50(composer_default, {})
5901
+ return /* @__PURE__ */ jsx49(ThreadRoot, { config, children: /* @__PURE__ */ jsxs13(ThreadViewport, { children: [
5902
+ /* @__PURE__ */ jsx49(thread_welcome_default, {}),
5903
+ /* @__PURE__ */ jsx49(ThreadMessages, {}),
5904
+ /* @__PURE__ */ jsxs13(ThreadViewportFooter, { children: [
5905
+ /* @__PURE__ */ jsx49(ThreadScrollToBottom, {}),
5906
+ /* @__PURE__ */ jsx49(composer_default, {})
5762
5907
  ] })
5763
5908
  ] }) });
5764
5909
  };
@@ -5767,7 +5912,7 @@ var ThreadRootStyled = withDefaults(thread_exports.Root, {
5767
5912
  });
5768
5913
  var ThreadRoot = forwardRef31(
5769
5914
  ({ config, ...props }, ref) => {
5770
- return /* @__PURE__ */ jsx50(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx50(ThreadRootStyled, { ...props, ref }) });
5915
+ return /* @__PURE__ */ jsx49(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx49(ThreadRootStyled, { ...props, ref }) });
5771
5916
  }
5772
5917
  );
5773
5918
  ThreadRoot.displayName = "ThreadRoot";
@@ -5781,7 +5926,7 @@ var ThreadViewportFooter = withDefaults("div", {
5781
5926
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
5782
5927
  var SystemMessage = () => null;
5783
5928
  var ThreadMessages = ({ components, ...rest }) => {
5784
- return /* @__PURE__ */ jsx50(
5929
+ return /* @__PURE__ */ jsx49(
5785
5930
  thread_exports.Messages,
5786
5931
  {
5787
5932
  components: {
@@ -5805,7 +5950,7 @@ var ThreadScrollToBottom = forwardRef31((props, ref) => {
5805
5950
  thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
5806
5951
  } = {}
5807
5952
  } = useThreadConfig();
5808
- return /* @__PURE__ */ jsx50(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx50(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx50(ArrowDownIcon, {}) }) });
5953
+ return /* @__PURE__ */ jsx49(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx49(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx49(ArrowDownIcon, {}) }) });
5809
5954
  });
5810
5955
  ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
5811
5956
  var exports12 = {
@@ -5818,20 +5963,20 @@ var exports12 = {
5818
5963
  var thread_default = Object.assign(Thread, exports12);
5819
5964
 
5820
5965
  // src/ui/assistant-modal.tsx
5821
- import { Fragment as Fragment6, jsx as jsx51, jsxs as jsxs15 } from "react/jsx-runtime";
5966
+ import { Fragment as Fragment6, jsx as jsx50, jsxs as jsxs14 } from "react/jsx-runtime";
5822
5967
  var AssistantModal = (config) => {
5823
- return /* @__PURE__ */ jsxs15(AssistantModalRoot, { config, children: [
5824
- /* @__PURE__ */ jsx51(AssistantModalTrigger, {}),
5825
- /* @__PURE__ */ jsx51(AssistantModalContent, { children: /* @__PURE__ */ jsx51(thread_default, {}) })
5968
+ return /* @__PURE__ */ jsxs14(AssistantModalRoot, { config, children: [
5969
+ /* @__PURE__ */ jsx50(AssistantModalTrigger, {}),
5970
+ /* @__PURE__ */ jsx50(AssistantModalContent, { children: /* @__PURE__ */ jsx50(thread_default, {}) })
5826
5971
  ] });
5827
5972
  };
5828
5973
  AssistantModal.displayName = "AssistantModal";
5829
5974
  var AssistantModalRoot = ({ config, ...props }) => {
5830
- return /* @__PURE__ */ jsx51(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx51(assistantModal_exports.Root, { ...props }) });
5975
+ return /* @__PURE__ */ jsx50(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx50(assistantModal_exports.Root, { ...props }) });
5831
5976
  };
5832
5977
  AssistantModalRoot.displayName = "AssistantModalRoot";
5833
5978
  var AssistantModalTrigger = forwardRef32((props, ref) => {
5834
- return /* @__PURE__ */ jsx51(AssistantModalAnchor, { children: /* @__PURE__ */ jsx51(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx51(AssistantModalButton, { ...props, ref }) }) });
5979
+ return /* @__PURE__ */ jsx50(AssistantModalAnchor, { children: /* @__PURE__ */ jsx50(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx50(AssistantModalButton, { ...props, ref }) }) });
5835
5980
  });
5836
5981
  AssistantModalTrigger.displayName = "AssistantModalTrigger";
5837
5982
  var AssistantModalAnchor = withDefaults(assistantModal_exports.Anchor, {
@@ -5856,7 +6001,7 @@ var AssistantModalButton = forwardRef32(({ "data-state": state, ...rest }, ref)
5856
6001
  } = {}
5857
6002
  } = useThreadConfig();
5858
6003
  const tooltip = state === "open" ? openTooltip : closedTooltip;
5859
- return /* @__PURE__ */ jsx51(
6004
+ return /* @__PURE__ */ jsx50(
5860
6005
  ModalButtonStyled,
5861
6006
  {
5862
6007
  side: "left",
@@ -5864,15 +6009,15 @@ var AssistantModalButton = forwardRef32(({ "data-state": state, ...rest }, ref)
5864
6009
  "data-state": state,
5865
6010
  ...rest,
5866
6011
  ref,
5867
- children: rest.children ?? /* @__PURE__ */ jsxs15(Fragment6, { children: [
5868
- /* @__PURE__ */ jsx51(
6012
+ children: rest.children ?? /* @__PURE__ */ jsxs14(Fragment6, { children: [
6013
+ /* @__PURE__ */ jsx50(
5869
6014
  BotIcon,
5870
6015
  {
5871
6016
  "data-state": state,
5872
6017
  className: "aui-modal-button-closed-icon"
5873
6018
  }
5874
6019
  ),
5875
- /* @__PURE__ */ jsx51(
6020
+ /* @__PURE__ */ jsx50(
5876
6021
  ChevronDownIcon,
5877
6022
  {
5878
6023
  "data-state": state,