@assistant-ui/react 0.5.67 → 0.5.68
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{edge-BDAlTCC1.d.mts → edge-BhYWMe-K.d.mts} +26 -6
- package/dist/{edge-BDAlTCC1.d.ts → edge-BhYWMe-K.d.ts} +26 -6
- package/dist/index.d.mts +153 -73
- package/dist/index.d.ts +153 -73
- package/dist/index.js +512 -367
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +588 -443
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
@@ -234,13 +234,7 @@ var ThreadRuntimeProvider = ({ children, runtime }) => {
|
|
234
234
|
useViewport
|
235
235
|
};
|
236
236
|
}, [useThread2, useThreadRuntime2, useThreadMessages2, useThreadComposer2]);
|
237
|
-
|
238
|
-
(t) => t.unstable_synchronizer
|
239
|
-
);
|
240
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadContext.Provider, { value: context, children: [
|
241
|
-
Synchronizer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Synchronizer, {}),
|
242
|
-
children
|
243
|
-
] });
|
237
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadContext.Provider, { value: context, children });
|
244
238
|
};
|
245
239
|
|
246
240
|
// src/context/providers/AssistantRuntimeProvider.tsx
|
@@ -576,11 +570,11 @@ var useActionBarCopy = ({
|
|
576
570
|
// src/primitive-hooks/actionBar/useActionBarEdit.tsx
|
577
571
|
|
578
572
|
var useActionBarEdit = () => {
|
579
|
-
const
|
580
|
-
const disabled =
|
573
|
+
const messageRuntime = useMessageRuntime();
|
574
|
+
const disabled = useEditComposer((c) => c.isEditing);
|
581
575
|
const callback = _react.useCallback.call(void 0, () => {
|
582
|
-
|
583
|
-
}, [
|
576
|
+
messageRuntime.composer.beginEdit();
|
577
|
+
}, [messageRuntime]);
|
584
578
|
if (disabled) return null;
|
585
579
|
return callback;
|
586
580
|
};
|
@@ -1589,40 +1583,204 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
1589
1583
|
};
|
1590
1584
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
1591
1585
|
|
1586
|
+
// src/api/AttachmentRuntime.ts
|
1587
|
+
var AttachmentRuntime = class {
|
1588
|
+
constructor(_core) {
|
1589
|
+
this._core = _core;
|
1590
|
+
}
|
1591
|
+
getState() {
|
1592
|
+
return this._core.getState();
|
1593
|
+
}
|
1594
|
+
subscribe(callback) {
|
1595
|
+
return this._core.subscribe(callback);
|
1596
|
+
}
|
1597
|
+
};
|
1598
|
+
var ComposerAttachmentRuntime = class extends AttachmentRuntime {
|
1599
|
+
constructor(core, _composerApi) {
|
1600
|
+
super(core);
|
1601
|
+
this._composerApi = _composerApi;
|
1602
|
+
}
|
1603
|
+
remove() {
|
1604
|
+
const core = this._composerApi.getState();
|
1605
|
+
if (!core) throw new Error("Composer is not available");
|
1606
|
+
return core.removeAttachment(this.getState().id);
|
1607
|
+
}
|
1608
|
+
};
|
1609
|
+
var ThreadComposerAttachmentRuntime = class extends ComposerAttachmentRuntime {
|
1610
|
+
get source() {
|
1611
|
+
return "thread-composer";
|
1612
|
+
}
|
1613
|
+
};
|
1614
|
+
var EditComposerAttachmentRuntime = class extends ComposerAttachmentRuntime {
|
1615
|
+
get source() {
|
1616
|
+
return "edit-composer";
|
1617
|
+
}
|
1618
|
+
};
|
1619
|
+
var MessageAttachmentRuntime = class extends AttachmentRuntime {
|
1620
|
+
get source() {
|
1621
|
+
return "message";
|
1622
|
+
}
|
1623
|
+
constructor(core) {
|
1624
|
+
super(core);
|
1625
|
+
}
|
1626
|
+
remove() {
|
1627
|
+
throw new Error("Message attachments cannot be removed");
|
1628
|
+
}
|
1629
|
+
};
|
1630
|
+
|
1631
|
+
// src/api/subscribable/BaseSubject.ts
|
1632
|
+
var BaseSubject = (_class2 = class {constructor() { _class2.prototype.__init5.call(this); }
|
1633
|
+
__init5() {this._subscriptions = /* @__PURE__ */ new Set()}
|
1634
|
+
|
1635
|
+
get isConnected() {
|
1636
|
+
return !!this._connection;
|
1637
|
+
}
|
1638
|
+
notifySubscribers() {
|
1639
|
+
for (const callback of this._subscriptions) callback();
|
1640
|
+
}
|
1641
|
+
_updateConnection() {
|
1642
|
+
if (this._subscriptions.size > 0) {
|
1643
|
+
if (this._connection) return;
|
1644
|
+
this._connection = this._connect();
|
1645
|
+
} else {
|
1646
|
+
_optionalChain([this, 'access', _16 => _16._connection, 'optionalCall', _17 => _17()]);
|
1647
|
+
this._connection = void 0;
|
1648
|
+
}
|
1649
|
+
}
|
1650
|
+
subscribe(callback) {
|
1651
|
+
this._subscriptions.add(callback);
|
1652
|
+
this._updateConnection();
|
1653
|
+
return () => {
|
1654
|
+
this._subscriptions.delete(callback);
|
1655
|
+
this._updateConnection();
|
1656
|
+
};
|
1657
|
+
}
|
1658
|
+
}, _class2);
|
1659
|
+
|
1660
|
+
// src/api/subscribable/SKIP_UPDATE.ts
|
1661
|
+
var SKIP_UPDATE = Symbol("skip-update");
|
1662
|
+
|
1663
|
+
// src/api/subscribable/LazyMemoizeSubject.ts
|
1664
|
+
var LazyMemoizeSubject = (_class3 = class extends BaseSubject {
|
1665
|
+
constructor(binding) {
|
1666
|
+
super();_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);;
|
1667
|
+
this.binding = binding;
|
1668
|
+
}
|
1669
|
+
__init6() {this._previousStateDirty = true}
|
1670
|
+
|
1671
|
+
__init7() {this.getState = () => {
|
1672
|
+
if (!this.isConnected || this._previousStateDirty) {
|
1673
|
+
const newState = this.binding.getState();
|
1674
|
+
if (newState !== SKIP_UPDATE) {
|
1675
|
+
this._previousState = newState;
|
1676
|
+
}
|
1677
|
+
this._previousStateDirty = false;
|
1678
|
+
}
|
1679
|
+
if (this._previousState === void 0)
|
1680
|
+
throw new Error("Entry not available in the store");
|
1681
|
+
return this._previousState;
|
1682
|
+
}}
|
1683
|
+
_connect() {
|
1684
|
+
const callback = () => {
|
1685
|
+
this._previousStateDirty = true;
|
1686
|
+
this.notifySubscribers();
|
1687
|
+
};
|
1688
|
+
return this.binding.subscribe(callback);
|
1689
|
+
}
|
1690
|
+
}, _class3);
|
1691
|
+
|
1692
|
+
// src/api/subscribable/shallowEqual.ts
|
1693
|
+
function shallowEqual(objA, objB) {
|
1694
|
+
if (objA === void 0 && objB === void 0) return true;
|
1695
|
+
if (objA === void 0) return false;
|
1696
|
+
if (objB === void 0) return false;
|
1697
|
+
for (const key of Object.keys(objA)) {
|
1698
|
+
const valueA = objA[key];
|
1699
|
+
const valueB = objB[key];
|
1700
|
+
if (!Object.is(valueA, valueB)) return false;
|
1701
|
+
}
|
1702
|
+
return true;
|
1703
|
+
}
|
1704
|
+
|
1705
|
+
// src/api/subscribable/ShallowMemoizeSubject.ts
|
1706
|
+
var ShallowMemoizeSubject = (_class4 = class extends BaseSubject {
|
1707
|
+
constructor(binding) {
|
1708
|
+
super();_class4.prototype.__init8.call(this);;
|
1709
|
+
this.binding = binding;
|
1710
|
+
const state = binding.getState();
|
1711
|
+
if (state === SKIP_UPDATE)
|
1712
|
+
throw new Error("Entry not available in the store");
|
1713
|
+
this._previousState = state;
|
1714
|
+
}
|
1715
|
+
|
1716
|
+
__init8() {this.getState = () => {
|
1717
|
+
if (!this.isConnected) this._syncState();
|
1718
|
+
return this._previousState;
|
1719
|
+
}}
|
1720
|
+
_syncState() {
|
1721
|
+
const state = this.binding.getState();
|
1722
|
+
if (state === SKIP_UPDATE) return false;
|
1723
|
+
if (shallowEqual(state, this._previousState)) return false;
|
1724
|
+
this._previousState = state;
|
1725
|
+
return true;
|
1726
|
+
}
|
1727
|
+
_connect() {
|
1728
|
+
const callback = () => {
|
1729
|
+
if (this._syncState()) {
|
1730
|
+
this.notifySubscribers();
|
1731
|
+
}
|
1732
|
+
};
|
1733
|
+
return this.binding.subscribe(callback);
|
1734
|
+
}
|
1735
|
+
}, _class4);
|
1736
|
+
|
1592
1737
|
// src/api/ComposerRuntime.ts
|
1593
1738
|
var METHOD_NOT_SUPPORTED = () => {
|
1594
1739
|
throw new Error("Composer is not available");
|
1595
1740
|
};
|
1596
1741
|
var EMPTY_ARRAY = Object.freeze([]);
|
1597
|
-
var getThreadComposerState = (
|
1742
|
+
var getThreadComposerState = (runtime, focus, onFocus) => {
|
1743
|
+
return Object.freeze({
|
1744
|
+
type: "thread",
|
1745
|
+
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _18 => _18.isEditing]), () => ( false)),
|
1746
|
+
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _19 => _19.canCancel]), () => ( false)),
|
1747
|
+
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _20 => _20.isEmpty]), () => ( true)),
|
1748
|
+
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _21 => _21.text]), () => ( "")),
|
1749
|
+
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _22 => _22.attachments]), () => ( EMPTY_ARRAY)),
|
1750
|
+
attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _23 => _23.attachmentAccept]), () => ( "*")),
|
1751
|
+
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _24 => _24.text]), () => ( "")),
|
1752
|
+
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _25 => _25.setText, 'access', _26 => _26.bind, 'call', _27 => _27(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1753
|
+
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _28 => _28.setText, 'access', _29 => _29.bind, 'call', _30 => _30(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1754
|
+
// edit: beginEdit,
|
1755
|
+
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _31 => _31.send, 'access', _32 => _32.bind, 'call', _33 => _33(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1756
|
+
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _34 => _34.cancel, 'access', _35 => _35.bind, 'call', _36 => _36(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1757
|
+
focus,
|
1758
|
+
onFocus,
|
1759
|
+
reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _37 => _37.reset, 'access', _38 => _38.bind, 'call', _39 => _39(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1760
|
+
addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _40 => _40.addAttachment, 'access', _41 => _41.bind, 'call', _42 => _42(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1761
|
+
removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _43 => _43.removeAttachment, 'access', _44 => _44.bind, 'call', _45 => _45(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1762
|
+
});
|
1763
|
+
};
|
1764
|
+
var getEditComposerState = (runtime, beginEdit) => {
|
1598
1765
|
return Object.freeze({
|
1599
|
-
type,
|
1600
|
-
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1601
|
-
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1602
|
-
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1603
|
-
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1604
|
-
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1605
|
-
attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1606
|
-
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1607
|
-
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1608
|
-
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1766
|
+
type: "edit",
|
1767
|
+
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _46 => _46.isEditing]), () => ( false)),
|
1768
|
+
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _47 => _47.canCancel]), () => ( false)),
|
1769
|
+
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _48 => _48.isEmpty]), () => ( true)),
|
1770
|
+
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _49 => _49.text]), () => ( "")),
|
1771
|
+
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _50 => _50.attachments]), () => ( EMPTY_ARRAY)),
|
1772
|
+
attachmentAccept: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _51 => _51.attachmentAccept]), () => ( "*")),
|
1773
|
+
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _52 => _52.text]), () => ( "")),
|
1774
|
+
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _53 => _53.setText, 'access', _54 => _54.bind, 'call', _55 => _55(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1775
|
+
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _56 => _56.setText, 'access', _57 => _57.bind, 'call', _58 => _58(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1609
1776
|
edit: beginEdit,
|
1610
|
-
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1611
|
-
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1612
|
-
focus: _nullishCoalesce(focus, () => ( METHOD_NOT_SUPPORTED)),
|
1613
|
-
onFocus: _nullishCoalesce(onFocus, () => ( METHOD_NOT_SUPPORTED)),
|
1614
|
-
reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _35 => _35.reset, 'access', _36 => _36.bind, 'call', _37 => _37(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1615
|
-
addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _38 => _38.addAttachment, 'access', _39 => _39.bind, 'call', _40 => _40(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1616
|
-
removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _41 => _41.removeAttachment, 'access', _42 => _42.bind, 'call', _43 => _43(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1777
|
+
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _59 => _59.send, 'access', _60 => _60.bind, 'call', _61 => _61(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1778
|
+
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _62 => _62.cancel, 'access', _63 => _63.bind, 'call', _64 => _64(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1617
1779
|
});
|
1618
1780
|
};
|
1619
|
-
var ComposerRuntime =
|
1620
|
-
constructor(_core
|
1781
|
+
var ComposerRuntime = class {
|
1782
|
+
constructor(_core) {
|
1621
1783
|
this._core = _core;
|
1622
|
-
this._beginEdit = _beginEdit;
|
1623
|
-
}
|
1624
|
-
get type() {
|
1625
|
-
return this._beginEdit ? "edit" : "thread";
|
1626
1784
|
}
|
1627
1785
|
/**
|
1628
1786
|
* @deprecated Use `getState().isEditing` instead. This will be removed in 0.6.0.
|
@@ -1654,7 +1812,6 @@ var ComposerRuntime = (_class2 = class {
|
|
1654
1812
|
get attachmentAccept() {
|
1655
1813
|
return this.getState().attachmentAccept;
|
1656
1814
|
}
|
1657
|
-
// TODO should this instead return getAttachmentByIndex([idx]) instead?
|
1658
1815
|
/**
|
1659
1816
|
* @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
|
1660
1817
|
*/
|
@@ -1667,15 +1824,6 @@ var ComposerRuntime = (_class2 = class {
|
|
1667
1824
|
get value() {
|
1668
1825
|
return this.text;
|
1669
1826
|
}
|
1670
|
-
getState() {
|
1671
|
-
return getThreadComposerState(
|
1672
|
-
this.type,
|
1673
|
-
this._core.getState(),
|
1674
|
-
_nullishCoalesce(_optionalChain([this, 'access', _44 => _44._beginEdit, 'optionalAccess', _45 => _45.bind, 'call', _46 => _46(this)]), () => ( METHOD_NOT_SUPPORTED)),
|
1675
|
-
this.focus.bind(this),
|
1676
|
-
this.onFocus.bind(this)
|
1677
|
-
);
|
1678
|
-
}
|
1679
1827
|
setText(text) {
|
1680
1828
|
const core = this._core.getState();
|
1681
1829
|
if (!core) throw new Error("Composer is not available");
|
@@ -1715,19 +1863,38 @@ var ComposerRuntime = (_class2 = class {
|
|
1715
1863
|
if (!core) throw new Error("Composer is not available");
|
1716
1864
|
core.cancel();
|
1717
1865
|
}
|
1718
|
-
beginEdit() {
|
1719
|
-
_optionalChain([this, 'access', _47 => _47._beginEdit, 'optionalCall', _48 => _48()]);
|
1720
|
-
}
|
1721
|
-
/**
|
1722
|
-
* @deprecated Use `beginEdit()` instead. This will be removed in 0.6.0.
|
1723
|
-
*/
|
1724
|
-
edit() {
|
1725
|
-
this.beginEdit();
|
1726
|
-
}
|
1727
1866
|
subscribe(callback) {
|
1728
1867
|
return this._core.subscribe(callback);
|
1729
1868
|
}
|
1730
|
-
|
1869
|
+
};
|
1870
|
+
var ThreadComposerRuntime = (_class5 = class extends ComposerRuntime {
|
1871
|
+
get type() {
|
1872
|
+
return "thread";
|
1873
|
+
}
|
1874
|
+
|
1875
|
+
constructor(core) {
|
1876
|
+
const stateBinding = new LazyMemoizeSubject({
|
1877
|
+
getState: () => getThreadComposerState(
|
1878
|
+
core.getState(),
|
1879
|
+
this.focus.bind(this),
|
1880
|
+
this.onFocus.bind(this)
|
1881
|
+
),
|
1882
|
+
subscribe: (callback) => core.subscribe(callback)
|
1883
|
+
});
|
1884
|
+
super({
|
1885
|
+
getState: () => core.getState(),
|
1886
|
+
subscribe: (callback) => stateBinding.subscribe(callback)
|
1887
|
+
});_class5.prototype.__init9.call(this);;
|
1888
|
+
this._getState = stateBinding.getState.bind(stateBinding);
|
1889
|
+
}
|
1890
|
+
get attachments() {
|
1891
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _65 => _65.getState, 'call', _66 => _66(), 'optionalAccess', _67 => _67.attachments]), () => ( EMPTY_ARRAY));
|
1892
|
+
}
|
1893
|
+
getState() {
|
1894
|
+
return this._getState();
|
1895
|
+
}
|
1896
|
+
// TODO replace with events
|
1897
|
+
__init9() {this._focusListeners = /* @__PURE__ */ new Set()}
|
1731
1898
|
focus() {
|
1732
1899
|
this._focusListeners.forEach((callback) => callback());
|
1733
1900
|
}
|
@@ -1735,36 +1902,73 @@ var ComposerRuntime = (_class2 = class {
|
|
1735
1902
|
this._focusListeners.add(callback);
|
1736
1903
|
return () => this._focusListeners.delete(callback);
|
1737
1904
|
}
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1905
|
+
unstable_getAttachmentByIndex(idx) {
|
1906
|
+
return new ThreadComposerAttachmentRuntime(
|
1907
|
+
new ShallowMemoizeSubject({
|
1908
|
+
getState: () => {
|
1909
|
+
const attachments = this.getState().attachments;
|
1910
|
+
const attachment = attachments[idx];
|
1911
|
+
if (!attachment) return SKIP_UPDATE;
|
1912
|
+
return {
|
1913
|
+
...attachment,
|
1914
|
+
attachment,
|
1915
|
+
source: "thread-composer"
|
1916
|
+
};
|
1917
|
+
},
|
1918
|
+
subscribe: (callback) => this._core.subscribe(callback)
|
1919
|
+
}),
|
1920
|
+
this._core
|
1921
|
+
);
|
1922
|
+
}
|
1923
|
+
}, _class5);
|
1924
|
+
var EditComposerRuntime = class extends ComposerRuntime {
|
1925
|
+
constructor(core, _beginEdit) {
|
1926
|
+
const stateBinding = new LazyMemoizeSubject({
|
1927
|
+
getState: () => getEditComposerState(core.getState(), this._beginEdit),
|
1928
|
+
subscribe: (callback) => core.subscribe(callback)
|
1929
|
+
});
|
1930
|
+
super({
|
1931
|
+
getState: () => core.getState(),
|
1932
|
+
subscribe: (callback) => stateBinding.subscribe(callback)
|
1933
|
+
});
|
1934
|
+
this._beginEdit = _beginEdit;
|
1935
|
+
this._getState = stateBinding.getState.bind(stateBinding);
|
1936
|
+
}
|
1937
|
+
get type() {
|
1938
|
+
return "edit";
|
1939
|
+
}
|
1743
1940
|
|
1744
|
-
|
1745
|
-
return
|
1941
|
+
getState() {
|
1942
|
+
return this._getState();
|
1746
1943
|
}
|
1747
|
-
|
1748
|
-
|
1944
|
+
beginEdit() {
|
1945
|
+
this._beginEdit();
|
1749
1946
|
}
|
1750
|
-
|
1751
|
-
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
_optionalChain([this, 'access', _49 => _49._connection, 'optionalCall', _50 => _50()]);
|
1756
|
-
this._connection = void 0;
|
1757
|
-
}
|
1947
|
+
/**
|
1948
|
+
* @deprecated Use `beginEdit()` instead. This will be removed in 0.6.0.
|
1949
|
+
*/
|
1950
|
+
edit() {
|
1951
|
+
this.beginEdit();
|
1758
1952
|
}
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1953
|
+
unstable_getAttachmentByIndex(idx) {
|
1954
|
+
return new EditComposerAttachmentRuntime(
|
1955
|
+
new ShallowMemoizeSubject({
|
1956
|
+
getState: () => {
|
1957
|
+
const attachments = this.getState().attachments;
|
1958
|
+
const attachment = attachments[idx];
|
1959
|
+
if (!attachment) return SKIP_UPDATE;
|
1960
|
+
return {
|
1961
|
+
...attachment,
|
1962
|
+
attachment,
|
1963
|
+
source: "edit-composer"
|
1964
|
+
};
|
1965
|
+
},
|
1966
|
+
subscribe: (callback) => this._core.subscribe(callback)
|
1967
|
+
}),
|
1968
|
+
this._core
|
1969
|
+
);
|
1766
1970
|
}
|
1767
|
-
}
|
1971
|
+
};
|
1768
1972
|
|
1769
1973
|
// src/api/subscribable/NestedSubscriptionSubject.ts
|
1770
1974
|
var NestedSubscriptionSubject = class extends BaseSubject {
|
@@ -1780,68 +1984,23 @@ var NestedSubscriptionSubject = class extends BaseSubject {
|
|
1780
1984
|
this.notifySubscribers();
|
1781
1985
|
};
|
1782
1986
|
let lastState = this.binding.getState();
|
1783
|
-
let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess',
|
1987
|
+
let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess', _68 => _68.subscribe, 'call', _69 => _69(callback)]);
|
1784
1988
|
const onRuntimeUpdate = () => {
|
1785
1989
|
const newState = this.binding.getState();
|
1786
1990
|
if (newState === lastState) return;
|
1787
1991
|
lastState = newState;
|
1788
|
-
_optionalChain([innerUnsubscribe, 'optionalCall',
|
1789
|
-
innerUnsubscribe = _optionalChain([this, 'access',
|
1992
|
+
_optionalChain([innerUnsubscribe, 'optionalCall', _70 => _70()]);
|
1993
|
+
innerUnsubscribe = _optionalChain([this, 'access', _71 => _71.binding, 'access', _72 => _72.getState, 'call', _73 => _73(), 'optionalAccess', _74 => _74.subscribe, 'call', _75 => _75(callback)]);
|
1790
1994
|
callback();
|
1791
1995
|
};
|
1792
1996
|
const outerUnsubscribe = this.binding.subscribe(onRuntimeUpdate);
|
1793
1997
|
return () => {
|
1794
|
-
_optionalChain([outerUnsubscribe, 'optionalCall',
|
1795
|
-
_optionalChain([innerUnsubscribe, 'optionalCall',
|
1998
|
+
_optionalChain([outerUnsubscribe, 'optionalCall', _76 => _76()]);
|
1999
|
+
_optionalChain([innerUnsubscribe, 'optionalCall', _77 => _77()]);
|
1796
2000
|
};
|
1797
2001
|
}
|
1798
2002
|
};
|
1799
2003
|
|
1800
|
-
// src/api/subscribable/shallowEqual.ts
|
1801
|
-
function shallowEqual(objA, objB) {
|
1802
|
-
if (objA === void 0 && objB === void 0) return true;
|
1803
|
-
if (objA === void 0) return false;
|
1804
|
-
if (objB === void 0) return false;
|
1805
|
-
for (const key of Object.keys(objA)) {
|
1806
|
-
const valueA = objA[key];
|
1807
|
-
const valueB = objB[key];
|
1808
|
-
if (!Object.is(valueA, valueB)) return false;
|
1809
|
-
}
|
1810
|
-
return true;
|
1811
|
-
}
|
1812
|
-
|
1813
|
-
// src/api/subscribable/ShallowMemoizeSubject.ts
|
1814
|
-
var ShallowMemoizeSubject = (_class4 = class extends BaseSubject {
|
1815
|
-
constructor(binding) {
|
1816
|
-
super();_class4.prototype.__init7.call(this);;
|
1817
|
-
this.binding = binding;
|
1818
|
-
const state = binding.getState();
|
1819
|
-
if (state === void 0)
|
1820
|
-
throw new Error("Entry not available in the store");
|
1821
|
-
this._previousState = state;
|
1822
|
-
}
|
1823
|
-
|
1824
|
-
__init7() {this.getState = () => {
|
1825
|
-
if (!this.isConnected) this._syncState();
|
1826
|
-
return this._previousState;
|
1827
|
-
}}
|
1828
|
-
_syncState() {
|
1829
|
-
const state = this.binding.getState();
|
1830
|
-
if (state === void 0) return false;
|
1831
|
-
if (shallowEqual(state, this._previousState)) return false;
|
1832
|
-
this._previousState = state;
|
1833
|
-
return true;
|
1834
|
-
}
|
1835
|
-
_connect() {
|
1836
|
-
const callback = () => {
|
1837
|
-
if (this._syncState()) {
|
1838
|
-
this.notifySubscribers();
|
1839
|
-
}
|
1840
|
-
};
|
1841
|
-
return this.binding.subscribe(callback);
|
1842
|
-
}
|
1843
|
-
}, _class4);
|
1844
|
-
|
1845
2004
|
// src/api/MessageRuntime.ts
|
1846
2005
|
var COMPLETE_STATUS2 = {
|
1847
2006
|
type: "complete"
|
@@ -1868,7 +2027,7 @@ var getContentPartState = (message, partIndex) => {
|
|
1868
2027
|
if (message.content.length === 0 && partIndex === 0) {
|
1869
2028
|
part = EMPTY_CONTENT;
|
1870
2029
|
} else {
|
1871
|
-
return
|
2030
|
+
return SKIP_UPDATE;
|
1872
2031
|
}
|
1873
2032
|
} else if (message.content.length === 1 && part.type === "text" && part.text.length === 0) {
|
1874
2033
|
part = EMPTY_CONTENT;
|
@@ -1876,12 +2035,12 @@ var getContentPartState = (message, partIndex) => {
|
|
1876
2035
|
const status = toContentPartStatus(message, partIndex, part);
|
1877
2036
|
return Object.freeze({ ...part, part, status });
|
1878
2037
|
};
|
1879
|
-
var MessageRuntime = (
|
1880
|
-
constructor(_core, _threadBinding) {;
|
2038
|
+
var MessageRuntime = (_class6 = class {
|
2039
|
+
constructor(_core, _threadBinding) {;_class6.prototype.__init10.call(this);
|
1881
2040
|
this._core = _core;
|
1882
2041
|
this._threadBinding = _threadBinding;
|
1883
2042
|
}
|
1884
|
-
|
2043
|
+
__init10() {this.composer = new EditComposerRuntime(
|
1885
2044
|
new NestedSubscriptionSubject({
|
1886
2045
|
getState: () => this._threadBinding.getState().getEditComposer(this._core.getState().id),
|
1887
2046
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
@@ -1958,7 +2117,24 @@ var MessageRuntime = (_class5 = class {
|
|
1958
2117
|
this._threadBinding
|
1959
2118
|
);
|
1960
2119
|
}
|
1961
|
-
|
2120
|
+
unstable_getAttachmentByIndex(idx) {
|
2121
|
+
return new MessageAttachmentRuntime(
|
2122
|
+
new ShallowMemoizeSubject({
|
2123
|
+
getState: () => {
|
2124
|
+
const attachments = this.getState().attachments;
|
2125
|
+
const attachment = _optionalChain([attachments, 'optionalAccess', _78 => _78[idx]]);
|
2126
|
+
if (!attachment) return SKIP_UPDATE;
|
2127
|
+
return {
|
2128
|
+
...attachment,
|
2129
|
+
attachment,
|
2130
|
+
source: "message"
|
2131
|
+
};
|
2132
|
+
},
|
2133
|
+
subscribe: (callback) => this._core.subscribe(callback)
|
2134
|
+
})
|
2135
|
+
);
|
2136
|
+
}
|
2137
|
+
}, _class6);
|
1962
2138
|
|
1963
2139
|
// src/primitives/message/MessageContent.tsx
|
1964
2140
|
|
@@ -2035,7 +2211,7 @@ var MessageContentPartImpl = ({
|
|
2035
2211
|
};
|
2036
2212
|
var MessageContentPart = _react.memo.call(void 0,
|
2037
2213
|
MessageContentPartImpl,
|
2038
|
-
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access',
|
2214
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _79 => _79.components, 'optionalAccess', _80 => _80.Text]) === _optionalChain([next, 'access', _81 => _81.components, 'optionalAccess', _82 => _82.Text]) && _optionalChain([prev, 'access', _83 => _83.components, 'optionalAccess', _84 => _84.Image]) === _optionalChain([next, 'access', _85 => _85.components, 'optionalAccess', _86 => _86.Image]) && _optionalChain([prev, 'access', _87 => _87.components, 'optionalAccess', _88 => _88.UI]) === _optionalChain([next, 'access', _89 => _89.components, 'optionalAccess', _90 => _90.UI]) && _optionalChain([prev, 'access', _91 => _91.components, 'optionalAccess', _92 => _92.tools]) === _optionalChain([next, 'access', _93 => _93.components, 'optionalAccess', _94 => _94.tools])
|
2039
2215
|
);
|
2040
2216
|
var MessagePrimitiveContent = ({
|
2041
2217
|
components
|
@@ -2061,86 +2237,93 @@ var AttachmentContext = _react.createContext.call(void 0,
|
|
2061
2237
|
);
|
2062
2238
|
function useAttachmentContext(options) {
|
2063
2239
|
const context = _react.useContext.call(void 0, AttachmentContext);
|
2064
|
-
if (!_optionalChain([options, 'optionalAccess',
|
2240
|
+
if (!_optionalChain([options, 'optionalAccess', _95 => _95.optional]) && !context)
|
2065
2241
|
throw new Error(
|
2066
2242
|
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
2067
2243
|
);
|
2068
2244
|
return context;
|
2069
2245
|
}
|
2070
|
-
function
|
2246
|
+
function useThreadComposerAttachmentContext(options) {
|
2247
|
+
const context = useAttachmentContext(options);
|
2248
|
+
if (!context) return null;
|
2249
|
+
if (context.source !== "thread-composer")
|
2250
|
+
throw new Error(
|
2251
|
+
"This component must be used within a thread's ComposerPrimitive.Attachments component."
|
2252
|
+
);
|
2253
|
+
return context;
|
2254
|
+
}
|
2255
|
+
function useEditComposerAttachmentContext(options) {
|
2071
2256
|
const context = useAttachmentContext(options);
|
2072
2257
|
if (!context) return null;
|
2073
|
-
if (context.
|
2258
|
+
if (context.source !== "edit-composer")
|
2074
2259
|
throw new Error(
|
2075
|
-
"This component must be used within a ComposerPrimitive.Attachments component."
|
2260
|
+
"This component must be used within a messages's ComposerPrimitive.Attachments component."
|
2076
2261
|
);
|
2077
2262
|
return context;
|
2078
2263
|
}
|
2079
2264
|
function useMessageAttachmentContext(options) {
|
2080
2265
|
const context = useAttachmentContext(options);
|
2081
2266
|
if (!context) return null;
|
2082
|
-
if (context.
|
2267
|
+
if (context.source !== "message")
|
2083
2268
|
throw new Error(
|
2084
2269
|
"This component must be used within a MessagePrimitive.Attachments component."
|
2085
2270
|
);
|
2086
2271
|
return context;
|
2087
2272
|
}
|
2088
|
-
|
2273
|
+
function useAttachmentRuntime(options) {
|
2274
|
+
const attachmentRuntime = useAttachmentContext(options);
|
2275
|
+
if (!attachmentRuntime) return null;
|
2276
|
+
return attachmentRuntime.useAttachmentRuntime();
|
2277
|
+
}
|
2278
|
+
var { useAttachment } = createContextStoreHook(
|
2089
2279
|
useAttachmentContext,
|
2090
2280
|
"useAttachment"
|
2091
2281
|
);
|
2092
|
-
var {
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2282
|
+
var { useAttachment: useThreadComposerAttachment } = createContextStoreHook(useThreadComposerAttachmentContext, "useAttachment");
|
2283
|
+
var { useAttachment: useEditComposerAttachment } = createContextStoreHook(useEditComposerAttachmentContext, "useAttachment");
|
2284
|
+
var { useAttachment: useMessageAttachment } = createContextStoreHook(
|
2285
|
+
useMessageAttachmentContext,
|
2286
|
+
"useAttachment"
|
2287
|
+
);
|
2288
|
+
|
2289
|
+
// src/context/providers/AttachmentRuntimeProvider.tsx
|
2290
|
+
|
2100
2291
|
|
2101
|
-
// src/context/providers/MessageAttachmentProvider.tsx
|
2102
2292
|
|
2103
2293
|
|
2104
2294
|
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
const
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
return
|
2295
|
+
|
2296
|
+
|
2297
|
+
var useAttachmentRuntimeStore = (runtime) => {
|
2298
|
+
const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime));
|
2299
|
+
_react.useEffect.call(void 0, () => {
|
2300
|
+
writableStore(store).setState(runtime, true);
|
2301
|
+
}, [runtime, store]);
|
2302
|
+
return store;
|
2113
2303
|
};
|
2114
|
-
var
|
2115
|
-
const
|
2116
|
-
const [context] = _react.useState.call(void 0,
|
2117
|
-
() => {
|
2118
|
-
const useAttachment2 = _zustand.create.call(void 0,
|
2119
|
-
() => getAttachment(messageStore.getState(), void 0, partIndex)
|
2120
|
-
);
|
2121
|
-
return { type: "message", useAttachment: useAttachment2 };
|
2122
|
-
}
|
2123
|
-
);
|
2304
|
+
var useAttachmentStore = (runtime) => {
|
2305
|
+
const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime.getState()));
|
2124
2306
|
_react.useEffect.call(void 0, () => {
|
2125
|
-
const
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
);
|
2131
|
-
if (!newState) return;
|
2132
|
-
writableStore(context.useAttachment).setState(newState, true);
|
2133
|
-
};
|
2134
|
-
syncAttachment(messageStore.getState());
|
2135
|
-
return messageStore.subscribe(syncAttachment);
|
2136
|
-
}, [context, messageStore, partIndex]);
|
2137
|
-
return context;
|
2307
|
+
const updateState = () => writableStore(store).setState(runtime.getState(), true);
|
2308
|
+
updateState();
|
2309
|
+
return runtime.subscribe(updateState);
|
2310
|
+
}, [runtime, store]);
|
2311
|
+
return store;
|
2138
2312
|
};
|
2139
|
-
var
|
2140
|
-
|
2313
|
+
var AttachmentRuntimeProvider = ({
|
2314
|
+
runtime,
|
2141
2315
|
children
|
2142
2316
|
}) => {
|
2143
|
-
const
|
2317
|
+
const useAttachmentRuntime2 = useAttachmentRuntimeStore(runtime);
|
2318
|
+
const useAttachment2 = useAttachmentStore(runtime);
|
2319
|
+
const source = useAttachment2((s) => s.source);
|
2320
|
+
const context = _react.useMemo.call(void 0, () => {
|
2321
|
+
return {
|
2322
|
+
source,
|
2323
|
+
useAttachmentRuntime: useAttachmentRuntime2,
|
2324
|
+
useAttachment: useAttachment2
|
2325
|
+
};
|
2326
|
+
}, [useAttachmentRuntime2, useAttachment2]);
|
2144
2327
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentContext.Provider, { value: context, children });
|
2145
2328
|
};
|
2146
2329
|
|
@@ -2150,11 +2333,11 @@ var getComponent = (components, attachment) => {
|
|
2150
2333
|
const type = attachment.type;
|
2151
2334
|
switch (type) {
|
2152
2335
|
case "image":
|
2153
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2336
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _96 => _96.Image]), () => ( _optionalChain([components, 'optionalAccess', _97 => _97.Attachment])));
|
2154
2337
|
case "document":
|
2155
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2338
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _98 => _98.Document]), () => ( _optionalChain([components, 'optionalAccess', _99 => _99.Attachment])));
|
2156
2339
|
case "file":
|
2157
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2340
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _100 => _100.File]), () => ( _optionalChain([components, 'optionalAccess', _101 => _101.Attachment])));
|
2158
2341
|
default:
|
2159
2342
|
const _exhaustiveCheck = type;
|
2160
2343
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -2168,11 +2351,16 @@ var AttachmentComponent = ({ components }) => {
|
|
2168
2351
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {});
|
2169
2352
|
};
|
2170
2353
|
var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
2171
|
-
|
2354
|
+
const messageRuntime = useMessageRuntime();
|
2355
|
+
const runtime = _react.useMemo.call(void 0,
|
2356
|
+
() => messageRuntime.unstable_getAttachmentByIndex(attachmentIndex),
|
2357
|
+
[messageRuntime, attachmentIndex]
|
2358
|
+
);
|
2359
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentComponent, { components }) });
|
2172
2360
|
};
|
2173
2361
|
var MessageAttachment = _react.memo.call(void 0,
|
2174
2362
|
MessageAttachmentImpl,
|
2175
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2363
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _102 => _102.components, 'optionalAccess', _103 => _103.Image]) === _optionalChain([next, 'access', _104 => _104.components, 'optionalAccess', _105 => _105.Image]) && _optionalChain([prev, 'access', _106 => _106.components, 'optionalAccess', _107 => _107.Document]) === _optionalChain([next, 'access', _108 => _108.components, 'optionalAccess', _109 => _109.Document]) && _optionalChain([prev, 'access', _110 => _110.components, 'optionalAccess', _111 => _111.File]) === _optionalChain([next, 'access', _112 => _112.components, 'optionalAccess', _113 => _113.File]) && _optionalChain([prev, 'access', _114 => _114.components, 'optionalAccess', _115 => _115.Attachment]) === _optionalChain([next, 'access', _116 => _116.components, 'optionalAccess', _117 => _117.Attachment])
|
2176
2364
|
);
|
2177
2365
|
var MessagePrimitiveAttachments = ({ components }) => {
|
2178
2366
|
const attachmentsCount = useMessage(({ message }) => {
|
@@ -2283,7 +2471,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
2283
2471
|
const { isRunning } = threadStore.getState();
|
2284
2472
|
if (!isRunning) {
|
2285
2473
|
e.preventDefault();
|
2286
|
-
_optionalChain([textareaRef, 'access',
|
2474
|
+
_optionalChain([textareaRef, 'access', _118 => _118.current, 'optionalAccess', _119 => _119.closest, 'call', _120 => _120("form"), 'optionalAccess', _121 => _121.requestSubmit, 'call', _122 => _122()]);
|
2287
2475
|
}
|
2288
2476
|
}
|
2289
2477
|
};
|
@@ -2344,79 +2532,41 @@ var ComposerPrimitiveAddAttachment = createActionButton(
|
|
2344
2532
|
// src/primitives/composer/ComposerAttachments.tsx
|
2345
2533
|
|
2346
2534
|
|
2347
|
-
// src/context/providers/ComposerAttachmentProvider.tsx
|
2348
|
-
|
2349
|
-
|
2350
|
-
|
2351
|
-
var getAttachment2 = ({ attachments }, useAttachment2, partIndex) => {
|
2352
|
-
const attachment = attachments[partIndex];
|
2353
|
-
if (!attachment) return null;
|
2354
|
-
const currentState = _optionalChain([useAttachment2, 'optionalAccess', _107 => _107.getState, 'call', _108 => _108()]);
|
2355
|
-
if (currentState && currentState.attachment === attachment) return null;
|
2356
|
-
return Object.freeze({ attachment });
|
2357
|
-
};
|
2358
|
-
var useComposerAttachmentContext2 = (partIndex) => {
|
2359
|
-
const threadComposerStore = useThreadComposerStore();
|
2360
|
-
const [context] = _react.useState.call(void 0,
|
2361
|
-
() => {
|
2362
|
-
const useAttachment2 = _zustand.create.call(void 0,
|
2363
|
-
() => getAttachment2(threadComposerStore.getState(), void 0, partIndex)
|
2364
|
-
);
|
2365
|
-
return { type: "composer", useAttachment: useAttachment2 };
|
2366
|
-
}
|
2367
|
-
);
|
2368
|
-
_react.useEffect.call(void 0, () => {
|
2369
|
-
const syncAttachment = (composer) => {
|
2370
|
-
const newState = getAttachment2(
|
2371
|
-
composer,
|
2372
|
-
context.useAttachment,
|
2373
|
-
partIndex
|
2374
|
-
);
|
2375
|
-
if (!newState) return;
|
2376
|
-
writableStore(context.useAttachment).setState(newState, true);
|
2377
|
-
};
|
2378
|
-
syncAttachment(threadComposerStore.getState());
|
2379
|
-
return threadComposerStore.subscribe(syncAttachment);
|
2380
|
-
}, [context, threadComposerStore, partIndex]);
|
2381
|
-
return context;
|
2382
|
-
};
|
2383
|
-
var ComposerAttachmentProvider = ({ attachmentIndex: partIndex, children }) => {
|
2384
|
-
const context = useComposerAttachmentContext2(partIndex);
|
2385
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentContext.Provider, { value: context, children });
|
2386
|
-
};
|
2387
|
-
|
2388
|
-
// src/primitives/composer/ComposerAttachments.tsx
|
2389
|
-
|
2390
2535
|
var getComponent2 = (components, attachment) => {
|
2391
2536
|
const type = attachment.type;
|
2392
2537
|
switch (type) {
|
2393
2538
|
case "image":
|
2394
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2539
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _123 => _123.Image]), () => ( _optionalChain([components, 'optionalAccess', _124 => _124.Attachment])));
|
2395
2540
|
case "document":
|
2396
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2541
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _125 => _125.Document]), () => ( _optionalChain([components, 'optionalAccess', _126 => _126.Attachment])));
|
2397
2542
|
case "file":
|
2398
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2543
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _127 => _127.File]), () => ( _optionalChain([components, 'optionalAccess', _128 => _128.Attachment])));
|
2399
2544
|
default:
|
2400
2545
|
const _exhaustiveCheck = type;
|
2401
2546
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
2402
2547
|
}
|
2403
2548
|
};
|
2404
2549
|
var AttachmentComponent2 = ({ components }) => {
|
2405
|
-
const Component =
|
2406
|
-
(a) => getComponent2(components, a
|
2550
|
+
const Component = useThreadComposerAttachment(
|
2551
|
+
(a) => getComponent2(components, a)
|
2407
2552
|
);
|
2408
2553
|
if (!Component) return null;
|
2409
2554
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {});
|
2410
2555
|
};
|
2411
2556
|
var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
2412
|
-
|
2557
|
+
const composerRuntime = useComposerRuntime();
|
2558
|
+
const runtime = _react.useMemo.call(void 0,
|
2559
|
+
() => composerRuntime.unstable_getAttachmentByIndex(attachmentIndex),
|
2560
|
+
[composerRuntime, attachmentIndex]
|
2561
|
+
);
|
2562
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentComponent2, { components }) });
|
2413
2563
|
};
|
2414
2564
|
var ComposerAttachment = _react.memo.call(void 0,
|
2415
2565
|
ComposerAttachmentImpl,
|
2416
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2566
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _129 => _129.components, 'optionalAccess', _130 => _130.Image]) === _optionalChain([next, 'access', _131 => _131.components, 'optionalAccess', _132 => _132.Image]) && _optionalChain([prev, 'access', _133 => _133.components, 'optionalAccess', _134 => _134.Document]) === _optionalChain([next, 'access', _135 => _135.components, 'optionalAccess', _136 => _136.Document]) && _optionalChain([prev, 'access', _137 => _137.components, 'optionalAccess', _138 => _138.File]) === _optionalChain([next, 'access', _139 => _139.components, 'optionalAccess', _140 => _140.File]) && _optionalChain([prev, 'access', _141 => _141.components, 'optionalAccess', _142 => _142.Attachment]) === _optionalChain([next, 'access', _143 => _143.components, 'optionalAccess', _144 => _144.Attachment])
|
2417
2567
|
);
|
2418
2568
|
var ComposerPrimitiveAttachments = ({ components }) => {
|
2419
|
-
const attachmentsCount =
|
2569
|
+
const attachmentsCount = useComposer((s) => s.attachments.length);
|
2420
2570
|
return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
2421
2571
|
ComposerAttachment,
|
2422
2572
|
{
|
@@ -2633,7 +2783,7 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
|
2633
2783
|
},
|
2634
2784
|
isSpeaking: false,
|
2635
2785
|
stopSpeaking: () => {
|
2636
|
-
_optionalChain([utterance, 'optionalAccess',
|
2786
|
+
_optionalChain([utterance, 'optionalAccess', _145 => _145.cancel, 'call', _146 => _146()]);
|
2637
2787
|
},
|
2638
2788
|
addUtterance: (utt) => {
|
2639
2789
|
utterance = utt;
|
@@ -2780,7 +2930,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2780
2930
|
let first = true;
|
2781
2931
|
let cleanup;
|
2782
2932
|
const inner = () => {
|
2783
|
-
_optionalChain([cleanup, 'optionalCall',
|
2933
|
+
_optionalChain([cleanup, 'optionalCall', _147 => _147()]);
|
2784
2934
|
cleanup = runtime.thread.subscribe(callback);
|
2785
2935
|
if (!first) {
|
2786
2936
|
callback();
|
@@ -2791,7 +2941,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2791
2941
|
inner();
|
2792
2942
|
return () => {
|
2793
2943
|
unsubscribe();
|
2794
|
-
_optionalChain([cleanup, 'optionalCall',
|
2944
|
+
_optionalChain([cleanup, 'optionalCall', _148 => _148()]);
|
2795
2945
|
};
|
2796
2946
|
};
|
2797
2947
|
|
@@ -2799,8 +2949,8 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2799
2949
|
|
2800
2950
|
|
2801
2951
|
// src/runtimes/core/BaseAssistantRuntimeCore.tsx
|
2802
|
-
var BaseAssistantRuntimeCore = (
|
2803
|
-
constructor(_thread) {;
|
2952
|
+
var BaseAssistantRuntimeCore = (_class7 = class {
|
2953
|
+
constructor(_thread) {;_class7.prototype.__init11.call(this);_class7.prototype.__init12.call(this);
|
2804
2954
|
this._thread = _thread;
|
2805
2955
|
this._thread = _thread;
|
2806
2956
|
}
|
@@ -2811,15 +2961,15 @@ var BaseAssistantRuntimeCore = (_class6 = class {
|
|
2811
2961
|
this._thread = thread;
|
2812
2962
|
this.subscriptionHandler();
|
2813
2963
|
}
|
2814
|
-
|
2964
|
+
__init11() {this._subscriptions = /* @__PURE__ */ new Set()}
|
2815
2965
|
subscribe(callback) {
|
2816
2966
|
this._subscriptions.add(callback);
|
2817
2967
|
return () => this._subscriptions.delete(callback);
|
2818
2968
|
}
|
2819
|
-
|
2969
|
+
__init12() {this.subscriptionHandler = () => {
|
2820
2970
|
for (const callback of this._subscriptions) callback();
|
2821
2971
|
}}
|
2822
|
-
},
|
2972
|
+
}, _class7);
|
2823
2973
|
|
2824
2974
|
// src/internal.ts
|
2825
2975
|
var internal_exports = {};
|
@@ -2838,10 +2988,11 @@ _chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
|
|
2838
2988
|
});
|
2839
2989
|
|
2840
2990
|
// src/runtimes/composer/BaseComposerRuntimeCore.tsx
|
2841
|
-
var
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2991
|
+
var isAttachmentComplete = (a) => a.status.type === "complete";
|
2992
|
+
var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototype.__init13.call(this);_class8.prototype.__init14.call(this);_class8.prototype.__init15.call(this);_class8.prototype.__init16.call(this);_class8.prototype.__init17.call(this); }
|
2993
|
+
__init13() {this.isEditing = true}
|
2994
|
+
__init14() {this.attachmentAccept = "*"}
|
2995
|
+
__init15() {this._attachments = []}
|
2845
2996
|
set attachments(value) {
|
2846
2997
|
this._attachments = value;
|
2847
2998
|
this.notifySubscribers();
|
@@ -2852,7 +3003,7 @@ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototyp
|
|
2852
3003
|
get isEmpty() {
|
2853
3004
|
return !this.text.trim() && !this.attachments.length;
|
2854
3005
|
}
|
2855
|
-
|
3006
|
+
__init16() {this._text = ""}
|
2856
3007
|
get text() {
|
2857
3008
|
return this._text;
|
2858
3009
|
}
|
@@ -2867,9 +3018,14 @@ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototyp
|
|
2867
3018
|
}
|
2868
3019
|
async send() {
|
2869
3020
|
const attachments = this._attachmentAdapter ? await Promise.all(
|
2870
|
-
this.attachments.map(
|
2871
|
-
|
2872
|
-
|
3021
|
+
this.attachments.map(async (a) => {
|
3022
|
+
if (isAttachmentComplete(a)) return a;
|
3023
|
+
const result = await this._attachmentAdapter.send(a);
|
3024
|
+
if (_optionalChain([result, 'access', _149 => _149.status, 'optionalAccess', _150 => _150.type]) !== "complete") {
|
3025
|
+
result.status = { type: "complete" };
|
3026
|
+
}
|
3027
|
+
return result;
|
3028
|
+
})
|
2873
3029
|
) : [];
|
2874
3030
|
const message = {
|
2875
3031
|
role: "user",
|
@@ -2882,7 +3038,7 @@ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototyp
|
|
2882
3038
|
|
2883
3039
|
setAttachmentAdapter(adapter) {
|
2884
3040
|
this._attachmentAdapter = adapter;
|
2885
|
-
const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess',
|
3041
|
+
const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess', _151 => _151.accept]), () => ( "*"));
|
2886
3042
|
if (this.attachmentAccept !== accept) {
|
2887
3043
|
this.attachmentAccept = accept;
|
2888
3044
|
this.notifySubscribers();
|
@@ -2892,6 +3048,9 @@ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototyp
|
|
2892
3048
|
if (!this._attachmentAdapter)
|
2893
3049
|
throw new Error("Attachments are not supported");
|
2894
3050
|
const attachment = await this._attachmentAdapter.add({ file });
|
3051
|
+
if (attachment.status === void 0) {
|
3052
|
+
attachment.status = { type: "requires-action", reason: "composer-send" };
|
3053
|
+
}
|
2895
3054
|
this._attachments = [...this._attachments, attachment];
|
2896
3055
|
this.notifySubscribers();
|
2897
3056
|
}
|
@@ -2905,7 +3064,7 @@ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototyp
|
|
2905
3064
|
this._attachments = this._attachments.toSpliced(index, 1);
|
2906
3065
|
this.notifySubscribers();
|
2907
3066
|
}
|
2908
|
-
|
3067
|
+
__init17() {this._subscriptions = /* @__PURE__ */ new Set()}
|
2909
3068
|
notifySubscribers() {
|
2910
3069
|
for (const callback of this._subscriptions) callback();
|
2911
3070
|
}
|
@@ -2913,19 +3072,22 @@ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototyp
|
|
2913
3072
|
this._subscriptions.add(callback);
|
2914
3073
|
return () => this._subscriptions.delete(callback);
|
2915
3074
|
}
|
2916
|
-
},
|
3075
|
+
}, _class8);
|
2917
3076
|
|
2918
3077
|
// src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx
|
2919
|
-
var DefaultThreadComposerRuntimeCore = (
|
3078
|
+
var DefaultThreadComposerRuntimeCore = (_class9 = class extends BaseComposerRuntimeCore {
|
2920
3079
|
constructor(runtime) {
|
2921
|
-
super();
|
3080
|
+
super();_class9.prototype.__init18.call(this);;
|
2922
3081
|
this.runtime = runtime;
|
2923
3082
|
this.connect();
|
2924
3083
|
}
|
2925
|
-
|
3084
|
+
__init18() {this._canCancel = false}
|
2926
3085
|
get canCancel() {
|
2927
3086
|
return this._canCancel;
|
2928
3087
|
}
|
3088
|
+
get attachments() {
|
3089
|
+
return super.attachments;
|
3090
|
+
}
|
2929
3091
|
connect() {
|
2930
3092
|
return this.runtime.subscribe(() => {
|
2931
3093
|
if (this.canCancel !== this.runtime.capabilities.cancel) {
|
@@ -2937,17 +3099,17 @@ var DefaultThreadComposerRuntimeCore = (_class8 = class extends BaseComposerRunt
|
|
2937
3099
|
async handleSend(message) {
|
2938
3100
|
this.runtime.append({
|
2939
3101
|
...message,
|
2940
|
-
parentId: _nullishCoalesce(_optionalChain([this, 'access',
|
3102
|
+
parentId: _nullishCoalesce(_optionalChain([this, 'access', _152 => _152.runtime, 'access', _153 => _153.messages, 'access', _154 => _154.at, 'call', _155 => _155(-1), 'optionalAccess', _156 => _156.id]), () => ( null))
|
2941
3103
|
});
|
2942
3104
|
}
|
2943
3105
|
async cancel() {
|
2944
3106
|
this.runtime.cancelRun();
|
2945
3107
|
}
|
2946
|
-
},
|
3108
|
+
}, _class9);
|
2947
3109
|
|
2948
3110
|
// src/utils/ProxyConfigProvider.ts
|
2949
|
-
var ProxyConfigProvider = (
|
2950
|
-
|
3111
|
+
var ProxyConfigProvider = (_class10 = class {constructor() { _class10.prototype.__init19.call(this); }
|
3112
|
+
__init19() {this._providers = /* @__PURE__ */ new Set()}
|
2951
3113
|
getModelConfig() {
|
2952
3114
|
return _chunk5KIEXJRKjs.mergeModelConfigs.call(void 0, this._providers);
|
2953
3115
|
}
|
@@ -2957,7 +3119,7 @@ var ProxyConfigProvider = (_class9 = class {constructor() { _class9.prototype.__
|
|
2957
3119
|
this._providers.delete(provider);
|
2958
3120
|
};
|
2959
3121
|
}
|
2960
|
-
},
|
3122
|
+
}, _class10);
|
2961
3123
|
|
2962
3124
|
// src/utils/idUtils.tsx
|
2963
3125
|
var _nonsecure = require('nanoid/non-secure');
|
@@ -3024,11 +3186,11 @@ var findHead = (message) => {
|
|
3024
3186
|
if ("current" in message) return message;
|
3025
3187
|
return null;
|
3026
3188
|
};
|
3027
|
-
var MessageRepository = (
|
3028
|
-
|
3189
|
+
var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__init20.call(this);_class11.prototype.__init21.call(this);_class11.prototype.__init22.call(this); }
|
3190
|
+
__init20() {this.messages = /* @__PURE__ */ new Map()}
|
3029
3191
|
// message_id -> item
|
3030
|
-
|
3031
|
-
|
3192
|
+
__init21() {this.head = null}
|
3193
|
+
__init22() {this.root = {
|
3032
3194
|
children: [],
|
3033
3195
|
next: null
|
3034
3196
|
}}
|
@@ -3070,7 +3232,7 @@ var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__
|
|
3070
3232
|
}
|
3071
3233
|
}
|
3072
3234
|
getMessages() {
|
3073
|
-
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access',
|
3235
|
+
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access', _157 => _157.head, 'optionalAccess', _158 => _158.level]), () => ( 0)));
|
3074
3236
|
for (let current = this.head; current; current = current.prev) {
|
3075
3237
|
messages2[current.level] = current.current;
|
3076
3238
|
}
|
@@ -3108,7 +3270,7 @@ var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__
|
|
3108
3270
|
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
3109
3271
|
);
|
3110
3272
|
return {
|
3111
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3273
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _159 => _159.prev, 'optionalAccess', _160 => _160.current, 'access', _161 => _161.id]), () => ( null)),
|
3112
3274
|
message: message.current
|
3113
3275
|
};
|
3114
3276
|
}
|
@@ -3192,11 +3354,11 @@ var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__
|
|
3192
3354
|
for (const [, message] of this.messages) {
|
3193
3355
|
exportItems.push({
|
3194
3356
|
message: message.current,
|
3195
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3357
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _162 => _162.prev, 'optionalAccess', _163 => _163.current, 'access', _164 => _164.id]), () => ( null))
|
3196
3358
|
});
|
3197
3359
|
}
|
3198
3360
|
return {
|
3199
|
-
headId: _nullishCoalesce(_optionalChain([this, 'access',
|
3361
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _165 => _165.head, 'optionalAccess', _166 => _166.current, 'access', _167 => _167.id]), () => ( null)),
|
3200
3362
|
messages: exportItems
|
3201
3363
|
};
|
3202
3364
|
}
|
@@ -3204,9 +3366,9 @@ var MessageRepository = (_class10 = class {constructor() { _class10.prototype.__
|
|
3204
3366
|
for (const { message, parentId } of messages2) {
|
3205
3367
|
this.addOrUpdateMessage(parentId, message);
|
3206
3368
|
}
|
3207
|
-
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access',
|
3369
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access', _168 => _168.at, 'call', _169 => _169(-1), 'optionalAccess', _170 => _170.message, 'access', _171 => _171.id]))), () => ( null)));
|
3208
3370
|
}
|
3209
|
-
},
|
3371
|
+
}, _class11);
|
3210
3372
|
|
3211
3373
|
// src/ui/base/tooltip-icon-button.tsx
|
3212
3374
|
|
@@ -3334,42 +3496,11 @@ var AssistantRuntime = class {
|
|
3334
3496
|
}
|
3335
3497
|
};
|
3336
3498
|
|
3337
|
-
// src/api/subscribable/LazyMemoizeSubject.ts
|
3338
|
-
var LazyMemoizeSubject = (_class11 = class extends BaseSubject {
|
3339
|
-
constructor(binding) {
|
3340
|
-
super();_class11.prototype.__init21.call(this);_class11.prototype.__init22.call(this);;
|
3341
|
-
this.binding = binding;
|
3342
|
-
const state = binding.getState();
|
3343
|
-
if (state === void 0)
|
3344
|
-
throw new Error("Entry not available in the store");
|
3345
|
-
this._previousState = state;
|
3346
|
-
}
|
3347
|
-
__init21() {this._previousStateDirty = true}
|
3348
|
-
|
3349
|
-
__init22() {this.getState = () => {
|
3350
|
-
if (!this.isConnected || this._previousStateDirty) {
|
3351
|
-
const newState = this.binding.getState();
|
3352
|
-
if (newState !== void 0) {
|
3353
|
-
this._previousState = newState;
|
3354
|
-
}
|
3355
|
-
this._previousStateDirty = false;
|
3356
|
-
}
|
3357
|
-
return this._previousState;
|
3358
|
-
}}
|
3359
|
-
_connect() {
|
3360
|
-
const callback = () => {
|
3361
|
-
this._previousStateDirty = true;
|
3362
|
-
this.notifySubscribers();
|
3363
|
-
};
|
3364
|
-
return this.binding.subscribe(callback);
|
3365
|
-
}
|
3366
|
-
}, _class11);
|
3367
|
-
|
3368
3499
|
// src/api/ThreadRuntime.ts
|
3369
3500
|
var toAppendMessage = (messages2, message) => {
|
3370
3501
|
if (typeof message === "string") {
|
3371
3502
|
return {
|
3372
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
3503
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _172 => _172.at, 'call', _173 => _173(-1), 'optionalAccess', _174 => _174.id]), () => ( null)),
|
3373
3504
|
role: "user",
|
3374
3505
|
content: [{ type: "text", text: message }],
|
3375
3506
|
attachments: []
|
@@ -3379,7 +3510,7 @@ var toAppendMessage = (messages2, message) => {
|
|
3379
3510
|
return message;
|
3380
3511
|
}
|
3381
3512
|
return {
|
3382
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access',
|
3513
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access', _175 => _175.at, 'call', _176 => _176(-1), 'optionalAccess', _177 => _177.id]))), () => ( null)),
|
3383
3514
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
3384
3515
|
content: message.content,
|
3385
3516
|
attachments: _nullishCoalesce(message.attachments, () => ( []))
|
@@ -3391,9 +3522,8 @@ var getThreadState = (runtime) => {
|
|
3391
3522
|
threadId: runtime.threadId,
|
3392
3523
|
capabilities: runtime.capabilities,
|
3393
3524
|
isDisabled: runtime.isDisabled,
|
3394
|
-
isRunning: _optionalChain([lastMessage, 'optionalAccess',
|
3395
|
-
messages: runtime.messages
|
3396
|
-
unstable_synchronizer: runtime.unstable_synchronizer
|
3525
|
+
isRunning: _optionalChain([lastMessage, 'optionalAccess', _178 => _178.role]) !== "assistant" ? false : lastMessage.status.type === "running",
|
3526
|
+
messages: runtime.messages
|
3397
3527
|
});
|
3398
3528
|
};
|
3399
3529
|
var ThreadRuntime = (_class12 = class {
|
@@ -3443,7 +3573,7 @@ var ThreadRuntime = (_class12 = class {
|
|
3443
3573
|
subscribe: (callback) => threadBinding.subscribe(callback)
|
3444
3574
|
};
|
3445
3575
|
}
|
3446
|
-
__init23() {this.composer = new
|
3576
|
+
__init23() {this.composer = new ThreadComposerRuntime(
|
3447
3577
|
new NestedSubscriptionSubject({
|
3448
3578
|
getState: () => this._threadBinding.getState().composer,
|
3449
3579
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
@@ -3500,13 +3630,13 @@ var ThreadRuntime = (_class12 = class {
|
|
3500
3630
|
return this._threadBinding.getState().submitFeedback(options);
|
3501
3631
|
}
|
3502
3632
|
/**
|
3503
|
-
* @deprecated
|
3633
|
+
* @deprecated Use `getMesssageById(id).unstable_getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
|
3504
3634
|
*/
|
3505
3635
|
getEditComposer(messageId) {
|
3506
3636
|
return this._threadBinding.getState().getEditComposer(messageId);
|
3507
3637
|
}
|
3508
3638
|
/**
|
3509
|
-
* @deprecated
|
3639
|
+
* @deprecated Use `getMesssageById(id).unstable_getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
|
3510
3640
|
*/
|
3511
3641
|
beginEdit(messageId) {
|
3512
3642
|
return this._threadBinding.getState().beginEdit(messageId);
|
@@ -3522,15 +3652,15 @@ var ThreadRuntime = (_class12 = class {
|
|
3522
3652
|
return new MessageRuntime(
|
3523
3653
|
new ShallowMemoizeSubject({
|
3524
3654
|
getState: () => {
|
3525
|
-
const messages2 = this.messages;
|
3655
|
+
const messages2 = this.getState().messages;
|
3526
3656
|
const message = messages2[idx];
|
3527
|
-
if (!message) return
|
3657
|
+
if (!message) return SKIP_UPDATE;
|
3528
3658
|
const branches = this._threadBinding.getState().getBranches(message.id);
|
3529
3659
|
return {
|
3530
3660
|
...message,
|
3531
3661
|
message,
|
3532
3662
|
isLast: idx === messages2.length - 1,
|
3533
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
3663
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _179 => _179[idx - 1], 'optionalAccess', _180 => _180.id]), () => ( null)),
|
3534
3664
|
branches,
|
3535
3665
|
branchNumber: branches.indexOf(message.id) + 1,
|
3536
3666
|
branchCount: branches.length
|
@@ -3582,6 +3712,9 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
3582
3712
|
}
|
3583
3713
|
throw new Error("Only images with URL data are supported");
|
3584
3714
|
}
|
3715
|
+
case "file": {
|
3716
|
+
throw new Error("File content parts are not supported");
|
3717
|
+
}
|
3585
3718
|
default: {
|
3586
3719
|
const unhandledType = type;
|
3587
3720
|
throw new Error(`Unknown content part type: ${unhandledType}`);
|
@@ -3606,7 +3739,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
3606
3739
|
});
|
3607
3740
|
if (mergeRoundtrips) {
|
3608
3741
|
const previousMessage = messages2[messages2.length - 1];
|
3609
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
3742
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _181 => _181.role]) === "assistant") {
|
3610
3743
|
previousMessage.content.push(...newContent);
|
3611
3744
|
break;
|
3612
3745
|
}
|
@@ -3619,7 +3752,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
3619
3752
|
}
|
3620
3753
|
case "tool": {
|
3621
3754
|
const previousMessage = messages2[messages2.length - 1];
|
3622
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
3755
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _182 => _182.role]) !== "assistant")
|
3623
3756
|
throw new Error(
|
3624
3757
|
"A tool message must be preceded by an assistant message."
|
3625
3758
|
);
|
@@ -3848,7 +3981,7 @@ var useEdgeRuntime = ({
|
|
3848
3981
|
};
|
3849
3982
|
|
3850
3983
|
// src/runtimes/local/shouldContinue.tsx
|
3851
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
3984
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _183 => _183.status, 'optionalAccess', _184 => _184.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
3852
3985
|
|
3853
3986
|
// src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
|
3854
3987
|
var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
@@ -3932,18 +4065,18 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
3932
4065
|
set options({ initialMessages, ...options }) {
|
3933
4066
|
this._options = options;
|
3934
4067
|
let hasUpdates = false;
|
3935
|
-
const canSpeak = _optionalChain([options, 'access',
|
4068
|
+
const canSpeak = _optionalChain([options, 'access', _185 => _185.adapters, 'optionalAccess', _186 => _186.speech]) !== void 0;
|
3936
4069
|
if (this.capabilities.speak !== canSpeak) {
|
3937
4070
|
this.capabilities.speak = canSpeak;
|
3938
4071
|
hasUpdates = true;
|
3939
4072
|
}
|
3940
|
-
this.composer.setAttachmentAdapter(_optionalChain([options, 'access',
|
3941
|
-
const canAttach = _optionalChain([options, 'access',
|
4073
|
+
this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _187 => _187.adapters, 'optionalAccess', _188 => _188.attachments]));
|
4074
|
+
const canAttach = _optionalChain([options, 'access', _189 => _189.adapters, 'optionalAccess', _190 => _190.attachments]) !== void 0;
|
3942
4075
|
if (this.capabilities.attachments !== canAttach) {
|
3943
4076
|
this.capabilities.attachments = canAttach;
|
3944
4077
|
hasUpdates = true;
|
3945
4078
|
}
|
3946
|
-
const canFeedback = _optionalChain([options, 'access',
|
4079
|
+
const canFeedback = _optionalChain([options, 'access', _191 => _191.adapters, 'optionalAccess', _192 => _192.feedback]) !== void 0;
|
3947
4080
|
if (this.capabilities.feedback !== canFeedback) {
|
3948
4081
|
this.capabilities.feedback = canFeedback;
|
3949
4082
|
hasUpdates = true;
|
@@ -4002,18 +4135,18 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4002
4135
|
}
|
4003
4136
|
async performRoundtrip(parentId, message) {
|
4004
4137
|
const messages2 = this.repository.getMessages();
|
4005
|
-
_optionalChain([this, 'access',
|
4138
|
+
_optionalChain([this, 'access', _193 => _193.abortController, 'optionalAccess', _194 => _194.abort, 'call', _195 => _195()]);
|
4006
4139
|
this.abortController = new AbortController();
|
4007
4140
|
const initialContent = message.content;
|
4008
|
-
const initialRoundtrips = _optionalChain([message, 'access',
|
4009
|
-
const initalCustom = _optionalChain([message, 'access',
|
4141
|
+
const initialRoundtrips = _optionalChain([message, 'access', _196 => _196.metadata, 'optionalAccess', _197 => _197.roundtrips]);
|
4142
|
+
const initalCustom = _optionalChain([message, 'access', _198 => _198.metadata, 'optionalAccess', _199 => _199.custom]);
|
4010
4143
|
const updateMessage = (m) => {
|
4011
4144
|
message = {
|
4012
4145
|
...message,
|
4013
4146
|
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
4014
4147
|
status: _nullishCoalesce(m.status, () => ( message.status)),
|
4015
4148
|
// TODO deprecated, remove in v0.6
|
4016
|
-
..._optionalChain([m, 'access',
|
4149
|
+
..._optionalChain([m, 'access', _200 => _200.metadata, 'optionalAccess', _201 => _201.roundtrips]) ? {
|
4017
4150
|
roundtrips: [
|
4018
4151
|
..._nullishCoalesce(initialRoundtrips, () => ( [])),
|
4019
4152
|
...m.metadata.roundtrips
|
@@ -4028,7 +4161,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4028
4161
|
...m.metadata.roundtrips
|
4029
4162
|
]
|
4030
4163
|
} : void 0,
|
4031
|
-
..._optionalChain([m, 'access',
|
4164
|
+
..._optionalChain([m, 'access', _202 => _202.metadata, 'optionalAccess', _203 => _203.custom]) ? {
|
4032
4165
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
4033
4166
|
} : void 0
|
4034
4167
|
}
|
@@ -4038,7 +4171,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4038
4171
|
this.notifySubscribers();
|
4039
4172
|
};
|
4040
4173
|
const maxToolRoundtrips = _nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1));
|
4041
|
-
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access',
|
4174
|
+
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _204 => _204.metadata, 'optionalAccess', _205 => _205.roundtrips, 'optionalAccess', _206 => _206.length]), () => ( 0));
|
4042
4175
|
if (toolRoundtrips > maxToolRoundtrips) {
|
4043
4176
|
updateMessage({
|
4044
4177
|
status: {
|
@@ -4137,7 +4270,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4137
4270
|
// TODO lift utterance state to thread runtime
|
4138
4271
|
|
4139
4272
|
speak(messageId) {
|
4140
|
-
const adapter = _optionalChain([this, 'access',
|
4273
|
+
const adapter = _optionalChain([this, 'access', _207 => _207.options, 'access', _208 => _208.adapters, 'optionalAccess', _209 => _209.speech]);
|
4141
4274
|
if (!adapter) throw new Error("Speech adapter not configured");
|
4142
4275
|
const { message } = this.repository.getMessage(messageId);
|
4143
4276
|
if (this._utterance) {
|
@@ -4154,7 +4287,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4154
4287
|
return this._utterance;
|
4155
4288
|
}
|
4156
4289
|
submitFeedback({ messageId, type }) {
|
4157
|
-
const adapter = _optionalChain([this, 'access',
|
4290
|
+
const adapter = _optionalChain([this, 'access', _210 => _210.options, 'access', _211 => _211.adapters, 'optionalAccess', _212 => _212.feedback]);
|
4158
4291
|
if (!adapter) throw new Error("Feedback adapter not configured");
|
4159
4292
|
const { message } = this.repository.getMessage(messageId);
|
4160
4293
|
adapter.submit({ message, type });
|
@@ -4201,7 +4334,7 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4201
4334
|
const messages2 = fromCoreMessages(initialMessages);
|
4202
4335
|
this.thread.import({
|
4203
4336
|
messages: messages2.map((m, idx) => ({
|
4204
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
4337
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _213 => _213[idx - 1], 'optionalAccess', _214 => _214.id]), () => ( null)),
|
4205
4338
|
message: m
|
4206
4339
|
}))
|
4207
4340
|
});
|
@@ -4334,7 +4467,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
4334
4467
|
|
4335
4468
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
4336
4469
|
var hasUpcomingMessage = (isRunning, messages2) => {
|
4337
|
-
return isRunning && _optionalChain([messages2, 'access',
|
4470
|
+
return isRunning && _optionalChain([messages2, 'access', _215 => _215[messages2.length - 1], 'optionalAccess', _216 => _216.role]) !== "assistant";
|
4338
4471
|
};
|
4339
4472
|
var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
4340
4473
|
constructor(configProvider, store) {;_class15.prototype.__init32.call(this);_class15.prototype.__init33.call(this);_class15.prototype.__init34.call(this);_class15.prototype.__init35.call(this);_class15.prototype.__init36.call(this);_class15.prototype.__init37.call(this);_class15.prototype.__init38.call(this);_class15.prototype.__init39.call(this);
|
@@ -4396,12 +4529,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4396
4529
|
reload: this._store.onReload !== void 0,
|
4397
4530
|
cancel: this._store.onCancel !== void 0,
|
4398
4531
|
speak: this._store.onSpeak !== void 0,
|
4399
|
-
unstable_copy: _optionalChain([this, 'access',
|
4532
|
+
unstable_copy: _optionalChain([this, 'access', _220 => _220._store, 'access', _221 => _221.unstable_capabilities, 'optionalAccess', _222 => _222.copy]) !== false,
|
4400
4533
|
// default true
|
4401
|
-
attachments: !!_optionalChain([this, 'access',
|
4402
|
-
feedback: !!_optionalChain([this, 'access',
|
4534
|
+
attachments: !!_optionalChain([this, 'access', _223 => _223.store, 'access', _224 => _224.adapters, 'optionalAccess', _225 => _225.attachments]),
|
4535
|
+
feedback: !!_optionalChain([this, 'access', _226 => _226.store, 'access', _227 => _227.adapters, 'optionalAccess', _228 => _228.feedback])
|
4403
4536
|
};
|
4404
|
-
this.composer.setAttachmentAdapter(_optionalChain([this, 'access',
|
4537
|
+
this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _229 => _229._store, 'access', _230 => _230.adapters, 'optionalAccess', _231 => _231.attachments]));
|
4405
4538
|
if (oldStore) {
|
4406
4539
|
if (oldStore.convertMessage !== store.convertMessage) {
|
4407
4540
|
this.converter = new ThreadMessageConverter();
|
@@ -4427,7 +4560,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4427
4560
|
for (let i = 0; i < messages2.length; i++) {
|
4428
4561
|
const message = messages2[i];
|
4429
4562
|
const parent = messages2[i - 1];
|
4430
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
4563
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _232 => _232.id]), () => ( null)), message);
|
4431
4564
|
}
|
4432
4565
|
if (this.assistantOptimisticId) {
|
4433
4566
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -4435,7 +4568,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4435
4568
|
}
|
4436
4569
|
if (hasUpcomingMessage(isRunning, messages2)) {
|
4437
4570
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
4438
|
-
_nullishCoalesce(_optionalChain([messages2, 'access',
|
4571
|
+
_nullishCoalesce(_optionalChain([messages2, 'access', _233 => _233.at, 'call', _234 => _234(-1), 'optionalAccess', _235 => _235.id]), () => ( null)),
|
4439
4572
|
{
|
4440
4573
|
role: "assistant",
|
4441
4574
|
content: []
|
@@ -4443,7 +4576,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4443
4576
|
);
|
4444
4577
|
}
|
4445
4578
|
this.repository.resetHead(
|
4446
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access',
|
4579
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _236 => _236.at, 'call', _237 => _237(-1), 'optionalAccess', _238 => _238.id]))), () => ( null))
|
4447
4580
|
);
|
4448
4581
|
this.messages = this.repository.getMessages();
|
4449
4582
|
this.notifySubscribers();
|
@@ -4464,7 +4597,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4464
4597
|
this.updateMessages(this.repository.getMessages());
|
4465
4598
|
}
|
4466
4599
|
async append(message) {
|
4467
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
4600
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _239 => _239.messages, 'access', _240 => _240.at, 'call', _241 => _241(-1), 'optionalAccess', _242 => _242.id]), () => ( null)))) {
|
4468
4601
|
if (!this._store.onEdit)
|
4469
4602
|
throw new Error("Runtime does not support editing messages.");
|
4470
4603
|
await this._store.onEdit(message);
|
@@ -4487,7 +4620,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4487
4620
|
}
|
4488
4621
|
let messages2 = this.repository.getMessages();
|
4489
4622
|
const previousMessage = messages2[messages2.length - 1];
|
4490
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
4623
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _243 => _243.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _244 => _244.at, 'call', _245 => _245(-1), 'optionalAccess', _246 => _246.id])) {
|
4491
4624
|
this.repository.deleteMessage(previousMessage.id);
|
4492
4625
|
if (!this.composer.text.trim()) {
|
4493
4626
|
this.composer.setText(getThreadMessageText(previousMessage));
|
@@ -4512,7 +4645,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4512
4645
|
return this._store.onSpeak(message);
|
4513
4646
|
}
|
4514
4647
|
submitFeedback({ messageId, type }) {
|
4515
|
-
const adapter = _optionalChain([this, 'access',
|
4648
|
+
const adapter = _optionalChain([this, 'access', _247 => _247._store, 'access', _248 => _248.adapters, 'optionalAccess', _249 => _249.feedback]);
|
4516
4649
|
if (!adapter) throw new Error("Feedback adapter not configured");
|
4517
4650
|
const { message } = this.repository.getMessage(messageId);
|
4518
4651
|
adapter.submit({ message, type });
|
@@ -4522,7 +4655,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4522
4655
|
return () => this._subscriptions.delete(callback);
|
4523
4656
|
}
|
4524
4657
|
__init39() {this.updateMessages = (messages2) => {
|
4525
|
-
_optionalChain([this, 'access',
|
4658
|
+
_optionalChain([this, 'access', _250 => _250._store, 'access', _251 => _251.setMessages, 'optionalCall', _252 => _252(
|
4526
4659
|
messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
4527
4660
|
)]);
|
4528
4661
|
}}
|
@@ -4819,12 +4952,15 @@ var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.p
|
|
4819
4952
|
id: state.file.name,
|
4820
4953
|
type: "image",
|
4821
4954
|
name: state.file.name,
|
4822
|
-
|
4955
|
+
contentType: state.file.type,
|
4956
|
+
file: state.file,
|
4957
|
+
status: { type: "requires-action", reason: "composer-send" }
|
4823
4958
|
};
|
4824
4959
|
}
|
4825
4960
|
async send(attachment) {
|
4826
4961
|
return {
|
4827
4962
|
...attachment,
|
4963
|
+
status: { type: "complete" },
|
4828
4964
|
content: [
|
4829
4965
|
{
|
4830
4966
|
type: "image",
|
@@ -4851,12 +4987,15 @@ var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.pr
|
|
4851
4987
|
id: state.file.name,
|
4852
4988
|
type: "document",
|
4853
4989
|
name: state.file.name,
|
4854
|
-
|
4990
|
+
contentType: state.file.type,
|
4991
|
+
file: state.file,
|
4992
|
+
status: { type: "requires-action", reason: "composer-send" }
|
4855
4993
|
};
|
4856
4994
|
}
|
4857
4995
|
async send(attachment) {
|
4858
4996
|
return {
|
4859
4997
|
...attachment,
|
4998
|
+
status: { type: "complete" },
|
4860
4999
|
content: [
|
4861
5000
|
{
|
4862
5001
|
type: "text",
|
@@ -4939,7 +5078,14 @@ var CompositeAttachmentAdapter = class {
|
|
4939
5078
|
async remove(attachment) {
|
4940
5079
|
const adapters = this._adapters.slice();
|
4941
5080
|
for (const adapter of adapters) {
|
4942
|
-
if (fileMatchesAccept(
|
5081
|
+
if (fileMatchesAccept(
|
5082
|
+
{
|
5083
|
+
name: attachment.name,
|
5084
|
+
type: _nullishCoalesce(attachment.contentType, () => ( "unknown/unknown"))
|
5085
|
+
// TODO remove after 0.6.0
|
5086
|
+
},
|
5087
|
+
adapter.accept
|
5088
|
+
)) {
|
4943
5089
|
return adapter.remove(attachment);
|
4944
5090
|
}
|
4945
5091
|
}
|
@@ -4963,7 +5109,7 @@ var ThreadConfigProvider = ({
|
|
4963
5109
|
}) => {
|
4964
5110
|
const hasAssistant = !!useAssistantRuntime({ optional: true });
|
4965
5111
|
const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
|
4966
|
-
if (!_optionalChain([config, 'optionalAccess',
|
5112
|
+
if (!_optionalChain([config, 'optionalAccess', _253 => _253.runtime])) return configProvider;
|
4967
5113
|
if (hasAssistant) {
|
4968
5114
|
throw new Error(
|
4969
5115
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -5157,7 +5303,7 @@ var useAllowBranchPicker = (ensureCapability = false) => {
|
|
5157
5303
|
return allowBranchPicker && (!ensureCapability || branchPickerSupported);
|
5158
5304
|
};
|
5159
5305
|
var BranchPicker = () => {
|
5160
|
-
const allowBranchPicker = useAllowBranchPicker();
|
5306
|
+
const allowBranchPicker = useAllowBranchPicker(true);
|
5161
5307
|
if (!allowBranchPicker) return null;
|
5162
5308
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, BranchPickerRoot, { hideWhenSingleBranch: true, children: [
|
5163
5309
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerPrevious2, {}),
|
@@ -5291,7 +5437,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
5291
5437
|
{
|
5292
5438
|
components: {
|
5293
5439
|
...componentsProp,
|
5294
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
5440
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _254 => _254.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
|
5295
5441
|
tools: toolsComponents
|
5296
5442
|
}
|
5297
5443
|
}
|
@@ -5346,7 +5492,7 @@ var ComposerAttachmentRoot = withDefaults("div", {
|
|
5346
5492
|
});
|
5347
5493
|
ComposerAttachmentRoot.displayName = "ComposerAttachmentRoot";
|
5348
5494
|
var ComposerAttachment2 = () => {
|
5349
|
-
const attachment =
|
5495
|
+
const attachment = useThreadComposerAttachment((a) => a.attachment);
|
5350
5496
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerAttachmentRoot, { children: [
|
5351
5497
|
".",
|
5352
5498
|
attachment.name.split(".").pop(),
|
@@ -5360,10 +5506,9 @@ var ComposerAttachmentRemove = _react.forwardRef.call(void 0, (props, ref) => {
|
|
5360
5506
|
composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
|
5361
5507
|
} = {}
|
5362
5508
|
} = useThreadConfig();
|
5363
|
-
const
|
5364
|
-
const attachmentStore = useAttachmentStore();
|
5509
|
+
const attachmentRuntime = useAttachmentRuntime();
|
5365
5510
|
const handleRemoveAttachment = () => {
|
5366
|
-
|
5511
|
+
attachmentRuntime.remove();
|
5367
5512
|
};
|
5368
5513
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5369
5514
|
TooltipIconButton,
|
@@ -5434,7 +5579,7 @@ var ComposerAttachments = ({ components }) => {
|
|
5434
5579
|
{
|
5435
5580
|
components: {
|
5436
5581
|
...components,
|
5437
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5582
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _255 => _255.Attachment]), () => ( composer_attachment_default))
|
5438
5583
|
}
|
5439
5584
|
}
|
5440
5585
|
) });
|
@@ -5566,7 +5711,7 @@ var ThreadWelcomeSuggestion = ({
|
|
5566
5711
|
};
|
5567
5712
|
var ThreadWelcomeSuggestions = () => {
|
5568
5713
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5569
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess',
|
5714
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _256 => _256.map, 'call', _257 => _257((suggestion, idx) => {
|
5570
5715
|
const key = `${suggestion.prompt}-${idx}`;
|
5571
5716
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
5572
5717
|
})]) });
|
@@ -5665,7 +5810,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
|
|
5665
5810
|
{
|
5666
5811
|
components: {
|
5667
5812
|
...components,
|
5668
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5813
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _258 => _258.Text]), () => ( content_part_default.Text))
|
5669
5814
|
}
|
5670
5815
|
}
|
5671
5816
|
) });
|
@@ -5683,7 +5828,7 @@ var UserMessageAttachments = ({
|
|
5683
5828
|
{
|
5684
5829
|
components: {
|
5685
5830
|
...components,
|
5686
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5831
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _259 => _259.Attachment]), () => ( user_message_attachment_default))
|
5687
5832
|
}
|
5688
5833
|
}
|
5689
5834
|
) }) });
|
@@ -5784,10 +5929,10 @@ var ThreadMessages = ({ components, ...rest }) => {
|
|
5784
5929
|
thread_exports.Messages,
|
5785
5930
|
{
|
5786
5931
|
components: {
|
5787
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5788
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5789
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5790
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5932
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _260 => _260.UserMessage]), () => ( user_message_default)),
|
5933
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _261 => _261.EditComposer]), () => ( edit_composer_default)),
|
5934
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _262 => _262.AssistantMessage]), () => ( assistant_message_default)),
|
5935
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _263 => _263.SystemMessage]), () => ( SystemMessage))
|
5791
5936
|
},
|
5792
5937
|
...rest
|
5793
5938
|
}
|