@assistant-ui/react 0.5.29 → 0.5.31
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/EdgeRuntimeRequestOptions-BD0mpoF6.d.mts +412 -0
- package/dist/EdgeRuntimeRequestOptions-BD0mpoF6.d.ts +412 -0
- package/dist/edge.d.mts +261 -3
- package/dist/edge.d.ts +261 -3
- package/dist/edge.js +98 -101
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +96 -100
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +50 -281
- package/dist/index.d.ts +50 -281
- package/dist/index.js +162 -124
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +106 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/AssistantTypes-Bo5YKjhV.d.mts +0 -162
- package/dist/AssistantTypes-Bo5YKjhV.d.ts +0 -162
package/dist/index.js
CHANGED
@@ -113,36 +113,35 @@ function useThreadContext(options) {
|
|
113
113
|
|
114
114
|
// src/context/stores/Composer.ts
|
115
115
|
|
116
|
-
|
117
|
-
// src/context/stores/BaseComposer.ts
|
118
|
-
var makeBaseComposer = (set) => ({
|
119
|
-
value: "",
|
120
|
-
setValue: (value) => {
|
121
|
-
set({ value });
|
122
|
-
}
|
123
|
-
});
|
124
|
-
|
125
|
-
// src/context/stores/Composer.ts
|
126
|
-
var makeComposerStore = (useThreadMessages, useThreadActions) => {
|
116
|
+
var makeComposerStore = (useThreadRuntime) => {
|
127
117
|
const focusListeners = /* @__PURE__ */ new Set();
|
128
|
-
return _zustand.create.call(void 0, )((
|
118
|
+
return _zustand.create.call(void 0, )((_, get) => {
|
119
|
+
const runtime = useThreadRuntime.getState();
|
129
120
|
return {
|
130
|
-
|
131
|
-
|
132
|
-
|
121
|
+
get value() {
|
122
|
+
return get().text;
|
123
|
+
},
|
124
|
+
setValue(value) {
|
125
|
+
get().setText(value);
|
126
|
+
},
|
127
|
+
text: runtime.composer.text,
|
128
|
+
setText: (value) => {
|
129
|
+
useThreadRuntime.getState().composer.setText(value);
|
133
130
|
},
|
131
|
+
canCancel: runtime.capabilities.cancel,
|
134
132
|
isEditing: true,
|
135
133
|
send: () => {
|
136
|
-
const
|
137
|
-
|
138
|
-
|
139
|
-
|
134
|
+
const runtime2 = useThreadRuntime.getState();
|
135
|
+
const text = runtime2.composer.text;
|
136
|
+
runtime2.composer.setText("");
|
137
|
+
runtime2.append({
|
138
|
+
parentId: _nullishCoalesce(_optionalChain([runtime2, 'access', _6 => _6.messages, 'access', _7 => _7.at, 'call', _8 => _8(-1), 'optionalAccess', _9 => _9.id]), () => ( null)),
|
140
139
|
role: "user",
|
141
|
-
content: [{ type: "text", text
|
140
|
+
content: [{ type: "text", text }]
|
142
141
|
});
|
143
142
|
},
|
144
143
|
cancel: () => {
|
145
|
-
|
144
|
+
useThreadRuntime.getState().cancelRun();
|
146
145
|
},
|
147
146
|
focus: () => {
|
148
147
|
for (const listener of focusListeners) {
|
@@ -163,14 +162,10 @@ var makeComposerStore = (useThreadMessages, useThreadActions) => {
|
|
163
162
|
|
164
163
|
var getThreadStateFromRuntime = (runtime) => {
|
165
164
|
const lastMessage = runtime.messages.at(-1);
|
166
|
-
if (_optionalChain([lastMessage, 'optionalAccess', _11 => _11.role]) !== "assistant")
|
167
|
-
return Object.freeze({
|
168
|
-
isDisabled: runtime.isDisabled,
|
169
|
-
isRunning: false
|
170
|
-
});
|
171
165
|
return Object.freeze({
|
166
|
+
capabilities: runtime.capabilities,
|
172
167
|
isDisabled: runtime.isDisabled,
|
173
|
-
isRunning: lastMessage.status.type === "running"
|
168
|
+
isRunning: _optionalChain([lastMessage, 'optionalAccess', _10 => _10.role]) !== "assistant" ? false : lastMessage.status.type === "running"
|
174
169
|
});
|
175
170
|
};
|
176
171
|
var makeThreadStore = (runtimeRef) => {
|
@@ -203,9 +198,6 @@ var makeThreadViewportStore = () => {
|
|
203
198
|
var makeThreadActionStore = (runtimeStore) => {
|
204
199
|
return _zustand.create.call(void 0,
|
205
200
|
() => Object.freeze({
|
206
|
-
get capabilities() {
|
207
|
-
return runtimeStore.getState().capabilities;
|
208
|
-
},
|
209
201
|
getBranches: (messageId) => runtimeStore.getState().getBranches(messageId),
|
210
202
|
switchToBranch: (branchId) => runtimeStore.getState().switchToBranch(branchId),
|
211
203
|
startRun: (parentId) => runtimeStore.getState().startRun(parentId),
|
@@ -258,7 +250,7 @@ var ThreadProvider = ({
|
|
258
250
|
const useThreadMessages = makeThreadMessagesStore(useThreadRuntime);
|
259
251
|
const useThreadActions = makeThreadActionStore(useThreadRuntime);
|
260
252
|
const useViewport = makeThreadViewportStore();
|
261
|
-
const useComposer = makeComposerStore(
|
253
|
+
const useComposer = makeComposerStore(useThreadRuntime);
|
262
254
|
return {
|
263
255
|
useThread,
|
264
256
|
useThreadRuntime,
|
@@ -274,15 +266,23 @@ var ThreadProvider = ({
|
|
274
266
|
const onThreadUpdate = () => {
|
275
267
|
const oldState = context.useThread.getState();
|
276
268
|
const state = getThreadStateFromRuntime(thread);
|
277
|
-
if (oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning
|
269
|
+
if (oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning || // TODO ensure capabilities is memoized
|
270
|
+
oldState.capabilities !== state.capabilities) {
|
278
271
|
context.useThread.setState(
|
279
|
-
|
272
|
+
state,
|
280
273
|
true
|
281
274
|
);
|
282
275
|
}
|
283
276
|
if (thread.messages !== context.useThreadMessages.getState()) {
|
284
277
|
context.useThreadMessages.setState(thread.messages, true);
|
285
278
|
}
|
279
|
+
const composerState = context.useComposer.getState();
|
280
|
+
if (thread.composer.text !== composerState.text || state.capabilities.cancel !== composerState.canCancel) {
|
281
|
+
context.useComposer.setState({
|
282
|
+
text: thread.composer.text,
|
283
|
+
canCancel: state.capabilities.cancel
|
284
|
+
});
|
285
|
+
}
|
286
286
|
};
|
287
287
|
onThreadUpdate();
|
288
288
|
return thread.subscribe(onThreadUpdate);
|
@@ -354,7 +354,7 @@ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProvider
|
|
354
354
|
var MessageContext = _react.createContext.call(void 0, null);
|
355
355
|
function useMessageContext(options) {
|
356
356
|
const context = _react.useContext.call(void 0, MessageContext);
|
357
|
-
if (!_optionalChain([options, 'optionalAccess',
|
357
|
+
if (!_optionalChain([options, 'optionalAccess', _11 => _11.optional]) && !context)
|
358
358
|
throw new Error(
|
359
359
|
"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
|
360
360
|
);
|
@@ -381,7 +381,7 @@ var ContentPartContext = _react.createContext.call(void 0,
|
|
381
381
|
);
|
382
382
|
function useContentPartContext(options) {
|
383
383
|
const context = _react.useContext.call(void 0, ContentPartContext);
|
384
|
-
if (!_optionalChain([options, 'optionalAccess',
|
384
|
+
if (!_optionalChain([options, 'optionalAccess', _12 => _12.optional]) && !context)
|
385
385
|
throw new Error(
|
386
386
|
"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
|
387
387
|
);
|
@@ -393,13 +393,13 @@ function useContentPartContext(options) {
|
|
393
393
|
var toAppendMessage = (useThreadMessages, message) => {
|
394
394
|
if (typeof message === "string") {
|
395
395
|
return {
|
396
|
-
parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access',
|
396
|
+
parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _13 => _13.getState, 'call', _14 => _14(), 'access', _15 => _15.at, 'call', _16 => _16(-1), 'optionalAccess', _17 => _17.id]), () => ( null)),
|
397
397
|
role: "user",
|
398
398
|
content: [{ type: "text", text: message }]
|
399
399
|
};
|
400
400
|
}
|
401
401
|
return {
|
402
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access',
|
402
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _18 => _18.getState, 'call', _19 => _19(), 'access', _20 => _20.at, 'call', _21 => _21(-1), 'optionalAccess', _22 => _22.id]))), () => ( null)),
|
403
403
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
404
404
|
content: message.content
|
405
405
|
};
|
@@ -451,7 +451,7 @@ var useAssistantTool = (tool) => {
|
|
451
451
|
const unsub2 = render ? setToolUI(toolName, render) : void 0;
|
452
452
|
return () => {
|
453
453
|
unsub1();
|
454
|
-
_optionalChain([unsub2, 'optionalCall',
|
454
|
+
_optionalChain([unsub2, 'optionalCall', _23 => _23()]);
|
455
455
|
};
|
456
456
|
}, [registerModelConfigProvider, setToolUI, tool]);
|
457
457
|
};
|
@@ -552,7 +552,7 @@ var useActionBarCopy = ({
|
|
552
552
|
const callback = _react.useCallback.call(void 0, () => {
|
553
553
|
const { message } = useMessage.getState();
|
554
554
|
const { setIsCopied } = useMessageUtils.getState();
|
555
|
-
const { isEditing,
|
555
|
+
const { isEditing, text: composerValue } = useEditComposer.getState();
|
556
556
|
const valueToCopy = isEditing ? composerValue : getThreadMessageText(message);
|
557
557
|
navigator.clipboard.writeText(valueToCopy).then(() => {
|
558
558
|
setIsCopied(true);
|
@@ -680,7 +680,7 @@ var useComposerSend = () => {
|
|
680
680
|
const { useComposer } = useComposerContext();
|
681
681
|
const disabled = useCombinedStore(
|
682
682
|
[useThread, useComposer],
|
683
|
-
(t, c) => t.isRunning || !c.isEditing || c.
|
683
|
+
(t, c) => t.isRunning || !c.isEditing || c.text.length === 0
|
684
684
|
);
|
685
685
|
const callback = _react.useCallback.call(void 0, () => {
|
686
686
|
const composerState = useComposer.getState();
|
@@ -799,9 +799,9 @@ var useThreadSuggestion = ({
|
|
799
799
|
const composer = useComposer.getState();
|
800
800
|
if (autoSend && !thread.isRunning) {
|
801
801
|
append(prompt);
|
802
|
-
composer.
|
802
|
+
composer.setText("");
|
803
803
|
} else {
|
804
|
-
composer.
|
804
|
+
composer.setText(prompt);
|
805
805
|
}
|
806
806
|
}, [useThread, useComposer, autoSend, append, prompt]);
|
807
807
|
if (disabled) return null;
|
@@ -888,7 +888,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
888
888
|
...primitiveProps,
|
889
889
|
ref: forwardedRef,
|
890
890
|
onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
|
891
|
-
_optionalChain([callback, 'optionalCall',
|
891
|
+
_optionalChain([callback, 'optionalCall', _24 => _24()]);
|
892
892
|
})
|
893
893
|
}
|
894
894
|
);
|
@@ -1176,7 +1176,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
|
|
1176
1176
|
}
|
1177
1177
|
}
|
1178
1178
|
const status = toContentPartStatus(message, partIndex, part);
|
1179
|
-
const currentState = _optionalChain([useContentPart, 'optionalAccess',
|
1179
|
+
const currentState = _optionalChain([useContentPart, 'optionalAccess', _25 => _25.getState, 'call', _26 => _26()]);
|
1180
1180
|
if (currentState && currentState.part === part && currentState.status === status)
|
1181
1181
|
return null;
|
1182
1182
|
return Object.freeze({ part, status });
|
@@ -1252,7 +1252,7 @@ var withSmoothContextProvider = (Component) => {
|
|
1252
1252
|
};
|
1253
1253
|
function useSmoothContext(options) {
|
1254
1254
|
const context = _react.useContext.call(void 0, SmoothContext);
|
1255
|
-
if (!_optionalChain([options, 'optionalAccess',
|
1255
|
+
if (!_optionalChain([options, 'optionalAccess', _27 => _27.optional]) && !context)
|
1256
1256
|
throw new Error(
|
1257
1257
|
"This component must be used within a SmoothContextProvider."
|
1258
1258
|
);
|
@@ -1323,7 +1323,7 @@ var useSmooth = (state, smooth = false) => {
|
|
1323
1323
|
const [displayedText, setDisplayedText] = _react.useState.call(void 0, text);
|
1324
1324
|
const setText = _reactusecallbackref.useCallbackRef.call(void 0, (text2) => {
|
1325
1325
|
setDisplayedText(text2);
|
1326
|
-
_optionalChain([useSmoothStatus2, 'optionalAccess',
|
1326
|
+
_optionalChain([useSmoothStatus2, 'optionalAccess', _28 => _28.setState, 'call', _29 => _29(text2 !== state.part.text ? SMOOTH_STATUS : state.status)]);
|
1327
1327
|
});
|
1328
1328
|
const [animatorRef] = _react.useState.call(void 0,
|
1329
1329
|
new TextStreamAnimator(text, setText)
|
@@ -1467,7 +1467,7 @@ var MessageContentPartImpl = ({
|
|
1467
1467
|
};
|
1468
1468
|
var MessageContentPart = _react.memo.call(void 0,
|
1469
1469
|
MessageContentPartImpl,
|
1470
|
-
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access',
|
1470
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _30 => _30.components, 'optionalAccess', _31 => _31.Text]) === _optionalChain([next, 'access', _32 => _32.components, 'optionalAccess', _33 => _33.Text]) && _optionalChain([prev, 'access', _34 => _34.components, 'optionalAccess', _35 => _35.Image]) === _optionalChain([next, 'access', _36 => _36.components, 'optionalAccess', _37 => _37.Image]) && _optionalChain([prev, 'access', _38 => _38.components, 'optionalAccess', _39 => _39.UI]) === _optionalChain([next, 'access', _40 => _40.components, 'optionalAccess', _41 => _41.UI]) && _optionalChain([prev, 'access', _42 => _42.components, 'optionalAccess', _43 => _43.tools]) === _optionalChain([next, 'access', _44 => _44.components, 'optionalAccess', _45 => _45.tools])
|
1471
1471
|
);
|
1472
1472
|
var MessagePrimitiveContent = ({
|
1473
1473
|
components
|
@@ -1562,7 +1562,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
1562
1562
|
const { useComposer, type } = useComposerContext();
|
1563
1563
|
const value = useComposer((c) => {
|
1564
1564
|
if (!c.isEditing) return "";
|
1565
|
-
return c.
|
1565
|
+
return c.text;
|
1566
1566
|
});
|
1567
1567
|
const Component = asChild ? _reactslot.Slot : _reacttextareaautosize2.default;
|
1568
1568
|
const isDisabled = _nullishCoalesce(_nullishCoalesce(useThread((t) => t.isDisabled), () => ( disabledProp)), () => ( false));
|
@@ -1577,11 +1577,12 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
1577
1577
|
});
|
1578
1578
|
const handleKeyPress = (e) => {
|
1579
1579
|
if (isDisabled) return;
|
1580
|
+
if (e.nativeEvent.isComposing) return;
|
1580
1581
|
if (e.key === "Enter" && e.shiftKey === false) {
|
1581
1582
|
const { isRunning } = useThread.getState();
|
1582
1583
|
if (!isRunning) {
|
1583
1584
|
e.preventDefault();
|
1584
|
-
_optionalChain([textareaRef, 'access',
|
1585
|
+
_optionalChain([textareaRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.closest, 'call', _48 => _48("form"), 'optionalAccess', _49 => _49.requestSubmit, 'call', _50 => _50()]);
|
1585
1586
|
}
|
1586
1587
|
}
|
1587
1588
|
};
|
@@ -1612,7 +1613,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
1612
1613
|
onChange: _primitive.composeEventHandlers.call(void 0, onChange, (e) => {
|
1613
1614
|
const composerState = useComposer.getState();
|
1614
1615
|
if (!composerState.isEditing) return;
|
1615
|
-
return composerState.
|
1616
|
+
return composerState.setText(e.target.value);
|
1616
1617
|
}),
|
1617
1618
|
onKeyDown: _primitive.composeEventHandlers.call(void 0, onKeyDown, handleKeyPress)
|
1618
1619
|
}
|
@@ -1627,7 +1628,7 @@ ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
|
|
1627
1628
|
|
1628
1629
|
var ComposerPrimitiveSend = _react.forwardRef.call(void 0, ({ disabled, ...rest }, ref) => {
|
1629
1630
|
const { useComposer } = useComposerContext();
|
1630
|
-
const hasValue = useComposer((c) => c.isEditing && c.
|
1631
|
+
const hasValue = useComposer((c) => c.isEditing && c.text.length > 0);
|
1631
1632
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
1632
1633
|
_reactprimitive.Primitive.button,
|
1633
1634
|
{
|
@@ -1841,18 +1842,27 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
|
1841
1842
|
var makeEditComposerStore = ({
|
1842
1843
|
onEdit,
|
1843
1844
|
onSend
|
1844
|
-
}) => _zustand.create.call(void 0, )((set, get
|
1845
|
-
|
1845
|
+
}) => _zustand.create.call(void 0, )((set, get) => ({
|
1846
|
+
get value() {
|
1847
|
+
return get().text;
|
1848
|
+
},
|
1849
|
+
setValue(value) {
|
1850
|
+
get().setText(value);
|
1851
|
+
},
|
1852
|
+
text: "",
|
1853
|
+
setText: (text) => {
|
1854
|
+
set({ text });
|
1855
|
+
},
|
1846
1856
|
canCancel: false,
|
1847
1857
|
isEditing: false,
|
1848
1858
|
edit: () => {
|
1849
|
-
const
|
1850
|
-
set({ isEditing: true, canCancel: true,
|
1859
|
+
const text = onEdit();
|
1860
|
+
set({ isEditing: true, canCancel: true, text });
|
1851
1861
|
},
|
1852
1862
|
send: () => {
|
1853
|
-
const
|
1863
|
+
const text = get().text;
|
1854
1864
|
set({ isEditing: false, canCancel: false });
|
1855
|
-
onSend(
|
1865
|
+
onSend(text);
|
1856
1866
|
},
|
1857
1867
|
cancel: () => {
|
1858
1868
|
set({ isEditing: false, canCancel: false });
|
@@ -1875,15 +1885,15 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => ({
|
|
1875
1885
|
// src/context/providers/MessageProvider.tsx
|
1876
1886
|
|
1877
1887
|
var getIsLast = (messages, message) => {
|
1878
|
-
return _optionalChain([messages, 'access',
|
1888
|
+
return _optionalChain([messages, 'access', _51 => _51[messages.length - 1], 'optionalAccess', _52 => _52.id]) === message.id;
|
1879
1889
|
};
|
1880
1890
|
var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
1881
|
-
const parentId = _nullishCoalesce(_optionalChain([messages, 'access',
|
1891
|
+
const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _53 => _53[messageIndex - 1], 'optionalAccess', _54 => _54.id]), () => ( null));
|
1882
1892
|
const message = messages[messageIndex];
|
1883
1893
|
if (!message) return null;
|
1884
1894
|
const isLast = getIsLast(messages, message);
|
1885
1895
|
const branches = getBranches(message.id);
|
1886
|
-
const currentState = _optionalChain([useMessage, 'optionalAccess',
|
1896
|
+
const currentState = _optionalChain([useMessage, 'optionalAccess', _55 => _55.getState, 'call', _56 => _56()]);
|
1887
1897
|
if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
|
1888
1898
|
return null;
|
1889
1899
|
return Object.freeze({
|
@@ -2010,7 +2020,7 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
2010
2020
|
ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
|
2011
2021
|
var ThreadPrimitiveMessages = _react.memo.call(void 0,
|
2012
2022
|
ThreadPrimitiveMessagesImpl,
|
2013
|
-
(prev, next) => _optionalChain([prev, 'access',
|
2023
|
+
(prev, next) => _optionalChain([prev, 'access', _57 => _57.components, 'optionalAccess', _58 => _58.Message]) === _optionalChain([next, 'access', _59 => _59.components, 'optionalAccess', _60 => _60.Message]) && _optionalChain([prev, 'access', _61 => _61.components, 'optionalAccess', _62 => _62.UserMessage]) === _optionalChain([next, 'access', _63 => _63.components, 'optionalAccess', _64 => _64.UserMessage]) && _optionalChain([prev, 'access', _65 => _65.components, 'optionalAccess', _66 => _66.EditComposer]) === _optionalChain([next, 'access', _67 => _67.components, 'optionalAccess', _68 => _68.EditComposer]) && _optionalChain([prev, 'access', _69 => _69.components, 'optionalAccess', _70 => _70.AssistantMessage]) === _optionalChain([next, 'access', _71 => _71.components, 'optionalAccess', _72 => _72.AssistantMessage]) && _optionalChain([prev, 'access', _73 => _73.components, 'optionalAccess', _74 => _74.SystemMessage]) === _optionalChain([next, 'access', _75 => _75.components, 'optionalAccess', _76 => _76.SystemMessage])
|
2014
2024
|
);
|
2015
2025
|
|
2016
2026
|
// src/primitives/thread/ThreadScrollToBottom.tsx
|
@@ -2142,7 +2152,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
2142
2152
|
parentOrRoot.children = parentOrRoot.children.filter(
|
2143
2153
|
(m) => m !== child.current.id
|
2144
2154
|
);
|
2145
|
-
if (_optionalChain([child, 'access',
|
2155
|
+
if (_optionalChain([child, 'access', _77 => _77.prev, 'optionalAccess', _78 => _78.next]) === child) {
|
2146
2156
|
const fallbackId = child.prev.children.at(-1);
|
2147
2157
|
const fallback = fallbackId ? this.messages.get(fallbackId) : null;
|
2148
2158
|
if (fallback === void 0) {
|
@@ -2172,7 +2182,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
2172
2182
|
}
|
2173
2183
|
}
|
2174
2184
|
getMessages() {
|
2175
|
-
const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access',
|
2185
|
+
const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access', _79 => _79.head, 'optionalAccess', _80 => _80.level]), () => ( 0)));
|
2176
2186
|
for (let current = this.head; current; current = current.prev) {
|
2177
2187
|
messages[current.level] = current.current;
|
2178
2188
|
}
|
@@ -2210,7 +2220,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
2210
2220
|
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
2211
2221
|
);
|
2212
2222
|
return {
|
2213
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
2223
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _81 => _81.prev, 'optionalAccess', _82 => _82.current, 'access', _83 => _83.id]), () => ( null)),
|
2214
2224
|
message: message.current
|
2215
2225
|
};
|
2216
2226
|
}
|
@@ -2295,11 +2305,11 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
2295
2305
|
for (const [, message] of this.messages) {
|
2296
2306
|
exportItems.push({
|
2297
2307
|
message: message.current,
|
2298
|
-
parentId: _nullishCoalesce(_optionalChain([message, 'access',
|
2308
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _84 => _84.prev, 'optionalAccess', _85 => _85.current, 'access', _86 => _86.id]), () => ( null))
|
2299
2309
|
});
|
2300
2310
|
}
|
2301
2311
|
return {
|
2302
|
-
headId: _nullishCoalesce(_optionalChain([this, 'access',
|
2312
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _87 => _87.head, 'optionalAccess', _88 => _88.current, 'access', _89 => _89.id]), () => ( null)),
|
2303
2313
|
messages: exportItems
|
2304
2314
|
};
|
2305
2315
|
}
|
@@ -2307,7 +2317,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
2307
2317
|
for (const { message, parentId } of messages) {
|
2308
2318
|
this.addOrUpdateMessage(parentId, message);
|
2309
2319
|
}
|
2310
|
-
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access',
|
2320
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access', _90 => _90.at, 'call', _91 => _91(-1), 'optionalAccess', _92 => _92.message, 'access', _93 => _93.id]))), () => ( null)));
|
2311
2321
|
}
|
2312
2322
|
}, _class4);
|
2313
2323
|
|
@@ -2470,7 +2480,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
2470
2480
|
});
|
2471
2481
|
if (mergeRoundtrips) {
|
2472
2482
|
const previousMessage = messages[messages.length - 1];
|
2473
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
2483
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _94 => _94.role]) === "assistant") {
|
2474
2484
|
previousMessage.content.push(...newContent);
|
2475
2485
|
break;
|
2476
2486
|
}
|
@@ -2483,7 +2493,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
2483
2493
|
}
|
2484
2494
|
case "tool": {
|
2485
2495
|
const previousMessage = messages[messages.length - 1];
|
2486
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
2496
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _95 => _95.role]) !== "assistant")
|
2487
2497
|
throw new Error(
|
2488
2498
|
"A tool message must be preceded by an assistant message."
|
2489
2499
|
);
|
@@ -2704,7 +2714,7 @@ var useEdgeRuntime = ({
|
|
2704
2714
|
};
|
2705
2715
|
|
2706
2716
|
// src/runtimes/local/shouldContinue.tsx
|
2707
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
2717
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _96 => _96.status, 'optionalAccess', _97 => _97.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
2708
2718
|
|
2709
2719
|
// src/runtimes/local/LocalThreadRuntime.tsx
|
2710
2720
|
var CAPABILITIES = Object.freeze({
|
@@ -2715,11 +2725,11 @@ var CAPABILITIES = Object.freeze({
|
|
2715
2725
|
copy: true
|
2716
2726
|
});
|
2717
2727
|
var LocalThreadRuntime = (_class5 = class {
|
2718
|
-
constructor(configProvider, adapter, options) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);
|
2728
|
+
constructor(configProvider, adapter, options) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);
|
2719
2729
|
this.configProvider = configProvider;
|
2720
2730
|
this.adapter = adapter;
|
2721
2731
|
this.options = options;
|
2722
|
-
if (_optionalChain([options, 'optionalAccess',
|
2732
|
+
if (_optionalChain([options, 'optionalAccess', _98 => _98.initialMessages])) {
|
2723
2733
|
let parentId = null;
|
2724
2734
|
const messages = fromCoreMessages(options.initialMessages);
|
2725
2735
|
for (const message of messages) {
|
@@ -2736,6 +2746,13 @@ var LocalThreadRuntime = (_class5 = class {
|
|
2736
2746
|
get messages() {
|
2737
2747
|
return this.repository.getMessages();
|
2738
2748
|
}
|
2749
|
+
__init16() {this.composer = {
|
2750
|
+
text: "",
|
2751
|
+
setText: (value) => {
|
2752
|
+
this.composer.text = value;
|
2753
|
+
this.notifySubscribers();
|
2754
|
+
}
|
2755
|
+
}}
|
2739
2756
|
getBranches(messageId) {
|
2740
2757
|
return this.repository.getBranches(messageId);
|
2741
2758
|
}
|
@@ -2774,7 +2791,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
2774
2791
|
}
|
2775
2792
|
async performRoundtrip(parentId, message) {
|
2776
2793
|
const messages = this.repository.getMessages();
|
2777
|
-
_optionalChain([this, 'access',
|
2794
|
+
_optionalChain([this, 'access', _99 => _99.abortController, 'optionalAccess', _100 => _100.abort, 'call', _101 => _101()]);
|
2778
2795
|
this.abortController = new AbortController();
|
2779
2796
|
const initialContent = message.content;
|
2780
2797
|
const initialRoundtrips = message.roundtrips;
|
@@ -2783,13 +2800,13 @@ var LocalThreadRuntime = (_class5 = class {
|
|
2783
2800
|
...message,
|
2784
2801
|
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
2785
2802
|
status: _nullishCoalesce(m.status, () => ( message.status)),
|
2786
|
-
..._optionalChain([m, 'access',
|
2803
|
+
..._optionalChain([m, 'access', _102 => _102.roundtrips, 'optionalAccess', _103 => _103.length]) ? { roundtrips: [..._nullishCoalesce(initialRoundtrips, () => ( [])), ...m.roundtrips] } : void 0
|
2787
2804
|
};
|
2788
2805
|
this.repository.addOrUpdateMessage(parentId, message);
|
2789
2806
|
this.notifySubscribers();
|
2790
2807
|
};
|
2791
|
-
const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access',
|
2792
|
-
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access',
|
2808
|
+
const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access', _104 => _104.options, 'optionalAccess', _105 => _105.maxToolRoundtrips]), () => ( 1));
|
2809
|
+
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _106 => _106.roundtrips, 'optionalAccess', _107 => _107.length]), () => ( 0));
|
2793
2810
|
if (toolRoundtrips > maxToolRoundtrips) {
|
2794
2811
|
updateMessage({
|
2795
2812
|
status: {
|
@@ -2929,8 +2946,8 @@ var getExternalStoreMessage = (message) => {
|
|
2929
2946
|
};
|
2930
2947
|
|
2931
2948
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
2932
|
-
var ThreadMessageConverter = (_class6 = class {constructor() { _class6.prototype.
|
2933
|
-
|
2949
|
+
var ThreadMessageConverter = (_class6 = class {constructor() { _class6.prototype.__init17.call(this); }
|
2950
|
+
__init17() {this.cache = /* @__PURE__ */ new WeakMap()}
|
2934
2951
|
convertMessages(messages, converter, keyMapper = (key) => key) {
|
2935
2952
|
return messages.map((m, idx) => {
|
2936
2953
|
const key = keyMapper(m);
|
@@ -3021,40 +3038,57 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
3021
3038
|
|
3022
3039
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
3023
3040
|
var hasUpcomingMessage = (isRunning, messages) => {
|
3024
|
-
return isRunning && _optionalChain([messages, 'access',
|
3041
|
+
return isRunning && _optionalChain([messages, 'access', _108 => _108[messages.length - 1], 'optionalAccess', _109 => _109.role]) !== "assistant";
|
3025
3042
|
};
|
3026
3043
|
var ExternalStoreThreadRuntime = (_class7 = class {
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3044
|
+
__init18() {this._subscriptions = /* @__PURE__ */ new Set()}
|
3045
|
+
__init19() {this.repository = new MessageRepository()}
|
3046
|
+
__init20() {this.assistantOptimisticId = null}
|
3047
|
+
__init21() {this._capabilities = {
|
3048
|
+
switchToBranch: false,
|
3049
|
+
edit: false,
|
3050
|
+
reload: false,
|
3051
|
+
cancel: false,
|
3052
|
+
copy: false
|
3053
|
+
}}
|
3030
3054
|
get capabilities() {
|
3031
|
-
return
|
3032
|
-
switchToBranch: this._store.setMessages !== void 0,
|
3033
|
-
edit: this._store.onEdit !== void 0,
|
3034
|
-
reload: this._store.onReload !== void 0,
|
3035
|
-
cancel: this._store.onCancel !== void 0,
|
3036
|
-
copy: this._store.onCopy !== null
|
3037
|
-
};
|
3055
|
+
return this._capabilities;
|
3038
3056
|
}
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3057
|
+
__init22() {this.messages = []}
|
3058
|
+
__init23() {this.isDisabled = false}
|
3059
|
+
__init24() {this.converter = new ThreadMessageConverter()}
|
3042
3060
|
|
3043
|
-
|
3061
|
+
__init25() {this.composer = {
|
3062
|
+
text: "",
|
3063
|
+
setText: (value) => {
|
3064
|
+
this.composer.text = value;
|
3065
|
+
this.notifySubscribers();
|
3066
|
+
}
|
3067
|
+
}}
|
3068
|
+
constructor(store) {;_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);_class7.prototype.__init24.call(this);_class7.prototype.__init25.call(this);_class7.prototype.__init26.call(this);
|
3044
3069
|
this.store = store;
|
3045
3070
|
}
|
3046
3071
|
set store(store) {
|
3072
|
+
if (this._store === store) return;
|
3073
|
+
const isRunning = _nullishCoalesce(store.isRunning, () => ( false));
|
3074
|
+
this.isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
|
3047
3075
|
const oldStore = this._store;
|
3076
|
+
this._store = store;
|
3077
|
+
this._capabilities = {
|
3078
|
+
switchToBranch: this._store.setMessages !== void 0,
|
3079
|
+
edit: this._store.onEdit !== void 0,
|
3080
|
+
reload: this._store.onReload !== void 0,
|
3081
|
+
cancel: this._store.onCancel !== void 0,
|
3082
|
+
copy: this._store.onCopy !== null
|
3083
|
+
};
|
3048
3084
|
if (oldStore) {
|
3049
3085
|
if (oldStore.convertMessage !== store.convertMessage) {
|
3050
3086
|
this.converter = new ThreadMessageConverter();
|
3051
|
-
} else if (oldStore.
|
3087
|
+
} else if (oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
|
3088
|
+
this.notifySubscribers();
|
3052
3089
|
return;
|
3053
3090
|
}
|
3054
3091
|
}
|
3055
|
-
this._store = store;
|
3056
|
-
const isRunning = _nullishCoalesce(store.isRunning, () => ( false));
|
3057
|
-
const isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
|
3058
3092
|
const convertCallback = (cache, m, idx) => {
|
3059
3093
|
if (!store.convertMessage) return m;
|
3060
3094
|
const isLast = idx === store.messages.length - 1;
|
@@ -3076,7 +3110,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
3076
3110
|
for (let i = 0; i < messages.length; i++) {
|
3077
3111
|
const message = messages[i];
|
3078
3112
|
const parent = messages[i - 1];
|
3079
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
3113
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _113 => _113.id]), () => ( null)), message);
|
3080
3114
|
}
|
3081
3115
|
if (this.assistantOptimisticId) {
|
3082
3116
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -3084,7 +3118,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
3084
3118
|
}
|
3085
3119
|
if (hasUpcomingMessage(isRunning, messages)) {
|
3086
3120
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
3087
|
-
_nullishCoalesce(_optionalChain([messages, 'access',
|
3121
|
+
_nullishCoalesce(_optionalChain([messages, 'access', _114 => _114.at, 'call', _115 => _115(-1), 'optionalAccess', _116 => _116.id]), () => ( null)),
|
3088
3122
|
{
|
3089
3123
|
role: "assistant",
|
3090
3124
|
content: []
|
@@ -3092,10 +3126,12 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
3092
3126
|
);
|
3093
3127
|
}
|
3094
3128
|
this.repository.resetHead(
|
3095
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access',
|
3129
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _117 => _117.at, 'call', _118 => _118(-1), 'optionalAccess', _119 => _119.id]))), () => ( null))
|
3096
3130
|
);
|
3097
3131
|
this.messages = this.repository.getMessages();
|
3098
|
-
this.
|
3132
|
+
this.notifySubscribers();
|
3133
|
+
}
|
3134
|
+
notifySubscribers() {
|
3099
3135
|
for (const callback of this._subscriptions) callback();
|
3100
3136
|
}
|
3101
3137
|
getBranches(messageId) {
|
@@ -3108,7 +3144,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
3108
3144
|
this.updateMessages(this.repository.getMessages());
|
3109
3145
|
}
|
3110
3146
|
async append(message) {
|
3111
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
3147
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _120 => _120.messages, 'access', _121 => _121.at, 'call', _122 => _122(-1), 'optionalAccess', _123 => _123.id]), () => ( null)))) {
|
3112
3148
|
if (!this._store.onEdit)
|
3113
3149
|
throw new Error("Runtime does not support editing messages.");
|
3114
3150
|
await this._store.onEdit(message);
|
@@ -3138,8 +3174,8 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
3138
3174
|
this._subscriptions.add(callback);
|
3139
3175
|
return () => this._subscriptions.delete(callback);
|
3140
3176
|
}
|
3141
|
-
|
3142
|
-
_optionalChain([this, 'access',
|
3177
|
+
__init26() {this.updateMessages = (messages) => {
|
3178
|
+
_optionalChain([this, 'access', _124 => _124._store, 'access', _125 => _125.setMessages, 'optionalCall', _126 => _126(
|
3143
3179
|
messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
3144
3180
|
)]);
|
3145
3181
|
}}
|
@@ -3152,9 +3188,9 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
3152
3188
|
|
3153
3189
|
// src/runtimes/external-store/ExternalStoreRuntime.tsx
|
3154
3190
|
var ExternalStoreRuntime = (_class8 = class extends BaseAssistantRuntime {
|
3155
|
-
|
3191
|
+
__init27() {this._proxyConfigProvider = new ProxyConfigProvider()}
|
3156
3192
|
constructor(store) {
|
3157
|
-
super(new ExternalStoreThreadRuntime(store));_class8.prototype.
|
3193
|
+
super(new ExternalStoreThreadRuntime(store));_class8.prototype.__init27.call(this);;
|
3158
3194
|
}
|
3159
3195
|
set store(store) {
|
3160
3196
|
this.thread.store = store;
|
@@ -3204,7 +3240,7 @@ var ThreadConfigProvider = ({
|
|
3204
3240
|
}) => {
|
3205
3241
|
const assistant = useAssistantContext({ optional: true });
|
3206
3242
|
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 });
|
3207
|
-
if (!_optionalChain([config, 'optionalAccess',
|
3243
|
+
if (!_optionalChain([config, 'optionalAccess', _127 => _127.runtime])) return configProvider;
|
3208
3244
|
if (assistant) {
|
3209
3245
|
throw new Error(
|
3210
3246
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -3220,14 +3256,14 @@ var _lucidereact = require('lucide-react');
|
|
3220
3256
|
|
3221
3257
|
var useAllowCopy = () => {
|
3222
3258
|
const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
|
3223
|
-
const {
|
3224
|
-
const copySupported =
|
3259
|
+
const { useThread } = useThreadContext();
|
3260
|
+
const copySupported = useThread((t) => t.capabilities.copy);
|
3225
3261
|
return copySupported && allowCopy;
|
3226
3262
|
};
|
3227
3263
|
var useAllowReload = () => {
|
3228
3264
|
const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();
|
3229
|
-
const {
|
3230
|
-
const reloadSupported =
|
3265
|
+
const { useThread } = useThreadContext();
|
3266
|
+
const reloadSupported = useThread((t) => t.capabilities.reload);
|
3231
3267
|
return reloadSupported && allowReload;
|
3232
3268
|
};
|
3233
3269
|
var AssistantActionBar = () => {
|
@@ -3296,8 +3332,8 @@ var assistant_action_bar_default = Object.assign(
|
|
3296
3332
|
|
3297
3333
|
var useAllowBranchPicker = () => {
|
3298
3334
|
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
3299
|
-
const {
|
3300
|
-
const branchPickerSupported =
|
3335
|
+
const { useThread } = useThreadContext();
|
3336
|
+
const branchPickerSupported = useThread((t) => t.capabilities.edit);
|
3301
3337
|
return branchPickerSupported && allowBranchPicker;
|
3302
3338
|
};
|
3303
3339
|
var BranchPicker = () => {
|
@@ -3420,7 +3456,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
3420
3456
|
{
|
3421
3457
|
components: {
|
3422
3458
|
...componentsProp,
|
3423
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
3459
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _128 => _128.Text]), () => ( components.Text)), () => ( content_part_default.Text))
|
3424
3460
|
}
|
3425
3461
|
}
|
3426
3462
|
) });
|
@@ -3457,6 +3493,8 @@ var CircleStopIcon = () => {
|
|
3457
3493
|
xmlns: "http://www.w3.org/2000/svg",
|
3458
3494
|
viewBox: "0 0 16 16",
|
3459
3495
|
fill: "currentColor",
|
3496
|
+
width: "16",
|
3497
|
+
height: "16",
|
3460
3498
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
|
3461
3499
|
}
|
3462
3500
|
);
|
@@ -3493,8 +3531,8 @@ var ComposerInput = _react.forwardRef.call(void 0,
|
|
3493
3531
|
);
|
3494
3532
|
ComposerInput.displayName = "ComposerInput";
|
3495
3533
|
var useAllowCancel = () => {
|
3496
|
-
const {
|
3497
|
-
const cancelSupported =
|
3534
|
+
const { useThread } = useThreadContext();
|
3535
|
+
const cancelSupported = useThread((t) => t.capabilities.cancel);
|
3498
3536
|
return cancelSupported;
|
3499
3537
|
};
|
3500
3538
|
var ComposerAction = () => {
|
@@ -3595,7 +3633,7 @@ var ThreadWelcomeSuggestion = ({
|
|
3595
3633
|
};
|
3596
3634
|
var ThreadWelcomeSuggestions = () => {
|
3597
3635
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
3598
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess',
|
3636
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _129 => _129.map, 'call', _130 => _130((suggestion, idx) => {
|
3599
3637
|
const key = `${suggestion.prompt}-${idx}`;
|
3600
3638
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
3601
3639
|
})]) });
|
@@ -3620,8 +3658,8 @@ var thread_welcome_default = Object.assign(ThreadWelcome, exports6);
|
|
3620
3658
|
|
3621
3659
|
var useAllowEdit = () => {
|
3622
3660
|
const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
|
3623
|
-
const {
|
3624
|
-
const editSupported =
|
3661
|
+
const { useThread } = useThreadContext();
|
3662
|
+
const editSupported = useThread((t) => t.capabilities.edit);
|
3625
3663
|
return editSupported && allowEdit;
|
3626
3664
|
};
|
3627
3665
|
var UserActionBar = () => {
|
@@ -3673,7 +3711,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
|
|
3673
3711
|
{
|
3674
3712
|
components: {
|
3675
3713
|
...components,
|
3676
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3714
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _131 => _131.Text]), () => ( content_part_default.Text))
|
3677
3715
|
}
|
3678
3716
|
}
|
3679
3717
|
) });
|
@@ -3775,10 +3813,10 @@ var ThreadMessages = ({ components, ...rest }) => {
|
|
3775
3813
|
thread_exports.Messages,
|
3776
3814
|
{
|
3777
3815
|
components: {
|
3778
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3779
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3780
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3781
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3816
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _132 => _132.UserMessage]), () => ( user_message_default)),
|
3817
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _133 => _133.EditComposer]), () => ( edit_composer_default)),
|
3818
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _134 => _134.AssistantMessage]), () => ( assistant_message_default)),
|
3819
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _135 => _135.SystemMessage]), () => ( SystemMessage))
|
3782
3820
|
},
|
3783
3821
|
...rest
|
3784
3822
|
}
|