@assistant-ui/react 0.5.38 → 0.5.39

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.mts CHANGED
@@ -118,7 +118,7 @@ type LocalRuntimeOptions = {
118
118
  declare class LocalThreadRuntime implements ThreadRuntime {
119
119
  private configProvider;
120
120
  adapter: ChatModelAdapter;
121
- private options?;
121
+ options: LocalRuntimeOptions;
122
122
  private _subscriptions;
123
123
  private abortController;
124
124
  private readonly repository;
@@ -135,7 +135,7 @@ declare class LocalThreadRuntime implements ThreadRuntime {
135
135
  text: string;
136
136
  setText: (value: string) => void;
137
137
  };
138
- constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options?: LocalRuntimeOptions | undefined);
138
+ constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options: LocalRuntimeOptions);
139
139
  getBranches(messageId: string): string[];
140
140
  switchToBranch(branchId: string): void;
141
141
  append(message: AppendMessage): Promise<void>;
@@ -151,8 +151,9 @@ declare class LocalThreadRuntime implements ThreadRuntime {
151
151
 
152
152
  declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
153
153
  private readonly _proxyConfigProvider;
154
- constructor(adapter: ChatModelAdapter, options?: LocalRuntimeOptions);
154
+ constructor(adapter: ChatModelAdapter, options: LocalRuntimeOptions);
155
155
  set adapter(adapter: ChatModelAdapter);
156
+ set options(options: LocalRuntimeOptions);
156
157
  registerModelConfigProvider(provider: ModelConfigProvider): () => void;
157
158
  switchToThread(threadId: string | null): LocalThreadRuntime;
158
159
  reset({ initialMessages, }?: {
package/dist/index.d.ts CHANGED
@@ -118,7 +118,7 @@ type LocalRuntimeOptions = {
118
118
  declare class LocalThreadRuntime implements ThreadRuntime {
119
119
  private configProvider;
120
120
  adapter: ChatModelAdapter;
121
- private options?;
121
+ options: LocalRuntimeOptions;
122
122
  private _subscriptions;
123
123
  private abortController;
124
124
  private readonly repository;
@@ -135,7 +135,7 @@ declare class LocalThreadRuntime implements ThreadRuntime {
135
135
  text: string;
136
136
  setText: (value: string) => void;
137
137
  };
138
- constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options?: LocalRuntimeOptions | undefined);
138
+ constructor(configProvider: ModelConfigProvider, adapter: ChatModelAdapter, options: LocalRuntimeOptions);
139
139
  getBranches(messageId: string): string[];
140
140
  switchToBranch(branchId: string): void;
141
141
  append(message: AppendMessage): Promise<void>;
@@ -151,8 +151,9 @@ declare class LocalThreadRuntime implements ThreadRuntime {
151
151
 
152
152
  declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
153
153
  private readonly _proxyConfigProvider;
154
- constructor(adapter: ChatModelAdapter, options?: LocalRuntimeOptions);
154
+ constructor(adapter: ChatModelAdapter, options: LocalRuntimeOptions);
155
155
  set adapter(adapter: ChatModelAdapter);
156
+ set options(options: LocalRuntimeOptions);
156
157
  registerModelConfigProvider(provider: ModelConfigProvider): () => void;
157
158
  switchToThread(threadId: string | null): LocalThreadRuntime;
158
159
  reset({ initialMessages, }?: {
package/dist/index.js CHANGED
@@ -1078,7 +1078,7 @@ var LocalThreadRuntime = (_class5 = class {
1078
1078
  this.configProvider = configProvider;
1079
1079
  this.adapter = adapter;
1080
1080
  this.options = options;
1081
- if (_optionalChain([options, 'optionalAccess', _35 => _35.initialMessages])) {
1081
+ if (options.initialMessages) {
1082
1082
  let parentId = null;
1083
1083
  const messages = fromCoreMessages(options.initialMessages);
1084
1084
  for (const message of messages) {
@@ -1140,18 +1140,18 @@ var LocalThreadRuntime = (_class5 = class {
1140
1140
  }
1141
1141
  async performRoundtrip(parentId, message) {
1142
1142
  const messages = this.repository.getMessages();
1143
- _optionalChain([this, 'access', _36 => _36.abortController, 'optionalAccess', _37 => _37.abort, 'call', _38 => _38()]);
1143
+ _optionalChain([this, 'access', _35 => _35.abortController, 'optionalAccess', _36 => _36.abort, 'call', _37 => _37()]);
1144
1144
  this.abortController = new AbortController();
1145
1145
  const initialContent = message.content;
1146
- const initialRoundtrips = _optionalChain([message, 'access', _39 => _39.metadata, 'optionalAccess', _40 => _40.roundtrips]);
1147
- const initalCustom = _optionalChain([message, 'access', _41 => _41.metadata, 'optionalAccess', _42 => _42.custom]);
1146
+ const initialRoundtrips = _optionalChain([message, 'access', _38 => _38.metadata, 'optionalAccess', _39 => _39.roundtrips]);
1147
+ const initalCustom = _optionalChain([message, 'access', _40 => _40.metadata, 'optionalAccess', _41 => _41.custom]);
1148
1148
  const updateMessage = (m) => {
1149
1149
  message = {
1150
1150
  ...message,
1151
1151
  ...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
1152
1152
  status: _nullishCoalesce(m.status, () => ( message.status)),
1153
1153
  // TODO deprecated, remove in v0.6
1154
- ..._optionalChain([m, 'access', _43 => _43.metadata, 'optionalAccess', _44 => _44.roundtrips]) ? {
1154
+ ..._optionalChain([m, 'access', _42 => _42.metadata, 'optionalAccess', _43 => _43.roundtrips]) ? {
1155
1155
  roundtrips: [
1156
1156
  ..._nullishCoalesce(initialRoundtrips, () => ( [])),
1157
1157
  ...m.metadata.roundtrips
@@ -1166,7 +1166,7 @@ var LocalThreadRuntime = (_class5 = class {
1166
1166
  ...m.metadata.roundtrips
1167
1167
  ]
1168
1168
  } : void 0,
1169
- ..._optionalChain([m, 'access', _45 => _45.metadata, 'optionalAccess', _46 => _46.custom]) ? {
1169
+ ..._optionalChain([m, 'access', _44 => _44.metadata, 'optionalAccess', _45 => _45.custom]) ? {
1170
1170
  custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
1171
1171
  } : void 0
1172
1172
  }
@@ -1175,8 +1175,8 @@ var LocalThreadRuntime = (_class5 = class {
1175
1175
  this.repository.addOrUpdateMessage(parentId, message);
1176
1176
  this.notifySubscribers();
1177
1177
  };
1178
- const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access', _47 => _47.options, 'optionalAccess', _48 => _48.maxToolRoundtrips]), () => ( 1));
1179
- const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _49 => _49.metadata, 'optionalAccess', _50 => _50.roundtrips, 'optionalAccess', _51 => _51.length]), () => ( 0));
1178
+ const maxToolRoundtrips = _nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1));
1179
+ const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _46 => _46.metadata, 'optionalAccess', _47 => _47.roundtrips, 'optionalAccess', _48 => _48.length]), () => ( 0));
1180
1180
  if (toolRoundtrips > maxToolRoundtrips) {
1181
1181
  updateMessage({
1182
1182
  status: {
@@ -1286,6 +1286,9 @@ var LocalRuntime = class extends BaseAssistantRuntime {
1286
1286
  set adapter(adapter) {
1287
1287
  this.thread.adapter = adapter;
1288
1288
  }
1289
+ set options(options) {
1290
+ this.thread.options = options;
1291
+ }
1289
1292
  registerModelConfigProvider(provider) {
1290
1293
  return this._proxyConfigProvider.registerModelConfigProvider(provider);
1291
1294
  }
@@ -1293,9 +1296,11 @@ var LocalRuntime = class extends BaseAssistantRuntime {
1293
1296
  if (threadId) {
1294
1297
  throw new Error("LocalRuntime does not yet support switching threads");
1295
1298
  }
1299
+ const { initialMessages, ...options } = this.thread.options;
1296
1300
  return this.thread = new LocalThreadRuntime(
1297
1301
  this._proxyConfigProvider,
1298
- this.thread.adapter
1302
+ this.thread.adapter,
1303
+ options
1299
1304
  );
1300
1305
  }
1301
1306
  reset({
@@ -1306,7 +1311,7 @@ var LocalRuntime = class extends BaseAssistantRuntime {
1306
1311
  const messages = fromCoreMessages(initialMessages);
1307
1312
  this.thread.import({
1308
1313
  messages: messages.map((m, idx) => ({
1309
- parentId: _nullishCoalesce(_optionalChain([messages, 'access', _52 => _52[idx - 1], 'optionalAccess', _53 => _53.id]), () => ( null)),
1314
+ parentId: _nullishCoalesce(_optionalChain([messages, 'access', _49 => _49[idx - 1], 'optionalAccess', _50 => _50.id]), () => ( null)),
1310
1315
  message: m
1311
1316
  }))
1312
1317
  });
@@ -1314,10 +1319,11 @@ var LocalRuntime = class extends BaseAssistantRuntime {
1314
1319
  };
1315
1320
 
1316
1321
  // src/runtimes/local/useLocalRuntime.tsx
1317
- var useLocalRuntime = (adapter, options) => {
1322
+ var useLocalRuntime = (adapter, options = {}) => {
1318
1323
  const [runtime] = _react.useState.call(void 0, () => new LocalRuntime(adapter, options));
1319
1324
  _react.useInsertionEffect.call(void 0, () => {
1320
1325
  runtime.adapter = adapter;
1326
+ runtime.options = options;
1321
1327
  });
1322
1328
  return runtime;
1323
1329
  };
@@ -1428,7 +1434,7 @@ var getThreadMessageText = (message) => {
1428
1434
 
1429
1435
  // src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
1430
1436
  var hasUpcomingMessage = (isRunning, messages) => {
1431
- return isRunning && _optionalChain([messages, 'access', _54 => _54[messages.length - 1], 'optionalAccess', _55 => _55.role]) !== "assistant";
1437
+ return isRunning && _optionalChain([messages, 'access', _51 => _51[messages.length - 1], 'optionalAccess', _52 => _52.role]) !== "assistant";
1432
1438
  };
1433
1439
  var ExternalStoreThreadRuntime = (_class7 = class {
1434
1440
  __init18() {this._subscriptions = /* @__PURE__ */ new Set()}
@@ -1496,7 +1502,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1496
1502
  for (let i = 0; i < messages.length; i++) {
1497
1503
  const message = messages[i];
1498
1504
  const parent = messages[i - 1];
1499
- this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _59 => _59.id]), () => ( null)), message);
1505
+ this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _56 => _56.id]), () => ( null)), message);
1500
1506
  }
1501
1507
  if (this.assistantOptimisticId) {
1502
1508
  this.repository.deleteMessage(this.assistantOptimisticId);
@@ -1504,7 +1510,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1504
1510
  }
1505
1511
  if (hasUpcomingMessage(isRunning, messages)) {
1506
1512
  this.assistantOptimisticId = this.repository.appendOptimisticMessage(
1507
- _nullishCoalesce(_optionalChain([messages, 'access', _60 => _60.at, 'call', _61 => _61(-1), 'optionalAccess', _62 => _62.id]), () => ( null)),
1513
+ _nullishCoalesce(_optionalChain([messages, 'access', _57 => _57.at, 'call', _58 => _58(-1), 'optionalAccess', _59 => _59.id]), () => ( null)),
1508
1514
  {
1509
1515
  role: "assistant",
1510
1516
  content: []
@@ -1512,7 +1518,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1512
1518
  );
1513
1519
  }
1514
1520
  this.repository.resetHead(
1515
- _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _63 => _63.at, 'call', _64 => _64(-1), 'optionalAccess', _65 => _65.id]))), () => ( null))
1521
+ _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _60 => _60.at, 'call', _61 => _61(-1), 'optionalAccess', _62 => _62.id]))), () => ( null))
1516
1522
  );
1517
1523
  this.messages = this.repository.getMessages();
1518
1524
  this.notifySubscribers();
@@ -1530,7 +1536,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1530
1536
  this.updateMessages(this.repository.getMessages());
1531
1537
  }
1532
1538
  async append(message) {
1533
- if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _66 => _66.messages, 'access', _67 => _67.at, 'call', _68 => _68(-1), 'optionalAccess', _69 => _69.id]), () => ( null)))) {
1539
+ if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _63 => _63.messages, 'access', _64 => _64.at, 'call', _65 => _65(-1), 'optionalAccess', _66 => _66.id]), () => ( null)))) {
1534
1540
  if (!this._store.onEdit)
1535
1541
  throw new Error("Runtime does not support editing messages.");
1536
1542
  await this._store.onEdit(message);
@@ -1553,7 +1559,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1553
1559
  }
