@assistant-ui/react 0.5.35 → 0.5.37

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -9,7 +9,8 @@
9
9
 
10
10
 
11
11
 
12
- var _chunkJKRONBQKjs = require('./chunk-JKRONBQK.js');
12
+
13
+ var _chunkBQ3MRWUVjs = require('./chunk-BQ3MRWUV.js');
13
14
 
14
15
 
15
16
  var _chunkDCHYNTHIjs = require('./chunk-DCHYNTHI.js');
@@ -41,7 +42,7 @@ var _zustand = require('zustand');
41
42
  var ProxyConfigProvider = (_class = class {constructor() { _class.prototype.__init.call(this); }
42
43
  __init() {this._providers = /* @__PURE__ */ new Set()}
43
44
  getModelConfig() {
44
- return _chunkJKRONBQKjs.mergeModelConfigs.call(void 0, this._providers);
45
+ return _chunkBQ3MRWUVjs.mergeModelConfigs.call(void 0, this._providers);
45
46
  }
46
47
  registerModelConfigProvider(provider) {
47
48
  this._providers.add(provider);
@@ -915,14 +916,14 @@ function streamPartDecoderStream() {
915
916
  controller.enqueue(decodeStreamPart(chunk));
916
917
  }
917
918
  });
918
- return new (0, _chunkJKRONBQKjs.PipeableTransformStream)((readable) => {
919
+ return new (0, _chunkBQ3MRWUVjs.PipeableTransformStream)((readable) => {
919
920
  return readable.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(decodeStream);
920
921
  });
921
922
  }
922
923
 
923
924
  // src/runtimes/edge/streams/utils/index.ts
924
925
  var streamUtils = {
925
- streamPartEncoderStream: _chunkJKRONBQKjs.streamPartEncoderStream,
926
+ streamPartEncoderStream: _chunkBQ3MRWUVjs.streamPartEncoderStream,
926
927
  streamPartDecoderStream
927
928
  };
928
929
 
@@ -1031,8 +1032,8 @@ var EdgeChatAdapter = class {
1031
1032
  credentials: _nullishCoalesce(this.options.credentials, () => ( "same-origin")),
1032
1033
  body: JSON.stringify({
1033
1034
  system: config.system,
1034
- messages: _chunkJKRONBQKjs.toCoreMessages.call(void 0, messages),
1035
- tools: config.tools ? _chunkJKRONBQKjs.toLanguageModelTools.call(void 0, config.tools) : [],
1035
+ messages: _chunkBQ3MRWUVjs.toCoreMessages.call(void 0, messages),
1036
+ tools: config.tools ? _chunkBQ3MRWUVjs.toLanguageModelTools.call(void 0, config.tools) : [],
1036
1037
  ...config.callSettings,
1037
1038
  ...config.config,
1038
1039
  ...this.options.body
@@ -1042,7 +1043,7 @@ var EdgeChatAdapter = class {
1042
1043
  if (result.status !== 200) {
1043
1044
  throw new Error(`Status ${result.status}: ${await result.text()}`);
1044
1045
  }
1045
- const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkJKRONBQKjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkJKRONBQKjs.runResultStream.call(void 0, ));
1046
+ const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkBQ3MRWUVjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkBQ3MRWUVjs.runResultStream.call(void 0, ));
1046
1047
  let update;
1047
1048
  for await (update of asAsyncIterable(stream)) {
1048
1049
  yield update;
@@ -1297,6 +1298,19 @@ var LocalRuntime = class extends BaseAssistantRuntime {
1297
1298
  this.thread.adapter
1298
1299
  );
1299
1300
  }
1301
+ reset({
1302
+ initialMessages
1303
+ } = {}) {
1304
+ this.switchToThread(null);
1305
+ if (!initialMessages) return;
1306
+ const messages = fromCoreMessages(initialMessages);
1307
+ this.thread.import({
1308
+ messages: messages.map((m, idx) => ({
1309
+ parentId: _nullishCoalesce(_optionalChain([messages, 'access', _52 => _52[idx - 1], 'optionalAccess', _53 => _53.id]), () => ( null)),
1310
+ message: m
1311
+ }))
1312
+ });
1313
+ }
1300
1314
  };
1301
1315
 
1302
1316
  // src/runtimes/local/useLocalRuntime.tsx
@@ -1414,7 +1428,7 @@ var getThreadMessageText = (message) => {
1414
1428
 
1415
1429
  // src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
1416
1430
  var hasUpcomingMessage = (isRunning, messages) => {
1417
- return isRunning && _optionalChain([messages, 'access', _52 => _52[messages.length - 1], 'optionalAccess', _53 => _53.role]) !== "assistant";
1431
+ return isRunning && _optionalChain([messages, 'access', _54 => _54[messages.length - 1], 'optionalAccess', _55 => _55.role]) !== "assistant";
1418
1432
  };
1419
1433
  var ExternalStoreThreadRuntime = (_class7 = class {
1420
1434
  __init18() {this._subscriptions = /* @__PURE__ */ new Set()}
@@ -1482,7 +1496,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1482
1496
  for (let i = 0; i < messages.length; i++) {
1483
1497
  const message = messages[i];
1484
1498
  const parent = messages[i - 1];
1485
- this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _57 => _57.id]), () => ( null)), message);
1499
+ this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _59 => _59.id]), () => ( null)), message);
1486
1500
  }
