@assistant-ui/react 0.5.75 → 0.5.76
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +160 -134
- package/dist/index.d.ts +160 -134
- package/dist/index.js +416 -412
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +297 -293
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +47 -18
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +19 -7
- package/package.json +3 -3
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17;
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13; var _class14; var _class15; var _class16; var _class17; var _class18;
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -631,13 +631,9 @@ var useActionBarStopSpeaking = () => {
|
|
631
631
|
|
632
632
|
var useActionBarFeedbackPositive = () => {
|
633
633
|
const messageRuntime = useMessageRuntime();
|
634
|
-
const messageUtilsStore = useMessageUtilsStore();
|
635
634
|
const callback = _react.useCallback.call(void 0, () => {
|
636
|
-
messageRuntime.submitFeedback({
|
637
|
-
|
638
|
-
});
|
639
|
-
messageUtilsStore.getState().setSubmittedFeedback("positive");
|
640
|
-
}, [messageUtilsStore, messageRuntime]);
|
635
|
+
messageRuntime.submitFeedback({ type: "positive" });
|
636
|
+
}, [messageRuntime]);
|
641
637
|
return callback;
|
642
638
|
};
|
643
639
|
|
@@ -645,13 +641,9 @@ var useActionBarFeedbackPositive = () => {
|
|
645
641
|
|
646
642
|
var useActionBarFeedbackNegative = () => {
|
647
643
|
const messageRuntime = useMessageRuntime();
|
648
|
-
const messageUtilsStore = useMessageUtilsStore();
|
649
644
|
const callback = _react.useCallback.call(void 0, () => {
|
650
|
-
messageRuntime.submitFeedback({
|
651
|
-
|
652
|
-
});
|
653
|
-
messageUtilsStore.getState().setSubmittedFeedback("negative");
|
654
|
-
}, [messageUtilsStore, messageRuntime]);
|
645
|
+
messageRuntime.submitFeedback({ type: "negative" });
|
646
|
+
}, [messageRuntime]);
|
655
647
|
return callback;
|
656
648
|
};
|
657
649
|
|
@@ -739,23 +731,21 @@ var useComposerSend = () => {
|
|
739
731
|
|
740
732
|
var useComposerAddAttachment = () => {
|
741
733
|
const disabled = useComposer((c) => !c.isEditing);
|
742
|
-
const
|
743
|
-
const threadRuntimeStore = useThreadComposerStore();
|
734
|
+
const composerRuntime = useComposerRuntime();
|
744
735
|
const callback = _react.useCallback.call(void 0, () => {
|
745
|
-
const { addAttachment } = threadComposerStore.getState();
|
746
|
-
const { attachmentAccept } = threadRuntimeStore.getState();
|
747
736
|
const input = document.createElement("input");
|
748
737
|
input.type = "file";
|
738
|
+
const attachmentAccept = composerRuntime.getAttachmentAccept();
|
749
739
|
if (attachmentAccept !== "*") {
|
750
740
|
input.accept = attachmentAccept;
|
751
741
|
}
|
752
742
|
input.onchange = (e) => {
|
753
743
|
const file = _optionalChain([e, 'access', _7 => _7.target, 'access', _8 => _8.files, 'optionalAccess', _9 => _9[0]]);
|
754
744
|
if (!file) return;
|
755
|
-
addAttachment(file);
|
745
|
+
composerRuntime.addAttachment(file);
|
756
746
|
};
|
757
747
|
input.click();
|
758
|
-
}, [
|
748
|
+
}, [composerRuntime]);
|
759
749
|
if (disabled) return null;
|
760
750
|
return callback;
|
761
751
|
};
|
@@ -802,7 +792,15 @@ var useMessageIf = (props) => {
|
|
802
792
|
const messageUtilsStore = useMessageUtilsStore();
|
803
793
|
return useCombinedStore(
|
804
794
|
[messageStore, messageUtilsStore],
|
805
|
-
({
|
795
|
+
({
|
796
|
+
role,
|
797
|
+
attachments,
|
798
|
+
content,
|
799
|
+
branchCount,
|
800
|
+
isLast,
|
801
|
+
speech,
|
802
|
+
submittedFeedback
|
803
|
+
}, { isCopied, isHovering }) => {
|
806
804
|
if (props.hasBranches === true && branchCount < 2) return false;
|
807
805
|
if (props.user && role !== "user") return false;
|
808
806
|
if (props.assistant && role !== "assistant") return false;
|
@@ -816,7 +814,9 @@ var useMessageIf = (props) => {
|
|
816
814
|
return false;
|
817
815
|
if (props.hasAttachments === false && role === "user" && !!attachments.length)
|
818
816
|
return false;
|
819
|
-
if (props.
|
817
|
+
if (props.hasContent === true && content.length === 0) return false;
|
818
|
+
if (props.hasContent === false && content.length > 0) return false;
|
819
|
+
if (props.submittedFeedback !== void 0 && (_nullishCoalesce(_optionalChain([submittedFeedback, 'optionalAccess', _10 => _10.type]), () => ( null))) !== props.submittedFeedback)
|
820
820
|
return false;
|
821
821
|
return true;
|
822
822
|
}
|
@@ -912,7 +912,7 @@ var useActionBarFloatStatus = ({
|
|
912
912
|
const autohideEnabled = autohide === "always" || autohide === "not-last" && !m.isLast;
|
913
913
|
if (!autohideEnabled) return "normal" /* Normal */;
|
914
914
|
if (!mu.isHovering) return "hidden" /* Hidden */;
|
915
|
-
if (autohideFloat === "always" || autohideFloat === "single-branch" && m.
|
915
|
+
if (autohideFloat === "always" || autohideFloat === "single-branch" && m.branchCount <= 1)
|
916
916
|
return "floating" /* Floating */;
|
917
917
|
return "normal" /* Normal */;
|
918
918
|
}
|
@@ -956,7 +956,7 @@ var ActionBarPrimitiveCopy = _react.forwardRef.call(void 0, ({ copiedDuration, o
|
|
956
956
|
ref: forwardedRef,
|
957
957
|
disabled: disabled || !callback,
|
958
958
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
959
|
-
_optionalChain([callback, 'optionalCall',
|
959
|
+
_optionalChain([callback, 'optionalCall', _11 => _11()]);
|
960
960
|
})
|
961
961
|
}
|
962
962
|
);
|
@@ -988,7 +988,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
988
988
|
ref: forwardedRef,
|
989
989
|
disabled: primitiveProps.disabled || !callback,
|
990
990
|
onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
|
991
|
-
_optionalChain([callback, 'optionalCall',
|
991
|
+
_optionalChain([callback, 'optionalCall', _12 => _12()]);
|
992
992
|
})
|
993
993
|
}
|
994
994
|
);
|
@@ -1037,7 +1037,7 @@ var ActionBarPrimitiveStopSpeaking = _react.forwardRef.call(void 0, (props, ref)
|
|
1037
1037
|
...props,
|
1038
1038
|
ref,
|
1039
1039
|
onClick: _primitive.composeEventHandlers.call(void 0, props.onClick, () => {
|
1040
|
-
_optionalChain([callback, 'optionalCall',
|
1040
|
+
_optionalChain([callback, 'optionalCall', _13 => _13()]);
|
1041
1041
|
})
|
1042
1042
|
}
|
1043
1043
|
);
|
@@ -1050,8 +1050,8 @@ ActionBarPrimitiveStopSpeaking.displayName = "ActionBarPrimitive.StopSpeaking";
|
|
1050
1050
|
|
1051
1051
|
|
1052
1052
|
var ActionBarPrimitiveFeedbackPositive = _react.forwardRef.call(void 0, ({ onClick, disabled, ...props }, forwardedRef) => {
|
1053
|
-
const isSubmitted =
|
1054
|
-
(u) => u.submittedFeedback === "positive"
|
1053
|
+
const isSubmitted = useMessage(
|
1054
|
+
(u) => _optionalChain([u, 'access', _14 => _14.submittedFeedback, 'optionalAccess', _15 => _15.type]) === "positive"
|
1055
1055
|
);
|
1056
1056
|
const callback = useActionBarFeedbackPositive();
|
1057
1057
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
@@ -1063,7 +1063,7 @@ var ActionBarPrimitiveFeedbackPositive = _react.forwardRef.call(void 0, ({ onCli
|
|
1063
1063
|
ref: forwardedRef,
|
1064
1064
|
disabled: disabled || !callback,
|
1065
1065
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
1066
|
-
_optionalChain([callback, 'optionalCall',
|
1066
|
+
_optionalChain([callback, 'optionalCall', _16 => _16()]);
|
1067
1067
|
})
|
1068
1068
|
}
|
1069
1069
|
);
|
@@ -1076,8 +1076,8 @@ ActionBarPrimitiveFeedbackPositive.displayName = "ActionBarPrimitive.FeedbackPos
|
|
1076
1076
|
|
1077
1077
|
|
1078
1078
|
var ActionBarPrimitiveFeedbackNegative = _react.forwardRef.call(void 0, ({ onClick, disabled, ...props }, forwardedRef) => {
|
1079
|
-
const isSubmitted =
|
1080
|
-
(u) => u.submittedFeedback === "negative"
|
1079
|
+
const isSubmitted = useMessage(
|
1080
|
+
(u) => _optionalChain([u, 'access', _17 => _17.submittedFeedback, 'optionalAccess', _18 => _18.type]) === "negative"
|
1081
1081
|
);
|
1082
1082
|
const callback = useActionBarFeedbackNegative();
|
1083
1083
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
@@ -1089,7 +1089,7 @@ var ActionBarPrimitiveFeedbackNegative = _react.forwardRef.call(void 0, ({ onCli
|
|
1089
1089
|
ref: forwardedRef,
|
1090
1090
|
disabled: disabled || !callback,
|
1091
1091
|
onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
|
1092
|
-
_optionalChain([callback, 'optionalCall',
|
1092
|
+
_optionalChain([callback, 'optionalCall', _19 => _19()]);
|
1093
1093
|
})
|
1094
1094
|
}
|
1095
1095
|
);
|
@@ -1249,7 +1249,7 @@ var AttachmentContext = _react.createContext.call(void 0,
|
|
1249
1249
|
);
|
1250
1250
|
function useAttachmentContext(options) {
|
1251
1251
|
const context = _react.useContext.call(void 0, AttachmentContext);
|
1252
|
-
if (!_optionalChain([options, 'optionalAccess',
|
1252
|
+
if (!_optionalChain([options, 'optionalAccess', _20 => _20.optional]) && !context)
|
1253
1253
|
throw new Error(
|
1254
1254
|
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
1255
1255
|
);
|
@@ -1301,9 +1301,9 @@ var { useAttachment: useMessageAttachment } = createContextStoreHook(
|
|
1301
1301
|
// src/primitives/attachment/AttachmentThumb.tsx
|
1302
1302
|
|
1303
1303
|
|
1304
|
-
var AttachmentPrimitiveThumb = _react.forwardRef.call(void 0, () => {
|
1304
|
+
var AttachmentPrimitiveThumb = _react.forwardRef.call(void 0, (props, ref) => {
|
1305
1305
|
const ext = useAttachment((a) => a.name.split(".").pop());
|
1306
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactprimitive.Primitive.div, { children: [
|
1306
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _reactprimitive.Primitive.div, { ...props, ref, children: [
|
1307
1307
|
".",
|
1308
1308
|
ext
|
1309
1309
|
] });
|
@@ -1530,7 +1530,7 @@ var withSmoothContextProvider = (Component) => {
|
|
1530
1530
|
};
|
1531
1531
|
function useSmoothContext(options) {
|
1532
1532
|
const context = _react.useContext.call(void 0, SmoothContext);
|
1533
|
-
if (!_optionalChain([options, 'optionalAccess',
|
1533
|
+
if (!_optionalChain([options, 'optionalAccess', _21 => _21.optional]) && !context)
|
1534
1534
|
throw new Error(
|
1535
1535
|
"This component must be used within a SmoothContextProvider."
|
1536
1536
|
);
|
@@ -1740,7 +1740,7 @@ var BaseSubject = (_class2 = class {constructor() { _class2.prototype.__init5.ca
|
|
1740
1740
|
if (this._connection) return;
|
1741
1741
|
this._connection = this._connect();
|
1742
1742
|
} else {
|
1743
|
-
_optionalChain([this, 'access',
|
1743
|
+
_optionalChain([this, 'access', _22 => _22._connection, 'optionalCall', _23 => _23()]);
|
1744
1744
|
this._connection = void 0;
|
1745
1745
|
}
|
1746
1746
|
}
|
@@ -1839,40 +1839,38 @@ var EMPTY_ARRAY = Object.freeze([]);
|
|
1839
1839
|
var getThreadComposerState = (runtime, focus, onFocus) => {
|
1840
1840
|
return Object.freeze({
|
1841
1841
|
type: "thread",
|
1842
|
-
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1843
|
-
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1844
|
-
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1845
|
-
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1846
|
-
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _29 => _29.setText, 'access', _30 => _30.bind, 'call', _31 => _31(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1842
|
+
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _24 => _24.isEditing]), () => ( false)),
|
1843
|
+
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _25 => _25.canCancel]), () => ( false)),
|
1844
|
+
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _26 => _26.isEmpty]), () => ( true)),
|
1845
|
+
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _27 => _27.text]), () => ( "")),
|
1846
|
+
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _28 => _28.attachments]), () => ( EMPTY_ARRAY)),
|
1847
|
+
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _29 => _29.text]), () => ( "")),
|
1848
|
+
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _30 => _30.setText, 'access', _31 => _31.bind, 'call', _32 => _32(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1849
|
+
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _33 => _33.setText, 'access', _34 => _34.bind, 'call', _35 => _35(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1851
1850
|
// edit: beginEdit,
|
1852
|
-
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1853
|
-
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1851
|
+
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _36 => _36.send, 'access', _37 => _37.bind, 'call', _38 => _38(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1852
|
+
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _39 => _39.cancel, 'access', _40 => _40.bind, 'call', _41 => _41(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1854
1853
|
focus,
|
1855
1854
|
onFocus,
|
1856
|
-
reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1857
|
-
addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1858
|
-
removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1855
|
+
reset: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _42 => _42.reset, 'access', _43 => _43.bind, 'call', _44 => _44(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1856
|
+
addAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _45 => _45.addAttachment, 'access', _46 => _46.bind, 'call', _47 => _47(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1857
|
+
removeAttachment: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _48 => _48.removeAttachment, 'access', _49 => _49.bind, 'call', _50 => _50(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1859
1858
|
});
|
1860
1859
|
};
|
1861
1860
|
var getEditComposerState = (runtime, beginEdit) => {
|
1862
1861
|
return Object.freeze({
|
1863
1862
|
type: "edit",
|
1864
|
-
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1865
|
-
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1866
|
-
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1867
|
-
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1868
|
-
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _57 => _57.setText, 'access', _58 => _58.bind, 'call', _59 => _59(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1863
|
+
isEditing: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _51 => _51.isEditing]), () => ( false)),
|
1864
|
+
canCancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _52 => _52.canCancel]), () => ( false)),
|
1865
|
+
isEmpty: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _53 => _53.isEmpty]), () => ( true)),
|
1866
|
+
text: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _54 => _54.text]), () => ( "")),
|
1867
|
+
attachments: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _55 => _55.attachments]), () => ( EMPTY_ARRAY)),
|
1868
|
+
value: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _56 => _56.text]), () => ( "")),
|
1869
|
+
setValue: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _57 => _57.setText, 'access', _58 => _58.bind, 'call', _59 => _59(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1870
|
+
setText: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _60 => _60.setText, 'access', _61 => _61.bind, 'call', _62 => _62(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1873
1871
|
edit: beginEdit,
|
1874
|
-
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1875
|
-
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess',
|
1872
|
+
send: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _63 => _63.send, 'access', _64 => _64.bind, 'call', _65 => _65(runtime)]), () => ( METHOD_NOT_SUPPORTED)),
|
1873
|
+
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _66 => _66.cancel, 'access', _67 => _67.bind, 'call', _68 => _68(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1876
1874
|
});
|
1877
1875
|
};
|
1878
1876
|
var ComposerRuntimeImpl = class {
|
@@ -1903,12 +1901,6 @@ var ComposerRuntimeImpl = class {
|
|
1903
1901
|
get text() {
|
1904
1902
|
return this.getState().text;
|
1905
1903
|
}
|
1906
|
-
/**
|
1907
|
-
* @deprecated Use `getState().attachmentAccept` instead. This will be removed in 0.6.0.
|
1908
|
-
*/
|
1909
|
-
get attachmentAccept() {
|
1910
|
-
return this.getState().attachmentAccept;
|
1911
|
-
}
|
1912
1904
|
/**
|
1913
1905
|
* @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
|
1914
1906
|
*/
|
@@ -1963,6 +1955,11 @@ var ComposerRuntimeImpl = class {
|
|
1963
1955
|
subscribe(callback) {
|
1964
1956
|
return this._core.subscribe(callback);
|
1965
1957
|
}
|
1958
|
+
getAttachmentAccept() {
|
1959
|
+
const core = this._core.getState();
|
1960
|
+
if (!core) throw new Error("Composer is not available");
|
1961
|
+
return core.getAttachmentAccept();
|
1962
|
+
}
|
1966
1963
|
};
|
1967
1964
|
var ThreadComposerRuntimeImpl = (_class5 = class extends ComposerRuntimeImpl {
|
1968
1965
|
get type() {
|
@@ -1985,7 +1982,7 @@ var ThreadComposerRuntimeImpl = (_class5 = class extends ComposerRuntimeImpl {
|
|
1985
1982
|
this._getState = stateBinding.getState.bind(stateBinding);
|
1986
1983
|
}
|
1987
1984
|
get attachments() {
|
1988
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
1985
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _69 => _69.getState, 'call', _70 => _70(), 'optionalAccess', _71 => _71.attachments]), () => ( EMPTY_ARRAY));
|
1989
1986
|
}
|
1990
1987
|
getState() {
|
1991
1988
|
return this._getState();
|
@@ -2087,19 +2084,19 @@ var NestedSubscriptionSubject = class extends BaseSubject {
|
|
2087
2084
|
this.notifySubscribers();
|
2088
2085
|
};
|
2089
2086
|
let lastState = this.binding.getState();
|
2090
|
-
let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess',
|
2087
|
+
let innerUnsubscribe = _optionalChain([lastState, 'optionalAccess', _72 => _72.subscribe, 'call', _73 => _73(callback)]);
|
2091
2088
|
const onRuntimeUpdate = () => {
|
2092
2089
|
const newState = this.binding.getState();
|
2093
2090
|
if (newState === lastState) return;
|
2094
2091
|
lastState = newState;
|
2095
|
-
_optionalChain([innerUnsubscribe, 'optionalCall',
|
2096
|
-
innerUnsubscribe = _optionalChain([this, 'access',
|
2092
|
+
_optionalChain([innerUnsubscribe, 'optionalCall', _74 => _74()]);
|
2093
|
+
innerUnsubscribe = _optionalChain([this, 'access', _75 => _75.binding, 'access', _76 => _76.getState, 'call', _77 => _77(), 'optionalAccess', _78 => _78.subscribe, 'call', _79 => _79(callback)]);
|
2097
2094
|
callback();
|
2098
2095
|
};
|
2099
2096
|
const outerUnsubscribe = this.binding.subscribe(onRuntimeUpdate);
|
2100
2097
|
return () => {
|
2101
|
-
_optionalChain([outerUnsubscribe, 'optionalCall',
|
2102
|
-
_optionalChain([innerUnsubscribe, 'optionalCall',
|
2098
|
+
_optionalChain([outerUnsubscribe, 'optionalCall', _80 => _80()]);
|
2099
|
+
_optionalChain([innerUnsubscribe, 'optionalCall', _81 => _81()]);
|
2103
2100
|
};
|
2104
2101
|
}
|
2105
2102
|
};
|
@@ -2169,7 +2166,7 @@ var MessageRuntimeImpl = (_class6 = class {
|
|
2169
2166
|
const state = this._core.getState();
|
2170
2167
|
if (!state) throw new Error("Message is not available");
|
2171
2168
|
const thread = this._threadBinding.getState();
|
2172
|
-
if (_optionalChain([thread, 'access',
|
2169
|
+
if (_optionalChain([thread, 'access', _82 => _82.speech, 'optionalAccess', _83 => _83.messageId]) === state.id) {
|
2173
2170
|
this._threadBinding.getState().stopSpeaking();
|
2174
2171
|
} else {
|
2175
2172
|
throw new Error("Message is not being spoken");
|
@@ -2226,7 +2223,7 @@ var MessageRuntimeImpl = (_class6 = class {
|
|
2226
2223
|
new ShallowMemoizeSubject({
|
2227
2224
|
getState: () => {
|
2228
2225
|
const attachments = this.getState().attachments;
|
2229
|
-
const attachment = _optionalChain([attachments, 'optionalAccess',
|
2226
|
+
const attachment = _optionalChain([attachments, 'optionalAccess', _84 => _84[idx]]);
|
2230
2227
|
if (!attachment) return SKIP_UPDATE;
|
2231
2228
|
return {
|
2232
2229
|
...attachment,
|
@@ -2315,7 +2312,7 @@ var MessageContentPartImpl = ({
|
|
2315
2312
|
};
|
2316
2313
|
var MessageContentPart = _react.memo.call(void 0,
|
2317
2314
|
MessageContentPartImpl,
|
2318
|
-
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access',
|
2315
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _85 => _85.components, 'optionalAccess', _86 => _86.Text]) === _optionalChain([next, 'access', _87 => _87.components, 'optionalAccess', _88 => _88.Text]) && _optionalChain([prev, 'access', _89 => _89.components, 'optionalAccess', _90 => _90.Image]) === _optionalChain([next, 'access', _91 => _91.components, 'optionalAccess', _92 => _92.Image]) && _optionalChain([prev, 'access', _93 => _93.components, 'optionalAccess', _94 => _94.UI]) === _optionalChain([next, 'access', _95 => _95.components, 'optionalAccess', _96 => _96.UI]) && _optionalChain([prev, 'access', _97 => _97.components, 'optionalAccess', _98 => _98.tools]) === _optionalChain([next, 'access', _99 => _99.components, 'optionalAccess', _100 => _100.tools])
|
2319
2316
|
);
|
2320
2317
|
var MessagePrimitiveContent = ({
|
2321
2318
|
components
|
@@ -2381,11 +2378,11 @@ var getComponent = (components, attachment) => {
|
|
2381
2378
|
const type = attachment.type;
|
2382
2379
|
switch (type) {
|
2383
2380
|
case "image":
|
2384
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2381
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _101 => _101.Image]), () => ( _optionalChain([components, 'optionalAccess', _102 => _102.Attachment])));
|
2385
2382
|
case "document":
|
2386
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2383
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _103 => _103.Document]), () => ( _optionalChain([components, 'optionalAccess', _104 => _104.Attachment])));
|
2387
2384
|
case "file":
|
2388
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2385
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _105 => _105.File]), () => ( _optionalChain([components, 'optionalAccess', _106 => _106.Attachment])));
|
2389
2386
|
default:
|
2390
2387
|
const _exhaustiveCheck = type;
|
2391
2388
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -2408,7 +2405,7 @@ var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2408
2405
|
};
|
2409
2406
|
var MessageAttachment = _react.memo.call(void 0,
|
2410
2407
|
MessageAttachmentImpl,
|
2411
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2408
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _107 => _107.components, 'optionalAccess', _108 => _108.Image]) === _optionalChain([next, 'access', _109 => _109.components, 'optionalAccess', _110 => _110.Image]) && _optionalChain([prev, 'access', _111 => _111.components, 'optionalAccess', _112 => _112.Document]) === _optionalChain([next, 'access', _113 => _113.components, 'optionalAccess', _114 => _114.Document]) && _optionalChain([prev, 'access', _115 => _115.components, 'optionalAccess', _116 => _116.File]) === _optionalChain([next, 'access', _117 => _117.components, 'optionalAccess', _118 => _118.File]) && _optionalChain([prev, 'access', _119 => _119.components, 'optionalAccess', _120 => _120.Attachment]) === _optionalChain([next, 'access', _121 => _121.components, 'optionalAccess', _122 => _122.Attachment])
|
2412
2409
|
);
|
2413
2410
|
var MessagePrimitiveAttachments = ({ components }) => {
|
2414
2411
|
const attachmentsCount = useMessage(({ message }) => {
|
@@ -2519,7 +2516,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
2519
2516
|
const { isRunning } = threadStore.getState();
|
2520
2517
|
if (!isRunning) {
|
2521
2518
|
e.preventDefault();
|
2522
|
-
_optionalChain([textareaRef, 'access',
|
2519
|
+
_optionalChain([textareaRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.closest, 'call', _125 => _125("form"), 'optionalAccess', _126 => _126.requestSubmit, 'call', _127 => _127()]);
|
2523
2520
|
}
|
2524
2521
|
}
|
2525
2522
|
};
|
@@ -2584,11 +2581,11 @@ var getComponent2 = (components, attachment) => {
|
|
2584
2581
|
const type = attachment.type;
|
2585
2582
|
switch (type) {
|
2586
2583
|
case "image":
|
2587
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2584
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _128 => _128.Image]), () => ( _optionalChain([components, 'optionalAccess', _129 => _129.Attachment])));
|
2588
2585
|
case "document":
|
2589
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2586
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _130 => _130.Document]), () => ( _optionalChain([components, 'optionalAccess', _131 => _131.Attachment])));
|
2590
2587
|
case "file":
|
2591
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
2588
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _132 => _132.File]), () => ( _optionalChain([components, 'optionalAccess', _133 => _133.Attachment])));
|
2592
2589
|
default:
|
2593
2590
|
const _exhaustiveCheck = type;
|
2594
2591
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
@@ -2611,7 +2608,7 @@ var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2611
2608
|
};
|
2612
2609
|
var ComposerAttachment = _react.memo.call(void 0,
|
2613
2610
|
ComposerAttachmentImpl,
|
2614
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
2611
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _134 => _134.components, 'optionalAccess', _135 => _135.Image]) === _optionalChain([next, 'access', _136 => _136.components, 'optionalAccess', _137 => _137.Image]) && _optionalChain([prev, 'access', _138 => _138.components, 'optionalAccess', _139 => _139.Document]) === _optionalChain([next, 'access', _140 => _140.components, 'optionalAccess', _141 => _141.Document]) && _optionalChain([prev, 'access', _142 => _142.components, 'optionalAccess', _143 => _143.File]) === _optionalChain([next, 'access', _144 => _144.components, 'optionalAccess', _145 => _145.File]) && _optionalChain([prev, 'access', _146 => _146.components, 'optionalAccess', _147 => _147.Attachment]) === _optionalChain([next, 'access', _148 => _148.components, 'optionalAccess', _149 => _149.Attachment])
|
2615
2612
|
);
|
2616
2613
|
var ComposerPrimitiveAttachments = ({ components }) => {
|
2617
2614
|
const attachmentsCount = useComposer((s) => s.attachments.length);
|
@@ -2827,10 +2824,6 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
|
2827
2824
|
isHovering: false,
|
2828
2825
|
setIsHovering: (value) => {
|
2829
2826
|
set({ isHovering: value });
|
2830
|
-
},
|
2831
|
-
submittedFeedback: null,
|
2832
|
-
setSubmittedFeedback: (feedback) => {
|
2833
|
-
set({ submittedFeedback: feedback });
|
2834
2827
|
}
|
2835
2828
|
};
|
2836
2829
|
});
|
@@ -2966,7 +2959,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2966
2959
|
let first = true;
|
2967
2960
|
let cleanup;
|
2968
2961
|
const inner = () => {
|
2969
|
-
_optionalChain([cleanup, 'optionalCall',
|
2962
|
+
_optionalChain([cleanup, 'optionalCall', _150 => _150()]);
|
2970
2963
|
cleanup = runtime.thread.subscribe(callback);
|
2971
2964
|
if (!first) {
|
2972
2965
|
callback();
|
@@ -2977,7 +2970,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
2977
2970
|
inner();
|
2978
2971
|
return () => {
|
2979
2972
|
unsubscribe();
|
2980
|
-
_optionalChain([cleanup, 'optionalCall',
|
2973
|
+
_optionalChain([cleanup, 'optionalCall', _151 => _151()]);
|
2981
2974
|
};
|
2982
2975
|
};
|
2983
2976
|
|
@@ -3025,10 +3018,12 @@ _chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
|
|
3025
3018
|
|
3026
3019
|
// src/runtimes/composer/BaseComposerRuntimeCore.tsx
|
3027
3020
|
var isAttachmentComplete = (a) => a.status.type === "complete";
|
3028
|
-
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);
|
3021
|
+
var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototype.__init13.call(this);_class8.prototype.__init14.call(this);_class8.prototype.__init15.call(this);_class8.prototype.__init16.call(this); }
|
3029
3022
|
__init13() {this.isEditing = true}
|
3030
|
-
|
3031
|
-
|
3023
|
+
getAttachmentAccept() {
|
3024
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _152 => _152.getAttachmentAdapter, 'call', _153 => _153(), 'optionalAccess', _154 => _154.accept]), () => ( "*"));
|
3025
|
+
}
|
3026
|
+
__init14() {this._attachments = []}
|
3032
3027
|
set attachments(value) {
|
3033
3028
|
this._attachments = value;
|
3034
3029
|
this.notifySubscribers();
|
@@ -3039,7 +3034,7 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
|
|
3039
3034
|
get isEmpty() {
|
3040
3035
|
return !this.text.trim() && !this.attachments.length;
|
3041
3036
|
}
|
3042
|
-
|
3037
|
+
__init15() {this._text = ""}
|
3043
3038
|
get text() {
|
3044
3039
|
return this._text;
|
3045
3040
|
}
|
@@ -3053,11 +3048,12 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
|
|
3053
3048
|
this.notifySubscribers();
|
3054
3049
|
}
|
3055
3050
|
async send() {
|
3056
|
-
const
|
3051
|
+
const adapter = this.getAttachmentAdapter();
|
3052
|
+
const attachments = adapter && this.attachments.length > 0 ? await Promise.all(
|
3057
3053
|
this.attachments.map(async (a) => {
|
3058
3054
|
if (isAttachmentComplete(a)) return a;
|
3059
|
-
const result = await
|
3060
|
-
if (_optionalChain([result, 'access',
|
3055
|
+
const result = await adapter.send(a);
|
3056
|
+
if (_optionalChain([result, 'access', _155 => _155.status, 'optionalAccess', _156 => _156.type]) !== "complete") {
|
3061
3057
|
result.status = { type: "complete" };
|
3062
3058
|
}
|
3063
3059
|
return result;
|
@@ -3071,19 +3067,10 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
|
|
3071
3067
|
this.reset();
|
3072
3068
|
this.handleSend(message);
|
3073
3069
|
}
|
3074
|
-
|
3075
|
-
setAttachmentAdapter(adapter) {
|
3076
|
-
this._attachmentAdapter = adapter;
|
3077
|
-
const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess', _151 => _151.accept]), () => ( "*"));
|
3078
|
-
if (this.attachmentAccept !== accept) {
|
3079
|
-
this.attachmentAccept = accept;
|
3080
|
-
this.notifySubscribers();
|
3081
|
-
}
|
3082
|
-
}
|
3083
3070
|
async addAttachment(file) {
|
3084
|
-
|
3085
|
-
|
3086
|
-
const attachment = await
|
3071
|
+
const adapter = this.getAttachmentAdapter();
|
3072
|
+
if (!adapter) throw new Error("Attachments are not supported");
|
3073
|
+
const attachment = await adapter.add({ file });
|
3087
3074
|
if (attachment.status === void 0) {
|
3088
3075
|
attachment.status = { type: "requires-action", reason: "composer-send" };
|
3089
3076
|
}
|
@@ -3091,16 +3078,16 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
|
|
3091
3078
|
this.notifySubscribers();
|
3092
3079
|
}
|
3093
3080
|
async removeAttachment(attachmentId) {
|
3094
|
-
|
3095
|
-
|
3081
|
+
const adapter = this.getAttachmentAdapter();
|
3082
|
+
if (!adapter) throw new Error("Attachments are not supported");
|
3096
3083
|
const index = this._attachments.findIndex((a) => a.id === attachmentId);
|
3097
3084
|
if (index === -1) throw new Error("Attachment not found");
|
3098
3085
|
const attachment = this._attachments[index];
|
3099
|
-
await
|
3086
|
+
await adapter.remove(attachment);
|
3100
3087
|
this._attachments = this._attachments.toSpliced(index, 1);
|
3101
3088
|
this.notifySubscribers();
|
3102
3089
|
}
|
3103
|
-
|
3090
|
+
__init16() {this._subscriptions = /* @__PURE__ */ new Set()}
|
3104
3091
|
notifySubscribers() {
|
3105
3092
|
for (const callback of this._subscriptions) callback();
|
3106
3093
|
}
|
@@ -3113,17 +3100,20 @@ var BaseComposerRuntimeCore = (_class8 = class {constructor() { _class8.prototyp
|
|
3113
3100
|
// src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx
|
3114
3101
|
var DefaultThreadComposerRuntimeCore = (_class9 = class extends BaseComposerRuntimeCore {
|
3115
3102
|
constructor(runtime) {
|
3116
|
-
super();_class9.prototype.
|
3103
|
+
super();_class9.prototype.__init17.call(this);;
|
3117
3104
|
this.runtime = runtime;
|
3118
3105
|
this.connect();
|
3119
3106
|
}
|
3120
|
-
|
3107
|
+
__init17() {this._canCancel = false}
|
3121
3108
|
get canCancel() {
|
3122
3109
|
return this._canCancel;
|
3123
3110
|
}
|
3124
3111
|
get attachments() {
|
3125
3112
|
return super.attachments;
|
3126
3113
|
}
|
3114
|
+
getAttachmentAdapter() {
|
3115
|
+
return _optionalChain([this, 'access', _157 => _157.runtime, 'access', _158 => _158.adapters, 'optionalAccess', _159 => _159.attachments]);
|
3116
|
+
}
|
3127
3117
|
connect() {
|
3128
3118
|
return this.runtime.subscribe(() => {
|
3129
3119
|
if (this.canCancel !== this.runtime.capabilities.cancel) {
|
@@ -3135,7 +3125,7 @@ var DefaultThreadComposerRuntimeCore = (_class9 = class extends BaseComposerRunt
|
|
3135
3125
|
async handleSend(message) {
|
3136
3126
|
this.runtime.append({
|
3137
3127
|
...message,
|
3138
|
-
parentId: _nullishCoalesce(_optionalChain([this, 'access',
|
3128
|
+
parentId: _nullishCoalesce(_optionalChain([this, 'access', _160 => _160.runtime, 'access', _161 => _161.messages, 'access', _162 => _162.at, 'call', _163 => _163(-1), 'optionalAccess', _164 => _164.id]), () => ( null))
|
3139
3129
|
});
|
3140
3130
|
}
|
3141
3131
|
async cancel() {
|
@@ -3144,8 +3134,8 @@ var DefaultThreadComposerRuntimeCore = (_class9 = class extends BaseComposerRunt
|
|
3144
3134
|
}, _class9);
|
3145
3135
|
|
3146
3136
|
// src/utils/ProxyConfigProvider.ts
|
3147
|
-
var ProxyConfigProvider = (_class10 = class {constructor() { _class10.prototype.
|
3148
|
-
|
3137
|
+
var ProxyConfigProvider = (_class10 = class {constructor() { _class10.prototype.__init18.call(this); }
|
3138
|
+
__init18() {this._providers = /* @__PURE__ */ new Set()}
|
3149
3139
|
getModelConfig() {
|
3150
3140
|
return _chunkKVXP3Q6Kjs.mergeModelConfigs.call(void 0, this._providers);
|
3151
3141
|
}
|
@@ -3222,11 +3212,11 @@ var findHead = (message) => {
|
|
3222
3212
|
if ("current" in message) return message;
|
3223
3213
|
return null;
|
3224
3214
|
};
|
3225
|
-
var MessageRepository = (_class11 = class {constructor() { _class11.prototype.
|
3226
|
-
|
3215
|
+
var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__init19.call(this);_class11.prototype.__init20.call(this);_class11.prototype.__init21.call(this); }
|
3216
|
+
__init19() {this.messages = /* @__PURE__ */ new Map()}
|
3227
3217
|
// message_id -> item
|
3228
|
-
|
3229
|
-
|
3218
|
+
__init20() {this.head = null}
|
3219
|
+
__init21() {this.root = {
|
3230
3220
|
children: [],
|
3231
3221
|
next: null
|
3232
3222
|
}}
|
@@ -3268,7 +3258,7 @@ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__
|
|
3268
3258
|
}
|
3269
3259
|
}
|
3270
3260
|
getMessages() {
|
3271
|
-
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access',
|
3261
|
+
const messages2 = new Array(_nullishCoalesce(_optionalChain([this, 'access', _165 => _165.head, 'optionalAccess', _166 => _166.level]), () => ( 0)));
|
3272
3262
|
for (let current = this.head; current; current = current.prev) {
|
3273
3263
|
messages2[current.level] = current.current;
|
3274
3264
|
}
|
@@ -3306,7 +3296,7 @@ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__
|
|
3306
3296
|
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
3307
3297
|
);
|
3308
3298
|
return {
|
3309
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3299
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _167 => _167.prev, 'optionalAccess', _168 => _168.current, 'access', _169 => _169.id]), () => ( null)),
|
3310
3300
|
message: message.current
|
3311
3301
|
};
|
3312
3302
|
}
|
@@ -3390,11 +3380,11 @@ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__
|
|
3390
3380
|
for (const [, message] of this.messages) {
|
3391
3381
|
exportItems.push({
|
3392
3382
|
message: message.current,
|
3393
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
3383
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _170 => _170.prev, 'optionalAccess', _171 => _171.current, 'access', _172 => _172.id]), () => ( null))
|
3394
3384
|
});
|
3395
3385
|
}
|
3396
3386
|
return {
|
3397
|
-
headId: _nullishCoalesce(_optionalChain([this, 'access',
|
3387
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _173 => _173.head, 'optionalAccess', _174 => _174.current, 'access', _175 => _175.id]), () => ( null)),
|
3398
3388
|
messages: exportItems
|
3399
3389
|
};
|
3400
3390
|
}
|
@@ -3402,7 +3392,7 @@ var MessageRepository = (_class11 = class {constructor() { _class11.prototype.__
|
|
3402
3392
|
for (const { message, parentId } of messages2) {
|
3403
3393
|
this.addOrUpdateMessage(parentId, message);
|
3404
3394
|
}
|
3405
|
-
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access',
|
3395
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages2, 'access', _176 => _176.at, 'call', _177 => _177(-1), 'optionalAccess', _178 => _178.message, 'access', _179 => _179.id]))), () => ( null)));
|
3406
3396
|
}
|
3407
3397
|
}, _class11);
|
3408
3398
|
|
@@ -3502,41 +3492,11 @@ var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, sid
|
|
3502
3492
|
});
|
3503
3493
|
TooltipIconButton.displayName = "TooltipIconButton";
|
3504
3494
|
|
3505
|
-
// src/api/AssistantRuntime.ts
|
3506
|
-
var AssistantRuntimeImpl = class {
|
3507
|
-
constructor(_core, CustomThreadRuntime) {
|
3508
|
-
this._core = _core;
|
3509
|
-
this.thread = new CustomThreadRuntime(
|
3510
|
-
new NestedSubscriptionSubject({
|
3511
|
-
getState: () => this._core.thread,
|
3512
|
-
subscribe: (callback) => this._core.subscribe(callback)
|
3513
|
-
})
|
3514
|
-
);
|
3515
|
-
}
|
3516
|
-
|
3517
|
-
switchToNewThread() {
|
3518
|
-
return this._core.switchToNewThread();
|
3519
|
-
}
|
3520
|
-
switchToThread(threadId) {
|
3521
|
-
return this._core.switchToThread(threadId);
|
3522
|
-
}
|
3523
|
-
registerModelConfigProvider(provider) {
|
3524
|
-
return this._core.registerModelConfigProvider(provider);
|
3525
|
-
}
|
3526
|
-
// TODO events for thread switching
|
3527
|
-
/**
|
3528
|
-
* @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
|
3529
|
-
*/
|
3530
|
-
subscribe(callback) {
|
3531
|
-
return this._core.subscribe(callback);
|
3532
|
-
}
|
3533
|
-
};
|
3534
|
-
|
3535
3495
|
// src/api/ThreadRuntime.ts
|
3536
3496
|
var toAppendMessage = (messages2, message) => {
|
3537
3497
|
if (typeof message === "string") {
|
3538
3498
|
return {
|
3539
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
3499
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _180 => _180.at, 'call', _181 => _181(-1), 'optionalAccess', _182 => _182.id]), () => ( null)),
|
3540
3500
|
role: "user",
|
3541
3501
|
content: [{ type: "text", text: message }],
|
3542
3502
|
attachments: []
|
@@ -3546,7 +3506,7 @@ var toAppendMessage = (messages2, message) => {
|
|
3546
3506
|
return message;
|
3547
3507
|
}
|
3548
3508
|
return {
|
3549
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access',
|
3509
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages2, 'access', _183 => _183.at, 'call', _184 => _184(-1), 'optionalAccess', _185 => _185.id]))), () => ( null)),
|
3550
3510
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
3551
3511
|
content: message.content,
|
3552
3512
|
attachments: _nullishCoalesce(message.attachments, () => ( []))
|
@@ -3558,7 +3518,7 @@ var getThreadState = (runtime) => {
|
|
3558
3518
|
threadId: runtime.threadId,
|
3559
3519
|
capabilities: runtime.capabilities,
|
3560
3520
|
isDisabled: runtime.isDisabled,
|
3561
|
-
isRunning: _optionalChain([lastMessage, 'optionalAccess',
|
3521
|
+
isRunning: _optionalChain([lastMessage, 'optionalAccess', _186 => _186.role]) !== "assistant" ? false : lastMessage.status.type === "running",
|
3562
3522
|
messages: runtime.messages,
|
3563
3523
|
suggestions: runtime.suggestions,
|
3564
3524
|
extras: runtime.extras,
|
@@ -3619,7 +3579,7 @@ var ThreadRuntimeImpl = (_class12 = class {
|
|
3619
3579
|
return this._threadBinding.getState();
|
3620
3580
|
}
|
3621
3581
|
|
3622
|
-
constructor(threadBinding) {;_class12.prototype.
|
3582
|
+
constructor(threadBinding) {;_class12.prototype.__init22.call(this);
|
3623
3583
|
const stateBinding = new LazyMemoizeSubject({
|
3624
3584
|
getState: () => getThreadState(threadBinding.getState()),
|
3625
3585
|
subscribe: (callback) => threadBinding.subscribe(callback)
|
@@ -3630,7 +3590,7 @@ var ThreadRuntimeImpl = (_class12 = class {
|
|
3630
3590
|
subscribe: (callback) => threadBinding.subscribe(callback)
|
3631
3591
|
};
|
3632
3592
|
}
|
3633
|
-
|
3593
|
+
__init22() {this.composer = new ThreadComposerRuntimeImpl(
|
3634
3594
|
new NestedSubscriptionSubject({
|
3635
3595
|
getState: () => this._threadBinding.getState().composer,
|
3636
3596
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
@@ -3684,6 +3644,9 @@ var ThreadRuntimeImpl = (_class12 = class {
|
|
3684
3644
|
stopSpeaking() {
|
3685
3645
|
return this._threadBinding.getState().stopSpeaking();
|
3686
3646
|
}
|
3647
|
+
getSubmittedFeedback(messageId) {
|
3648
|
+
return this._threadBinding.getState().getSubmittedFeedback(messageId);
|
3649
|
+
}
|
3687
3650
|
/**
|
3688
3651
|
* @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
|
3689
3652
|
*/
|
@@ -3716,16 +3679,19 @@ var ThreadRuntimeImpl = (_class12 = class {
|
|
3716
3679
|
const { messages: messages2, speech: speechState } = this.getState();
|
3717
3680
|
const message = messages2[idx];
|
3718
3681
|
if (!message) return SKIP_UPDATE;
|
3719
|
-
const
|
3682
|
+
const thread = this._threadBinding.getState();
|
3683
|
+
const branches = thread.getBranches(message.id);
|
3684
|
+
const submittedFeedback = thread.getSubmittedFeedback(message.id);
|
3720
3685
|
return {
|
3721
3686
|
...message,
|
3722
3687
|
message,
|
3723
3688
|
isLast: idx === messages2.length - 1,
|
3724
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
3689
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _187 => _187[idx - 1], 'optionalAccess', _188 => _188.id]), () => ( null)),
|
3725
3690
|
branches,
|
3726
3691
|
branchNumber: branches.indexOf(message.id) + 1,
|
3727
3692
|
branchCount: branches.length,
|
3728
|
-
speech: _optionalChain([speechState, 'optionalAccess',
|
3693
|
+
speech: _optionalChain([speechState, 'optionalAccess', _189 => _189.messageId]) === message.id ? speechState : void 0,
|
3694
|
+
submittedFeedback
|
3729
3695
|
};
|
3730
3696
|
},
|
3731
3697
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
@@ -3735,6 +3701,47 @@ var ThreadRuntimeImpl = (_class12 = class {
|
|
3735
3701
|
}
|
3736
3702
|
}, _class12);
|
3737
3703
|
|
3704
|
+
// src/api/AssistantRuntime.ts
|
3705
|
+
var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
|
3706
|
+
constructor(_core, _thread) {
|
3707
|
+
this._core = _core;
|
3708
|
+
this._thread = _thread;
|
3709
|
+
}
|
3710
|
+
get thread() {
|
3711
|
+
return this._thread;
|
3712
|
+
}
|
3713
|
+
switchToNewThread() {
|
3714
|
+
return this._core.switchToNewThread();
|
3715
|
+
}
|
3716
|
+
switchToThread(threadId) {
|
3717
|
+
return this._core.switchToThread(threadId);
|
3718
|
+
}
|
3719
|
+
registerModelConfigProvider(provider) {
|
3720
|
+
return this._core.registerModelConfigProvider(provider);
|
3721
|
+
}
|
3722
|
+
// TODO events for thread switching
|
3723
|
+
/**
|
3724
|
+
* @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
|
3725
|
+
*/
|
3726
|
+
subscribe(callback) {
|
3727
|
+
return this._core.subscribe(callback);
|
3728
|
+
}
|
3729
|
+
static createThreadRuntime(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
|
3730
|
+
return new CustomThreadRuntime(
|
3731
|
+
new NestedSubscriptionSubject({
|
3732
|
+
getState: () => _core.thread,
|
3733
|
+
subscribe: (callback) => _core.subscribe(callback)
|
3734
|
+
})
|
3735
|
+
);
|
3736
|
+
}
|
3737
|
+
static create(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
|
3738
|
+
return new _AssistantRuntimeImpl(
|
3739
|
+
_core,
|
3740
|
+
_AssistantRuntimeImpl.createThreadRuntime(_core, CustomThreadRuntime)
|
3741
|
+
);
|
3742
|
+
}
|
3743
|
+
};
|
3744
|
+
|
3738
3745
|
// src/runtimes/edge/converters/fromLanguageModelMessages.ts
|
3739
3746
|
var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
3740
3747
|
const messages2 = [];
|
@@ -3801,7 +3808,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
|
3801
3808
|
});
|
3802
3809
|
if (mergeSteps) {
|
3803
3810
|
const previousMessage = messages2[messages2.length - 1];
|
3804
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
3811
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _190 => _190.role]) === "assistant") {
|
3805
3812
|
previousMessage.content.push(...newContent);
|
3806
3813
|
break;
|
3807
3814
|
}
|
@@ -3814,7 +3821,7 @@ var fromLanguageModelMessages = (lm, { mergeSteps }) => {
|
|
3814
3821
|
}
|
3815
3822
|
case "tool": {
|
3816
3823
|
const previousMessage = messages2[messages2.length - 1];
|
3817
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
3824
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _191 => _191.role]) !== "assistant")
|
3818
3825
|
throw new Error(
|
3819
3826
|
"A tool message must be preceded by an assistant message."
|
3820
3827
|
);
|
@@ -3936,7 +3943,7 @@ function assistantDecoderStream() {
|
|
3936
3943
|
}
|
3937
3944
|
case "c" /* ToolCallDelta */: {
|
3938
3945
|
const { toolCallId, argsTextDelta } = value;
|
3939
|
-
if (_optionalChain([currentToolCall, 'optionalAccess',
|
3946
|
+
if (_optionalChain([currentToolCall, 'optionalAccess', _192 => _192.id]) !== toolCallId) {
|
3940
3947
|
throw new Error(
|
3941
3948
|
`Received tool call delta for unknown tool call "${toolCallId}".`
|
3942
3949
|
);
|
@@ -4083,7 +4090,7 @@ var useEdgeRuntime = (options) => {
|
|
4083
4090
|
};
|
4084
4091
|
|
4085
4092
|
// src/runtimes/local/shouldContinue.tsx
|
4086
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
4093
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _193 => _193.status, 'optionalAccess', _194 => _194.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
4087
4094
|
|
4088
4095
|
// src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
|
4089
4096
|
var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
@@ -4097,10 +4104,14 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
4097
4104
|
this._nonTextParts = message.content.filter(
|
4098
4105
|
(part) => part.type !== "text" && part.type !== "ui"
|
4099
4106
|
);
|
4107
|
+
this.attachments = _nullishCoalesce(message.attachments, () => ( []));
|
4100
4108
|
}
|
4101
4109
|
get canCancel() {
|
4102
4110
|
return true;
|
4103
4111
|
}
|
4112
|
+
getAttachmentAdapter() {
|
4113
|
+
return _optionalChain([this, 'access', _195 => _195.runtime, 'access', _196 => _196.adapters, 'optionalAccess', _197 => _197.attachments]);
|
4114
|
+
}
|
4104
4115
|
|
4105
4116
|
|
4106
4117
|
|
@@ -4122,10 +4133,107 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
4122
4133
|
}
|
4123
4134
|
};
|
4124
4135
|
|
4125
|
-
// src/runtimes/
|
4126
|
-
var
|
4127
|
-
constructor(configProvider
|
4136
|
+
// src/runtimes/core/BaseThreadRuntimeCore.tsx
|
4137
|
+
var BaseThreadRuntimeCore = (_class13 = class {
|
4138
|
+
constructor(configProvider) {;_class13.prototype.__init23.call(this);_class13.prototype.__init24.call(this);_class13.prototype.__init25.call(this);_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);
|
4128
4139
|
this.configProvider = configProvider;
|
4140
|
+
}
|
4141
|
+
__init23() {this._subscriptions = /* @__PURE__ */ new Set()}
|
4142
|
+
__init24() {this.repository = new MessageRepository()}
|
4143
|
+
get messages() {
|
4144
|
+
return this.repository.getMessages();
|
4145
|
+
}
|
4146
|
+
__init25() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4147
|
+
getModelConfig() {
|
4148
|
+
return this.configProvider.getModelConfig();
|
4149
|
+
}
|
4150
|
+
__init26() {this._editComposers = /* @__PURE__ */ new Map()}
|
4151
|
+
getEditComposer(messageId) {
|
4152
|
+
return this._editComposers.get(messageId);
|
4153
|
+
}
|
4154
|
+
beginEdit(messageId) {
|
4155
|
+
if (this._editComposers.has(messageId))
|
4156
|
+
throw new Error("Edit already in progress");
|
4157
|
+
this._editComposers.set(
|
4158
|
+
messageId,
|
4159
|
+
new DefaultEditComposerRuntimeCore(
|
4160
|
+
this,
|
4161
|
+
() => this._editComposers.delete(messageId),
|
4162
|
+
this.repository.getMessage(messageId)
|
4163
|
+
)
|
4164
|
+
);
|
4165
|
+
this.notifySubscribers();
|
4166
|
+
}
|
4167
|
+
getBranches(messageId) {
|
4168
|
+
return this.repository.getBranches(messageId);
|
4169
|
+
}
|
4170
|
+
switchToBranch(branchId) {
|
4171
|
+
this.repository.switchToBranch(branchId);
|
4172
|
+
this.notifySubscribers();
|
4173
|
+
}
|
4174
|
+
notifySubscribers() {
|
4175
|
+
for (const callback of this._subscriptions) callback();
|
4176
|
+
}
|
4177
|
+
subscribe(callback) {
|
4178
|
+
this._subscriptions.add(callback);
|
4179
|
+
return () => this._subscriptions.delete(callback);
|
4180
|
+
}
|
4181
|
+
__init27() {this._submittedFeedback = {}}
|
4182
|
+
getSubmittedFeedback(messageId) {
|
4183
|
+
return this._submittedFeedback[messageId];
|
4184
|
+
}
|
4185
|
+
submitFeedback({ messageId, type }) {
|
4186
|
+
const adapter = _optionalChain([this, 'access', _198 => _198.adapters, 'optionalAccess', _199 => _199.feedback]);
|
4187
|
+
if (!adapter) throw new Error("Feedback adapter not configured");
|
4188
|
+
const { message } = this.repository.getMessage(messageId);
|
4189
|
+
adapter.submit({ message, type });
|
4190
|
+
this._submittedFeedback[messageId] = { type };
|
4191
|
+
this.notifySubscribers();
|
4192
|
+
}
|
4193
|
+
|
4194
|
+
|
4195
|
+
speak(messageId) {
|
4196
|
+
const adapter = _optionalChain([this, 'access', _200 => _200.adapters, 'optionalAccess', _201 => _201.speech]);
|
4197
|
+
if (!adapter) throw new Error("Speech adapter not configured");
|
4198
|
+
const { message } = this.repository.getMessage(messageId);
|
4199
|
+
_optionalChain([this, 'access', _202 => _202._stopSpeaking, 'optionalCall', _203 => _203()]);
|
4200
|
+
const utterance = adapter.speak(message);
|
4201
|
+
const unsub = utterance.subscribe(() => {
|
4202
|
+
if (utterance.status.type === "ended") {
|
4203
|
+
this._stopSpeaking = void 0;
|
4204
|
+
this.speech = void 0;
|
4205
|
+
} else {
|
4206
|
+
this.speech = { messageId, status: utterance.status };
|
4207
|
+
}
|
4208
|
+
this.notifySubscribers();
|
4209
|
+
});
|
4210
|
+
this.speech = { messageId, status: utterance.status };
|
4211
|
+
this.notifySubscribers();
|
4212
|
+
this._stopSpeaking = () => {
|
4213
|
+
utterance.cancel();
|
4214
|
+
unsub();
|
4215
|
+
this.speech = void 0;
|
4216
|
+
this._stopSpeaking = void 0;
|
4217
|
+
};
|
4218
|
+
}
|
4219
|
+
stopSpeaking() {
|
4220
|
+
if (!this._stopSpeaking) throw new Error("No message is being spoken");
|
4221
|
+
this._stopSpeaking();
|
4222
|
+
this.notifySubscribers();
|
4223
|
+
}
|
4224
|
+
export() {
|
4225
|
+
return this.repository.export();
|
4226
|
+
}
|
4227
|
+
import(data) {
|
4228
|
+
this.repository.import(data);
|
4229
|
+
this.notifySubscribers();
|
4230
|
+
}
|
4231
|
+
}, _class13);
|
4232
|
+
|
4233
|
+
// src/runtimes/local/LocalThreadRuntimeCore.tsx
|
4234
|
+
var LocalThreadRuntimeCore = (_class14 = class extends BaseThreadRuntimeCore {
|
4235
|
+
constructor(configProvider, adapter, { initialMessages, ...options }) {
|
4236
|
+
super(configProvider);_class14.prototype.__init28.call(this);_class14.prototype.__init29.call(this);_class14.prototype.__init30.call(this);_class14.prototype.__init31.call(this);;
|
4129
4237
|
this.adapter = adapter;
|
4130
4238
|
this.threadId = generateId();
|
4131
4239
|
this.options = options;
|
@@ -4138,28 +4246,22 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4138
4246
|
}
|
4139
4247
|
}
|
4140
4248
|
}
|
4141
|
-
|
4142
|
-
__init25() {this.abortController = null}
|
4143
|
-
__init26() {this.repository = new MessageRepository()}
|
4144
|
-
__init27() {this.capabilities = {
|
4249
|
+
__init28() {this.capabilities = {
|
4145
4250
|
switchToBranch: true,
|
4146
4251
|
edit: true,
|
4147
4252
|
reload: true,
|
4148
4253
|
cancel: true,
|
4149
4254
|
unstable_copy: true,
|
4150
|
-
|
4255
|
+
speech: false,
|
4151
4256
|
attachments: false,
|
4152
4257
|
feedback: false
|
4153
4258
|
}}
|
4259
|
+
__init29() {this.abortController = null}
|
4154
4260
|
|
4155
|
-
|
4156
|
-
|
4157
|
-
get
|
4158
|
-
return this.
|
4159
|
-
}
|
4160
|
-
__init30() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4161
|
-
getModelConfig() {
|
4162
|
-
return this.configProvider.getModelConfig();
|
4261
|
+
__init30() {this.isDisabled = false}
|
4262
|
+
__init31() {this.suggestions = []}
|
4263
|
+
get adapters() {
|
4264
|
+
return this.options.adapters;
|
4163
4265
|
}
|
4164
4266
|
|
4165
4267
|
get options() {
|
@@ -4171,48 +4273,23 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4171
4273
|
set options({ initialMessages, ...options }) {
|
4172
4274
|
this._options = options;
|
4173
4275
|
let hasUpdates = false;
|
4174
|
-
const canSpeak = _optionalChain([options, 'access',
|
4175
|
-
if (this.capabilities.
|
4176
|
-
this.capabilities.
|
4276
|
+
const canSpeak = _optionalChain([options, 'access', _204 => _204.adapters, 'optionalAccess', _205 => _205.speech]) !== void 0;
|
4277
|
+
if (this.capabilities.speech !== canSpeak) {
|
4278
|
+
this.capabilities.speech = canSpeak;
|
4177
4279
|
hasUpdates = true;
|
4178
4280
|
}
|
4179
|
-
|
4180
|
-
const canAttach = _optionalChain([options, 'access', _191 => _191.adapters, 'optionalAccess', _192 => _192.attachments]) !== void 0;
|
4281
|
+
const canAttach = _optionalChain([options, 'access', _206 => _206.adapters, 'optionalAccess', _207 => _207.attachments]) !== void 0;
|
4181
4282
|
if (this.capabilities.attachments !== canAttach) {
|
4182
4283
|
this.capabilities.attachments = canAttach;
|
4183
4284
|
hasUpdates = true;
|
4184
4285
|
}
|
4185
|
-
const canFeedback = _optionalChain([options, 'access',
|
4286
|
+
const canFeedback = _optionalChain([options, 'access', _208 => _208.adapters, 'optionalAccess', _209 => _209.feedback]) !== void 0;
|
4186
4287
|
if (this.capabilities.feedback !== canFeedback) {
|
4187
4288
|
this.capabilities.feedback = canFeedback;
|
4188
4289
|
hasUpdates = true;
|
4189
4290
|
}
|
4190
4291
|
if (hasUpdates) this.notifySubscribers();
|
4191
4292
|
}
|
4192
|
-
__init31() {this._editComposers = /* @__PURE__ */ new Map()}
|
4193
|
-
getEditComposer(messageId) {
|
4194
|
-
return this._editComposers.get(messageId);
|
4195
|
-
}
|
4196
|
-
beginEdit(messageId) {
|
4197
|
-
if (this._editComposers.has(messageId))
|
4198
|
-
throw new Error("Edit already in progress");
|
4199
|
-
this._editComposers.set(
|
4200
|
-
messageId,
|
4201
|
-
new DefaultEditComposerRuntimeCore(
|
4202
|
-
this,
|
4203
|
-
() => this._editComposers.delete(messageId),
|
4204
|
-
this.repository.getMessage(messageId)
|
4205
|
-
)
|
4206
|
-
);
|
4207
|
-
this.notifySubscribers();
|
4208
|
-
}
|
4209
|
-
getBranches(messageId) {
|
4210
|
-
return this.repository.getBranches(messageId);
|
4211
|
-
}
|
4212
|
-
switchToBranch(branchId) {
|
4213
|
-
this.repository.switchToBranch(branchId);
|
4214
|
-
this.notifySubscribers();
|
4215
|
-
}
|
4216
4293
|
async append(message) {
|
4217
4294
|
const newMessage = fromCoreMessage(message, {
|
4218
4295
|
attachments: message.attachments
|
@@ -4241,13 +4318,13 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4241
4318
|
}
|
4242
4319
|
async performRoundtrip(parentId, message) {
|
4243
4320
|
const messages2 = this.repository.getMessages();
|
4244
|
-
_optionalChain([this, 'access',
|
4321
|
+
_optionalChain([this, 'access', _210 => _210.abortController, 'optionalAccess', _211 => _211.abort, 'call', _212 => _212()]);
|
4245
4322
|
this.abortController = new AbortController();
|
4246
4323
|
const initialContent = message.content;
|
4247
|
-
const initialSteps = _optionalChain([message, 'access',
|
4248
|
-
const initalCustom = _optionalChain([message, 'access',
|
4324
|
+
const initialSteps = _optionalChain([message, 'access', _213 => _213.metadata, 'optionalAccess', _214 => _214.steps]);
|
4325
|
+
const initalCustom = _optionalChain([message, 'access', _215 => _215.metadata, 'optionalAccess', _216 => _216.custom]);
|
4249
4326
|
const updateMessage = (m) => {
|
4250
|
-
const newSteps = _optionalChain([m, 'access',
|
4327
|
+
const newSteps = _optionalChain([m, 'access', _217 => _217.metadata, 'optionalAccess', _218 => _218.steps]) || _optionalChain([m, 'access', _219 => _219.metadata, 'optionalAccess', _220 => _220.roundtrips]);
|
4251
4328
|
const steps2 = newSteps ? [..._nullishCoalesce(initialSteps, () => ( [])), ...newSteps] : void 0;
|
4252
4329
|
message = {
|
4253
4330
|
...message,
|
@@ -4259,7 +4336,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4259
4336
|
metadata: {
|
4260
4337
|
...message.metadata,
|
4261
4338
|
...steps2 ? { roundtrips: steps2, steps: steps2 } : void 0,
|
4262
|
-
..._optionalChain([m, 'access',
|
4339
|
+
..._optionalChain([m, 'access', _221 => _221.metadata, 'optionalAccess', _222 => _222.custom]) ? {
|
4263
4340
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
4264
4341
|
} : void 0
|
4265
4342
|
}
|
@@ -4269,7 +4346,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4269
4346
|
this.notifySubscribers();
|
4270
4347
|
};
|
4271
4348
|
const maxSteps = this.options.maxSteps ? this.options.maxSteps : (_nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1))) + 1;
|
4272
|
-
const steps = _nullishCoalesce(_optionalChain([message, 'access',
|
4349
|
+
const steps = _nullishCoalesce(_optionalChain([message, 'access', _223 => _223.metadata, 'optionalAccess', _224 => _224.steps, 'optionalAccess', _225 => _225.length]), () => ( 0));
|
4273
4350
|
if (steps >= maxSteps) {
|
4274
4351
|
updateMessage({
|
4275
4352
|
status: {
|
@@ -4289,7 +4366,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4289
4366
|
const promiseOrGenerator = this.adapter.run({
|
4290
4367
|
messages: messages2,
|
4291
4368
|
abortSignal: this.abortController.signal,
|
4292
|
-
config: this.
|
4369
|
+
config: this.getModelConfig(),
|
4293
4370
|
onUpdate: updateMessage
|
4294
4371
|
});
|
4295
4372
|
if (Symbol.asyncIterator in promiseOrGenerator) {
|
@@ -4321,17 +4398,9 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4321
4398
|
return message;
|
4322
4399
|
}
|
4323
4400
|
cancelRun() {
|
4324
|
-
|
4325
|
-
this.abortController.abort();
|
4401
|
+
_optionalChain([this, 'access', _226 => _226.abortController, 'optionalAccess', _227 => _227.abort, 'call', _228 => _228()]);
|
4326
4402
|
this.abortController = null;
|
4327
4403
|
}
|
4328
|
-
notifySubscribers() {
|
4329
|
-
for (const callback of this._subscriptions) callback();
|
4330
|
-
}
|
4331
|
-
subscribe(callback) {
|
4332
|
-
this._subscriptions.add(callback);
|
4333
|
-
return () => this._subscriptions.delete(callback);
|
4334
|
-
}
|
4335
4404
|
addToolResult({
|
4336
4405
|
messageId,
|
4337
4406
|
toolCallId,
|
@@ -4365,50 +4434,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4365
4434
|
this.performRoundtrip(parentId, message);
|
4366
4435
|
}
|
4367
4436
|
}
|
4368
|
-
|
4369
|
-
|
4370
|
-
__init32() {this.speech = null}
|
4371
|
-
speak(messageId) {
|
4372
|
-
const adapter = _optionalChain([this, 'access', _211 => _211.options, 'access', _212 => _212.adapters, 'optionalAccess', _213 => _213.speech]);
|
4373
|
-
if (!adapter) throw new Error("Speech adapter not configured");
|
4374
|
-
const { message } = this.repository.getMessage(messageId);
|
4375
|
-
_optionalChain([this, 'access', _214 => _214._stopSpeaking, 'optionalCall', _215 => _215()]);
|
4376
|
-
const utterance = adapter.speak(message);
|
4377
|
-
const unsub = utterance.subscribe(() => {
|
4378
|
-
if (utterance.status.type === "ended") {
|
4379
|
-
this._stopSpeaking = void 0;
|
4380
|
-
this.speech = null;
|
4381
|
-
} else {
|
4382
|
-
this.speech = { messageId, status: utterance.status };
|
4383
|
-
}
|
4384
|
-
this.notifySubscribers();
|
4385
|
-
});
|
4386
|
-
this.speech = { messageId, status: utterance.status };
|
4387
|
-
this._stopSpeaking = () => {
|
4388
|
-
utterance.cancel();
|
4389
|
-
unsub();
|
4390
|
-
this.speech = null;
|
4391
|
-
this._stopSpeaking = void 0;
|
4392
|
-
};
|
4393
|
-
}
|
4394
|
-
stopSpeaking() {
|
4395
|
-
if (!this._stopSpeaking) throw new Error("No message is being spoken");
|
4396
|
-
this._stopSpeaking();
|
4397
|
-
}
|
4398
|
-
submitFeedback({ messageId, type }) {
|
4399
|
-
const adapter = _optionalChain([this, 'access', _216 => _216.options, 'access', _217 => _217.adapters, 'optionalAccess', _218 => _218.feedback]);
|
4400
|
-
if (!adapter) throw new Error("Feedback adapter not configured");
|
4401
|
-
const { message } = this.repository.getMessage(messageId);
|
4402
|
-
adapter.submit({ message, type });
|
4403
|
-
}
|
4404
|
-
export() {
|
4405
|
-
return this.repository.export();
|
4406
|
-
}
|
4407
|
-
import(data) {
|
4408
|
-
this.repository.import(data);
|
4409
|
-
this.notifySubscribers();
|
4410
|
-
}
|
4411
|
-
}, _class13);
|
4437
|
+
}, _class14);
|
4412
4438
|
|
4413
4439
|
// src/runtimes/local/LocalRuntimeCore.tsx
|
4414
4440
|
var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
@@ -4443,7 +4469,7 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4443
4469
|
const messages2 = fromCoreMessages(initialMessages);
|
4444
4470
|
this.thread.import({
|
4445
4471
|
messages: messages2.map((m, idx) => ({
|
4446
|
-
parentId: _nullishCoalesce(_optionalChain([messages2, 'access',
|
4472
|
+
parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _229 => _229[idx - 1], 'optionalAccess', _230 => _230.id]), () => ( null)),
|
4447
4473
|
message: m
|
4448
4474
|
}))
|
4449
4475
|
});
|
@@ -4451,14 +4477,20 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4451
4477
|
};
|
4452
4478
|
|
4453
4479
|
// src/runtimes/local/useLocalRuntime.tsx
|
4454
|
-
var
|
4455
|
-
constructor(core) {
|
4456
|
-
super(core,
|
4480
|
+
var LocalRuntimeImpl = class _LocalRuntimeImpl extends AssistantRuntimeImpl {
|
4481
|
+
constructor(core, thread) {
|
4482
|
+
super(core, thread);
|
4457
4483
|
this.core = core;
|
4458
4484
|
}
|
4459
4485
|
reset(options) {
|
4460
4486
|
this.core.reset(options);
|
4461
4487
|
}
|
4488
|
+
static create(_core) {
|
4489
|
+
return new _LocalRuntimeImpl(
|
4490
|
+
_core,
|
4491
|
+
AssistantRuntimeImpl.createThreadRuntime(_core, ThreadRuntimeImpl)
|
4492
|
+
);
|
4493
|
+
}
|
4462
4494
|
};
|
4463
4495
|
var useLocalRuntime = (adapter, options = {}) => {
|
4464
4496
|
const [runtime] = _react.useState.call(void 0, () => new LocalRuntimeCore(adapter, options));
|
@@ -4466,7 +4498,7 @@ var useLocalRuntime = (adapter, options = {}) => {
|
|
4466
4498
|
runtime.thread.adapter = adapter;
|
4467
4499
|
runtime.thread.options = options;
|
4468
4500
|
});
|
4469
|
-
return _react.useMemo.call(void 0, () =>
|
4501
|
+
return _react.useMemo.call(void 0, () => LocalRuntimeImpl.create(runtime), [runtime]);
|
4470
4502
|
};
|
4471
4503
|
|
4472
4504
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
@@ -4479,8 +4511,8 @@ var getExternalStoreMessage = (message) => {
|
|
4479
4511
|
};
|
4480
4512
|
|
4481
4513
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
4482
|
-
var ThreadMessageConverter = (
|
4483
|
-
|
4514
|
+
var ThreadMessageConverter = (_class15 = class {constructor() { _class15.prototype.__init32.call(this); }
|
4515
|
+
__init32() {this.cache = /* @__PURE__ */ new WeakMap()}
|
4484
4516
|
convertMessages(messages2, converter) {
|
4485
4517
|
return messages2.map((m, idx) => {
|
4486
4518
|
const cached = this.cache.get(m);
|
@@ -4489,7 +4521,7 @@ var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototy
|
|
4489
4521
|
return newMessage;
|
4490
4522
|
});
|
4491
4523
|
}
|
4492
|
-
},
|
4524
|
+
}, _class15);
|
4493
4525
|
|
4494
4526
|
// src/runtimes/external-store/auto-status.tsx
|
4495
4527
|
var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
|
@@ -4577,23 +4609,17 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
4577
4609
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
4578
4610
|
var EMPTY_ARRAY2 = Object.freeze([]);
|
4579
4611
|
var hasUpcomingMessage = (isRunning, messages2) => {
|
4580
|
-
return isRunning && _optionalChain([messages2, 'access',
|
4612
|
+
return isRunning && _optionalChain([messages2, 'access', _231 => _231[messages2.length - 1], 'optionalAccess', _232 => _232.role]) !== "assistant";
|
4581
4613
|
};
|
4582
|
-
var ExternalStoreThreadRuntimeCore = (
|
4583
|
-
|
4584
|
-
|
4585
|
-
this.store = store;
|
4586
|
-
}
|
4587
|
-
__init34() {this._subscriptions = /* @__PURE__ */ new Set()}
|
4588
|
-
__init35() {this.repository = new MessageRepository()}
|
4589
|
-
__init36() {this.assistantOptimisticId = null}
|
4590
|
-
__init37() {this._capabilities = {
|
4614
|
+
var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntimeCore {
|
4615
|
+
__init33() {this.assistantOptimisticId = null}
|
4616
|
+
__init34() {this._capabilities = {
|
4591
4617
|
switchToBranch: false,
|
4592
4618
|
edit: false,
|
4593
4619
|
reload: false,
|
4594
4620
|
cancel: false,
|
4595
4621
|
unstable_copy: false,
|
4596
|
-
|
4622
|
+
speech: false,
|
4597
4623
|
attachments: false,
|
4598
4624
|
feedback: false
|
4599
4625
|
}}
|
@@ -4603,27 +4629,24 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4603
4629
|
|
4604
4630
|
|
4605
4631
|
|
4606
|
-
|
4607
|
-
|
4608
|
-
__init40() {this._converter = new ThreadMessageConverter()}
|
4609
|
-
|
4610
|
-
__init41() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4611
|
-
__init42() {this._editComposers = /* @__PURE__ */ new Map()}
|
4612
|
-
getEditComposer(messageId) {
|
4613
|
-
return this._editComposers.get(messageId);
|
4632
|
+
get messages() {
|
4633
|
+
return this._messages;
|
4614
4634
|
}
|
4635
|
+
get adapters() {
|
4636
|
+
return this._store.adapters;
|
4637
|
+
}
|
4638
|
+
__init35() {this.suggestions = []}
|
4639
|
+
__init36() {this.extras = void 0}
|
4640
|
+
__init37() {this._converter = new ThreadMessageConverter()}
|
4641
|
+
|
4615
4642
|
beginEdit(messageId) {
|
4616
|
-
if (this.
|
4617
|
-
throw new Error("
|
4618
|
-
|
4619
|
-
|
4620
|
-
|
4621
|
-
|
4622
|
-
|
4623
|
-
this.repository.getMessage(messageId)
|
4624
|
-
)
|
4625
|
-
);
|
4626
|
-
this.notifySubscribers();
|
4643
|
+
if (!this.store.onEdit)
|
4644
|
+
throw new Error("Runtime does not support editing.");
|
4645
|
+
super.beginEdit(messageId);
|
4646
|
+
}
|
4647
|
+
constructor(configProvider, store) {
|
4648
|
+
super(configProvider);_class16.prototype.__init33.call(this);_class16.prototype.__init34.call(this);_class16.prototype.__init35.call(this);_class16.prototype.__init36.call(this);_class16.prototype.__init37.call(this);_class16.prototype.__init38.call(this);;
|
4649
|
+
this.store = store;
|
4627
4650
|
}
|
4628
4651
|
get store() {
|
4629
4652
|
return this._store;
|
@@ -4642,13 +4665,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4642
4665
|
edit: this._store.onEdit !== void 0,
|
4643
4666
|
reload: this._store.onReload !== void 0,
|
4644
4667
|
cancel: this._store.onCancel !== void 0,
|
4645
|
-
|
4646
|
-
unstable_copy: _optionalChain([this, 'access',
|
4668
|
+
speech: _optionalChain([this, 'access', _236 => _236._store, 'access', _237 => _237.adapters, 'optionalAccess', _238 => _238.speech]) !== void 0,
|
4669
|
+
unstable_copy: _optionalChain([this, 'access', _239 => _239._store, 'access', _240 => _240.unstable_capabilities, 'optionalAccess', _241 => _241.copy]) !== false,
|
4647
4670
|
// default true
|
4648
|
-
attachments: !!_optionalChain([this, 'access',
|
4649
|
-
feedback: !!_optionalChain([this, 'access',
|
4671
|
+
attachments: !!_optionalChain([this, 'access', _242 => _242.store, 'access', _243 => _243.adapters, 'optionalAccess', _244 => _244.attachments]),
|
4672
|
+
feedback: !!_optionalChain([this, 'access', _245 => _245.store, 'access', _246 => _246.adapters, 'optionalAccess', _247 => _247.feedback])
|
4650
4673
|
};
|
4651
|
-
this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _235 => _235._store, 'access', _236 => _236.adapters, 'optionalAccess', _237 => _237.attachments]));
|
4652
4674
|
if (oldStore) {
|
4653
4675
|
if (oldStore.convertMessage !== store.convertMessage) {
|
4654
4676
|
this._converter = new ThreadMessageConverter();
|
@@ -4674,7 +4696,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4674
4696
|
for (let i = 0; i < messages2.length; i++) {
|
4675
4697
|
const message = messages2[i];
|
4676
4698
|
const parent = messages2[i - 1];
|
4677
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
4699
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _248 => _248.id]), () => ( null)), message);
|
4678
4700
|
}
|
4679
4701
|
if (this.assistantOptimisticId) {
|
4680
4702
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -4682,7 +4704,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4682
4704
|
}
|
4683
4705
|
if (hasUpcomingMessage(isRunning, messages2)) {
|
4684
4706
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
4685
|
-
_nullishCoalesce(_optionalChain([messages2, 'access',
|
4707
|
+
_nullishCoalesce(_optionalChain([messages2, 'access', _249 => _249.at, 'call', _250 => _250(-1), 'optionalAccess', _251 => _251.id]), () => ( null)),
|
4686
4708
|
{
|
4687
4709
|
role: "assistant",
|
4688
4710
|
content: []
|
@@ -4690,20 +4712,11 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4690
4712
|
);
|
4691
4713
|
}
|
4692
4714
|
this.repository.resetHead(
|
4693
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access',
|
4715
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _252 => _252.at, 'call', _253 => _253(-1), 'optionalAccess', _254 => _254.id]))), () => ( null))
|
4694
4716
|
);
|
4695
|
-
this.
|
4717
|
+
this._messages = this.repository.getMessages();
|
4696
4718
|
this.notifySubscribers();
|
4697
4719
|
}
|
4698
|
-
getModelConfig() {
|
4699
|
-
return this.configProvider.getModelConfig();
|
4700
|
-
}
|
4701
|
-
notifySubscribers() {
|
4702
|
-
for (const callback of this._subscriptions) callback();
|
4703
|
-
}
|
4704
|
-
getBranches(messageId) {
|
4705
|
-
return this.repository.getBranches(messageId);
|
4706
|
-
}
|
4707
4720
|
switchToBranch(branchId) {
|
4708
4721
|
if (!this._store.setMessages)
|
4709
4722
|
throw new Error("Runtime does not support switching branches.");
|
@@ -4711,7 +4724,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4711
4724
|
this.updateMessages(this.repository.getMessages());
|
4712
4725
|
}
|
4713
4726
|
async append(message) {
|
4714
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
4727
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _255 => _255.messages, 'access', _256 => _256.at, 'call', _257 => _257(-1), 'optionalAccess', _258 => _258.id]), () => ( null)))) {
|
4715
4728
|
if (!this._store.onEdit)
|
4716
4729
|
throw new Error("Runtime does not support editing messages.");
|
4717
4730
|
await this._store.onEdit(message);
|
@@ -4734,7 +4747,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4734
4747
|
}
|
4735
4748
|
let messages2 = this.repository.getMessages();
|
4736
4749
|
const previousMessage = messages2[messages2.length - 1];
|
4737
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
4750
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _259 => _259.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _260 => _260.at, 'call', _261 => _261(-1), 'optionalAccess', _262 => _262.id])) {
|
4738
4751
|
this.repository.deleteMessage(previousMessage.id);
|
4739
4752
|
if (!this.composer.text.trim()) {
|
4740
4753
|
this.composer.setText(getThreadMessageText(previousMessage));
|
@@ -4752,61 +4765,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4752
4765
|
throw new Error("Runtime does not support tool results.");
|
4753
4766
|
this._store.onAddToolResult(options);
|
4754
4767
|
}
|
4755
|
-
|
4756
|
-
|
4757
|
-
__init43() {this.speech = null}
|
4758
|
-
speak(messageId) {
|
4759
|
-
let adapter = _optionalChain([this, 'access', _253 => _253.store, 'access', _254 => _254.adapters, 'optionalAccess', _255 => _255.speech]);
|
4760
|
-
if (!adapter && this.store.onSpeak) {
|
4761
|
-
adapter = { speak: this.store.onSpeak };
|
4762
|
-
}
|
4763
|
-
if (!adapter) throw new Error("Speech adapter not configured");
|
4764
|
-
const { message } = this.repository.getMessage(messageId);
|
4765
|
-
_optionalChain([this, 'access', _256 => _256._stopSpeaking, 'optionalCall', _257 => _257()]);
|
4766
|
-
const utterance = adapter.speak(message);
|
4767
|
-
const unsub = utterance.subscribe(() => {
|
4768
|
-
if (utterance.status.type === "ended") {
|
4769
|
-
this._stopSpeaking = void 0;
|
4770
|
-
this.speech = null;
|
4771
|
-
} else {
|
4772
|
-
this.speech = { messageId, status: utterance.status };
|
4773
|
-
}
|
4774
|
-
this.notifySubscribers();
|
4775
|
-
});
|
4776
|
-
this.speech = { messageId, status: utterance.status };
|
4777
|
-
this._stopSpeaking = () => {
|
4778
|
-
utterance.cancel();
|
4779
|
-
unsub();
|
4780
|
-
this.speech = null;
|
4781
|
-
this._stopSpeaking = void 0;
|
4782
|
-
};
|
4783
|
-
}
|
4784
|
-
stopSpeaking() {
|
4785
|
-
if (!this._stopSpeaking) throw new Error("No message is being spoken");
|
4786
|
-
this._stopSpeaking();
|
4787
|
-
}
|
4788
|
-
submitFeedback({ messageId, type }) {
|
4789
|
-
const adapter = _optionalChain([this, 'access', _258 => _258._store, 'access', _259 => _259.adapters, 'optionalAccess', _260 => _260.feedback]);
|
4790
|
-
if (!adapter) throw new Error("Feedback adapter not configured");
|
4791
|
-
const { message } = this.repository.getMessage(messageId);
|
4792
|
-
adapter.submit({ message, type });
|
4793
|
-
}
|
4794
|
-
subscribe(callback) {
|
4795
|
-
this._subscriptions.add(callback);
|
4796
|
-
return () => this._subscriptions.delete(callback);
|
4797
|
-
}
|
4798
|
-
__init44() {this.updateMessages = (messages2) => {
|
4799
|
-
_optionalChain([this, 'access', _261 => _261._store, 'access', _262 => _262.setMessages, 'optionalCall', _263 => _263(
|
4768
|
+
__init38() {this.updateMessages = (messages2) => {
|
4769
|
+
_optionalChain([this, 'access', _263 => _263._store, 'access', _264 => _264.setMessages, 'optionalCall', _265 => _265(
|
4800
4770
|
messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
4801
4771
|
)]);
|
4802
4772
|
}}
|
4803
|
-
|
4804
|
-
this.repository.import(repository);
|
4805
|
-
}
|
4806
|
-
export() {
|
4807
|
-
return this.repository.export();
|
4808
|
-
}
|
4809
|
-
}, _class15);
|
4773
|
+
}, _class16);
|
4810
4774
|
|
4811
4775
|
// src/runtimes/external-store/ExternalStoreRuntimeCore.tsx
|
4812
4776
|
var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
@@ -4860,7 +4824,7 @@ var useExternalStoreRuntime = (store) => {
|
|
4860
4824
|
runtime.thread.store = store;
|
4861
4825
|
});
|
4862
4826
|
return _react.useMemo.call(void 0,
|
4863
|
-
() =>
|
4827
|
+
() => AssistantRuntimeImpl.create(runtime, ThreadRuntimeImpl),
|
4864
4828
|
[runtime]
|
4865
4829
|
);
|
4866
4830
|
};
|
@@ -5087,8 +5051,8 @@ var WebSpeechSynthesisAdapter = class {
|
|
5087
5051
|
};
|
5088
5052
|
|
5089
5053
|
// src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
|
5090
|
-
var SimpleImageAttachmentAdapter = (
|
5091
|
-
|
5054
|
+
var SimpleImageAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init39.call(this); }
|
5055
|
+
__init39() {this.accept = "image/*"}
|
5092
5056
|
async add(state) {
|
5093
5057
|
return {
|
5094
5058
|
id: state.file.name,
|
@@ -5113,7 +5077,7 @@ var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.p
|
|
5113
5077
|
}
|
5114
5078
|
async remove() {
|
5115
5079
|
}
|
5116
|
-
},
|
5080
|
+
}, _class17);
|
5117
5081
|
var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
5118
5082
|
const reader = new FileReader();
|
5119
5083
|
reader.onload = () => resolve(reader.result);
|
@@ -5122,8 +5086,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
|
5122
5086
|
});
|
5123
5087
|
|
5124
5088
|
// src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
|
5125
|
-
var SimpleTextAttachmentAdapter = (
|
5126
|
-
|
5089
|
+
var SimpleTextAttachmentAdapter = (_class18 = class {constructor() { _class18.prototype.__init40.call(this); }
|
5090
|
+
__init40() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
|
5127
5091
|
async add(state) {
|
5128
5092
|
return {
|
5129
5093
|
id: state.file.name,
|
@@ -5150,7 +5114,7 @@ ${await getFileText(attachment.file)}
|
|
5150
5114
|
}
|
5151
5115
|
async remove() {
|
5152
5116
|
}
|
5153
|
-
},
|
5117
|
+
}, _class18);
|
5154
5118
|
var getFileText = (file) => new Promise((resolve, reject) => {
|
5155
5119
|
const reader = new FileReader();
|
5156
5120
|
reader.onload = () => resolve(reader.result);
|
@@ -5251,7 +5215,7 @@ var ThreadConfigProvider = ({
|
|
5251
5215
|
}) => {
|
5252
5216
|
const hasAssistant = !!useAssistantRuntime({ optional: true });
|
5253
5217
|
const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
|
5254
|
-
if (!_optionalChain([config, 'optionalAccess',
|
5218
|
+
if (!_optionalChain([config, 'optionalAccess', _266 => _266.runtime])) return configProvider;
|
5255
5219
|
if (hasAssistant) {
|
5256
5220
|
throw new Error(
|
5257
5221
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -5280,8 +5244,8 @@ var useAllowCopy = (ensureCapability = false) => {
|
|
5280
5244
|
};
|
5281
5245
|
var useAllowSpeak = (ensureCapability = false) => {
|
5282
5246
|
const { assistantMessage: { allowSpeak = true } = {} } = useThreadConfig();
|
5283
|
-
const
|
5284
|
-
return allowSpeak && (!ensureCapability ||
|
5247
|
+
const speechSupported = useThread((t) => t.capabilities.speech);
|
5248
|
+
return allowSpeak && (!ensureCapability || speechSupported);
|
5285
5249
|
};
|
5286
5250
|
var useAllowReload = (ensureCapability = false) => {
|
5287
5251
|
const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();
|
@@ -5579,7 +5543,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
5579
5543
|
{
|
5580
5544
|
components: {
|
5581
5545
|
...componentsProp,
|
5582
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
5546
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _267 => _267.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
|
5583
5547
|
tools: toolsComponents
|
5584
5548
|
}
|
5585
5549
|
}
|
@@ -5630,12 +5594,30 @@ CircleStopIcon.displayName = "CircleStopIcon";
|
|
5630
5594
|
|
5631
5595
|
|
5632
5596
|
var ComposerAttachmentRoot = withDefaults(attachment_exports.Root, {
|
5633
|
-
className: "aui-
|
5597
|
+
className: "aui-attachment-root"
|
5634
5598
|
});
|
5635
5599
|
ComposerAttachmentRoot.displayName = "ComposerAttachmentRoot";
|
5636
5600
|
var ComposerAttachment2 = () => {
|
5601
|
+
const typeLabel = useAttachment((a) => {
|
5602
|
+
const type = a.type;
|
5603
|
+
switch (type) {
|
5604
|
+
case "image":
|
5605
|
+
return "Image";
|
5606
|
+
case "document":
|
5607
|
+
return "Document";
|
5608
|
+
case "file":
|
5609
|
+
return "File";
|
5610
|
+
default:
|
5611
|
+
const _exhaustiveCheck = type;
|
5612
|
+
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
5613
|
+
}
|
5614
|
+
});
|
5637
5615
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerAttachmentRoot, { children: [
|
5638
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, {}),
|
5616
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, { className: "aui-attachment-thumb" }),
|
5617
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "aui-attachment-text", children: [
|
5618
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "aui-attachment-name", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.Name, {}) }),
|
5619
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "aui-attachment-type", children: typeLabel })
|
5620
|
+
] }),
|
5639
5621
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAttachmentRemove, {})
|
5640
5622
|
] });
|
5641
5623
|
};
|
@@ -5714,7 +5696,7 @@ var ComposerAttachments = ({ components }) => {
|
|
5714
5696
|
{
|
5715
5697
|
components: {
|
5716
5698
|
...components,
|
5717
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5699
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _268 => _268.Attachment]), () => ( composer_attachment_default))
|
5718
5700
|
}
|
5719
5701
|
}
|
5720
5702
|
) });
|
@@ -5842,7 +5824,7 @@ var ThreadWelcomeSuggestions = () => {
|
|
5842
5824
|
const suggestions2 = useThread((t) => t.suggestions);
|
5843
5825
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5844
5826
|
const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
|
5845
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess',
|
5827
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _269 => _269.map, 'call', _270 => _270((suggestion, idx) => {
|
5846
5828
|
const key = `${suggestion.prompt}-${idx}`;
|
5847
5829
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
5848
5830
|
})]) });
|
@@ -5897,11 +5879,31 @@ var user_action_bar_default = Object.assign(UserActionBar, exports8);
|
|
5897
5879
|
// src/ui/user-message-attachment.tsx
|
5898
5880
|
|
5899
5881
|
var UserMessageAttachmentRoot = withDefaults(attachment_exports.Root, {
|
5900
|
-
className: "aui-
|
5882
|
+
className: "aui-attachment-root"
|
5901
5883
|
});
|
5902
5884
|
UserMessageAttachmentRoot.displayName = "UserMessageAttachmentRoot";
|
5903
5885
|
var UserMessageAttachment = () => {
|
5904
|
-
|
5886
|
+
const typeLabel = useAttachment((a) => {
|
5887
|
+
const type = a.type;
|
5888
|
+
switch (type) {
|
5889
|
+
case "image":
|
5890
|
+
return "Image";
|
5891
|
+
case "document":
|
5892
|
+
return "Document";
|
5893
|
+
case "file":
|
5894
|
+
return "File";
|
5895
|
+
default:
|
5896
|
+
const _exhaustiveCheck = type;
|
5897
|
+
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
5898
|
+
}
|
5899
|
+
});
|
5900
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageAttachmentRoot, { children: [
|
5901
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.unstable_Thumb, { className: "aui-attachment-thumb" }),
|
5902
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "aui-attachment-text", children: [
|
5903
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "aui-attachment-name", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, attachment_exports.Name, {}) }),
|
5904
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "aui-attachment-type", children: typeLabel })
|
5905
|
+
] })
|
5906
|
+
] });
|
5905
5907
|
};
|
5906
5908
|
UserMessageAttachment.displayName = "UserMessageAttachment";
|
5907
5909
|
var exports9 = {
|
@@ -5917,8 +5919,10 @@ var user_message_attachment_default = Object.assign(
|
|
5917
5919
|
var UserMessage = () => {
|
5918
5920
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageRoot, { children: [
|
5919
5921
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageAttachments, {}),
|
5920
|
-
/* @__PURE__ */ _jsxruntime.
|
5921
|
-
|
5922
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, message_exports.If, { hasContent: true, children: [
|
5923
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, user_action_bar_default, {}),
|
5924
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContent, {})
|
5925
|
+
] }),
|
5922
5926
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, branch_picker_default, {})
|
5923
5927
|
] });
|
5924
5928
|
};
|
@@ -5936,7 +5940,7 @@ var UserMessageContent = _react.forwardRef.call(void 0, ({ components, ...props
|
|
5936
5940
|
{
|
5937
5941
|
components: {
|
5938
5942
|
...components,
|
5939
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5943
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _271 => _271.Text]), () => ( content_part_default.Text))
|
5940
5944
|
}
|
5941
5945
|
}
|
5942
5946
|
) });
|
@@ -5953,7 +5957,7 @@ var UserMessageAttachments = ({
|
|
5953
5957
|
{
|
5954
5958
|
components: {
|
5955
5959
|
...components,
|
5956
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5960
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _272 => _272.Attachment]), () => ( user_message_attachment_default))
|
5957
5961
|
}
|
5958
5962
|
}
|
5959
5963
|
) }) });
|
@@ -6056,10 +6060,10 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
|
|
6056
6060
|
thread_exports.Messages,
|
6057
6061
|
{
|
6058
6062
|
components: {
|
6059
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6060
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6061
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6062
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
6063
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _273 => _273.UserMessage]), () => ( user_message_default)),
|
6064
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _274 => _274.EditComposer]), () => ( edit_composer_default)),
|
6065
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _275 => _275.AssistantMessage]), () => ( assistant_message_default)),
|
6066
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _276 => _276.SystemMessage]), () => ( SystemMessage))
|
6063
6067
|
},
|
6064
6068
|
...rest
|
6065
6069
|
}
|
@@ -6070,7 +6074,7 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
|
|
6070
6074
|
ThreadMessages.displayName = "ThreadMessages";
|
6071
6075
|
var ThreadFollowupSuggestions = () => {
|
6072
6076
|
const suggestions = useThread((t) => t.suggestions);
|
6073
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess',
|
6077
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _277 => _277.map, 'call', _278 => _278((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
6074
6078
|
thread_exports.Suggestion,
|
6075
6079
|
{
|
6076
6080
|
className: "aui-thread-followup-suggestion",
|