1554
1560
  let messages = this.repository.getMessages();
1555
1561
  const previousMessage = messages[messages.length - 1];
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])) {
1562
+ if (_optionalChain([previousMessage, 'optionalAccess', _67 => _67.role]) === "user" && previousMessage.id === _optionalChain([messages, 'access', _68 => _68.at, 'call', _69 => _69(-1), 'optionalAccess', _70 => _70.id])) {
1557
1563
  this.repository.deleteMessage(previousMessage.id);
1558
1564
  if (!this.composer.text.trim()) {
1559
1565
  this.composer.setText(getThreadMessageText(previousMessage));
@@ -1571,7 +1577,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
1571
1577
  return () => this._subscriptions.delete(callback);
1572
1578
  }
1573
1579
  __init26() {this.updateMessages = (messages) => {
1574
- _optionalChain([this, 'access', _74 => _74._store, 'access', _75 => _75.setMessages, 'optionalCall', _76 => _76(
1580
+ _optionalChain([this, 'access', _71 => _71._store, 'access', _72 => _72.setMessages, 'optionalCall', _73 => _73(
1575
1581
  messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
1576
1582
  )]);
1577
1583
  }}
@@ -1787,7 +1793,7 @@ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProvider
1787
1793
  var MessageContext = _react.createContext.call(void 0, null);
1788
1794
  function useMessageContext(options) {
1789
1795
  const context = _react.useContext.call(void 0, MessageContext);
1790
- if (!_optionalChain([options, 'optionalAccess', _77 => _77.optional]) && !context)
1796
+ if (!_optionalChain([options, 'optionalAccess', _74 => _74.optional]) && !context)
1791
1797
  throw new Error(
1792
1798
  "This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
1793
1799
  );
@@ -1814,7 +1820,7 @@ var ContentPartContext = _react.createContext.call(void 0,
1814
1820
  );
1815
1821
  function useContentPartContext(options) {
1816
1822
  const context = _react.useContext.call(void 0, ContentPartContext);
1817
- if (!_optionalChain([options, 'optionalAccess', _78 => _78.optional]) && !context)
1823
+ if (!_optionalChain([options, 'optionalAccess', _75 => _75.optional]) && !context)
1818
1824
  throw new Error(
1819
1825
  "This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
1820
1826
  );
@@ -1826,13 +1832,13 @@ function useContentPartContext(options) {
1826
1832
  var toAppendMessage = (useThreadMessages, message) => {
1827
1833
  if (typeof message === "string") {
1828
1834
  return {
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)),
1835
+ parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _76 => _76.getState, 'call', _77 => _77(), 'access', _78 => _78.at, 'call', _79 => _79(-1), 'optionalAccess', _80 => _80.id]), () => ( null)),
1830
1836
  role: "user",
1831
1837
  content: [{ type: "text", text: message }]
1832
1838
  };
1833
1839
  }
1834
1840
  return {
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)),
1841
+ parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _81 => _81.getState, 'call', _82 => _82(), 'access', _83 => _83.at, 'call', _84 => _84(-1), 'optionalAccess', _85 => _85.id]))), () => ( null)),
1836
1842
  role: _nullishCoalesce(message.role, () => ( "user")),