1487
1501
  if (this.assistantOptimisticId) {
1488
1502
  this.repository.deleteMessage(this.assistantOptimisticId);
@@ -1490,7 +1504,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1490
1504
  }
1491
1505
  if (hasUpcomingMessage(isRunning, messages)) {
1492
1506
  this.assistantOptimisticId = this.repository.appendOptimisticMessage(
1493
- _nullishCoalesce(_optionalChain([messages, 'access', _58 => _58.at, 'call', _59 => _59(-1), 'optionalAccess', _60 => _60.id]), () => ( null)),
1507
+ _nullishCoalesce(_optionalChain([messages, 'access', _60 => _60.at, 'call', _61 => _61(-1), 'optionalAccess', _62 => _62.id]), () => ( null)),
1494
1508
  {
1495
1509
  role: "assistant",
1496
1510
  content: []
@@ -1498,7 +1512,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1498
1512
  );
1499
1513
  }
1500
1514
  this.repository.resetHead(
1501
- _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _61 => _61.at, 'call', _62 => _62(-1), 'optionalAccess', _63 => _63.id]))), () => ( null))
1515
+ _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _63 => _63.at, 'call', _64 => _64(-1), 'optionalAccess', _65 => _65.id]))), () => ( null))
1502
1516
  );
1503
1517
  this.messages = this.repository.getMessages();
1504
1518
  this.notifySubscribers();
@@ -1516,7 +1530,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1516
1530
  this.updateMessages(this.repository.getMessages());
1517
1531
  }
1518
1532
  async append(message) {
1519
- if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _64 => _64.messages, 'access', _65 => _65.at, 'call', _66 => _66(-1), 'optionalAccess', _67 => _67.id]), () => ( null)))) {
1533
+ if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _66 => _66.messages, 'access', _67 => _67.at, 'call', _68 => _68(-1), 'optionalAccess', _69 => _69.id]), () => ( null)))) {
1520
1534
  if (!this._store.onEdit)
1521
1535
  throw new Error("Runtime does not support editing messages.");
1522
1536
  await this._store.onEdit(message);
@@ -1539,7 +1553,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1539
1553
  }
1540
1554
  let messages = this.repository.getMessages();
1541
1555
  const previousMessage = messages[messages.length - 1];
