@assistant-ui/react 0.5.69 → 0.5.71

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -289,7 +289,7 @@ var { useContentPart, useContentPartStore } = createContextStoreHook(
289
289
  );
290
290
 
291
291
  // src/api/ContentPartRuntime.ts
292
- var ContentPartRuntime = class {
292
+ var ContentPartRuntimeImpl = class {
293
293
  constructor(contentBinding, messageApi, threadApi) {
294
294
  this.contentBinding = contentBinding;
295
295
  this.messageApi = messageApi;
@@ -331,7 +331,7 @@ var TextContentPartProvider = ({ children, text, isRunning }) => {
331
331
  const [context] = useState3(() => {
332
332
  const useContentPartRuntime2 = create5(
333
333
  // TODO
334
- () => new ContentPartRuntime(null, null, null)
334
+ () => new ContentPartRuntimeImpl(null, null, null)
335
335
  );
336
336
  const useContentPart2 = create5(() => ({
337
337
  status: isRunning ? RUNNING_STATUS : COMPLETE_STATUS,
@@ -344,13 +344,14 @@ var TextContentPartProvider = ({ children, text, isRunning }) => {
344
344
  useEffect3(() => {
345
345
  const state = context.useContentPart.getState();
346
346
  const textUpdated = state.text !== text;
347
- const targetTextPart = textUpdated ? { type: "text", text } : state;
348
347
  const targetStatus = isRunning ? RUNNING_STATUS : COMPLETE_STATUS;
349
348
  const statusUpdated = state.status !== targetStatus;
350
349
  if (!textUpdated && !statusUpdated) return;
351
350
  writableStore(context.useContentPart).setState(
352
351
  {
353
- part: targetTextPart,
352
+ type: "text",
353
+ text,
354
+ part: { type: "text", text },
354
355
  status: targetStatus
355
356
  },
356
357
  true
@@ -1585,7 +1586,7 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
1585
1586
  ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
1586
1587
 
1587
1588
  // src/api/AttachmentRuntime.ts
1588
- var AttachmentRuntime = class {
1589
+ var AttachmentRuntimeImpl = class {
1589
1590
  constructor(_core) {
1590
1591
  this._core = _core;
1591
1592
  }
@@ -1596,7 +1597,7 @@ var AttachmentRuntime = class {
1596
1597
  return this._core.subscribe(callback);
1597
1598
  }
1598
1599
  };
1599
- var ComposerAttachmentRuntime = class extends AttachmentRuntime {
1600
+ var ComposerAttachmentRuntime = class extends AttachmentRuntimeImpl {
1600
1601
  constructor(core, _composerApi) {
1601
1602
  super(core);
1602
1603
  this._composerApi = _composerApi;
@@ -1607,17 +1608,17 @@ var ComposerAttachmentRuntime = class extends AttachmentRuntime {
1607
1608
  return core.removeAttachment(this.getState().id);
1608
1609
  }
1609
1610
  };
1610
- var ThreadComposerAttachmentRuntime = class extends ComposerAttachmentRuntime {
1611
+ var ThreadComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
1611
1612
  get source() {
1612
1613
  return "thread-composer";
1613
1614
  }
1614
1615
  };
1615
- var EditComposerAttachmentRuntime = class extends ComposerAttachmentRuntime {
1616
+ var EditComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
1616
1617
  get source() {
1617
1618
  return "edit-composer";
1618
1619
  }
1619
1620
  };
1620
- var MessageAttachmentRuntime = class extends AttachmentRuntime {
1621
+ var MessageAttachmentRuntimeImpl = class extends AttachmentRuntimeImpl {
1621
1622
  get source() {
1622
1623
  return "message";
1623
1624
  }
@@ -1779,7 +1780,7 @@ var getEditComposerState = (runtime, beginEdit) => {
1779
1780
  cancel: runtime?.cancel.bind(runtime) ?? METHOD_NOT_SUPPORTED
1780
1781
  });
1781
1782
  };
1782
- var ComposerRuntime = class {
1783
+ var ComposerRuntimeImpl = class {
1783
1784
  constructor(_core) {
1784
1785
  this._core = _core;
1785
1786
  }
@@ -1838,9 +1839,9 @@ var ComposerRuntime = class {
1838
1839
  if (!core) throw new Error("Composer is not available");
1839
1840
  return core.addAttachment(file);
1840
1841
  }
1841
- // /**
1842
- // * @deprecated Use `getAttachmentById(id).removeAttachment` instead. This will be removed in 0.6.0.
1843
- // */
1842
+ /**
1843
+ * @deprecated Use `getAttachmentById(id).removeAttachment()` instead. This will be removed in 0.6.0.
1844
+ */
1844
1845
  removeAttachment(attachmentId) {
1845
1846
  const core = this._core.getState();
1846
1847
  if (!core) throw new Error("Composer is not available");
@@ -1868,7 +1869,7 @@ var ComposerRuntime = class {
1868
1869
  return this._core.subscribe(callback);
1869
1870
  }
1870
1871
  };
1871
- var ThreadComposerRuntime = class extends ComposerRuntime {
1872
+ var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
1872
1873
  get type() {
1873
1874
  return "thread";
1874
1875
  }
@@ -1896,15 +1897,21 @@ var ThreadComposerRuntime = class extends ComposerRuntime {
1896
1897
  }
1897
1898
  // TODO replace with events
1898
1899
  _focusListeners = /* @__PURE__ */ new Set();
1900
+ /**
1901
+ * @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
1902
+ */
1899
1903
  focus() {
1900
1904
  this._focusListeners.forEach((callback) => callback());
1901
1905
  }
1906
+ /**
1907
+ * @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
1908
+ */
1902
1909
  onFocus(callback) {
1903
1910
  this._focusListeners.add(callback);
1904
1911
  return () => this._focusListeners.delete(callback);
1905
1912
  }
1906
- unstable_getAttachmentByIndex(idx) {
1907
- return new ThreadComposerAttachmentRuntime(
1913
+ getAttachmentByIndex(idx) {
1914
+ return new ThreadComposerAttachmentRuntimeImpl(
1908
1915
  new ShallowMemoizeSubject({
1909
1916
  getState: () => {
1910
1917
  const attachments = this.getState().attachments;
@@ -1922,7 +1929,7 @@ var ThreadComposerRuntime = class extends ComposerRuntime {
1922
1929
  );
1923
1930
  }
1924
1931
  };
1925
- var EditComposerRuntime = class extends ComposerRuntime {
1932
+ var EditComposerRuntimeImpl = class extends ComposerRuntimeImpl {
1926
1933
  constructor(core, _beginEdit) {
1927
1934
  const stateBinding = new LazyMemoizeSubject({
1928
1935
  getState: () => getEditComposerState(core.getState(), this._beginEdit),
@@ -1951,8 +1958,8 @@ var EditComposerRuntime = class extends ComposerRuntime {
1951
1958
  edit() {
1952
1959
  this.beginEdit();
1953
1960
  }
1954
- unstable_getAttachmentByIndex(idx) {
1955
- return new EditComposerAttachmentRuntime(
1961
+ getAttachmentByIndex(idx) {
1962
+ return new EditComposerAttachmentRuntimeImpl(
1956
1963
  new ShallowMemoizeSubject({
1957
1964
  getState: () => {
1958
1965
  const attachments = this.getState().attachments;
@@ -2036,12 +2043,12 @@ var getContentPartState = (message, partIndex) => {
2036
2043
  const status = toContentPartStatus(message, partIndex, part);
2037
2044
  return Object.freeze({ ...part, part, status });
2038
2045
  };
2039
- var MessageRuntime = class {
2046
+ var MessageRuntimeImpl = class {
2040
2047
  constructor(_core, _threadBinding) {
2041
2048
  this._core = _core;
2042
2049
  this._threadBinding = _threadBinding;
2043
2050
  }
2044
- composer = new EditComposerRuntime(
2051
+ composer = new EditComposerRuntimeImpl(
2045
2052
  new NestedSubscriptionSubject({
2046
2053
  getState: () => this._threadBinding.getState().getEditComposer(this._core.getState().id),
2047
2054
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -2051,15 +2058,6 @@ var MessageRuntime = class {
2051
2058
  getState() {
2052
2059
  return this._core.getState();
2053
2060
  }
2054
- // TODO improve type
2055
- unstable_edit(message) {
2056
- const state = this._core.getState();
2057
- if (!state) throw new Error("Message is not available");
2058
- this._threadBinding.getState().append({
2059
- ...message,
2060
- parentId: state.parentId
2061
- });
2062
- }
2063
2061
  reload() {
2064
2062
  const state = this._core.getState();
2065
2063
  if (!state) throw new Error("Message is not available");
@@ -2105,9 +2103,9 @@ var MessageRuntime = class {
2105
2103
  subscribe(callback) {
2106
2104
  return this._core.subscribe(callback);
2107
2105
  }
2108
- unstable_getContentPartByIndex(idx) {
2106
+ getContentPartByIndex(idx) {
2109
2107
  if (idx < 0) throw new Error("Message index must be >= 0");
2110
- return new ContentPartRuntime(
2108
+ return new ContentPartRuntimeImpl(
2111
2109
  new ShallowMemoizeSubject({
2112
2110
  getState: () => {
2113
2111
  return getContentPartState(this.getState(), idx);
@@ -2118,8 +2116,8 @@ var MessageRuntime = class {
2118
2116
  this._threadBinding
2119
2117
  );
2120
2118
  }
2121
- unstable_getAttachmentByIndex(idx) {
2122
- return new MessageAttachmentRuntime(
2119
+ getAttachmentByIndex(idx) {
2120
+ return new MessageAttachmentRuntimeImpl(
2123
2121
  new ShallowMemoizeSubject({
2124
2122
  getState: () => {
2125
2123
  const attachments = this.getState().attachments;
@@ -2205,7 +2203,7 @@ var MessageContentPartImpl = ({
2205
2203
  }) => {
2206
2204
  const messageRuntime = useMessageRuntime();
2207
2205
  const runtime = useMemo6(
2208
- () => messageRuntime.unstable_getContentPartByIndex(partIndex),
2206
+ () => messageRuntime.getContentPartByIndex(partIndex),
2209
2207
  [messageRuntime, partIndex]
2210
2208
  );
2211
2209
  return /* @__PURE__ */ jsx21(ContentPartRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx21(MessageContentPartComponent, { components }) });
@@ -2354,7 +2352,7 @@ var AttachmentComponent = ({ components }) => {
2354
2352
  var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
2355
2353
  const messageRuntime = useMessageRuntime();
2356
2354
  const runtime = useMemo8(
2357
- () => messageRuntime.unstable_getAttachmentByIndex(attachmentIndex),
2355
+ () => messageRuntime.getAttachmentByIndex(attachmentIndex),
2358
2356
  [messageRuntime, attachmentIndex]
2359
2357
  );
2360
2358
  return /* @__PURE__ */ jsx23(AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx23(AttachmentComponent, { components }) });
@@ -2557,7 +2555,7 @@ var AttachmentComponent2 = ({ components }) => {
2557
2555
  var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
2558
2556
  const composerRuntime = useComposerRuntime();
2559
2557
  const runtime = useMemo9(
2560
- () => composerRuntime.unstable_getAttachmentByIndex(attachmentIndex),
2558
+ () => composerRuntime.getAttachmentByIndex(attachmentIndex),
2561
2559
  [composerRuntime, attachmentIndex]
2562
2560
  );
2563
2561
  return /* @__PURE__ */ jsx27(AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx27(AttachmentComponent2, { components }) });
@@ -2891,7 +2889,7 @@ var ThreadMessageImpl = ({
2891
2889
  }) => {
2892
2890
  const threadRuntime = useThreadRuntime();
2893
2891
  const runtime = useMemo10(
2894
- () => threadRuntime.unstable_getMesssageByIndex(messageIndex),
2892
+ () => threadRuntime.getMesssageByIndex(messageIndex),
2895
2893
  [threadRuntime, messageIndex]
2896
2894
  );
2897
2895
  return /* @__PURE__ */ jsx31(MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx31(ThreadMessageComponent, { components }) });
@@ -2975,12 +2973,12 @@ var BaseAssistantRuntimeCore = class {
2975
2973
  // src/internal.ts
2976
2974
  var internal_exports = {};
2977
2975
  __export(internal_exports, {
2978
- AssistantRuntime: () => AssistantRuntime,
2976
+ AssistantRuntimeImpl: () => AssistantRuntimeImpl,
2979
2977
  BaseAssistantRuntimeCore: () => BaseAssistantRuntimeCore,
2980
2978
  DefaultThreadComposerRuntimeCore: () => DefaultThreadComposerRuntimeCore,
2981
2979
  MessageRepository: () => MessageRepository,
2982
2980
  ProxyConfigProvider: () => ProxyConfigProvider,
2983
- ThreadRuntime: () => ThreadRuntime,
2981
+ ThreadRuntimeImpl: () => ThreadRuntimeImpl,
2984
2982
  TooltipIconButton: () => TooltipIconButton,
2985
2983
  generateId: () => generateId,
2986
2984
  useSmooth: () => useSmooth,
@@ -3468,7 +3466,7 @@ var TooltipIconButton = forwardRef21(({ children, tooltip, side = "bottom", ...r
3468
3466
  TooltipIconButton.displayName = "TooltipIconButton";
3469
3467
 
3470
3468
  // src/api/AssistantRuntime.ts
3471
- var AssistantRuntime = class {
3469
+ var AssistantRuntimeImpl = class {
3472
3470
  constructor(_core, CustomThreadRuntime) {
3473
3471
  this._core = _core;
3474
3472
  this.thread = new CustomThreadRuntime(
@@ -3524,10 +3522,12 @@ var getThreadState = (runtime) => {
3524
3522
  capabilities: runtime.capabilities,
3525
3523
  isDisabled: runtime.isDisabled,
3526
3524
  isRunning: lastMessage?.role !== "assistant" ? false : lastMessage.status.type === "running",
3527
- messages: runtime.messages
3525
+ messages: runtime.messages,
3526
+ suggestions: runtime.suggestions,
3527
+ extras: runtime.extras
3528
3528
  });
3529
3529
  };
3530
- var ThreadRuntime = class {
3530
+ var ThreadRuntimeImpl = class {
3531
3531
  // public path = "assistant.threads[main]"; // TODO
3532
3532
  /**
3533
3533
  * @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
@@ -3553,6 +3553,18 @@ var ThreadRuntime = class {
3553
3553
  get capabilities() {
3554
3554
  return this.getState().capabilities;
3555
3555
  }
3556
+ /**
3557
+ * @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
3558
+ */
3559
+ get extras() {
3560
+ return this._threadBinding.getState().extras;
3561
+ }
3562
+ /**
3563
+ * @deprecated Use `getState().followupSuggestions` instead. This will be removed in 0.6.0.
3564
+ */
3565
+ get suggestions() {
3566
+ return this._threadBinding.getState().suggestions;
3567
+ }
3556
3568
  /**
3557
3569
  * @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
3558
3570
  */
@@ -3574,7 +3586,7 @@ var ThreadRuntime = class {
3574
3586
  subscribe: (callback) => threadBinding.subscribe(callback)
3575
3587
  };
3576
3588
  }
3577
- composer = new ThreadComposerRuntime(
3589
+ composer = new ThreadComposerRuntimeImpl(
3578
3590
  new NestedSubscriptionSubject({
3579
3591
  getState: () => this._threadBinding.getState().composer,
3580
3592
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -3591,9 +3603,9 @@ var ThreadRuntime = class {
3591
3603
  subscribe(callback) {
3592
3604
  return this._threadBinding.subscribe(callback);
3593
3605
  }
3594
- // /**
3595
- // * @derprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
3596
- // */
3606
+ /**
3607
+ * @derprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
3608
+ */
3597
3609
  getBranches(messageId) {
3598
3610
  return this._threadBinding.getState().getBranches(messageId);
3599
3611
  }
@@ -3604,17 +3616,18 @@ var ThreadRuntime = class {
3604
3616
  startRun(parentId) {
3605
3617
  return this._threadBinding.getState().startRun(parentId);
3606
3618
  }
3607
- // TODO
3608
3619
  cancelRun() {
3609
3620
  this._threadBinding.getState().cancelRun();
3610
3621
  }
3611
- // /**
3612
- // * @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
3613
- // */
3622
+ /**
3623
+ * @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
3624
+ */
3614
3625
  addToolResult(options) {
3615
3626
  this._threadBinding.getState().addToolResult(options);
3616
3627
  }
3617
- // TODO
3628
+ /**
3629
+ * @deprecated Use `getMesssageById(id).switchToBranch({ options })` instead. This will be removed in 0.6.0.
3630
+ */
3618
3631
  switchToBranch(branchId) {
3619
3632
  return this._threadBinding.getState().switchToBranch(branchId);
3620
3633
  }
@@ -3631,13 +3644,13 @@ var ThreadRuntime = class {
3631
3644
  return this._threadBinding.getState().submitFeedback(options);
3632
3645
  }
3633
3646
  /**
3634
- * @deprecated Use `getMesssageById(id).unstable_getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
3647
+ * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
3635
3648
  */
3636
3649
  getEditComposer(messageId) {
3637
3650
  return this._threadBinding.getState().getEditComposer(messageId);
3638
3651
  }
3639
3652
  /**
3640
- * @deprecated Use `getMesssageById(id).unstable_getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
3653
+ * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
3641
3654
  */
3642
3655
  beginEdit(messageId) {
3643
3656
  return this._threadBinding.getState().beginEdit(messageId);
@@ -3648,9 +3661,9 @@ var ThreadRuntime = class {
3648
3661
  import(data) {
3649
3662
  this._threadBinding.getState().import(data);
3650
3663
  }
3651
- unstable_getMesssageByIndex(idx) {
3664
+ getMesssageByIndex(idx) {
3652
3665
  if (idx < 0) throw new Error("Message index must be >= 0");
3653
- return new MessageRuntime(
3666
+ return new MessageRuntimeImpl(
3654
3667
  new ShallowMemoizeSubject({
3655
3668
  getState: () => {
3656
3669
  const messages2 = this.getState().messages;
@@ -3953,7 +3966,7 @@ var EdgeChatAdapter = class {
3953
3966
  }),
3954
3967
  signal: abortSignal
3955
3968
  });
3956
- if (result.status !== 200) {
3969
+ if (!result.ok) {
3957
3970
  throw new Error(`Status ${result.status}: ${await result.text()}`);
3958
3971
  }
3959
3972
  const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools, abortSignal)).pipeThrough(runResultStream());
@@ -4052,6 +4065,7 @@ var LocalThreadRuntimeCore = class {
4052
4065
  };
4053
4066
  threadId;
4054
4067
  isDisabled = false;
4068
+ suggestions = [];
4055
4069
  get messages() {
4056
4070
  return this.repository.getMessages();
4057
4071
  }
@@ -4063,6 +4077,9 @@ var LocalThreadRuntimeCore = class {
4063
4077
  get options() {
4064
4078
  return this._options;
4065
4079
  }
4080
+ get extras() {
4081
+ return void 0;
4082
+ }
4066
4083
  set options({ initialMessages, ...options }) {
4067
4084
  this._options = options;
4068
4085
  let hasUpdates = false;
@@ -4343,9 +4360,9 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4343
4360
  };
4344
4361
 
4345
4362
  // src/runtimes/local/useLocalRuntime.tsx
4346
- var LocalRuntime = class extends AssistantRuntime {
4363
+ var LocalRuntime = class extends AssistantRuntimeImpl {
4347
4364
  constructor(core) {
4348
- super(core, ThreadRuntime);
4365
+ super(core, ThreadRuntimeImpl);
4349
4366
  this.core = core;
4350
4367
  }
4351
4368
  reset(options) {
@@ -4467,6 +4484,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
4467
4484
  };
4468
4485
 
4469
4486
  // src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
4487
+ var EMPTY_ARRAY2 = Object.freeze([]);
4470
4488
  var hasUpcomingMessage = (isRunning, messages2) => {
4471
4489
  return isRunning && messages2[messages2.length - 1]?.role !== "assistant";
4472
4490
  };
@@ -4494,7 +4512,9 @@ var ExternalStoreThreadRuntimeCore = class {
4494
4512
  threadId;
4495
4513
  messages;
4496
4514
  isDisabled;
4497
- converter = new ThreadMessageConverter();
4515
+ suggestions = [];
4516
+ extras = void 0;
4517
+ _converter = new ThreadMessageConverter();
4498
4518
  _store;
4499
4519
  composer = new DefaultThreadComposerRuntimeCore(this);
4500
4520
  _editComposers = /* @__PURE__ */ new Map();
@@ -4524,6 +4544,8 @@ var ExternalStoreThreadRuntimeCore = class {
4524
4544
  this.isDisabled = store.isDisabled ?? false;
4525
4545
  const oldStore = this._store;
4526
4546
  this._store = store;
4547
+ this.extras = store.extras;
4548
+ this.suggestions = store.suggestions ?? EMPTY_ARRAY2;
4527
4549
  this._capabilities = {
4528
4550
  switchToBranch: this._store.setMessages !== void 0,
4529
4551
  edit: this._store.onEdit !== void 0,
@@ -4538,13 +4560,13 @@ var ExternalStoreThreadRuntimeCore = class {
4538
4560
  this.composer.setAttachmentAdapter(this._store.adapters?.attachments);
4539
4561
  if (oldStore) {
4540
4562
  if (oldStore.convertMessage !== store.convertMessage) {
4541
- this.converter = new ThreadMessageConverter();
4563
+ this._converter = new ThreadMessageConverter();
4542
4564
  } else if (oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
4543
4565
  this.notifySubscribers();
4544
4566
  return;
4545
4567
  }
4546
4568
  }
4547
- const messages2 = !store.convertMessage ? store.messages : this.converter.convertMessages(store.messages, (cache, m, idx) => {
4569
+ const messages2 = !store.convertMessage ? store.messages : this._converter.convertMessages(store.messages, (cache, m, idx) => {
4548
4570
  if (!store.convertMessage) return m;
4549
4571
  const isLast = idx === store.messages.length - 1;
4550
4572
  const autoStatus = getAutoStatus(isLast, isRunning);
@@ -4719,7 +4741,10 @@ var useExternalStoreRuntime = (store) => {
4719
4741
  useEffect14(() => {
4720
4742
  runtime.thread.store = store;
4721
4743
  });
4722
- return useMemo12(() => new AssistantRuntime(runtime, ThreadRuntime), [runtime]);
4744
+ return useMemo12(
4745
+ () => new AssistantRuntimeImpl(runtime, ThreadRuntimeImpl),
4746
+ [runtime]
4747
+ );
4723
4748
  };
4724
4749
 
4725
4750
  // src/runtimes/external-store/external-message-converter.tsx
@@ -5700,19 +5725,13 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
5700
5725
  var ThreadWelcomeSuggestion = ({
5701
5726
  suggestion: { text, prompt }
5702
5727
  }) => {
5703
- return /* @__PURE__ */ jsx45(
5704
- ThreadWelcomeSuggestionStyled,
5705
- {
5706
- prompt,
5707
- method: "replace",
5708
- autoSend: true,
5709
- children: /* @__PURE__ */ jsx45("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
5710
- }
5711
- );
5728
+ return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestionStyled, { prompt, method: "replace", autoSend: true, children: /* @__PURE__ */ jsx45("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt }) });
5712
5729
  };
5713
5730
  var ThreadWelcomeSuggestions = () => {
5731
+ const suggestions2 = useThread((t) => t.suggestions);
5714
5732
  const { welcome: { suggestions } = {} } = useThreadConfig();
5715
- return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestionContainer, { children: suggestions?.map((suggestion, idx) => {
5733
+ const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
5734
+ return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestionContainer, { children: finalSuggestions?.map((suggestion, idx) => {
5716
5735
  const key = `${suggestion.prompt}-${idx}`;
5717
5736
  return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestion, { suggestion }, key);
5718
5737
  }) });
@@ -5896,14 +5915,16 @@ var exports11 = {
5896
5915
  var edit_composer_default = Object.assign(EditComposer, exports11);
5897
5916
 
5898
5917
  // src/ui/thread.tsx
5899
- import { jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
5918
+ import { Fragment as Fragment6, jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
5900
5919
  var Thread = (config) => {
5920
+ const { components: { Composer: ComposerComponent = composer_default } = {} } = config;
5901
5921
  return /* @__PURE__ */ jsx49(ThreadRoot, { config, children: /* @__PURE__ */ jsxs13(ThreadViewport, { children: [
5902
5922
  /* @__PURE__ */ jsx49(thread_welcome_default, {}),
5903
5923
  /* @__PURE__ */ jsx49(ThreadMessages, {}),
5924
+ /* @__PURE__ */ jsx49(ThreadFollowupSuggestions, {}),
5904
5925
  /* @__PURE__ */ jsxs13(ThreadViewportFooter, { children: [
5905
5926
  /* @__PURE__ */ jsx49(ThreadScrollToBottom, {}),
5906
- /* @__PURE__ */ jsx49(composer_default, {})
5927
+ /* @__PURE__ */ jsx49(ComposerComponent, {})
5907
5928
  ] })
5908
5929
  ] }) });
5909
5930
  };
@@ -5925,21 +5946,38 @@ var ThreadViewportFooter = withDefaults("div", {
5925
5946
  });
5926
5947
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
5927
5948
  var SystemMessage = () => null;
5928
- var ThreadMessages = ({ components, ...rest }) => {
5929
- return /* @__PURE__ */ jsx49(
5930
- thread_exports.Messages,
5931
- {
5932
- components: {
5933
- UserMessage: components?.UserMessage ?? user_message_default,
5934
- EditComposer: components?.EditComposer ?? edit_composer_default,
5935
- AssistantMessage: components?.AssistantMessage ?? assistant_message_default,
5936
- SystemMessage: components?.SystemMessage ?? SystemMessage
5937
- },
5938
- ...rest
5939
- }
5940
- );
5949
+ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
5950
+ return /* @__PURE__ */ jsxs13(Fragment6, { children: [
5951
+ /* @__PURE__ */ jsx49(
5952
+ thread_exports.Messages,
5953
+ {
5954
+ components: {
5955
+ UserMessage: components?.UserMessage ?? user_message_default,
5956
+ EditComposer: components?.EditComposer ?? edit_composer_default,
5957
+ AssistantMessage: components?.AssistantMessage ?? assistant_message_default,
5958
+ SystemMessage: components?.SystemMessage ?? SystemMessage
5959
+ },
5960
+ ...rest
5961
+ }
5962
+ ),
5963
+ flexGrowDiv && /* @__PURE__ */ jsx49(thread_exports.If, { empty: false, children: /* @__PURE__ */ jsx49("div", { style: { flexGrow: 1 } }) })
5964
+ ] });
5941
5965
  };
5942
5966
  ThreadMessages.displayName = "ThreadMessages";
5967
+ var ThreadFollowupSuggestions = () => {
5968
+ const suggestions = useThread((t) => t.suggestions);
5969
+ return /* @__PURE__ */ jsx49(thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ jsx49("div", { className: "aui-thread-followup-suggestions", children: suggestions?.map((suggestion, idx) => /* @__PURE__ */ jsx49(
5970
+ thread_exports.Suggestion,
5971
+ {
5972
+ className: "aui-thread-followup-suggestion",
5973
+ prompt: suggestion.prompt,
5974
+ method: "replace",
5975
+ autoSend: true,
5976
+ children: suggestion.prompt
5977
+ },
5978
+ idx
5979
+ )) }) });
5980
+ };
5943
5981
  var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
5944
5982
  variant: "outline",
5945
5983
  className: "aui-thread-scroll-to-bottom"
@@ -5957,13 +5995,14 @@ var exports12 = {
5957
5995
  Root: ThreadRoot,
5958
5996
  Viewport: ThreadViewport,
5959
5997
  Messages: ThreadMessages,
5998
+ FollowupSuggestions: ThreadFollowupSuggestions,
5960
5999
  ScrollToBottom: ThreadScrollToBottom,
5961
6000
  ViewportFooter: ThreadViewportFooter
5962
6001
  };
5963
6002
  var thread_default = Object.assign(Thread, exports12);
5964
6003
 
5965
6004
  // src/ui/assistant-modal.tsx
5966
- import { Fragment as Fragment6, jsx as jsx50, jsxs as jsxs14 } from "react/jsx-runtime";
6005
+ import { Fragment as Fragment7, jsx as jsx50, jsxs as jsxs14 } from "react/jsx-runtime";
5967
6006
  var AssistantModal = (config) => {
5968
6007
  return /* @__PURE__ */ jsxs14(AssistantModalRoot, { config, children: [
5969
6008
  /* @__PURE__ */ jsx50(AssistantModalTrigger, {}),
@@ -6009,7 +6048,7 @@ var AssistantModalButton = forwardRef32(({ "data-state": state, ...rest }, ref)
6009
6048
  "data-state": state,
6010
6049
  ...rest,
6011
6050
  ref,
6012
- children: rest.children ?? /* @__PURE__ */ jsxs14(Fragment6, { children: [
6051
+ children: rest.children ?? /* @__PURE__ */ jsxs14(Fragment7, { children: [
6013
6052
  /* @__PURE__ */ jsx50(
6014
6053
  BotIcon,
6015
6054
  {