1837
1843
  content: message.content
1838
1844
  };
@@ -1884,7 +1890,7 @@ var useAssistantTool = (tool) => {
1884
1890
  const unsub2 = render ? setToolUI(toolName, render) : void 0;
1885
1891
  return () => {
1886
1892
  unsub1();
1887
- _optionalChain([unsub2, 'optionalCall', _89 => _89()]);
1893
+ _optionalChain([unsub2, 'optionalCall', _86 => _86()]);
1888
1894
  };
1889
1895
  }, [registerModelConfigProvider, setToolUI, tool]);
1890
1896
  };
@@ -2313,7 +2319,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
2313
2319
  ...primitiveProps,
2314
2320
  ref: forwardedRef,
2315
2321
  onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
2316
- _optionalChain([callback, 'optionalCall', _90 => _90()]);
2322
+ _optionalChain([callback, 'optionalCall', _87 => _87()]);
2317
2323
  })
2318
2324
  }
2319
2325
  );
@@ -2621,7 +2627,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
2621
2627
  }
2622
2628
  }
2623
2629
  const status = toContentPartStatus(message, partIndex, part);
2624
- const currentState = _optionalChain([useContentPart, 'optionalAccess', _91 => _91.getState, 'call', _92 => _92()]);
2630
+ const currentState = _optionalChain([useContentPart, 'optionalAccess', _88 => _88.getState, 'call', _89 => _89()]);
2625
2631
  if (currentState && currentState.part === part && currentState.status === status)