1542
- if (_optionalChain([previousMessage, 'optionalAccess', _68 => _68.role]) === "user" && previousMessage.id === _optionalChain([messages, 'access', _69 => _69.at, 'call', _70 => _70(-1), 'optionalAccess', _71 => _71.id])) {
1556
+ if (_optionalChain([previousMessage, 'optionalAccess', _70 => _70.role]) === "user" && previousMessage.id === _optionalChain([messages, 'access', _71 => _71.at, 'call', _72 => _72(-1), 'optionalAccess', _73 => _73.id])) {
1543
1557
  this.repository.deleteMessage(previousMessage.id);
1544
1558
  if (!this.composer.text.trim()) {
1545
1559
  this.composer.setText(getThreadMessageText(previousMessage));
@@ -1557,7 +1571,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1557
1571
  return () => this._subscriptions.delete(callback);
1558
1572
  }
1559
1573
  __init26() {this.updateMessages = (messages) => {
1560
- _optionalChain([this, 'access', _72 => _72._store, 'access', _73 => _73.setMessages, 'optionalCall', _74 => _74(
1574
+ _optionalChain([this, 'access', _74 => _74._store, 'access', _75 => _75.setMessages, 'optionalCall', _76 => _76(
1561
1575
  messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
1562
1576
  )]);
1563
1577
  }}
@@ -1614,6 +1628,42 @@ var useExternalStoreRuntime = (store) => {
1614
1628
  return runtime;
1615
1629
  };
1616
1630
 
1631
+ // src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
1632
+
1633
+
1634
+ // src/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.ts
1635
+ var DangerousInBrowserAdapter = class {
1636
+ constructor(options) {
1637
+ this.options = options;
1638
+ }
1639
+ async *run({ messages, abortSignal, config }) {
1640
+ const res = await _chunkBQ3MRWUVjs.getEdgeRuntimeStream.call(void 0, {
1641
+ options: this.options,
1642
+ abortSignal,
1643
+ requestData: {
1644
+ system: config.system,
1645
+ messages: _chunkBQ3MRWUVjs.toCoreMessages.call(void 0, messages),
1646
+ tools: config.tools ? _chunkBQ3MRWUVjs.toLanguageModelTools.call(void 0, config.tools) : [],
1647
+ ...config.callSettings,
1648
+ ...config.config
1649
+ }
1650
+ });
1651
+ const stream = res.pipeThrough(_chunkBQ3MRWUVjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkBQ3MRWUVjs.runResultStream.call(void 0, ));
1652
+ for await (const update of asAsyncIterable(stream)) {
1653
+ yield update;
1654
+ }
1655
+ }
1656
+ };
1657
+
1658
+ // src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
1659
+ var useDangerousInBrowserRuntime = ({
1660
+ initialMessages,
1661
+ ...options
1662
+ }) => {
1663
+ const [adapter] = _react.useState.call(void 0, () => new DangerousInBrowserAdapter(options));
1664
+ return useLocalRuntime(adapter, { initialMessages });
1665
+ };
1666
+
1617
1667
  // src/context/providers/ThreadProvider.tsx
1618
1668
 
1619
1669
  var ThreadProvider = ({
@@ -1686,6 +1736,12 @@ var makeAssistantActionsStore = (runtimeRef) => _zustand.create.call(void 0,
1686
1736
  })
1687
1737
  );
1688
1738
 
1739
+ // src/context/stores/AssistantRuntime.tsx
1740
+
1741
+ var makeAssistantRuntimeStore = (runtime) => {
1742
+ return _zustand.create.call(void 0, () => runtime);
1743
+ };
1744
+
1689
1745
  // src/context/providers/AssistantProvider.tsx
1690
1746
 
1691
1747
  var AssistantProvider = ({ children, runtime }) => {
@@ -1694,15 +1750,25 @@ var AssistantProvider = ({ children, runtime }) => {
1694
1750
  runtimeRef.current = runtime;
1695
1751
  });
1696
1752
  const [context] = _react.useState.call(void 0, () => {
1753
+ const useAssistantRuntime = makeAssistantRuntimeStore(runtime);
1697
1754
  const useModelConfig = makeAssistantModelConfigStore();
1698
1755
  const useToolUIs = makeAssistantToolUIsStore();
1699
1756
  const useAssistantActions = makeAssistantActionsStore(runtimeRef);
1700
- return { useModelConfig, useToolUIs, useAssistantActions };
1757
+ return {
1758
+ useModelConfig,
1759
+ useToolUIs,
1760
+ useAssistantRuntime,
1761
+ useAssistantActions
1762
+ };
1701
1763
  });
1702
1764
  const getModelConfig = context.useModelConfig();
1703
1765
  _react.useEffect.call(void 0, () => {
1704
1766
  return runtime.registerModelConfigProvider(getModelConfig);
1705
1767
  }, [runtime, getModelConfig]);
1768
+ _react.useEffect.call(void 0,
1769
+ () => context.useAssistantRuntime.setState(runtime, true),
1770
+ [runtime, context]
1771
+ );
1706
1772
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantContext.Provider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadProvider, { provider: runtime, children }) });
1707
1773
  };
1708
1774
 
@@ -1721,7 +1787,7 @@ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProvider
1721
1787
  var MessageContext = _react.createContext.call(void 0, null);
1722
1788
  function useMessageContext(options) {
1723
1789
  const context = _react.useContext.call(void 0, MessageContext);
1724
- if (!_optionalChain([options, 'optionalAccess', _75 => _75.optional]) && !context)
1790
+ if (!_optionalChain([options, 'optionalAccess', _77 => _77.optional]) && !context)
1725
1791
  throw new Error(
1726
1792
  "This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
1727
1793
  );
@@ -1748,7 +1814,7 @@ var ContentPartContext = _react.createContext.call(void 0,
1748
1814
  );
1749
1815
  function useContentPartContext(options) {
1750
1816
  const context = _react.useContext.call(void 0, ContentPartContext);
1751
- if (!_optionalChain([options, 'optionalAccess', _76 => _76.optional]) && !context)
1817
+ if (!_optionalChain([options, 'optionalAccess', _78 => _78.optional]) && !context)
1752
1818
  throw new Error(
1753
1819
  "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
1754
1820
  );
@@ -1760,13 +1826,13 @@ function useContentPartContext(options) {
1760
1826
  var toAppendMessage = (useThreadMessages, message) => {
1761
1827
  if (typeof message === "string") {
1762
1828
  return {
1763
- parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _77 => _77.getState, 'call', _78 => _78(), 'access', _79 => _79.at, 'call', _80 => _80(-1), 'optionalAccess', _81 => _81.id]), () => ( null)),
1829
+ parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _79 => _79.getState, 'call', _80 => _80(), 'access', _81 => _81.at, 'call', _82 => _82(-1), 'optionalAccess', _83 => _83.id]), () => ( null)),
1764
1830
  role: "user",
1765
1831
  content: [{ type: "text", text: message }]
1766
1832
  };
