@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.js CHANGED
@@ -288,7 +288,7 @@ var { useContentPart, useContentPartStore } = createContextStoreHook(
288
288
  );
289
289
 
290
290
  // src/api/ContentPartRuntime.ts
291
- var ContentPartRuntime = class {
291
+ var ContentPartRuntimeImpl = class {
292
292
  constructor(contentBinding, messageApi, threadApi) {
293
293
  this.contentBinding = contentBinding;
294
294
  this.messageApi = messageApi;
@@ -330,7 +330,7 @@ var TextContentPartProvider = ({ children, text, isRunning }) => {
330
330
  const [context] = _react.useState.call(void 0, () => {
331
331
  const useContentPartRuntime2 = _zustand.create.call(void 0,
332
332
  // TODO
333
- () => new ContentPartRuntime(null, null, null)
333
+ () => new ContentPartRuntimeImpl(null, null, null)
334
334
  );
335
335
  const useContentPart2 = _zustand.create.call(void 0, () => ({
336
336
  status: isRunning ? RUNNING_STATUS : COMPLETE_STATUS,
@@ -343,13 +343,14 @@ var TextContentPartProvider = ({ children, text, isRunning }) => {
343
343
  _react.useEffect.call(void 0, () => {
344
344
  const state = context.useContentPart.getState();
345
345
  const textUpdated = state.text !== text;
346
- const targetTextPart = textUpdated ? { type: "text", text } : state;
347
346
  const targetStatus = isRunning ? RUNNING_STATUS : COMPLETE_STATUS;
348
347
  const statusUpdated = state.status !== targetStatus;
349
348
  if (!textUpdated && !statusUpdated) return;
350
349
  writableStore(context.useContentPart).setState(
351
350
  {
352
- part: targetTextPart,
351
+ type: "text",
352
+ text,
353
+ part: { type: "text", text },
353
354
  status: targetStatus
354
355
  },
355
356
  true
@@ -1584,7 +1585,7 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
1584
1585
  ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
1585
1586
 
1586
1587
  // src/api/AttachmentRuntime.ts
1587
- var AttachmentRuntime = class {
1588
+ var AttachmentRuntimeImpl = class {
1588
1589
  constructor(_core) {
1589
1590
  this._core = _core;
1590
1591
  }
@@ -1595,7 +1596,7 @@ var AttachmentRuntime = class {
1595
1596
  return this._core.subscribe(callback);
1596
1597
  }
1597
1598
  };
1598
- var ComposerAttachmentRuntime = class extends AttachmentRuntime {
1599
+ var ComposerAttachmentRuntime = class extends AttachmentRuntimeImpl {
1599
1600
  constructor(core, _composerApi) {
1600
1601
  super(core);
1601
1602
  this._composerApi = _composerApi;
@@ -1606,17 +1607,17 @@ var ComposerAttachmentRuntime = class extends AttachmentRuntime {
1606
1607
  return core.removeAttachment(this.getState().id);
1607
1608
  }
1608
1609
  };
1609
- var ThreadComposerAttachmentRuntime = class extends ComposerAttachmentRuntime {
1610
+ var ThreadComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
1610
1611
  get source() {
1611
1612
  return "thread-composer";
1612
1613
  }
1613
1614
  };
1614
- var EditComposerAttachmentRuntime = class extends ComposerAttachmentRuntime {
1615
+ var EditComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
1615
1616
  get source() {
1616
1617
  return "edit-composer";
1617
1618
  }
1618
1619
  };
1619
- var MessageAttachmentRuntime = class extends AttachmentRuntime {
1620
+ var MessageAttachmentRuntimeImpl = class extends AttachmentRuntimeImpl {
1620
1621
  get source() {
1621
1622
  return "message";
1622
1623
  }
@@ -1778,7 +1779,7 @@ var getEditComposerState = (runtime, beginEdit) => {
1778
1779
  cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _62 => _62.cancel, 'access', _63 => _63.bind, 'call', _64 => _64(runtime)]), () => ( METHOD_NOT_SUPPORTED))
1779
1780
  });
1780
1781
  };
1781
- var ComposerRuntime = class {
1782
+ var ComposerRuntimeImpl = class {
1782
1783
  constructor(_core) {
1783
1784
  this._core = _core;
1784
1785
  }
@@ -1837,9 +1838,9 @@ var ComposerRuntime = class {
1837
1838
  if (!core) throw new Error("Composer is not available");
1838
1839
  return core.addAttachment(file);
1839
1840
  }
1840
- // /**
1841
- // * @deprecated Use `getAttachmentById(id).removeAttachment` instead. This will be removed in 0.6.0.
1842
- // */
1841
+ /**
1842
+ * @deprecated Use `getAttachmentById(id).removeAttachment()` instead. This will be removed in 0.6.0.
1843
+ */
1843
1844
  removeAttachment(attachmentId) {
1844
1845
  const core = this._core.getState();
1845
1846
  if (!core) throw new Error("Composer is not available");
@@ -1867,7 +1868,7 @@ var ComposerRuntime = class {
1867
1868
  return this._core.subscribe(callback);
1868
1869
  }
1869
1870
  };
1870
- var ThreadComposerRuntime = (_class5 = class extends ComposerRuntime {
1871
+ var ThreadComposerRuntimeImpl = (_class5 = class extends ComposerRuntimeImpl {
1871
1872
  get type() {
1872
1873
  return "thread";
1873
1874
  }
@@ -1895,15 +1896,21 @@ var ThreadComposerRuntime = (_class5 = class extends ComposerRuntime {
1895
1896
  }
1896
1897
  // TODO replace with events
1897
1898
  __init9() {this._focusListeners = /* @__PURE__ */ new Set()}
1899
+ /**
1900
+ * @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
1901
+ */
1898
1902
  focus() {
1899
1903
  this._focusListeners.forEach((callback) => callback());
1900
1904
  }
1905
+ /**
1906
+ * @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
1907
+ */
1901
1908
  onFocus(callback) {
1902
1909
  this._focusListeners.add(callback);
1903
1910
  return () => this._focusListeners.delete(callback);
1904
1911
  }
1905
- unstable_getAttachmentByIndex(idx) {
1906
- return new ThreadComposerAttachmentRuntime(
1912
+ getAttachmentByIndex(idx) {
1913
+ return new ThreadComposerAttachmentRuntimeImpl(
1907
1914
  new ShallowMemoizeSubject({
1908
1915
  getState: () => {
1909
1916
  const attachments = this.getState().attachments;
@@ -1921,7 +1928,7 @@ var ThreadComposerRuntime = (_class5 = class extends ComposerRuntime {
1921
1928
  );
1922
1929
  }
1923
1930
  }, _class5);
1924
- var EditComposerRuntime = class extends ComposerRuntime {
1931
+ var EditComposerRuntimeImpl = class extends ComposerRuntimeImpl {
1925
1932
  constructor(core, _beginEdit) {
1926
1933
  const stateBinding = new LazyMemoizeSubject({
1927
1934
  getState: () => getEditComposerState(core.getState(), this._beginEdit),
@@ -1950,8 +1957,8 @@ var EditComposerRuntime = class extends ComposerRuntime {
1950
1957
  edit() {
1951
1958
  this.beginEdit();
1952
1959
  }
1953
- unstable_getAttachmentByIndex(idx) {
1954
- return new EditComposerAttachmentRuntime(
1960
+ getAttachmentByIndex(idx) {
1961
+ return new EditComposerAttachmentRuntimeImpl(
1955
1962
  new ShallowMemoizeSubject({
1956
1963
  getState: () => {
1957
1964
  const attachments = this.getState().attachments;
@@ -2035,12 +2042,12 @@ var getContentPartState = (message, partIndex) => {
2035
2042
  const status = toContentPartStatus(message, partIndex, part);
2036
2043
  return Object.freeze({ ...part, part, status });
2037
2044
  };
2038
- var MessageRuntime = (_class6 = class {
2045
+ var MessageRuntimeImpl = (_class6 = class {
2039
2046
  constructor(_core, _threadBinding) {;_class6.prototype.__init10.call(this);
2040
2047
  this._core = _core;
2041
2048
  this._threadBinding = _threadBinding;
2042
2049
  }
2043
- __init10() {this.composer = new EditComposerRuntime(
2050
+ __init10() {this.composer = new EditComposerRuntimeImpl(
2044
2051
  new NestedSubscriptionSubject({
2045
2052
  getState: () => this._threadBinding.getState().getEditComposer(this._core.getState().id),
2046
2053
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -2050,15 +2057,6 @@ var MessageRuntime = (_class6 = class {
2050
2057
  getState() {
2051
2058
  return this._core.getState();
2052
2059
  }
2053
- // TODO improve type
2054
- unstable_edit(message) {
2055
- const state = this._core.getState();
2056
- if (!state) throw new Error("Message is not available");
2057
- this._threadBinding.getState().append({
2058
- ...message,
2059
- parentId: state.parentId
2060
- });
2061
- }
2062
2060
  reload() {
2063
2061
  const state = this._core.getState();
2064
2062
  if (!state) throw new Error("Message is not available");
@@ -2104,9 +2102,9 @@ var MessageRuntime = (_class6 = class {
2104
2102
  subscribe(callback) {
2105
2103
  return this._core.subscribe(callback);
2106
2104
  }
2107
- unstable_getContentPartByIndex(idx) {
2105
+ getContentPartByIndex(idx) {
2108
2106
  if (idx < 0) throw new Error("Message index must be >= 0");
2109
- return new ContentPartRuntime(
2107
+ return new ContentPartRuntimeImpl(
2110
2108
  new ShallowMemoizeSubject({
2111
2109
  getState: () => {
2112
2110
  return getContentPartState(this.getState(), idx);
@@ -2117,8 +2115,8 @@ var MessageRuntime = (_class6 = class {
2117
2115
  this._threadBinding
2118
2116
  );
2119
2117
  }
2120
- unstable_getAttachmentByIndex(idx) {
2121
- return new MessageAttachmentRuntime(
2118
+ getAttachmentByIndex(idx) {
2119
+ return new MessageAttachmentRuntimeImpl(
2122
2120
  new ShallowMemoizeSubject({
2123
2121
  getState: () => {
2124
2122
  const attachments = this.getState().attachments;
@@ -2204,7 +2202,7 @@ var MessageContentPartImpl = ({
2204
2202
  }) => {
2205
2203
  const messageRuntime = useMessageRuntime();
2206
2204
  const runtime = _react.useMemo.call(void 0,
2207
- () => messageRuntime.unstable_getContentPartByIndex(partIndex),
2205
+ () => messageRuntime.getContentPartByIndex(partIndex),
2208
2206
  [messageRuntime, partIndex]
2209
2207
  );
2210
2208
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPartComponent, { components }) });
@@ -2353,7 +2351,7 @@ var AttachmentComponent = ({ components }) => {
2353
2351
  var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
2354
2352
  const messageRuntime = useMessageRuntime();
2355
2353
  const runtime = _react.useMemo.call(void 0,
2356
- () => messageRuntime.unstable_getAttachmentByIndex(attachmentIndex),
2354
+ () => messageRuntime.getAttachmentByIndex(attachmentIndex),
2357
2355
  [messageRuntime, attachmentIndex]
2358
2356
  );
2359
2357
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentComponent, { components }) });
@@ -2556,7 +2554,7 @@ var AttachmentComponent2 = ({ components }) => {
2556
2554
  var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
2557
2555
  const composerRuntime = useComposerRuntime();
2558
2556
  const runtime = _react.useMemo.call(void 0,
2559
- () => composerRuntime.unstable_getAttachmentByIndex(attachmentIndex),
2557
+ () => composerRuntime.getAttachmentByIndex(attachmentIndex),
2560
2558
  [composerRuntime, attachmentIndex]
2561
2559
  );
2562
2560
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentComponent2, { components }) });
@@ -2890,7 +2888,7 @@ var ThreadMessageImpl = ({
2890
2888
  }) => {
2891
2889
  const threadRuntime = useThreadRuntime();
2892
2890
  const runtime = _react.useMemo.call(void 0,
2893
- () => threadRuntime.unstable_getMesssageByIndex(messageIndex),
2891
+ () => threadRuntime.getMesssageByIndex(messageIndex),
2894
2892
  [threadRuntime, messageIndex]
2895
2893
  );
2896
2894
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessageComponent, { components }) });
@@ -2974,12 +2972,12 @@ var BaseAssistantRuntimeCore = (_class7 = class {
2974
2972
  // src/internal.ts
2975
2973
  var internal_exports = {};
2976
2974
  _chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
2977
- AssistantRuntime: () => AssistantRuntime,
2975
+ AssistantRuntimeImpl: () => AssistantRuntimeImpl,
2978
2976
  BaseAssistantRuntimeCore: () => BaseAssistantRuntimeCore,
2979
2977
  DefaultThreadComposerRuntimeCore: () => DefaultThreadComposerRuntimeCore,
2980
2978
  MessageRepository: () => MessageRepository,
2981
2979
  ProxyConfigProvider: () => ProxyConfigProvider,
2982
- ThreadRuntime: () => ThreadRuntime,
2980
+ ThreadRuntimeImpl: () => ThreadRuntimeImpl,
2983
2981
  TooltipIconButton: () => TooltipIconButton,
2984
2982
  generateId: () => generateId,
2985
2983
  useSmooth: () => useSmooth,
@@ -3467,7 +3465,7 @@ var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, sid
3467
3465
  TooltipIconButton.displayName = "TooltipIconButton";
3468
3466
 
3469
3467
  // src/api/AssistantRuntime.ts
3470
- var AssistantRuntime = class {
3468
+ var AssistantRuntimeImpl = class {
3471
3469
  constructor(_core, CustomThreadRuntime) {
3472
3470
  this._core = _core;
3473
3471
  this.thread = new CustomThreadRuntime(
@@ -3523,10 +3521,12 @@ var getThreadState = (runtime) => {
3523
3521
  capabilities: runtime.capabilities,
3524
3522
  isDisabled: runtime.isDisabled,
3525
3523
  isRunning: _optionalChain([lastMessage, 'optionalAccess', _178 => _178.role]) !== "assistant" ? false : lastMessage.status.type === "running",
3526
- messages: runtime.messages
3524
+ messages: runtime.messages,
3525
+ suggestions: runtime.suggestions,
3526
+ extras: runtime.extras
3527
3527
  });
3528
3528
  };
3529
- var ThreadRuntime = (_class12 = class {
3529
+ var ThreadRuntimeImpl = (_class12 = class {
3530
3530
  // public path = "assistant.threads[main]"; // TODO
3531
3531
  /**
3532
3532
  * @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
@@ -3552,6 +3552,18 @@ var ThreadRuntime = (_class12 = class {
3552
3552
  get capabilities() {
3553
3553
  return this.getState().capabilities;
3554
3554
  }
3555
+ /**
3556
+ * @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
3557
+ */
3558
+ get extras() {
3559
+ return this._threadBinding.getState().extras;
3560
+ }
3561
+ /**
3562
+ * @deprecated Use `getState().followupSuggestions` instead. This will be removed in 0.6.0.
3563
+ */
3564
+ get suggestions() {
3565
+ return this._threadBinding.getState().suggestions;
3566
+ }
3555
3567
  /**
3556
3568
  * @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
3557
3569
  */
@@ -3573,7 +3585,7 @@ var ThreadRuntime = (_class12 = class {
3573
3585
  subscribe: (callback) => threadBinding.subscribe(callback)
3574
3586
  };
3575
3587
  }
3576
- __init23() {this.composer = new ThreadComposerRuntime(
3588
+ __init23() {this.composer = new ThreadComposerRuntimeImpl(
3577
3589
  new NestedSubscriptionSubject({
3578
3590
  getState: () => this._threadBinding.getState().composer,
3579
3591
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -3590,9 +3602,9 @@ var ThreadRuntime = (_class12 = class {
3590
3602
  subscribe(callback) {
3591
3603
  return this._threadBinding.subscribe(callback);
3592
3604
  }
3593
- // /**
3594
- // * @derprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
3595
- // */
3605
+ /**
3606
+ * @derprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
3607
+ */
3596
3608
  getBranches(messageId) {
3597
3609
  return this._threadBinding.getState().getBranches(messageId);
3598
3610
  }
@@ -3603,17 +3615,18 @@ var ThreadRuntime = (_class12 = class {
3603
3615
  startRun(parentId) {
3604
3616
  return this._threadBinding.getState().startRun(parentId);
3605
3617
  }
3606
- // TODO
3607
3618
  cancelRun() {
3608
3619
  this._threadBinding.getState().cancelRun();
3609
3620
  }
3610
- // /**
3611
- // * @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
3612
- // */
3621
+ /**
3622
+ * @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
3623
+ */
3613
3624
  addToolResult(options) {
3614
3625
  this._threadBinding.getState().addToolResult(options);
3615
3626
  }
3616
- // TODO
3627
+ /**
3628
+ * @deprecated Use `getMesssageById(id).switchToBranch({ options })` instead. This will be removed in 0.6.0.
3629
+ */
3617
3630
  switchToBranch(branchId) {
3618
3631
  return this._threadBinding.getState().switchToBranch(branchId);
3619
3632
  }
@@ -3630,13 +3643,13 @@ var ThreadRuntime = (_class12 = class {
3630
3643
  return this._threadBinding.getState().submitFeedback(options);
3631
3644
  }
3632
3645
  /**
3633
- * @deprecated Use `getMesssageById(id).unstable_getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
3646
+ * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
3634
3647
  */
3635
3648
  getEditComposer(messageId) {
3636
3649
  return this._threadBinding.getState().getEditComposer(messageId);
3637
3650
  }
3638
3651
  /**
3639
- * @deprecated Use `getMesssageById(id).unstable_getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
3652
+ * @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
3640
3653
  */
3641
3654
  beginEdit(messageId) {
3642
3655
  return this._threadBinding.getState().beginEdit(messageId);
@@ -3647,9 +3660,9 @@ var ThreadRuntime = (_class12 = class {
3647
3660
  import(data) {
3648
3661
  this._threadBinding.getState().import(data);
3649
3662
  }
3650
- unstable_getMesssageByIndex(idx) {
3663
+ getMesssageByIndex(idx) {
3651
3664
  if (idx < 0) throw new Error("Message index must be >= 0");
3652
- return new MessageRuntime(
3665
+ return new MessageRuntimeImpl(
3653
3666
  new ShallowMemoizeSubject({
3654
3667
  getState: () => {
3655
3668
  const messages2 = this.getState().messages;
@@ -3952,7 +3965,7 @@ var EdgeChatAdapter = class {
3952
3965
  }),
3953
3966
  signal: abortSignal
3954
3967
  });
3955
- if (result.status !== 200) {
3968
+ if (!result.ok) {
3956
3969
  throw new Error(`Status ${result.status}: ${await result.text()}`);
3957
3970
  }
3958
3971
  const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunk5KIEXJRKjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunk5KIEXJRKjs.runResultStream.call(void 0, ));
@@ -4022,7 +4035,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
4022
4035
 
4023
4036
  // src/runtimes/local/LocalThreadRuntimeCore.tsx
4024
4037
  var LocalThreadRuntimeCore = (_class13 = class {
4025
- constructor(configProvider, adapter, { initialMessages, ...options }) {;_class13.prototype.__init24.call(this);_class13.prototype.__init25.call(this);_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);_class13.prototype.__init28.call(this);_class13.prototype.__init29.call(this);_class13.prototype.__init30.call(this);
4038
+ constructor(configProvider, adapter, { initialMessages, ...options }) {;_class13.prototype.__init24.call(this);_class13.prototype.__init25.call(this);_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);_class13.prototype.__init28.call(this);_class13.prototype.__init29.call(this);_class13.prototype.__init30.call(this);_class13.prototype.__init31.call(this);
4026
4039
  this.configProvider = configProvider;
4027
4040
  this.adapter = adapter;
4028
4041
  this.threadId = generateId();
@@ -4051,10 +4064,11 @@ var LocalThreadRuntimeCore = (_class13 = class {
4051
4064
  }}
4052
4065
 
4053
4066
  __init28() {this.isDisabled = false}
4067
+ __init29() {this.suggestions = []}
4054
4068
  get messages() {
4055
4069
  return this.repository.getMessages();
4056
4070
  }
4057
- __init29() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4071
+ __init30() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4058
4072
  getModelConfig() {
4059
4073
  return this.configProvider.getModelConfig();
4060
4074
  }
@@ -4062,6 +4076,9 @@ var LocalThreadRuntimeCore = (_class13 = class {
4062
4076
  get options() {
4063
4077
  return this._options;
4064
4078
  }
4079
+ get extras() {
4080
+ return void 0;
4081
+ }
4065
4082
  set options({ initialMessages, ...options }) {
4066
4083
  this._options = options;
4067
4084
  let hasUpdates = false;
@@ -4083,7 +4100,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
4083
4100
  }
4084
4101
  if (hasUpdates) this.notifySubscribers();
4085
4102
  }
4086
- __init30() {this._editComposers = /* @__PURE__ */ new Map()}
4103
+ __init31() {this._editComposers = /* @__PURE__ */ new Map()}
4087
4104
  getEditComposer(messageId) {
4088
4105
  return this._editComposers.get(messageId);
4089
4106
  }
@@ -4342,9 +4359,9 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4342
4359
  };
4343
4360
 
4344
4361
  // src/runtimes/local/useLocalRuntime.tsx
4345
- var LocalRuntime = class extends AssistantRuntime {
4362
+ var LocalRuntime = class extends AssistantRuntimeImpl {
4346
4363
  constructor(core) {
4347
- super(core, ThreadRuntime);
4364
+ super(core, ThreadRuntimeImpl);
4348
4365
  this.core = core;
4349
4366
  }
4350
4367
  reset(options) {
@@ -4370,8 +4387,8 @@ var getExternalStoreMessage = (message) => {
4370
4387
  };
4371
4388
 
4372
4389
  // src/runtimes/external-store/ThreadMessageConverter.ts
4373
- var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.__init31.call(this); }
4374
- __init31() {this.cache = /* @__PURE__ */ new WeakMap()}
4390
+ var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.__init32.call(this); }
4391
+ __init32() {this.cache = /* @__PURE__ */ new WeakMap()}
4375
4392
  convertMessages(messages2, converter) {
4376
4393
  return messages2.map((m, idx) => {
4377
4394
  const cached = this.cache.get(m);
@@ -4466,18 +4483,19 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
4466
4483
  };
4467
4484
 
4468
4485
  // src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
4486
+ var EMPTY_ARRAY2 = Object.freeze([]);
4469
4487
  var hasUpcomingMessage = (isRunning, messages2) => {
4470
4488
  return isRunning && _optionalChain([messages2, 'access', _215 => _215[messages2.length - 1], 'optionalAccess', _216 => _216.role]) !== "assistant";
4471
4489
  };
4472
4490
  var ExternalStoreThreadRuntimeCore = (_class15 = class {
4473
- constructor(configProvider, store) {;_class15.prototype.__init32.call(this);_class15.prototype.__init33.call(this);_class15.prototype.__init34.call(this);_class15.prototype.__init35.call(this);_class15.prototype.__init36.call(this);_class15.prototype.__init37.call(this);_class15.prototype.__init38.call(this);_class15.prototype.__init39.call(this);
4491
+ constructor(configProvider, store) {;_class15.prototype.__init33.call(this);_class15.prototype.__init34.call(this);_class15.prototype.__init35.call(this);_class15.prototype.__init36.call(this);_class15.prototype.__init37.call(this);_class15.prototype.__init38.call(this);_class15.prototype.__init39.call(this);_class15.prototype.__init40.call(this);_class15.prototype.__init41.call(this);_class15.prototype.__init42.call(this);
4474
4492
  this.configProvider = configProvider;
4475
4493
  this.store = store;
4476
4494
  }
4477
- __init32() {this._subscriptions = /* @__PURE__ */ new Set()}
4478
- __init33() {this.repository = new MessageRepository()}
4479
- __init34() {this.assistantOptimisticId = null}
4480
- __init35() {this._capabilities = {
4495
+ __init33() {this._subscriptions = /* @__PURE__ */ new Set()}
4496
+ __init34() {this.repository = new MessageRepository()}
4497
+ __init35() {this.assistantOptimisticId = null}
4498
+ __init36() {this._capabilities = {
4481
4499
  switchToBranch: false,
4482
4500
  edit: false,
4483
4501
  reload: false,
@@ -4493,10 +4511,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4493
4511
 
4494
4512
 
4495
4513
 
4496
- __init36() {this.converter = new ThreadMessageConverter()}
4514
+ __init37() {this.suggestions = []}
4515
+ __init38() {this.extras = void 0}
4516
+ __init39() {this._converter = new ThreadMessageConverter()}
4497
4517
 
4498
- __init37() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4499
- __init38() {this._editComposers = /* @__PURE__ */ new Map()}
4518
+ __init40() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4519
+ __init41() {this._editComposers = /* @__PURE__ */ new Map()}
4500
4520
  getEditComposer(messageId) {
4501
4521
  return this._editComposers.get(messageId);
4502
4522
  }
@@ -4523,6 +4543,8 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4523
4543
  this.isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
4524
4544
  const oldStore = this._store;
4525
4545
  this._store = store;
4546
+ this.extras = store.extras;
4547
+ this.suggestions = _nullishCoalesce(store.suggestions, () => ( EMPTY_ARRAY2));
4526
4548
  this._capabilities = {
4527
4549
  switchToBranch: this._store.setMessages !== void 0,
4528
4550
  edit: this._store.onEdit !== void 0,
@@ -4537,13 +4559,13 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4537
4559
  this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _229 => _229._store, 'access', _230 => _230.adapters, 'optionalAccess', _231 => _231.attachments]));
4538
4560
  if (oldStore) {
4539
4561
  if (oldStore.convertMessage !== store.convertMessage) {
4540
- this.converter = new ThreadMessageConverter();
4562
+ this._converter = new ThreadMessageConverter();
4541
4563
  } else if (oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
4542
4564
  this.notifySubscribers();
4543
4565
  return;
4544
4566
  }
4545
4567
  }
4546
- const messages2 = !store.convertMessage ? store.messages : this.converter.convertMessages(store.messages, (cache, m, idx) => {
4568
+ const messages2 = !store.convertMessage ? store.messages : this._converter.convertMessages(store.messages, (cache, m, idx) => {
4547
4569
  if (!store.convertMessage) return m;
4548
4570
  const isLast = idx === store.messages.length - 1;
4549
4571
  const autoStatus = getAutoStatus(isLast, isRunning);
@@ -4654,7 +4676,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
4654
4676
  this._subscriptions.add(callback);
4655
4677
  return () => this._subscriptions.delete(callback);
4656
4678
  }
4657
- __init39() {this.updateMessages = (messages2) => {
4679
+ __init42() {this.updateMessages = (messages2) => {
4658
4680
  _optionalChain([this, 'access', _250 => _250._store, 'access', _251 => _251.setMessages, 'optionalCall', _252 => _252(
4659
4681
  messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
4660
4682
  )]);
@@ -4718,7 +4740,10 @@ var useExternalStoreRuntime = (store) => {
4718
4740
  _react.useEffect.call(void 0, () => {
4719
4741
  runtime.thread.store = store;
4720
4742
  });
4721
- return _react.useMemo.call(void 0, () => new AssistantRuntime(runtime, ThreadRuntime), [runtime]);
4743
+ return _react.useMemo.call(void 0,
4744
+ () => new AssistantRuntimeImpl(runtime, ThreadRuntimeImpl),
4745
+ [runtime]
4746
+ );
4722
4747
  };
4723
4748
 
4724
4749
  // src/runtimes/external-store/external-message-converter.tsx
@@ -4945,8 +4970,8 @@ var WebSpeechSynthesisAdapter = class {
4945
4970
  };
4946
4971
 
4947
4972
  // src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
4948
- var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init40.call(this); }
4949
- __init40() {this.accept = "image/*"}
4973
+ var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init43.call(this); }
4974
+ __init43() {this.accept = "image/*"}
4950
4975
  async add(state) {
4951
4976
  return {
4952
4977
  id: state.file.name,
@@ -4980,8 +5005,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
4980
5005
  });
4981
5006
 
4982
5007
  // src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
4983
- var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init41.call(this); }
4984
- __init41() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
5008
+ var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init44.call(this); }
5009
+ __init44() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
4985
5010
  async add(state) {
4986
5011
  return {
4987
5012
  id: state.file.name,
@@ -5699,19 +5724,13 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
5699
5724
  var ThreadWelcomeSuggestion = ({
5700
5725
  suggestion: { text, prompt }
5701
5726
  }) => {
5702
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5703
- ThreadWelcomeSuggestionStyled,
5704
- {
5705
- prompt,
5706
- method: "replace",
5707
- autoSend: true,
5708
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-thread-welcome-suggestion-text", children: _nullishCoalesce(text, () => ( prompt)) })
5709
- }
5710
- );
5727
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionStyled, { prompt, method: "replace", autoSend: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-thread-welcome-suggestion-text", children: _nullishCoalesce(text, () => ( prompt)) }) });
5711
5728
  };
5712
5729
  var ThreadWelcomeSuggestions = () => {
5730
+ const suggestions2 = useThread((t) => t.suggestions);
5713
5731
  const { welcome: { suggestions } = {} } = useThreadConfig();
5714
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _256 => _256.map, 'call', _257 => _257((suggestion, idx) => {
5732
+ const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
5733
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _256 => _256.map, 'call', _257 => _257((suggestion, idx) => {
5715
5734
  const key = `${suggestion.prompt}-${idx}`;
5716
5735
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
5717
5736
  })]) });
@@ -5897,12 +5916,14 @@ var edit_composer_default = Object.assign(EditComposer, exports11);
5897
5916
  // src/ui/thread.tsx
5898
5917
 
5899
5918
  var Thread = (config) => {
5919
+ const { components: { Composer: ComposerComponent = composer_default } = {} } = config;
5900
5920
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRoot, { config, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewport, { children: [
5901
5921
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_welcome_default, {}),
5902
5922
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessages, {}),
5923
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadFollowupSuggestions, {}),
5903
5924
  /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewportFooter, { children: [
5904
5925
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadScrollToBottom, {}),
5905
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_default, {})
5926
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerComponent, {})
5906
5927
  ] })
5907
5928
  ] }) });
5908
5929
  };
@@ -5924,21 +5945,38 @@ var ThreadViewportFooter = withDefaults("div", {
5924
5945
  });
5925
5946
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
5926
5947
  var SystemMessage = () => null;
5927
- var ThreadMessages = ({ components, ...rest }) => {
5928
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5929
- thread_exports.Messages,
5930
- {
5931
- components: {
5932
- UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _260 => _260.UserMessage]), () => ( user_message_default)),
5933
- EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _261 => _261.EditComposer]), () => ( edit_composer_default)),
5934
- AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _262 => _262.AssistantMessage]), () => ( assistant_message_default)),
5935
- SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _263 => _263.SystemMessage]), () => ( SystemMessage))
5936
- },
5937
- ...rest
5938
- }
5939
- );
5948
+ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
5949
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
5950
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5951
+ thread_exports.Messages,
5952
+ {
5953
+ components: {
5954
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _260 => _260.UserMessage]), () => ( user_message_default)),
5955
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _261 => _261.EditComposer]), () => ( edit_composer_default)),
5956
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _262 => _262.AssistantMessage]), () => ( assistant_message_default)),
5957
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _263 => _263.SystemMessage]), () => ( SystemMessage))
5958
+ },
5959
+ ...rest
5960
+ }
5961
+ ),
5962
+ flexGrowDiv && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { flexGrow: 1 } }) })
5963
+ ] });
5940
5964
  };
5941
5965
  ThreadMessages.displayName = "ThreadMessages";
5966
+ var ThreadFollowupSuggestions = () => {
5967
+ const suggestions = useThread((t) => t.suggestions);
5968
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _264 => _264.map, 'call', _265 => _265((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
5969
+ thread_exports.Suggestion,
5970
+ {
5971
+ className: "aui-thread-followup-suggestion",
5972
+ prompt: suggestion.prompt,
5973
+ method: "replace",
5974
+ autoSend: true,
5975
+ children: suggestion.prompt
5976
+ },
5977
+ idx
5978
+ ))]) }) });
5979
+ };
5942
5980
  var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
5943
5981
  variant: "outline",
5944
5982
  className: "aui-thread-scroll-to-bottom"
@@ -5956,6 +5994,7 @@ var exports12 = {
5956
5994
  Root: ThreadRoot,
5957
5995
  Viewport: ThreadViewport,
5958
5996
  Messages: ThreadMessages,
5997
+ FollowupSuggestions: ThreadFollowupSuggestions,
5959
5998
  ScrollToBottom: ThreadScrollToBottom,
5960
5999
  ViewportFooter: ThreadViewportFooter
5961
6000
  };