2626
2632
  return null;
2627
2633
  return Object.freeze({ part, status });
@@ -2769,7 +2775,7 @@ var MessageContentPartImpl = ({
2769
2775
  };
2770
2776
  var MessageContentPart = _react.memo.call(void 0,
2771
2777
  MessageContentPartImpl,
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])
2778
+ (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _90 => _90.components, 'optionalAccess', _91 => _91.Text]) === _optionalChain([next, 'access', _92 => _92.components, 'optionalAccess', _93 => _93.Text]) && _optionalChain([prev, 'access', _94 => _94.components, 'optionalAccess', _95 => _95.Image]) === _optionalChain([next, 'access', _96 => _96.components, 'optionalAccess', _97 => _97.Image]) && _optionalChain([prev, 'access', _98 => _98.components, 'optionalAccess', _99 => _99.UI]) === _optionalChain([next, 'access', _100 => _100.components, 'optionalAccess', _101 => _101.UI]) && _optionalChain([prev, 'access', _102 => _102.components, 'optionalAccess', _103 => _103.tools]) === _optionalChain([next, 'access', _104 => _104.components, 'optionalAccess', _105 => _105.tools])
2773
2779
  );
2774
2780
  var MessagePrimitiveContent = ({
2775
2781
  components
@@ -2884,7 +2890,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
2884
2890
  const { isRunning } = useThread.getState();
2885
2891
  if (!isRunning) {
2886
2892
  e.preventDefault();
2887
- _optionalChain([textareaRef, 'access', _109 => _109.current, 'optionalAccess', _110 => _110.closest, 'call', _111 => _111("form"), 'optionalAccess', _112 => _112.requestSubmit, 'call', _113 => _113()]);
2893
+ _optionalChain([textareaRef, 'access', _106 => _106.current, 'optionalAccess', _107 => _107.closest, 'call', _108 => _108("form"), 'optionalAccess', _109 => _109.requestSubmit, 'call', _110 => _110()]);
2888
2894
  }
2889
2895
  }
2890
2896
  };