1767
1833
  }
1768
1834
  return {
1769
- parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _82 => _82.getState, 'call', _83 => _83(), 'access', _84 => _84.at, 'call', _85 => _85(-1), 'optionalAccess', _86 => _86.id]))), () => ( null)),
1835
+ parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _84 => _84.getState, 'call', _85 => _85(), 'access', _86 => _86.at, 'call', _87 => _87(-1), 'optionalAccess', _88 => _88.id]))), () => ( null)),
1770
1836
  role: _nullishCoalesce(message.role, () => ( "user")),
1771
1837
  content: message.content
1772
1838
  };
@@ -1818,7 +1884,7 @@ var useAssistantTool = (tool) => {
1818
1884
  const unsub2 = render ? setToolUI(toolName, render) : void 0;
1819
1885
  return () => {
1820
1886
  unsub1();
1821
- _optionalChain([unsub2, 'optionalCall', _87 => _87()]);
1887
+ _optionalChain([unsub2, 'optionalCall', _89 => _89()]);
1822
1888
  };
1823
1889
  }, [registerModelConfigProvider, setToolUI, tool]);
1824
1890
  };
@@ -2247,7 +2313,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
2247
2313
  ...primitiveProps,
2248
2314
  ref: forwardedRef,
2249
2315
  onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