@@ -3187,15 +3193,15 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => ({
3187
3193
  // src/context/providers/MessageProvider.tsx
3188
3194
 
3189
3195
  var getIsLast = (messages, message) => {
3190
- return _optionalChain([messages, 'access', _114 => _114[messages.length - 1], 'optionalAccess', _115 => _115.id]) === message.id;
3196
+ return _optionalChain([messages, 'access', _111 => _111[messages.length - 1], 'optionalAccess', _112 => _112.id]) === message.id;
3191
3197
  };
3192
3198
  var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
3193
- const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _116 => _116[messageIndex - 1], 'optionalAccess', _117 => _117.id]), () => ( null));
3199
+ const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _113 => _113[messageIndex - 1], 'optionalAccess', _114 => _114.id]), () => ( null));
3194
3200
  const message = messages[messageIndex];
3195
3201
  if (!message) return null;
3196
3202
  const isLast = getIsLast(messages, message);
3197
3203
  const branches = getBranches(message.id);
3198
- const currentState = _optionalChain([useMessage, 'optionalAccess', _118 => _118.getState, 'call', _119 => _119()]);
3204
+ const currentState = _optionalChain([useMessage, 'optionalAccess', _115 => _115.getState, 'call', _116 => _116()]);
3199
3205
  if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
3200
3206
  return null;
3201
3207
  return Object.freeze({
@@ -3322,7 +3328,7 @@ var ThreadPrimitiveMessagesImpl = ({
3322
3328
  ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
3323
3329
  var ThreadPrimitiveMessages = _react.memo.call(void 0,
3324
3330
  ThreadPrimitiveMessagesImpl,
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])
3331
+ (prev, next) => _optionalChain([prev, 'access', _117 => _117.components, 'optionalAccess', _118 => _118.Message]) === _optionalChain([next, 'access', _119 => _119.components, 'optionalAccess', _120 => _120.Message]) && _optionalChain([prev, 'access', _121 => _121.components, 'optionalAccess', _122 => _122.UserMessage]) === _optionalChain([next, 'access', _123 => _123.components, 'optionalAccess', _124 => _124.UserMessage]) && _optionalChain([prev, 'access', _125 => _125.components, 'optionalAccess', _126 => _126.EditComposer]) === _optionalChain([next, 'access', _127 => _127.components, 'optionalAccess', _128 => _128.EditComposer]) && _optionalChain([prev, 'access', _129 => _129.components, 'optionalAccess', _130 => _130.AssistantMessage]) === _optionalChain([next, 'access', _131 => _131.components, 'optionalAccess', _132 => _132.AssistantMessage]) && _optionalChain([prev, 'access', _133 => _133.components, 'optionalAccess', _134 => _134.SystemMessage]) === _optionalChain([next, 'access', _135 => _135.components, 'optionalAccess', _136 => _136.SystemMessage])
3326
3332
  );
3327
3333
 
3328
3334
  // src/primitives/thread/ThreadScrollToBottom.tsx
@@ -3354,7 +3360,7 @@ var ThreadConfigProvider = ({
3354
3360
  }) => {
3355
3361
  const assistant = useAssistantContext({ optional: true });
3356
3362
  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 });
3357
- if (!_optionalChain([config, 'optionalAccess', _140 => _140.runtime])) return configProvider;
3363
+ if (!_optionalChain([config, 'optionalAccess', _137 => _137.runtime])) return configProvider;
3358
3364
  if (assistant) {
3359
3365
  throw new Error(
3360
3366
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
@@ -3570,7 +3576,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
3570
3576
  {
3571
3577
  components: {
3572
3578
  ...componentsProp,
3573
- Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _141 => _141.Text]), () => ( components.Text)), () => ( content_part_default.Text))
3579
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _138 => _138.Text]), () => ( components.Text)), () => ( content_part_default.Text))
3574
3580
  }
3575
3581
  }
3576
3582
  ) });
@@ -3747,7 +3753,7 @@ var ThreadWelcomeSuggestion = ({
3747
3753
  };
3748
3754
  var ThreadWelcomeSuggestions = () => {
3749
3755
  const { welcome: { suggestions } = {} } = useThreadConfig();
3750
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _142 => _142.map, 'call', _143 => _143((suggestion, idx) => {
3756
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _139 => _139.map, 'call', _140 => _140((suggestion, idx) => {
3751
3757
  const key = `${suggestion.prompt}-${idx}`;
3752
3758
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
3753
3759
  })]) });
@@ -3825,7 +3831,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
3825
3831
  {
3826
3832
  components: {
3827
3833
  ...components,
3828
- Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _144 => _144.Text]), () => ( content_part_default.Text))
3834
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _141 => _141.Text]), () => ( content_part_default.Text))
3829
3835
  }
3830
3836
  }
3831
3837
  ) });
@@ -3927,10 +3933,10 @@ var ThreadMessages = ({ components, ...rest }) => {
3927
3933
  thread_exports.Messages,
3928
3934
  {
3929
3935
  components: {
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))
3936
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _142 => _142.UserMessage]), () => ( user_message_default)),
3937
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _143 => _143.EditComposer]), () => ( edit_composer_default)),
3938
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _144 => _144.AssistantMessage]), () => ( assistant_message_default)),
3939
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _145 => _145.SystemMessage]), () => ( SystemMessage))
3934
3940
  },
3935
3941
  ...rest
3936
3942
  }