2250
- _optionalChain([callback, 'optionalCall', _88 => _88()]);
2316
+ _optionalChain([callback, 'optionalCall', _90 => _90()]);
2251
2317
  })
2252
2318
  }
2253
2319
  );
@@ -2555,7 +2621,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
2555
2621
  }
2556
2622
  }
2557
2623
  const status = toContentPartStatus(message, partIndex, part);
2558
- const currentState = _optionalChain([useContentPart, 'optionalAccess', _89 => _89.getState, 'call', _90 => _90()]);
2624
+ const currentState = _optionalChain([useContentPart, 'optionalAccess', _91 => _91.getState, 'call', _92 => _92()]);
2559
2625
  if (currentState && currentState.part === part && currentState.status === status)
2560
2626
  return null;
2561
2627
  return Object.freeze({ part, status });
@@ -2703,7 +2769,7 @@ var MessageContentPartImpl = ({
2703
2769
  };
2704
2770
  var MessageContentPart = _react.memo.call(void 0,
2705
2771
  MessageContentPartImpl,
2706
- (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _91 => _91.components, 'optionalAccess', _92 => _92.Text]) === _optionalChain([next, 'access', _93 => _93.components, 'optionalAccess', _94 => _94.Text]) && _optionalChain([prev, 'access', _95 => _95.components, 'optionalAccess', _96 => _96.Image]) === _optionalChain([next, 'access', _97 => _97.components, 'optionalAccess', _98 => _98.Image]) && _optionalChain([prev, 'access', _99 => _99.components, 'optionalAccess', _100 => _100.UI]) === _optionalChain([next, 'access', _101 => _101.components, 'optionalAccess', _102 => _102.UI]) && _optionalChain([prev, 'access', _103 => _103.components, 'optionalAccess', _104 => _104.tools]) === _optionalChain([next, 'access', _105 => _105.components, 'optionalAccess', _106 => _106.tools])
2772
+ (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _93 => _93.components, 'optionalAccess', _94 => _94.Text]) === _optionalChain([next, 'access', _95 => _95.components, 'optionalAccess', _96 => _96.Text]) && _optionalChain([prev, 'access', _97 => _97.components, 'optionalAccess', _98 => _98.Image]) === _optionalChain([next, 'access', _99 => _99.components, 'optionalAccess', _100 => _100.Image]) && _optionalChain([prev, 'access', _101 => _101.components, 'optionalAccess', _102 => _102.UI]) === _optionalChain([next, 'access', _103 => _103.components, 'optionalAccess', _104 => _104.UI]) && _optionalChain([prev, 'access', _105 => _105.components, 'optionalAccess', _106 => _106.tools]) === _optionalChain([next, 'access', _107 => _107.components, 'optionalAccess', _108 => _108.tools])
2707
2773
  );
2708
2774
  var MessagePrimitiveContent = ({
2709
2775
  components
@@ -2818,7 +2884,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
2818
2884
  const { isRunning } = useThread.getState();
2819
2885
  if (!isRunning) {
2820
2886
  e.preventDefault();
2821
- _optionalChain([textareaRef, 'access', _107 => _107.current, 'optionalAccess', _108 => _108.closest, 'call', _109 => _109("form"), 'optionalAccess', _110 => _110.requestSubmit, 'call', _111 => _111()]);
2887
+ _optionalChain([textareaRef, 'access', _109 => _109.current, 'optionalAccess', _110 => _110.closest, 'call', _111 => _111("form"), 'optionalAccess', _112 => _112.requestSubmit, 'call', _113 => _113()]);
2822
2888
  }
2823
2889
  }
2824
2890
  };
@@ -3121,15 +3187,15 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => ({
3121
3187
  // src/context/providers/MessageProvider.tsx
3122
3188
 
3123
3189
  var getIsLast = (messages, message) => {
3124
- return _optionalChain([messages, 'access', _112 => _112[messages.length - 1], 'optionalAccess', _113 => _113.id]) === message.id;
3190
+ return _optionalChain([messages, 'access', _114 => _114[messages.length - 1], 'optionalAccess', _115 => _115.id]) === message.id;
3125
3191
  };
3126
3192
  var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
3127
- const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _114 => _114[messageIndex - 1], 'optionalAccess', _115 => _115.id]), () => ( null));
3193
+ const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _116 => _116[messageIndex - 1], 'optionalAccess', _117 => _117.id]), () => ( null));
3128
3194
  const message = messages[messageIndex];
3129
3195
  if (!message) return null;
3130
3196
  const isLast = getIsLast(messages, message);
3131
3197
  const branches = getBranches(message.id);
3132
- const currentState = _optionalChain([useMessage, 'optionalAccess', _116 => _116.getState, 'call', _117 => _117()]);
3198
+ const currentState = _optionalChain([useMessage, 'optionalAccess', _118 => _118.getState, 'call', _119 => _119()]);
3133
3199
  if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
3134
3200
  return null;
3135
3201
  return Object.freeze({
@@ -3256,7 +3322,7 @@ var ThreadPrimitiveMessagesImpl = ({
3256
3322
  ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
3257
3323
  var ThreadPrimitiveMessages = _react.memo.call(void 0,
3258
3324
  ThreadPrimitiveMessagesImpl,
3259
- (prev, next) => _optionalChain([prev, 'access', _118 => _118.components, 'optionalAccess', _119 => _119.Message]) === _optionalChain([next, 'access', _120 => _120.components, 'optionalAccess', _121 => _121.Message]) && _optionalChain([prev, 'access', _122 => _122.components, 'optionalAccess', _123 => _123.UserMessage]) === _optionalChain([next, 'access', _124 => _124.components, 'optionalAccess', _125 => _125.UserMessage]) && _optionalChain([prev, 'access', _126 => _126.components, 'optionalAccess', _127 => _127.EditComposer]) === _optionalChain([next, 'access', _128 => _128.components, 'optionalAccess', _129 => _129.EditComposer]) && _optionalChain([prev, 'access', _130 => _130.components, 'optionalAccess', _131 => _131.AssistantMessage]) === _optionalChain([next, 'access', _132 => _132.components, 'optionalAccess', _133 => _133.AssistantMessage]) && _optionalChain([prev, 'access', _134 => _134.components, 'optionalAccess', _135 => _135.SystemMessage]) === _optionalChain([next, 'access', _136 => _136.components, 'optionalAccess', _137 => _137.SystemMessage])
3325
+ (prev, next) => _optionalChain([prev, 'access', _120 => _120.components, 'optionalAccess', _121 => _121.Message]) === _optionalChain([next, 'access', _122 => _122.components, 'optionalAccess', _123 => _123.Message]) && _optionalChain([prev, 'access', _124 => _124.components, 'optionalAccess', _125 => _125.UserMessage]) === _optionalChain([next, 'access', _126 => _126.components, 'optionalAccess', _127 => _127.UserMessage]) && _optionalChain([prev, 'access', _128 => _128.components, 'optionalAccess', _129 => _129.EditComposer]) === _optionalChain([next, 'access', _130 => _130.components, 'optionalAccess', _131 => _131.EditComposer]) && _optionalChain([prev, 'access', _132 => _132.components, 'optionalAccess', _133 => _133.AssistantMessage]) === _optionalChain([next, 'access', _134 => _134.components, 'optionalAccess', _135 => _135.AssistantMessage]) && _optionalChain([prev, 'access', _136 => _136.components, 'optionalAccess', _137 => _137.SystemMessage]) === _optionalChain([next, 'access', _138 => _138.components, 'optionalAccess', _139 => _139.SystemMessage])
3260
3326
  );
3261
3327
 
3262
3328
  // src/primitives/thread/ThreadScrollToBottom.tsx
@@ -3288,7 +3354,7 @@ var ThreadConfigProvider = ({
3288
3354
  }) => {
3289
3355
  const assistant = useAssistantContext({ optional: true });
3290
3356
  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 });
3291
- if (!_optionalChain([config, 'optionalAccess', _138 => _138.runtime])) return configProvider;
3357
+ if (!_optionalChain([config, 'optionalAccess', _140 => _140.runtime])) return configProvider;
3292
3358
  if (assistant) {
3293
3359
  throw new Error(
3294
3360
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
@@ -3504,7 +3570,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
3504
3570
  {
3505
3571
  components: {
3506
3572
  ...componentsProp,
3507
- Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _139 => _139.Text]), () => ( components.Text)), () => ( content_part_default.Text))
3573
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _141 => _141.Text]), () => ( components.Text)), () => ( content_part_default.Text))
3508
3574
  }
3509
3575
  }
3510
3576
  ) });
@@ -3681,7 +3747,7 @@ var ThreadWelcomeSuggestion = ({
3681
3747
  };
3682
3748
  var ThreadWelcomeSuggestions = () => {
3683
3749
  const { welcome: { suggestions } = {} } = useThreadConfig();
3684
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _140 => _140.map, 'call', _141 => _141((suggestion, idx) => {
3750
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _142 => _142.map, 'call', _143 => _143((suggestion, idx) => {
3685
3751
  const key = `${suggestion.prompt}-${idx}`;
3686
3752
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
3687
3753
  })]) });
@@ -3759,7 +3825,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
3759
3825
  {
3760
3826
  components: {
3761
3827
  ...components,
3762
- Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _142 => _142.Text]), () => ( content_part_default.Text))
3828
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _144 => _144.Text]), () => ( content_part_default.Text))
3763
3829
  }
3764
3830
  }
3765
3831
  ) });
@@ -3861,10 +3927,10 @@ var ThreadMessages = ({ components, ...rest }) => {
3861
3927
  thread_exports.Messages,
3862
3928
  {
3863
3929
  components: {
3864
- UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _143 => _143.UserMessage]), () => ( user_message_default)),
3865
- EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _144 => _144.EditComposer]), () => ( edit_composer_default)),
3866
- AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _145 => _145.AssistantMessage]), () => ( assistant_message_default)),
3867
- SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _146 => _146.SystemMessage]), () => ( SystemMessage))
3930
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _145 => _145.UserMessage]), () => ( user_message_default)),
3931
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _146 => _146.EditComposer]), () => ( edit_composer_default)),
3932
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _147 => _147.AssistantMessage]), () => ( assistant_message_default)),
3933
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _148 => _148.SystemMessage]), () => ( SystemMessage))
3868
3934
  },
3869
3935
  ...rest
3870
3936
  }
@@ -4042,5 +4108,6 @@ var assistant_modal_default = Object.assign(AssistantModal, exports11);
4042
4108
 
4043
4109
 
4044
4110
 
4045
- exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerPrimitive = composer_exports; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkJKRONBQKjs.toCoreMessage; exports.toCoreMessages = _chunkJKRONBQKjs.toCoreMessages; exports.toLanguageModelMessages = _chunkJKRONBQKjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkJKRONBQKjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useAppendMessage = useAppendMessage; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartText = useContentPartText; exports.useEdgeRuntime = useEdgeRuntime; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadSuggestion = useThreadSuggestion;
4111
+
4112
+ exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerPrimitive = composer_exports; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkBQ3MRWUVjs.toCoreMessage; exports.toCoreMessages = _chunkBQ3MRWUVjs.toCoreMessages; exports.toLanguageModelMessages = _chunkBQ3MRWUVjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkBQ3MRWUVjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useAppendMessage = useAppendMessage; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadSuggestion = useThreadSuggestion;
4046
4113
  //# sourceMappingURL=index.js.map