@assistant-ui/react 0.5.75 → 0.5.77

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.mjs CHANGED
@@ -632,13 +632,9 @@ var useActionBarStopSpeaking = () => {
632
632
  import { useCallback as useCallback8 } from "react";
633
633
  var useActionBarFeedbackPositive = () => {
634
634
  const messageRuntime = useMessageRuntime();
635
- const messageUtilsStore = useMessageUtilsStore();
636
635
  const callback = useCallback8(() => {
637
- messageRuntime.submitFeedback({
638
- type: "positive"
639
- });
640
- messageUtilsStore.getState().setSubmittedFeedback("positive");
641
- }, [messageUtilsStore, messageRuntime]);
636
+ messageRuntime.submitFeedback({ type: "positive" });
637
+ }, [messageRuntime]);
642
638
  return callback;
643
639
  };
644
640
 
@@ -646,13 +642,9 @@ var useActionBarFeedbackPositive = () => {
646
642
  import { useCallback as useCallback9 } from "react";
647
643
  var useActionBarFeedbackNegative = () => {
648
644
  const messageRuntime = useMessageRuntime();
649
- const messageUtilsStore = useMessageUtilsStore();
650
645
  const callback = useCallback9(() => {
651
- messageRuntime.submitFeedback({
652
- type: "negative"
653
- });
654
- messageUtilsStore.getState().setSubmittedFeedback("negative");
655
- }, [messageUtilsStore, messageRuntime]);
646
+ messageRuntime.submitFeedback({ type: "negative" });
647
+ }, [messageRuntime]);
656
648
  return callback;
657
649
  };
658
650
 
@@ -740,23 +732,21 @@ var useComposerSend = () => {
740
732
  import { useCallback as useCallback14 } from "react";
741
733
  var useComposerAddAttachment = () => {
742
734
  const disabled = useComposer((c) => !c.isEditing);
743
- const threadComposerStore = useThreadComposerStore();
744
- const threadRuntimeStore = useThreadComposerStore();
735
+ const composerRuntime = useComposerRuntime();
745
736
  const callback = useCallback14(() => {
746
- const { addAttachment } = threadComposerStore.getState();
747
- const { attachmentAccept } = threadRuntimeStore.getState();
748
737
  const input = document.createElement("input");
749
738
  input.type = "file";
739
+ const attachmentAccept = composerRuntime.getAttachmentAccept();
750
740
  if (attachmentAccept !== "*") {
751
741
  input.accept = attachmentAccept;
752
742
  }
753
743
  input.onchange = (e) => {
754
744
  const file = e.target.files?.[0];
755
745
  if (!file) return;
756
- addAttachment(file);
746
+ composerRuntime.addAttachment(file);
757
747
  };
758
748
  input.click();
759
- }, [threadComposerStore, threadRuntimeStore]);
749
+ }, [composerRuntime]);
760
750
  if (disabled) return null;
761
751
  return callback;
762
752
  };
@@ -803,7 +793,15 @@ var useMessageIf = (props) => {
803
793
  const messageUtilsStore = useMessageUtilsStore();
804
794
  return useCombinedStore(
805
795
  [messageStore, messageUtilsStore],
806
- ({ role, attachments, branchCount, isLast, speech }, { isCopied, isHovering, submittedFeedback }) => {
796
+ ({
797
+ role,
798
+ attachments,
799
+ content,
800
+ branchCount,
801
+ isLast,
802
+ speech,
803
+ submittedFeedback
804
+ }, { isCopied, isHovering }) => {
807
805
  if (props.hasBranches === true && branchCount < 2) return false;
808
806
  if (props.user && role !== "user") return false;
809
807
  if (props.assistant && role !== "assistant") return false;
@@ -817,7 +815,9 @@ var useMessageIf = (props) => {
817
815
  return false;
818
816
  if (props.hasAttachments === false && role === "user" && !!attachments.length)
819
817
  return false;
820
- if (props.submittedFeedback !== void 0 && submittedFeedback !== props.submittedFeedback)
818
+ if (props.hasContent === true && content.length === 0) return false;
819
+ if (props.hasContent === false && content.length > 0) return false;
820
+ if (props.submittedFeedback !== void 0 && (submittedFeedback?.type ?? null) !== props.submittedFeedback)
821
821
  return false;
822
822
  return true;
823
823
  }
@@ -913,7 +913,7 @@ var useActionBarFloatStatus = ({
913
913
  const autohideEnabled = autohide === "always" || autohide === "not-last" && !m.isLast;
914
914
  if (!autohideEnabled) return "normal" /* Normal */;
915
915
  if (!mu.isHovering) return "hidden" /* Hidden */;
916
- if (autohideFloat === "always" || autohideFloat === "single-branch" && m.branches.length <= 1)
916
+ if (autohideFloat === "always" || autohideFloat === "single-branch" && m.branchCount <= 1)
917
917
  return "floating" /* Floating */;
918
918
  return "normal" /* Normal */;
919
919
  }
@@ -1051,8 +1051,8 @@ import { composeEventHandlers as composeEventHandlers4 } from "@radix-ui/primiti
1051
1051
  import { Primitive as Primitive5 } from "@radix-ui/react-primitive";
1052
1052
  import { jsx as jsx8 } from "react/jsx-runtime";
1053
1053
  var ActionBarPrimitiveFeedbackPositive = forwardRef5(({ onClick, disabled, ...props }, forwardedRef) => {
1054
- const isSubmitted = useMessageUtils(
1055
- (u) => u.submittedFeedback === "positive"
1054
+ const isSubmitted = useMessage(
1055
+ (u) => u.submittedFeedback?.type === "positive"
1056
1056
  );
1057
1057
  const callback = useActionBarFeedbackPositive();
1058
1058
  return /* @__PURE__ */ jsx8(
@@ -1077,8 +1077,8 @@ import { composeEventHandlers as composeEventHandlers5 } from "@radix-ui/primiti
1077
1077
  import { Primitive as Primitive6 } from "@radix-ui/react-primitive";
1078
1078
  import { jsx as jsx9 } from "react/jsx-runtime";
1079
1079
  var ActionBarPrimitiveFeedbackNegative = forwardRef6(({ onClick, disabled, ...props }, forwardedRef) => {
1080
- const isSubmitted = useMessageUtils(
1081
- (u) => u.submittedFeedback === "negative"
1080
+ const isSubmitted = useMessage(
1081
+ (u) => u.submittedFeedback?.type === "negative"
1082
1082
  );
1083
1083
  const callback = useActionBarFeedbackNegative();
1084
1084
  return /* @__PURE__ */ jsx9(
@@ -1302,9 +1302,9 @@ var { useAttachment: useMessageAttachment } = createContextStoreHook(
1302
1302
  // src/primitives/attachment/AttachmentThumb.tsx
1303
1303
  import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
1304
1304
  import { jsxs } from "react/jsx-runtime";
1305
- var AttachmentPrimitiveThumb = forwardRef11(() => {
1305
+ var AttachmentPrimitiveThumb = forwardRef11((props, ref) => {
1306
1306
  const ext = useAttachment((a) => a.name.split(".").pop());
1307
- return /* @__PURE__ */ jsxs(Primitive8.div, { children: [
1307
+ return /* @__PURE__ */ jsxs(Primitive8.div, { ...props, ref, children: [
1308
1308
  ".",
1309
1309
  ext
1310
1310
  ] });
@@ -1438,9 +1438,9 @@ var useIsHoveringRef = () => {
1438
1438
  );
1439
1439
  return useManagedRef(callbackRef);
1440
1440
  };
1441
- var MessagePrimitiveRoot = forwardRef12((props, forwardRef35) => {
1441
+ var MessagePrimitiveRoot = forwardRef12((props, forwardRef36) => {
1442
1442
  const isHoveringRef = useIsHoveringRef();
1443
- const ref = useComposedRefs(forwardRef35, isHoveringRef);
1443
+ const ref = useComposedRefs(forwardRef36, isHoveringRef);
1444
1444
  return /* @__PURE__ */ jsx18(Primitive9.div, { ...props, ref });
1445
1445
  });
1446
1446
  MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
@@ -1845,7 +1845,6 @@ var getThreadComposerState = (runtime, focus, onFocus) => {
1845
1845
  isEmpty: runtime?.isEmpty ?? true,
1846
1846
  text: runtime?.text ?? "",
1847
1847
  attachments: runtime?.attachments ?? EMPTY_ARRAY,
1848
- attachmentAccept: runtime?.attachmentAccept ?? "*",
1849
1848
  value: runtime?.text ?? "",
1850
1849
  setValue: runtime?.setText.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1851
1850
  setText: runtime?.setText.bind(runtime) ?? METHOD_NOT_SUPPORTED,
@@ -1867,7 +1866,6 @@ var getEditComposerState = (runtime, beginEdit) => {
1867
1866
  isEmpty: runtime?.isEmpty ?? true,
1868
1867
  text: runtime?.text ?? "",
1869
1868
  attachments: runtime?.attachments ?? EMPTY_ARRAY,
1870
- attachmentAccept: runtime?.attachmentAccept ?? "*",
1871
1869
  value: runtime?.text ?? "",
1872
1870
  setValue: runtime?.setText.bind(runtime) ?? METHOD_NOT_SUPPORTED,
1873
1871
  setText: runtime?.setText.bind(runtime) ?? METHOD_NOT_SUPPORTED,
@@ -1904,12 +1902,6 @@ var ComposerRuntimeImpl = class {
1904
1902
  get text() {
1905
1903
  return this.getState().text;
1906
1904
  }
1907
- /**
1908
- * @deprecated Use `getState().attachmentAccept` instead. This will be removed in 0.6.0.
1909
- */
1910
- get attachmentAccept() {
1911
- return this.getState().attachmentAccept;
1912
- }
1913
1905
  /**
1914
1906
  * @deprecated Use `getState().attachments` instead. This will be removed in 0.6.0.
1915
1907
  */
@@ -1964,6 +1956,11 @@ var ComposerRuntimeImpl = class {
1964
1956
  subscribe(callback) {
1965
1957
  return this._core.subscribe(callback);
1966
1958
  }
1959
+ getAttachmentAccept() {
1960
+ const core = this._core.getState();
1961
+ if (!core) throw new Error("Composer is not available");
1962
+ return core.getAttachmentAccept();
1963
+ }
1967
1964
  };
1968
1965
  var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
1969
1966
  get type() {
@@ -2828,10 +2825,6 @@ var makeMessageUtilsStore = () => create9((set) => {
2828
2825
  isHovering: false,
2829
2826
  setIsHovering: (value) => {
2830
2827
  set({ isHovering: value });
2831
- },
2832
- submittedFeedback: null,
2833
- setSubmittedFeedback: (feedback) => {
2834
- set({ submittedFeedback: feedback });
2835
2828
  }
2836
2829
  };
2837
2830
  });
@@ -3028,7 +3021,9 @@ __export(internal_exports, {
3028
3021
  var isAttachmentComplete = (a) => a.status.type === "complete";
3029
3022
  var BaseComposerRuntimeCore = class {
3030
3023
  isEditing = true;
3031
- attachmentAccept = "*";
3024
+ getAttachmentAccept() {
3025
+ return this.getAttachmentAdapter()?.accept ?? "*";
3026
+ }
3032
3027
  _attachments = [];
3033
3028
  set attachments(value) {
3034
3029
  this._attachments = value;
@@ -3054,10 +3049,11 @@ var BaseComposerRuntimeCore = class {
3054
3049
  this.notifySubscribers();
3055
3050
  }
3056
3051
  async send() {
3057
- const attachments = this._attachmentAdapter ? await Promise.all(
3052
+ const adapter = this.getAttachmentAdapter();
3053
+ const attachments = adapter && this.attachments.length > 0 ? await Promise.all(
3058
3054
  this.attachments.map(async (a) => {
3059
3055
  if (isAttachmentComplete(a)) return a;
3060
- const result = await this._attachmentAdapter.send(a);
3056
+ const result = await adapter.send(a);
3061
3057
  if (result.status?.type !== "complete") {
3062
3058
  result.status = { type: "complete" };
3063
3059
  }
@@ -3072,19 +3068,10 @@ var BaseComposerRuntimeCore = class {
3072
3068
  this.reset();
3073
3069
  this.handleSend(message);
3074
3070
  }
3075
- _attachmentAdapter;
3076
- setAttachmentAdapter(adapter) {
3077
- this._attachmentAdapter = adapter;
3078
- const accept = adapter?.accept ?? "*";
3079
- if (this.attachmentAccept !== accept) {
3080
- this.attachmentAccept = accept;
3081
- this.notifySubscribers();
3082
- }
3083
- }
3084
3071
  async addAttachment(file) {
3085
- if (!this._attachmentAdapter)
3086
- throw new Error("Attachments are not supported");
3087
- const attachment = await this._attachmentAdapter.add({ file });
3072
+ const adapter = this.getAttachmentAdapter();
3073
+ if (!adapter) throw new Error("Attachments are not supported");
3074
+ const attachment = await adapter.add({ file });
3088
3075
  if (attachment.status === void 0) {
3089
3076
  attachment.status = { type: "requires-action", reason: "composer-send" };
3090
3077
  }
@@ -3092,12 +3079,12 @@ var BaseComposerRuntimeCore = class {
3092
3079
  this.notifySubscribers();
3093
3080
  }
3094
3081
  async removeAttachment(attachmentId) {
3095
- if (!this._attachmentAdapter)
3096
- throw new Error("Attachments are not supported");
3082
+ const adapter = this.getAttachmentAdapter();
3083
+ if (!adapter) throw new Error("Attachments are not supported");
3097
3084
  const index = this._attachments.findIndex((a) => a.id === attachmentId);
3098
3085
  if (index === -1) throw new Error("Attachment not found");
3099
3086
  const attachment = this._attachments[index];
3100
- await this._attachmentAdapter.remove(attachment);
3087
+ await adapter.remove(attachment);
3101
3088
  this._attachments = this._attachments.toSpliced(index, 1);
3102
3089
  this.notifySubscribers();
3103
3090
  }
@@ -3125,6 +3112,9 @@ var DefaultThreadComposerRuntimeCore = class extends BaseComposerRuntimeCore {
3125
3112
  get attachments() {
3126
3113
  return super.attachments;
3127
3114
  }
3115
+ getAttachmentAdapter() {
3116
+ return this.runtime.adapters?.attachments;
3117
+ }
3128
3118
  connect() {
3129
3119
  return this.runtime.subscribe(() => {
3130
3120
  if (this.canCancel !== this.runtime.capabilities.cancel) {
@@ -3503,36 +3493,6 @@ var TooltipIconButton = forwardRef23(({ children, tooltip, side = "bottom", ...r
3503
3493
  });
3504
3494
  TooltipIconButton.displayName = "TooltipIconButton";
3505
3495
 
3506
- // src/api/AssistantRuntime.ts
3507
- var AssistantRuntimeImpl = class {
3508
- constructor(_core, CustomThreadRuntime) {
3509
- this._core = _core;
3510
- this.thread = new CustomThreadRuntime(
3511
- new NestedSubscriptionSubject({
3512
- getState: () => this._core.thread,
3513
- subscribe: (callback) => this._core.subscribe(callback)
3514
- })
3515
- );
3516
- }
3517
- thread;
3518
- switchToNewThread() {
3519
- return this._core.switchToNewThread();
3520
- }
3521
- switchToThread(threadId) {
3522
- return this._core.switchToThread(threadId);
3523
- }
3524
- registerModelConfigProvider(provider) {
3525
- return this._core.registerModelConfigProvider(provider);
3526
- }
3527
- // TODO events for thread switching
3528
- /**
3529
- * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
3530
- */
3531
- subscribe(callback) {
3532
- return this._core.subscribe(callback);
3533
- }
3534
- };
3535
-
3536
3496
  // src/api/ThreadRuntime.ts
3537
3497
  var toAppendMessage = (messages2, message) => {
3538
3498
  if (typeof message === "string") {
@@ -3685,6 +3645,9 @@ var ThreadRuntimeImpl = class {
3685
3645
  stopSpeaking() {
3686
3646
  return this._threadBinding.getState().stopSpeaking();
3687
3647
  }
3648
+ getSubmittedFeedback(messageId) {
3649
+ return this._threadBinding.getState().getSubmittedFeedback(messageId);
3650
+ }
3688
3651
  /**
3689
3652
  * @deprecated Use `getMesssageById(id).submitFeedback({ type })` instead. This will be removed in 0.6.0.
3690
3653
  */
@@ -3717,7 +3680,9 @@ var ThreadRuntimeImpl = class {
3717
3680
  const { messages: messages2, speech: speechState } = this.getState();
3718
3681
  const message = messages2[idx];
3719
3682
  if (!message) return SKIP_UPDATE;
3720
- const branches = this._threadBinding.getState().getBranches(message.id);
3683
+ const thread = this._threadBinding.getState();
3684
+ const branches = thread.getBranches(message.id);
3685
+ const submittedFeedback = thread.getSubmittedFeedback(message.id);
3721
3686
  return {
3722
3687
  ...message,
3723
3688
  message,
@@ -3726,7 +3691,8 @@ var ThreadRuntimeImpl = class {
3726
3691
  branches,
3727
3692
  branchNumber: branches.indexOf(message.id) + 1,
3728
3693
  branchCount: branches.length,
3729
- speech: speechState?.messageId === message.id ? speechState : null
3694
+ speech: speechState?.messageId === message.id ? speechState : void 0,
3695
+ submittedFeedback
3730
3696
  };
3731
3697
  },
3732
3698
  subscribe: (callback) => this._threadBinding.subscribe(callback)
@@ -3736,6 +3702,47 @@ var ThreadRuntimeImpl = class {
3736
3702
  }
3737
3703
  };
3738
3704
 
3705
+ // src/api/AssistantRuntime.ts
3706
+ var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
3707
+ constructor(_core, _thread) {
3708
+ this._core = _core;
3709
+ this._thread = _thread;
3710
+ }
3711
+ get thread() {
3712
+ return this._thread;
3713
+ }
3714
+ switchToNewThread() {
3715
+ return this._core.switchToNewThread();
3716
+ }
3717
+ switchToThread(threadId) {
3718
+ return this._core.switchToThread(threadId);
3719
+ }
3720
+ registerModelConfigProvider(provider) {
3721
+ return this._core.registerModelConfigProvider(provider);
3722
+ }
3723
+ // TODO events for thread switching
3724
+ /**
3725
+ * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
3726
+ */
3727
+ subscribe(callback) {
3728
+ return this._core.subscribe(callback);
3729
+ }
3730
+ static createThreadRuntime(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
3731
+ return new CustomThreadRuntime(
3732
+ new NestedSubscriptionSubject({
3733
+ getState: () => _core.thread,
3734
+ subscribe: (callback) => _core.subscribe(callback)
3735
+ })
3736
+ );
3737
+ }
3738
+ static create(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
3739
+ return new _AssistantRuntimeImpl(
3740
+ _core,
3741
+ _AssistantRuntimeImpl.createThreadRuntime(_core, CustomThreadRuntime)
3742
+ );
3743
+ }
3744
+ };
3745
+
3739
3746
  // src/runtimes/edge/converters/fromLanguageModelMessages.ts
3740
3747
  var fromLanguageModelMessages = (lm, { mergeSteps }) => {
3741
3748
  const messages2 = [];
@@ -4098,10 +4105,14 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
4098
4105
  this._nonTextParts = message.content.filter(
4099
4106
  (part) => part.type !== "text" && part.type !== "ui"
4100
4107
  );
4108
+ this.attachments = message.attachments ?? [];
4101
4109
  }
4102
4110
  get canCancel() {
4103
4111
  return true;
4104
4112
  }
4113
+ getAttachmentAdapter() {
4114
+ return this.runtime.adapters?.attachments;
4115
+ }
4105
4116
  _nonTextParts;
4106
4117
  _previousText;
4107
4118
  _parentId;
@@ -4123,10 +4134,107 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
4123
4134
  }
4124
4135
  };
4125
4136
 
4137
+ // src/runtimes/core/BaseThreadRuntimeCore.tsx
4138
+ var BaseThreadRuntimeCore = class {
4139
+ constructor(configProvider) {
4140
+ this.configProvider = configProvider;
4141
+ }
4142
+ _subscriptions = /* @__PURE__ */ new Set();
4143
+ repository = new MessageRepository();
4144
+ get messages() {
4145
+ return this.repository.getMessages();
4146
+ }
4147
+ composer = new DefaultThreadComposerRuntimeCore(this);
4148
+ getModelConfig() {
4149
+ return this.configProvider.getModelConfig();
4150
+ }
4151
+ _editComposers = /* @__PURE__ */ new Map();
4152
+ getEditComposer(messageId) {
4153
+ return this._editComposers.get(messageId);
4154
+ }
4155
+ beginEdit(messageId) {
4156
+ if (this._editComposers.has(messageId))
4157
+ throw new Error("Edit already in progress");
4158
+ this._editComposers.set(
4159
+ messageId,
4160
+ new DefaultEditComposerRuntimeCore(
4161
+ this,
4162
+ () => this._editComposers.delete(messageId),
4163
+ this.repository.getMessage(messageId)
4164
+ )
4165
+ );
4166
+ this.notifySubscribers();
4167
+ }
4168
+ getBranches(messageId) {
4169
+ return this.repository.getBranches(messageId);
4170
+ }
4171
+ switchToBranch(branchId) {
4172
+ this.repository.switchToBranch(branchId);
4173
+ this.notifySubscribers();
4174
+ }
4175
+ notifySubscribers() {
4176
+ for (const callback of this._subscriptions) callback();
4177
+ }
4178
+ subscribe(callback) {
4179
+ this._subscriptions.add(callback);
4180
+ return () => this._subscriptions.delete(callback);
4181
+ }
4182
+ _submittedFeedback = {};
4183
+ getSubmittedFeedback(messageId) {
4184
+ return this._submittedFeedback[messageId];
4185
+ }
4186
+ submitFeedback({ messageId, type }) {
4187
+ const adapter = this.adapters?.feedback;
4188
+ if (!adapter) throw new Error("Feedback adapter not configured");
4189
+ const { message } = this.repository.getMessage(messageId);
4190
+ adapter.submit({ message, type });
4191
+ this._submittedFeedback[messageId] = { type };
4192
+ this.notifySubscribers();
4193
+ }
4194
+ _stopSpeaking;
4195
+ speech;
4196
+ speak(messageId) {
4197
+ const adapter = this.adapters?.speech;
4198
+ if (!adapter) throw new Error("Speech adapter not configured");
4199
+ const { message } = this.repository.getMessage(messageId);
4200
+ this._stopSpeaking?.();
4201
+ const utterance = adapter.speak(message);
4202
+ const unsub = utterance.subscribe(() => {
4203
+ if (utterance.status.type === "ended") {
4204
+ this._stopSpeaking = void 0;
4205
+ this.speech = void 0;
4206
+ } else {
4207
+ this.speech = { messageId, status: utterance.status };
4208
+ }
4209
+ this.notifySubscribers();
4210
+ });
4211
+ this.speech = { messageId, status: utterance.status };
4212
+ this.notifySubscribers();
4213
+ this._stopSpeaking = () => {
4214
+ utterance.cancel();
4215
+ unsub();
4216
+ this.speech = void 0;
4217
+ this._stopSpeaking = void 0;
4218
+ };
4219
+ }
4220
+ stopSpeaking() {
4221
+ if (!this._stopSpeaking) throw new Error("No message is being spoken");
4222
+ this._stopSpeaking();
4223
+ this.notifySubscribers();
4224
+ }
4225
+ export() {
4226
+ return this.repository.export();
4227
+ }
4228
+ import(data) {
4229
+ this.repository.import(data);
4230
+ this.notifySubscribers();
4231
+ }
4232
+ };
4233
+
4126
4234
  // src/runtimes/local/LocalThreadRuntimeCore.tsx
4127
- var LocalThreadRuntimeCore = class {
4235
+ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
4128
4236
  constructor(configProvider, adapter, { initialMessages, ...options }) {
4129
- this.configProvider = configProvider;
4237
+ super(configProvider);
4130
4238
  this.adapter = adapter;
4131
4239
  this.threadId = generateId();
4132
4240
  this.options = options;
@@ -4139,28 +4247,22 @@ var LocalThreadRuntimeCore = class {
4139
4247
  }
4140
4248
  }
4141
4249
  }
4142
- _subscriptions = /* @__PURE__ */ new Set();
4143
- abortController = null;
4144
- repository = new MessageRepository();
4145
4250
  capabilities = {
4146
4251
  switchToBranch: true,
4147
4252
  edit: true,
4148
4253
  reload: true,
4149
4254
  cancel: true,
4150
4255
  unstable_copy: true,
4151
- speak: false,
4256
+ speech: false,
4152
4257
  attachments: false,
4153
4258
  feedback: false
4154
4259
  };
4260
+ abortController = null;
4155
4261
  threadId;
4156
4262
  isDisabled = false;
4157
4263
  suggestions = [];
4158
- get messages() {
4159
- return this.repository.getMessages();
4160
- }
4161
- composer = new DefaultThreadComposerRuntimeCore(this);
4162
- getModelConfig() {
4163
- return this.configProvider.getModelConfig();
4264
+ get adapters() {
4265
+ return this.options.adapters;
4164
4266
  }
4165
4267
  _options;
4166
4268
  get options() {
@@ -4173,11 +4275,10 @@ var LocalThreadRuntimeCore = class {
4173
4275
  this._options = options;
4174
4276
  let hasUpdates = false;
4175
4277
  const canSpeak = options.adapters?.speech !== void 0;
4176
- if (this.capabilities.speak !== canSpeak) {
4177
- this.capabilities.speak = canSpeak;
4278
+ if (this.capabilities.speech !== canSpeak) {
4279
+ this.capabilities.speech = canSpeak;
4178
4280
  hasUpdates = true;
4179
4281
  }
4180
- this.composer.setAttachmentAdapter(options.adapters?.attachments);
4181
4282
  const canAttach = options.adapters?.attachments !== void 0;
4182
4283
  if (this.capabilities.attachments !== canAttach) {
4183
4284
  this.capabilities.attachments = canAttach;
@@ -4190,30 +4291,6 @@ var LocalThreadRuntimeCore = class {
4190
4291
  }
4191
4292
  if (hasUpdates) this.notifySubscribers();
4192
4293
  }
4193
- _editComposers = /* @__PURE__ */ new Map();
4194
- getEditComposer(messageId) {
4195
- return this._editComposers.get(messageId);
4196
- }
4197
- beginEdit(messageId) {
4198
- if (this._editComposers.has(messageId))
4199
- throw new Error("Edit already in progress");
4200
- this._editComposers.set(
4201
- messageId,
4202
- new DefaultEditComposerRuntimeCore(
4203
- this,
4204
- () => this._editComposers.delete(messageId),
4205
- this.repository.getMessage(messageId)
4206
- )
4207
- );
4208
- this.notifySubscribers();
4209
- }
4210
- getBranches(messageId) {
4211
- return this.repository.getBranches(messageId);
4212
- }
4213
- switchToBranch(branchId) {
4214
- this.repository.switchToBranch(branchId);
4215
- this.notifySubscribers();
4216
- }
4217
4294
  async append(message) {
4218
4295
  const newMessage = fromCoreMessage(message, {
4219
4296
  attachments: message.attachments
@@ -4290,7 +4367,7 @@ var LocalThreadRuntimeCore = class {
4290
4367
  const promiseOrGenerator = this.adapter.run({
4291
4368
  messages: messages2,
4292
4369
  abortSignal: this.abortController.signal,
4293
- config: this.configProvider.getModelConfig(),
4370
+ config: this.getModelConfig(),
4294
4371
  onUpdate: updateMessage
4295
4372
  });
4296
4373
  if (Symbol.asyncIterator in promiseOrGenerator) {
@@ -4322,17 +4399,9 @@ var LocalThreadRuntimeCore = class {
4322
4399
  return message;
4323
4400
  }
4324
4401
  cancelRun() {
4325
- if (!this.abortController) return;
4326
- this.abortController.abort();
4402
+ this.abortController?.abort();
4327
4403
  this.abortController = null;
4328
4404
  }
4329
- notifySubscribers() {
4330
- for (const callback of this._subscriptions) callback();
4331
- }
4332
- subscribe(callback) {
4333
- this._subscriptions.add(callback);
4334
- return () => this._subscriptions.delete(callback);
4335
- }
4336
4405
  addToolResult({
4337
4406
  messageId,
4338
4407
  toolCallId,
@@ -4366,49 +4435,6 @@ var LocalThreadRuntimeCore = class {
4366
4435
  this.performRoundtrip(parentId, message);
4367
4436
  }
4368
4437
  }
4369
- // TODO speech runtime?
4370
- _stopSpeaking;
4371
- speech = null;
4372
- speak(messageId) {
4373
- const adapter = this.options.adapters?.speech;
4374
- if (!adapter) throw new Error("Speech adapter not configured");
4375
- const { message } = this.repository.getMessage(messageId);
4376
- this._stopSpeaking?.();
4377
- const utterance = adapter.speak(message);
4378
- const unsub = utterance.subscribe(() => {
4379
- if (utterance.status.type === "ended") {
4380
- this._stopSpeaking = void 0;
4381
- this.speech = null;
4382
- } else {
4383
- this.speech = { messageId, status: utterance.status };
4384
- }
4385
- this.notifySubscribers();
4386
- });
4387
- this.speech = { messageId, status: utterance.status };
4388
- this._stopSpeaking = () => {
4389
- utterance.cancel();
4390
- unsub();
4391
- this.speech = null;
4392
- this._stopSpeaking = void 0;
4393
- };
4394
- }
4395
- stopSpeaking() {
4396
- if (!this._stopSpeaking) throw new Error("No message is being spoken");
4397
- this._stopSpeaking();
4398
- }
4399
- submitFeedback({ messageId, type }) {
4400
- const adapter = this.options.adapters?.feedback;
4401
- if (!adapter) throw new Error("Feedback adapter not configured");
4402
- const { message } = this.repository.getMessage(messageId);
4403
- adapter.submit({ message, type });
4404
- }
4405
- export() {
4406
- return this.repository.export();
4407
- }
4408
- import(data) {
4409
- this.repository.import(data);
4410
- this.notifySubscribers();
4411
- }
4412
4438
  };
4413
4439
 
4414
4440
  // src/runtimes/local/LocalRuntimeCore.tsx
@@ -4452,14 +4478,20 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4452
4478
  };
4453
4479
 
4454
4480
  // src/runtimes/local/useLocalRuntime.tsx
4455
- var LocalRuntime = class extends AssistantRuntimeImpl {
4456
- constructor(core) {
4457
- super(core, ThreadRuntimeImpl);
4481
+ var LocalRuntimeImpl = class _LocalRuntimeImpl extends AssistantRuntimeImpl {
4482
+ constructor(core, thread) {
4483
+ super(core, thread);
4458
4484
  this.core = core;
4459
4485
  }
4460
4486
  reset(options) {
4461
4487
  this.core.reset(options);
4462
4488
  }
4489
+ static create(_core) {
4490
+ return new _LocalRuntimeImpl(
4491
+ _core,
4492
+ AssistantRuntimeImpl.createThreadRuntime(_core, ThreadRuntimeImpl)
4493
+ );
4494
+ }
4463
4495
  };
4464
4496
  var useLocalRuntime = (adapter, options = {}) => {
4465
4497
  const [runtime] = useState11(() => new LocalRuntimeCore(adapter, options));
@@ -4467,7 +4499,7 @@ var useLocalRuntime = (adapter, options = {}) => {
4467
4499
  runtime.thread.adapter = adapter;
4468
4500
  runtime.thread.options = options;
4469
4501
  });
4470
- return useMemo11(() => new LocalRuntime(runtime), [runtime]);
4502
+ return useMemo11(() => LocalRuntimeImpl.create(runtime), [runtime]);
4471
4503
  };
4472
4504
 
4473
4505
  // src/runtimes/external-store/useExternalStoreRuntime.tsx
@@ -4580,13 +4612,7 @@ var EMPTY_ARRAY2 = Object.freeze([]);
4580
4612
  var hasUpcomingMessage = (isRunning, messages2) => {
4581
4613
  return isRunning && messages2[messages2.length - 1]?.role !== "assistant";
4582
4614
  };
4583
- var ExternalStoreThreadRuntimeCore = class {
4584
- constructor(configProvider, store) {
4585
- this.configProvider = configProvider;
4586
- this.store = store;
4587
- }
4588
- _subscriptions = /* @__PURE__ */ new Set();
4589
- repository = new MessageRepository();
4615
+ var ExternalStoreThreadRuntimeCore = class extends BaseThreadRuntimeCore {
4590
4616
  assistantOptimisticId = null;
4591
4617
  _capabilities = {
4592
4618
  switchToBranch: false,
@@ -4594,7 +4620,7 @@ var ExternalStoreThreadRuntimeCore = class {
4594
4620
  reload: false,
4595
4621
  cancel: false,
4596
4622
  unstable_copy: false,
4597
- speak: false,
4623
+ speech: false,
4598
4624
  attachments: false,
4599
4625
  feedback: false
4600
4626
  };
@@ -4602,29 +4628,26 @@ var ExternalStoreThreadRuntimeCore = class {
4602
4628
  return this._capabilities;
4603
4629
  }
4604
4630
  threadId;
4605
- messages;
4631
+ _messages;
4606
4632
  isDisabled;
4633
+ get messages() {
4634
+ return this._messages;
4635
+ }
4636
+ get adapters() {
4637
+ return this._store.adapters;
4638
+ }
4607
4639
  suggestions = [];
4608
4640
  extras = void 0;
4609
4641
  _converter = new ThreadMessageConverter();
4610
4642
  _store;
4611
- composer = new DefaultThreadComposerRuntimeCore(this);
4612
- _editComposers = /* @__PURE__ */ new Map();
4613
- getEditComposer(messageId) {
4614
- return this._editComposers.get(messageId);
4615
- }
4616
4643
  beginEdit(messageId) {
4617
- if (this._editComposers.has(messageId))
4618
- throw new Error("Edit already in progress");
4619
- this._editComposers.set(
4620
- messageId,
4621
- new DefaultEditComposerRuntimeCore(
4622
- this,
4623
- () => this._editComposers.delete(messageId),
4624
- this.repository.getMessage(messageId)
4625
- )
4626
- );
4627
- this.notifySubscribers();
4644
+ if (!this.store.onEdit)
4645
+ throw new Error("Runtime does not support editing.");
4646
+ super.beginEdit(messageId);
4647
+ }
4648
+ constructor(configProvider, store) {
4649
+ super(configProvider);
4650
+ this.store = store;
4628
4651
  }
4629
4652
  get store() {
4630
4653
  return this._store;
@@ -4643,13 +4666,12 @@ var ExternalStoreThreadRuntimeCore = class {
4643
4666
  edit: this._store.onEdit !== void 0,
4644
4667
  reload: this._store.onReload !== void 0,
4645
4668
  cancel: this._store.onCancel !== void 0,
4646
- speak: this._store.onSpeak !== void 0,
4669
+ speech: this._store.adapters?.speech !== void 0,
4647
4670
  unstable_copy: this._store.unstable_capabilities?.copy !== false,
4648
4671
  // default true
4649
4672
  attachments: !!this.store.adapters?.attachments,
4650
4673
  feedback: !!this.store.adapters?.feedback
4651
4674
  };
4652
- this.composer.setAttachmentAdapter(this._store.adapters?.attachments);
4653
4675
  if (oldStore) {
4654
4676
  if (oldStore.convertMessage !== store.convertMessage) {
4655
4677
  this._converter = new ThreadMessageConverter();
@@ -4693,18 +4715,9 @@ var ExternalStoreThreadRuntimeCore = class {
4693
4715
  this.repository.resetHead(
4694
4716
  this.assistantOptimisticId ?? messages2.at(-1)?.id ?? null
4695
4717
  );
4696
- this.messages = this.repository.getMessages();
4718
+ this._messages = this.repository.getMessages();
4697
4719
  this.notifySubscribers();
4698
4720
  }
4699
- getModelConfig() {
4700
- return this.configProvider.getModelConfig();
4701
- }
4702
- notifySubscribers() {
4703
- for (const callback of this._subscriptions) callback();
4704
- }
4705
- getBranches(messageId) {
4706
- return this.repository.getBranches(messageId);
4707
- }
4708
4721
  switchToBranch(branchId) {
4709
4722
  if (!this._store.setMessages)
4710
4723
  throw new Error("Runtime does not support switching branches.");
@@ -4753,60 +4766,11 @@ var ExternalStoreThreadRuntimeCore = class {
4753
4766
  throw new Error("Runtime does not support tool results.");
4754
4767
  this._store.onAddToolResult(options);
4755
4768
  }
4756
- // TODO speech runtime?
4757
- _stopSpeaking;
4758
- speech = null;
4759
- speak(messageId) {
4760
- let adapter = this.store.adapters?.speech;
4761
- if (!adapter && this.store.onSpeak) {
4762
- adapter = { speak: this.store.onSpeak };
4763
- }
4764
- if (!adapter) throw new Error("Speech adapter not configured");
4765
- const { message } = this.repository.getMessage(messageId);
4766
- this._stopSpeaking?.();
4767
- const utterance = adapter.speak(message);
4768
- const unsub = utterance.subscribe(() => {
4769
- if (utterance.status.type === "ended") {
4770
- this._stopSpeaking = void 0;
4771
- this.speech = null;
4772
- } else {
4773
- this.speech = { messageId, status: utterance.status };
4774
- }
4775
- this.notifySubscribers();
4776
- });
4777
- this.speech = { messageId, status: utterance.status };
4778
- this._stopSpeaking = () => {
4779
- utterance.cancel();
4780
- unsub();
4781
- this.speech = null;
4782
- this._stopSpeaking = void 0;
4783
- };
4784
- }
4785
- stopSpeaking() {
4786
- if (!this._stopSpeaking) throw new Error("No message is being spoken");
4787
- this._stopSpeaking();
4788
- }
4789
- submitFeedback({ messageId, type }) {
4790
- const adapter = this._store.adapters?.feedback;
4791
- if (!adapter) throw new Error("Feedback adapter not configured");
4792
- const { message } = this.repository.getMessage(messageId);
4793
- adapter.submit({ message, type });
4794
- }
4795
- subscribe(callback) {
4796
- this._subscriptions.add(callback);
4797
- return () => this._subscriptions.delete(callback);
4798
- }
4799
4769
  updateMessages = (messages2) => {
4800
4770
  this._store.setMessages?.(
4801
4771
  messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
4802
4772
  );
4803
4773
  };
4804
- import(repository) {
4805
- this.repository.import(repository);
4806
- }
4807
- export() {
4808
- return this.repository.export();
4809
- }
4810
4774
  };
4811
4775
 
4812
4776
  // src/runtimes/external-store/ExternalStoreRuntimeCore.tsx
@@ -4861,7 +4825,7 @@ var useExternalStoreRuntime = (store) => {
4861
4825
  runtime.thread.store = store;
4862
4826
  });
4863
4827
  return useMemo12(
4864
- () => new AssistantRuntimeImpl(runtime, ThreadRuntimeImpl),
4828
+ () => AssistantRuntimeImpl.create(runtime, ThreadRuntimeImpl),
4865
4829
  [runtime]
4866
4830
  );
4867
4831
  };
@@ -5281,8 +5245,8 @@ var useAllowCopy = (ensureCapability = false) => {
5281
5245
  };
5282
5246
  var useAllowSpeak = (ensureCapability = false) => {
5283
5247
  const { assistantMessage: { allowSpeak = true } = {} } = useThreadConfig();
5284
- const speakSupported = useThread((t) => t.capabilities.speak);
5285
- return allowSpeak && (!ensureCapability || speakSupported);
5248
+ const speechSupported = useThread((t) => t.capabilities.speech);
5249
+ return allowSpeak && (!ensureCapability || speechSupported);
5286
5250
  };
5287
5251
  var useAllowReload = (ensureCapability = false) => {
5288
5252
  const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();
@@ -5598,15 +5562,15 @@ var assistant_message_default = Object.assign(
5598
5562
  );
5599
5563
 
5600
5564
  // src/ui/assistant-modal.tsx
5601
- import { forwardRef as forwardRef34 } from "react";
5565
+ import { forwardRef as forwardRef35 } from "react";
5602
5566
  import { BotIcon, ChevronDownIcon } from "lucide-react";
5603
5567
 
5604
5568
  // src/ui/thread.tsx
5605
- import { forwardRef as forwardRef33 } from "react";
5569
+ import { forwardRef as forwardRef34 } from "react";
5606
5570
  import { ArrowDownIcon } from "lucide-react";
5607
5571
 
5608
5572
  // src/ui/composer.tsx
5609
- import { forwardRef as forwardRef28 } from "react";
5573
+ import { forwardRef as forwardRef29 } from "react";
5610
5574
  import { PaperclipIcon, SendHorizontalIcon } from "lucide-react";
5611
5575
 
5612
5576
  // src/ui/base/CircleStopIcon.tsx
@@ -5626,51 +5590,171 @@ var CircleStopIcon = () => {
5626
5590
  };
5627
5591
  CircleStopIcon.displayName = "CircleStopIcon";
5628
5592
 
5629
- // src/ui/composer-attachment.tsx
5630
- import { forwardRef as forwardRef27 } from "react";
5631
- import { CircleXIcon } from "lucide-react";
5593
+ // src/ui/attachment.tsx
5594
+ import {
5595
+ forwardRef as forwardRef28,
5596
+ useEffect as useEffect15,
5597
+ useState as useState14
5598
+ } from "react";
5599
+ import { CircleXIcon, FileIcon } from "lucide-react";
5600
+
5601
+ // src/ui/base/dialog.tsx
5602
+ import * as React from "react";
5603
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
5604
+ import classNames3 from "classnames";
5632
5605
  import { jsx as jsx45, jsxs as jsxs8 } from "react/jsx-runtime";
5633
- var ComposerAttachmentRoot = withDefaults(attachment_exports.Root, {
5634
- className: "aui-composer-attachment-root"
5606
+ var Dialog = DialogPrimitive.Root;
5607
+ var DialogTrigger = DialogPrimitive.Trigger;
5608
+ var DialogPortal = DialogPrimitive.Portal;
5609
+ var DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx45(
5610
+ DialogPrimitive.Overlay,
5611
+ {
5612
+ ref,
5613
+ className: classNames3("aui-dialog-overlay", className),
5614
+ ...props
5615
+ }
5616
+ ));
5617
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
5618
+ var DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs8(DialogPortal, { children: [
5619
+ /* @__PURE__ */ jsx45(DialogOverlay, {}),
5620
+ /* @__PURE__ */ jsx45(
5621
+ DialogPrimitive.Content,
5622
+ {
5623
+ ref,
5624
+ className: classNames3("aui-dialog-content", className),
5625
+ ...props,
5626
+ children
5627
+ }
5628
+ )
5629
+ ] }));
5630
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
5631
+
5632
+ // src/ui/attachment.tsx
5633
+ import { AvatarFallback as AvatarFallback2 } from "@radix-ui/react-avatar";
5634
+ import { jsx as jsx46, jsxs as jsxs9 } from "react/jsx-runtime";
5635
+ var AttachmentRoot = withDefaults(attachment_exports.Root, {
5636
+ className: "aui-attachment-root"
5635
5637
  });
5636
- ComposerAttachmentRoot.displayName = "ComposerAttachmentRoot";
5637
- var ComposerAttachment2 = () => {
5638
- return /* @__PURE__ */ jsxs8(ComposerAttachmentRoot, { children: [
5639
- /* @__PURE__ */ jsx45(attachment_exports.unstable_Thumb, {}),
5640
- /* @__PURE__ */ jsx45(ComposerAttachmentRemove, {})
5638
+ AttachmentRoot.displayName = "AttachmentRoot";
5639
+ var useFileSrc = (file) => {
5640
+ const [src, setSrc] = useState14(void 0);
5641
+ useEffect15(() => {
5642
+ if (!file) {
5643
+ setSrc(void 0);
5644
+ return;
5645
+ }
5646
+ const objectUrl = URL.createObjectURL(file);
5647
+ setSrc(objectUrl);
5648
+ return () => {
5649
+ URL.revokeObjectURL(objectUrl);
5650
+ };
5651
+ }, [file]);
5652
+ return src;
5653
+ };
5654
+ var useAttachmentSrc = () => {
5655
+ const { file, src } = useAttachment((a) => {
5656
+ if (a.type !== "image") return {};
5657
+ if (a.file) return { file: a.file };
5658
+ const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
5659
+ if (!src2) return {};
5660
+ return { src: src2 };
5661
+ });
5662
+ return useFileSrc(file) ?? src;
5663
+ };
5664
+ var AttachmentPreview = ({ src }) => {
5665
+ const [isLoaded, setIsLoaded] = useState14(false);
5666
+ return (
5667
+ // eslint-disable-next-line @next/next/no-img-element
5668
+ /* @__PURE__ */ jsx46(
5669
+ "img",
5670
+ {
5671
+ src,
5672
+ style: {
5673
+ width: "auto",
5674
+ height: "auto",
5675
+ maxWidth: "75dvh",
5676
+ maxHeight: "75dvh",
5677
+ display: isLoaded ? "block" : "none",
5678
+ overflow: "clip"
5679
+ },
5680
+ onLoad: () => setIsLoaded(true),
5681
+ alt: "Image Preview"
5682
+ }
5683
+ )
5684
+ );
5685
+ };
5686
+ var AttachmentPreviewDialog = ({ children }) => {
5687
+ const src = useAttachmentSrc();
5688
+ if (!src) return children;
5689
+ return /* @__PURE__ */ jsxs9(Dialog, { children: [
5690
+ /* @__PURE__ */ jsx46(DialogTrigger, { className: "aui-attachment-preview-trigger", asChild: true, children }),
5691
+ /* @__PURE__ */ jsx46(DialogContent, { children: /* @__PURE__ */ jsx46(AttachmentPreview, { src }) })
5692
+ ] });
5693
+ };
5694
+ var AttachmentThumb = () => {
5695
+ const isImage = useAttachment((a) => a.type === "image");
5696
+ const src = useAttachmentSrc();
5697
+ return /* @__PURE__ */ jsxs9(AvatarRoot, { className: "aui-attachment-thumb", children: [
5698
+ /* @__PURE__ */ jsx46(AvatarFallback2, { delayMs: isImage ? 200 : 0, children: /* @__PURE__ */ jsx46(FileIcon, {}) }),
5699
+ /* @__PURE__ */ jsx46(AvatarImage, { src })
5641
5700
  ] });
5642
5701
  };
5643
- ComposerAttachment2.displayName = "ComposerAttachment";
5644
- var ComposerAttachmentRemove = forwardRef27((props, ref) => {
5702
+ var Attachment = () => {
5703
+ const canRemove = useAttachment((a) => a.source !== "message");
5704
+ const typeLabel = useAttachment((a) => {
5705
+ const type = a.type;
5706
+ switch (type) {
5707
+ case "image":
5708
+ return "Image";
5709
+ case "document":
5710
+ return "Document";
5711
+ case "file":
5712
+ return "File";
5713
+ default:
5714
+ const _exhaustiveCheck = type;
5715
+ throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
5716
+ }
5717
+ });
5718
+ return /* @__PURE__ */ jsxs9(Tooltip, { children: [
5719
+ /* @__PURE__ */ jsx46(AttachmentPreviewDialog, { children: /* @__PURE__ */ jsx46(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxs9(AttachmentRoot, { children: [
5720
+ /* @__PURE__ */ jsx46(AttachmentThumb, {}),
5721
+ /* @__PURE__ */ jsxs9("div", { className: "aui-attachment-text", children: [
5722
+ /* @__PURE__ */ jsx46("p", { className: "aui-attachment-name", children: /* @__PURE__ */ jsx46(attachment_exports.Name, {}) }),
5723
+ /* @__PURE__ */ jsx46("p", { className: "aui-attachment-type", children: typeLabel })
5724
+ ] }),
5725
+ canRemove && /* @__PURE__ */ jsx46(AttachmentRemove, {})
5726
+ ] }) }) }),
5727
+ /* @__PURE__ */ jsx46(TooltipContent, { side: "top", children: /* @__PURE__ */ jsx46(attachment_exports.Name, {}) })
5728
+ ] });
5729
+ };
5730
+ Attachment.displayName = "Attachment";
5731
+ var AttachmentRemove = forwardRef28((props, ref) => {
5645
5732
  const {
5646
5733
  strings: {
5647
5734
  composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
5648
5735
  } = {}
5649
5736
  } = useThreadConfig();
5650
- return /* @__PURE__ */ jsx45(attachment_exports.Remove, { asChild: true, children: /* @__PURE__ */ jsx45(
5737
+ return /* @__PURE__ */ jsx46(attachment_exports.Remove, { asChild: true, children: /* @__PURE__ */ jsx46(
5651
5738
  TooltipIconButton,
5652
5739
  {
5653
5740
  tooltip,
5654
- className: "aui-composer-attachment-remove",
5741
+ className: "aui-attachment-remove",
5655
5742
  side: "top",
5656
5743
  ...props,
5657
5744
  ref,
5658
- children: props.children ?? /* @__PURE__ */ jsx45(CircleXIcon, {})
5745
+ children: props.children ?? /* @__PURE__ */ jsx46(CircleXIcon, {})
5659
5746
  }
5660
5747
  ) });
5661
5748
  });
5662
- ComposerAttachmentRemove.displayName = "ComposerAttachmentRemove";
5749
+ AttachmentRemove.displayName = "AttachmentRemove";
5663
5750
  var exports5 = {
5664
- Root: ComposerAttachmentRoot,
5665
- Remove: ComposerAttachmentRemove
5751
+ Root: AttachmentRoot,
5752
+ Remove: AttachmentRemove
5666
5753
  };
5667
- var composer_attachment_default = Object.assign(
5668
- ComposerAttachment2,
5669
- exports5
5670
- );
5754
+ var attachment_default = Object.assign(Attachment, exports5);
5671
5755
 
5672
5756
  // src/ui/composer.tsx
5673
- import { Fragment as Fragment6, jsx as jsx46, jsxs as jsxs9 } from "react/jsx-runtime";
5757
+ import { Fragment as Fragment6, jsx as jsx47, jsxs as jsxs10 } from "react/jsx-runtime";
5674
5758
  var useAllowAttachments = (ensureCapability = false) => {
5675
5759
  const { composer: { allowAttachments = true } = {} } = useThreadConfig();
5676
5760
  const attachmentsSupported = useThread((t) => t.capabilities.attachments);
@@ -5678,11 +5762,11 @@ var useAllowAttachments = (ensureCapability = false) => {
5678
5762
  };
5679
5763
  var Composer = () => {
5680
5764
  const allowAttachments = useAllowAttachments(true);
5681
- return /* @__PURE__ */ jsxs9(ComposerRoot, { children: [
5682
- allowAttachments && /* @__PURE__ */ jsx46(ComposerAttachments, {}),
5683
- allowAttachments && /* @__PURE__ */ jsx46(ComposerAddAttachment, {}),
5684
- /* @__PURE__ */ jsx46(ComposerInput, { autoFocus: true }),
5685
- /* @__PURE__ */ jsx46(ComposerAction, {})
5765
+ return /* @__PURE__ */ jsxs10(ComposerRoot, { children: [
5766
+ allowAttachments && /* @__PURE__ */ jsx47(ComposerAttachments, {}),
5767
+ allowAttachments && /* @__PURE__ */ jsx47(ComposerAddAttachment, {}),
5768
+ /* @__PURE__ */ jsx47(ComposerInput, { autoFocus: true }),
5769
+ /* @__PURE__ */ jsx47(ComposerAction, {})
5686
5770
  ] });
5687
5771
  };
5688
5772
  Composer.displayName = "Composer";
@@ -5695,14 +5779,14 @@ var ComposerInputStyled = withDefaults(composer_exports.Input, {
5695
5779
  autoFocus: true,
5696
5780
  className: "aui-composer-input"
5697
5781
  });
5698
- var ComposerInput = forwardRef28(
5782
+ var ComposerInput = forwardRef29(
5699
5783
  (props, ref) => {
5700
5784
  const {
5701
5785
  strings: {
5702
5786
  composer: { input: { placeholder = "Write a message..." } = {} } = {}
5703
5787
  } = {}
5704
5788
  } = useThreadConfig();
5705
- return /* @__PURE__ */ jsx46(ComposerInputStyled, { placeholder, ...props, ref });
5789
+ return /* @__PURE__ */ jsx47(ComposerInputStyled, { placeholder, ...props, ref });
5706
5790
  }
5707
5791
  );
5708
5792
  ComposerInput.displayName = "ComposerInput";
@@ -5710,12 +5794,12 @@ var ComposerAttachmentsContainer = withDefaults("div", {
5710
5794
  className: "aui-composer-attachments"
5711
5795
  });
5712
5796
  var ComposerAttachments = ({ components }) => {
5713
- return /* @__PURE__ */ jsx46(ComposerAttachmentsContainer, { children: /* @__PURE__ */ jsx46(
5797
+ return /* @__PURE__ */ jsx47(ComposerAttachmentsContainer, { children: /* @__PURE__ */ jsx47(
5714
5798
  composer_exports.Attachments,
5715
5799
  {
5716
5800
  components: {
5717
5801
  ...components,
5718
- Attachment: components?.Attachment ?? composer_attachment_default
5802
+ Attachment: components?.Attachment ?? attachment_default
5719
5803
  }
5720
5804
  }
5721
5805
  ) });
@@ -5724,21 +5808,21 @@ var ComposerAttachButton = withDefaults(TooltipIconButton, {
5724
5808
  variant: "default",
5725
5809
  className: "aui-composer-attach"
5726
5810
  });
5727
- var ComposerAddAttachment = forwardRef28((props, ref) => {
5811
+ var ComposerAddAttachment = forwardRef29((props, ref) => {
5728
5812
  const {
5729
5813
  strings: {
5730
5814
  composer: { addAttachment: { tooltip = "Attach file" } = {} } = {}
5731
5815
  } = {}
5732
5816
  } = useThreadConfig();
5733
5817
  const allowAttachments = useAllowAttachments();
5734
- return /* @__PURE__ */ jsx46(composer_exports.AddAttachment, { disabled: !allowAttachments, asChild: true, children: /* @__PURE__ */ jsx46(
5818
+ return /* @__PURE__ */ jsx47(composer_exports.AddAttachment, { disabled: !allowAttachments, asChild: true, children: /* @__PURE__ */ jsx47(
5735
5819
  ComposerAttachButton,
5736
5820
  {
5737
5821
  tooltip,
5738
5822
  variant: "ghost",
5739
5823
  ...props,
5740
5824
  ref,
5741
- children: props.children ?? /* @__PURE__ */ jsx46(PaperclipIcon, {})
5825
+ children: props.children ?? /* @__PURE__ */ jsx47(PaperclipIcon, {})
5742
5826
  }
5743
5827
  ) });
5744
5828
  });
@@ -5749,10 +5833,10 @@ var useAllowCancel = () => {
5749
5833
  };
5750
5834
  var ComposerAction = () => {
5751
5835
  const allowCancel = useAllowCancel();
5752
- if (!allowCancel) return /* @__PURE__ */ jsx46(ComposerSend, {});
5753
- return /* @__PURE__ */ jsxs9(Fragment6, { children: [
5754
- /* @__PURE__ */ jsx46(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx46(ComposerSend, {}) }),
5755
- /* @__PURE__ */ jsx46(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx46(ComposerCancel, {}) })
5836
+ if (!allowCancel) return /* @__PURE__ */ jsx47(ComposerSend, {});
5837
+ return /* @__PURE__ */ jsxs10(Fragment6, { children: [
5838
+ /* @__PURE__ */ jsx47(thread_exports.If, { running: false, children: /* @__PURE__ */ jsx47(ComposerSend, {}) }),
5839
+ /* @__PURE__ */ jsx47(thread_exports.If, { running: true, children: /* @__PURE__ */ jsx47(ComposerCancel, {}) })
5756
5840
  ] });
5757
5841
  };
5758
5842
  ComposerAction.displayName = "ComposerAction";
@@ -5760,12 +5844,12 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
5760
5844
  variant: "default",
5761
5845
  className: "aui-composer-send"
5762
5846
  });
5763
- var ComposerSend = forwardRef28(
5847
+ var ComposerSend = forwardRef29(
5764
5848
  (props, ref) => {
5765
5849
  const {
5766
5850
  strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
5767
5851
  } = useThreadConfig();
5768
- return /* @__PURE__ */ jsx46(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx46(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx46(SendHorizontalIcon, {}) }) });
5852
+ return /* @__PURE__ */ jsx47(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx47(ComposerSendButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx47(SendHorizontalIcon, {}) }) });
5769
5853
  }
5770
5854
  );
5771
5855
  ComposerSend.displayName = "ComposerSend";
@@ -5773,12 +5857,12 @@ var ComposerCancelButton = withDefaults(TooltipIconButton, {
5773
5857
  variant: "default",
5774
5858
  className: "aui-composer-cancel"
5775
5859
  });
5776
- var ComposerCancel = forwardRef28(
5860
+ var ComposerCancel = forwardRef29(
5777
5861
  (props, ref) => {
5778
5862
  const {
5779
5863
  strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
5780
5864
  } = useThreadConfig();
5781
- return /* @__PURE__ */ jsx46(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx46(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx46(CircleStopIcon, {}) }) });
5865
+ return /* @__PURE__ */ jsx47(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx47(ComposerCancelButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx47(CircleStopIcon, {}) }) });
5782
5866
  }
5783
5867
  );
5784
5868
  ComposerCancel.displayName = "ComposerCancel";
@@ -5794,15 +5878,15 @@ var exports6 = {
5794
5878
  var composer_default = Object.assign(Composer, exports6);
5795
5879
 
5796
5880
  // src/ui/thread-welcome.tsx
5797
- import { forwardRef as forwardRef29 } from "react";
5798
- import { jsx as jsx47, jsxs as jsxs10 } from "react/jsx-runtime";
5881
+ import { forwardRef as forwardRef30 } from "react";
5882
+ import { jsx as jsx48, jsxs as jsxs11 } from "react/jsx-runtime";
5799
5883
  var ThreadWelcome = () => {
5800
- return /* @__PURE__ */ jsxs10(ThreadWelcomeRoot, { children: [
5801
- /* @__PURE__ */ jsxs10(ThreadWelcomeCenter, { children: [
5802
- /* @__PURE__ */ jsx47(ThreadWelcomeAvatar, {}),
5803
- /* @__PURE__ */ jsx47(ThreadWelcomeMessage, {})
5884
+ return /* @__PURE__ */ jsxs11(ThreadWelcomeRoot, { children: [
5885
+ /* @__PURE__ */ jsxs11(ThreadWelcomeCenter, { children: [
5886
+ /* @__PURE__ */ jsx48(ThreadWelcomeAvatar, {}),
5887
+ /* @__PURE__ */ jsx48(ThreadWelcomeMessage, {})
5804
5888
  ] }),
5805
- /* @__PURE__ */ jsx47(ThreadWelcomeSuggestions, {})
5889
+ /* @__PURE__ */ jsx48(ThreadWelcomeSuggestions, {})
5806
5890
  ] });
5807
5891
  };
5808
5892
  ThreadWelcome.displayName = "ThreadWelcome";
@@ -5812,20 +5896,20 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
5812
5896
  var ThreadWelcomeCenter = withDefaults("div", {
5813
5897
  className: "aui-thread-welcome-center"
5814
5898
  });
5815
- var ThreadWelcomeRoot = forwardRef29((props, ref) => {
5816
- return /* @__PURE__ */ jsx47(thread_exports.Empty, { children: /* @__PURE__ */ jsx47(ThreadWelcomeRootStyled, { ...props, ref }) });
5899
+ var ThreadWelcomeRoot = forwardRef30((props, ref) => {
5900
+ return /* @__PURE__ */ jsx48(thread_exports.Empty, { children: /* @__PURE__ */ jsx48(ThreadWelcomeRootStyled, { ...props, ref }) });
5817
5901
  });
5818
5902
  ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
5819
5903
  var ThreadWelcomeAvatar = () => {
5820
5904
  const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
5821
- return /* @__PURE__ */ jsx47(Avatar, { ...avatar });
5905
+ return /* @__PURE__ */ jsx48(Avatar, { ...avatar });
5822
5906
  };
5823
5907
  var ThreadWelcomeMessageStyled = withDefaults("p", {
5824
5908
  className: "aui-thread-welcome-message"
5825
5909
  });
5826
- var ThreadWelcomeMessage = forwardRef29(({ message: messageProp, ...rest }, ref) => {
5910
+ var ThreadWelcomeMessage = forwardRef30(({ message: messageProp, ...rest }, ref) => {
5827
5911
  const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
5828
- return /* @__PURE__ */ jsx47(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
5912
+ return /* @__PURE__ */ jsx48(ThreadWelcomeMessageStyled, { ...rest, ref, children: messageProp ?? message });
5829
5913
  });
5830
5914
  ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
5831
5915
  var ThreadWelcomeSuggestionContainer = withDefaults("div", {
@@ -5837,15 +5921,15 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
5837
5921
  var ThreadWelcomeSuggestion = ({
5838
5922
  suggestion: { text, prompt }
5839
5923
  }) => {
5840
- return /* @__PURE__ */ jsx47(ThreadWelcomeSuggestionStyled, { prompt, method: "replace", autoSend: true, children: /* @__PURE__ */ jsx47("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt }) });
5924
+ return /* @__PURE__ */ jsx48(ThreadWelcomeSuggestionStyled, { prompt, method: "replace", autoSend: true, children: /* @__PURE__ */ jsx48("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt }) });
5841
5925
  };
5842
5926
  var ThreadWelcomeSuggestions = () => {
5843
5927
  const suggestions2 = useThread((t) => t.suggestions);
5844
5928
  const { welcome: { suggestions } = {} } = useThreadConfig();
5845
5929
  const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
5846
- return /* @__PURE__ */ jsx47(ThreadWelcomeSuggestionContainer, { children: finalSuggestions?.map((suggestion, idx) => {
5930
+ return /* @__PURE__ */ jsx48(ThreadWelcomeSuggestionContainer, { children: finalSuggestions?.map((suggestion, idx) => {
5847
5931
  const key = `${suggestion.prompt}-${idx}`;
5848
- return /* @__PURE__ */ jsx47(ThreadWelcomeSuggestion, { suggestion }, key);
5932
+ return /* @__PURE__ */ jsx48(ThreadWelcomeSuggestion, { suggestion }, key);
5849
5933
  }) });
5850
5934
  };
5851
5935
  ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
@@ -5860,12 +5944,12 @@ var exports7 = {
5860
5944
  var thread_welcome_default = Object.assign(ThreadWelcome, exports7);
5861
5945
 
5862
5946
  // src/ui/user-message.tsx
5863
- import { forwardRef as forwardRef31 } from "react";
5947
+ import { forwardRef as forwardRef32 } from "react";
5864
5948
 
5865
5949
  // src/ui/user-action-bar.tsx
5866
- import { forwardRef as forwardRef30 } from "react";
5950
+ import { forwardRef as forwardRef31 } from "react";
5867
5951
  import { PencilIcon } from "lucide-react";
5868
- import { jsx as jsx48 } from "react/jsx-runtime";
5952
+ import { jsx as jsx49 } from "react/jsx-runtime";
5869
5953
  var useAllowEdit = (ensureCapability = false) => {
5870
5954
  const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
5871
5955
  const editSupported = useThread((t) => t.capabilities.edit);
@@ -5874,19 +5958,19 @@ var useAllowEdit = (ensureCapability = false) => {
5874
5958
  var UserActionBar = () => {
5875
5959
  const allowEdit = useAllowEdit(true);
5876
5960
  if (!allowEdit) return null;
5877
- return /* @__PURE__ */ jsx48(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx48(UserActionBarEdit, {}) });
5961
+ return /* @__PURE__ */ jsx49(UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ jsx49(UserActionBarEdit, {}) });
5878
5962
  };
5879
5963
  UserActionBar.displayName = "UserActionBar";
5880
5964
  var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
5881
5965
  className: "aui-user-action-bar-root"
5882
5966
  });
5883
5967
  UserActionBarRoot.displayName = "UserActionBarRoot";
5884
- var UserActionBarEdit = forwardRef30((props, ref) => {
5968
+ var UserActionBarEdit = forwardRef31((props, ref) => {
5885
5969
  const {
5886
5970
  strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
5887
5971
  } = useThreadConfig();
5888
5972
  const allowEdit = useAllowEdit();
5889
- return /* @__PURE__ */ jsx48(actionBar_exports.Edit, { disabled: !allowEdit, asChild: true, children: /* @__PURE__ */ jsx48(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx48(PencilIcon, {}) }) });
5973
+ return /* @__PURE__ */ jsx49(actionBar_exports.Edit, { disabled: !allowEdit, asChild: true, children: /* @__PURE__ */ jsx49(TooltipIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx49(PencilIcon, {}) }) });
5890
5974
  });
5891
5975
  UserActionBarEdit.displayName = "UserActionBarEdit";
5892
5976
  var exports8 = {
@@ -5895,31 +5979,15 @@ var exports8 = {
5895
5979
  };
5896
5980
  var user_action_bar_default = Object.assign(UserActionBar, exports8);
5897
5981
 
5898
- // src/ui/user-message-attachment.tsx
5899
- import { jsx as jsx49 } from "react/jsx-runtime";
5900
- var UserMessageAttachmentRoot = withDefaults(attachment_exports.Root, {
5901
- className: "aui-user-message-attachment-root"
5902
- });
5903
- UserMessageAttachmentRoot.displayName = "UserMessageAttachmentRoot";
5904
- var UserMessageAttachment = () => {
5905
- return /* @__PURE__ */ jsx49(UserMessageAttachmentRoot, { children: /* @__PURE__ */ jsx49(attachment_exports.unstable_Thumb, {}) });
5906
- };
5907
- UserMessageAttachment.displayName = "UserMessageAttachment";
5908
- var exports9 = {
5909
- Root: UserMessageAttachmentRoot
5910
- };
5911
- var user_message_attachment_default = Object.assign(
5912
- UserMessageAttachment,
5913
- exports9
5914
- );
5915
-
5916
5982
  // src/ui/user-message.tsx
5917
- import { jsx as jsx50, jsxs as jsxs11 } from "react/jsx-runtime";
5983
+ import { jsx as jsx50, jsxs as jsxs12 } from "react/jsx-runtime";
5918
5984
  var UserMessage = () => {
5919
- return /* @__PURE__ */ jsxs11(UserMessageRoot, { children: [
5985
+ return /* @__PURE__ */ jsxs12(UserMessageRoot, { children: [
5920
5986
  /* @__PURE__ */ jsx50(UserMessageAttachments, {}),
5921
- /* @__PURE__ */ jsx50(user_action_bar_default, {}),
5922
- /* @__PURE__ */ jsx50(UserMessageContent, {}),
5987
+ /* @__PURE__ */ jsxs12(message_exports.If, { hasContent: true, children: [
5988
+ /* @__PURE__ */ jsx50(user_action_bar_default, {}),
5989
+ /* @__PURE__ */ jsx50(UserMessageContent, {})
5990
+ ] }),
5923
5991
  /* @__PURE__ */ jsx50(branch_picker_default, {})
5924
5992
  ] });
5925
5993
  };
@@ -5931,7 +5999,7 @@ UserMessageRoot.displayName = "UserMessageRoot";
5931
5999
  var UserMessageContentWrapper = withDefaults("div", {
5932
6000
  className: "aui-user-message-content"
5933
6001
  });
5934
- var UserMessageContent = forwardRef31(({ components, ...props }, ref) => {
6002
+ var UserMessageContent = forwardRef32(({ components, ...props }, ref) => {
5935
6003
  return /* @__PURE__ */ jsx50(UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ jsx50(
5936
6004
  message_exports.Content,
5937
6005
  {
@@ -5954,25 +6022,25 @@ var UserMessageAttachments = ({
5954
6022
  {
5955
6023
  components: {
5956
6024
  ...components,
5957
- Attachment: components?.Attachment ?? user_message_attachment_default
6025
+ Attachment: components?.Attachment ?? attachment_default
5958
6026
  }
5959
6027
  }
5960
6028
  ) }) });
5961
6029
  };
5962
- var exports10 = {
6030
+ var exports9 = {
5963
6031
  Root: UserMessageRoot,
5964
6032
  Content: UserMessageContent,
5965
6033
  Attachments: UserMessageAttachments
5966
6034
  };
5967
- var user_message_default = Object.assign(UserMessage, exports10);
6035
+ var user_message_default = Object.assign(UserMessage, exports9);
5968
6036
 
5969
6037
  // src/ui/edit-composer.tsx
5970
- import { forwardRef as forwardRef32 } from "react";
5971
- import { jsx as jsx51, jsxs as jsxs12 } from "react/jsx-runtime";
6038
+ import { forwardRef as forwardRef33 } from "react";
6039
+ import { jsx as jsx51, jsxs as jsxs13 } from "react/jsx-runtime";
5972
6040
  var EditComposer = () => {
5973
- return /* @__PURE__ */ jsxs12(EditComposerRoot, { children: [
6041
+ return /* @__PURE__ */ jsxs13(EditComposerRoot, { children: [
5974
6042
  /* @__PURE__ */ jsx51(EditComposerInput, {}),
5975
- /* @__PURE__ */ jsxs12(EditComposerFooter, { children: [
6043
+ /* @__PURE__ */ jsxs13(EditComposerFooter, { children: [
5976
6044
  /* @__PURE__ */ jsx51(EditComposerCancel, {}),
5977
6045
  /* @__PURE__ */ jsx51(EditComposerSend, {})
5978
6046
  ] })
@@ -5991,31 +6059,31 @@ var EditComposerFooter = withDefaults("div", {
5991
6059
  className: "aui-edit-composer-footer"
5992
6060
  });
5993
6061
  EditComposerFooter.displayName = "EditComposerFooter";
5994
- var EditComposerCancel = forwardRef32((props, ref) => {
6062
+ var EditComposerCancel = forwardRef33((props, ref) => {
5995
6063
  const {
5996
6064
  strings: { editComposer: { cancel: { label = "Cancel" } = {} } = {} } = {}
5997
6065
  } = useThreadConfig();
5998
6066
  return /* @__PURE__ */ jsx51(composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ jsx51(Button, { variant: "ghost", ...props, ref, children: props.children ?? label }) });
5999
6067
  });
6000
6068
  EditComposerCancel.displayName = "EditComposerCancel";
6001
- var EditComposerSend = forwardRef32((props, ref) => {
6069
+ var EditComposerSend = forwardRef33((props, ref) => {
6002
6070
  const {
6003
6071
  strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
6004
6072
  } = useThreadConfig();
6005
6073
  return /* @__PURE__ */ jsx51(composer_exports.Send, { asChild: true, children: /* @__PURE__ */ jsx51(Button, { ...props, ref, children: props.children ?? label }) });
6006
6074
  });
6007
6075
  EditComposerSend.displayName = "EditComposerSend";
6008
- var exports11 = {
6076
+ var exports10 = {
6009
6077
  Root: EditComposerRoot,
6010
6078
  Input: EditComposerInput,
6011
6079
  Footer: EditComposerFooter,
6012
6080
  Cancel: EditComposerCancel,
6013
6081
  Send: EditComposerSend
6014
6082
  };
6015
- var edit_composer_default = Object.assign(EditComposer, exports11);
6083
+ var edit_composer_default = Object.assign(EditComposer, exports10);
6016
6084
 
6017
6085
  // src/ui/thread.tsx
6018
- import { Fragment as Fragment7, jsx as jsx52, jsxs as jsxs13 } from "react/jsx-runtime";
6086
+ import { Fragment as Fragment7, jsx as jsx52, jsxs as jsxs14 } from "react/jsx-runtime";
6019
6087
  var Thread = (config) => {
6020
6088
  const {
6021
6089
  components: {
@@ -6023,11 +6091,11 @@ var Thread = (config) => {
6023
6091
  ThreadWelcome: ThreadWelcomeComponent = thread_welcome_default
6024
6092
  } = {}
6025
6093
  } = config;
6026
- return /* @__PURE__ */ jsx52(ThreadRoot, { config, children: /* @__PURE__ */ jsxs13(ThreadViewport, { children: [
6094
+ return /* @__PURE__ */ jsx52(ThreadRoot, { config, children: /* @__PURE__ */ jsxs14(ThreadViewport, { children: [
6027
6095
  /* @__PURE__ */ jsx52(ThreadWelcomeComponent, {}),
6028
6096
  /* @__PURE__ */ jsx52(ThreadMessages, {}),
6029
6097
  /* @__PURE__ */ jsx52(ThreadFollowupSuggestions, {}),
6030
- /* @__PURE__ */ jsxs13(ThreadViewportFooter, { children: [
6098
+ /* @__PURE__ */ jsxs14(ThreadViewportFooter, { children: [
6031
6099
  /* @__PURE__ */ jsx52(ThreadScrollToBottom, {}),
6032
6100
  /* @__PURE__ */ jsx52(ComposerComponent, {})
6033
6101
  ] })
@@ -6036,7 +6104,7 @@ var Thread = (config) => {
6036
6104
  var ThreadRootStyled = withDefaults(thread_exports.Root, {
6037
6105
  className: "aui-root aui-thread-root"
6038
6106
  });
6039
- var ThreadRoot = forwardRef33(
6107
+ var ThreadRoot = forwardRef34(
6040
6108
  ({ config, ...props }, ref) => {
6041
6109
  return /* @__PURE__ */ jsx52(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx52(ThreadRootStyled, { ...props, ref }) });
6042
6110
  }
@@ -6052,7 +6120,7 @@ var ThreadViewportFooter = withDefaults("div", {
6052
6120
  ThreadViewportFooter.displayName = "ThreadViewportFooter";
6053
6121
  var SystemMessage = () => null;
6054
6122
  var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
6055
- return /* @__PURE__ */ jsxs13(Fragment7, { children: [
6123
+ return /* @__PURE__ */ jsxs14(Fragment7, { children: [
6056
6124
  /* @__PURE__ */ jsx52(
6057
6125
  thread_exports.Messages,
6058
6126
  {
@@ -6087,7 +6155,7 @@ var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
6087
6155
  variant: "outline",
6088
6156
  className: "aui-thread-scroll-to-bottom"
6089
6157
  });
6090
- var ThreadScrollToBottom = forwardRef33((props, ref) => {
6158
+ var ThreadScrollToBottom = forwardRef34((props, ref) => {
6091
6159
  const {
6092
6160
  strings: {
6093
6161
  thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
@@ -6096,7 +6164,7 @@ var ThreadScrollToBottom = forwardRef33((props, ref) => {
6096
6164
  return /* @__PURE__ */ jsx52(thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ jsx52(ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: props.children ?? /* @__PURE__ */ jsx52(ArrowDownIcon, {}) }) });
6097
6165
  });
6098
6166
  ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
6099
- var exports12 = {
6167
+ var exports11 = {
6100
6168
  Root: ThreadRoot,
6101
6169
  Viewport: ThreadViewport,
6102
6170
  Messages: ThreadMessages,
@@ -6104,12 +6172,12 @@ var exports12 = {
6104
6172
  ScrollToBottom: ThreadScrollToBottom,
6105
6173
  ViewportFooter: ThreadViewportFooter
6106
6174
  };
6107
- var thread_default = Object.assign(Thread, exports12);
6175
+ var thread_default = Object.assign(Thread, exports11);
6108
6176
 
6109
6177
  // src/ui/assistant-modal.tsx
6110
- import { Fragment as Fragment8, jsx as jsx53, jsxs as jsxs14 } from "react/jsx-runtime";
6178
+ import { Fragment as Fragment8, jsx as jsx53, jsxs as jsxs15 } from "react/jsx-runtime";
6111
6179
  var AssistantModal = (config) => {
6112
- return /* @__PURE__ */ jsxs14(AssistantModalRoot, { config, children: [
6180
+ return /* @__PURE__ */ jsxs15(AssistantModalRoot, { config, children: [
6113
6181
  /* @__PURE__ */ jsx53(AssistantModalTrigger, {}),
6114
6182
  /* @__PURE__ */ jsx53(AssistantModalContent, { children: /* @__PURE__ */ jsx53(thread_default, {}) })
6115
6183
  ] });
@@ -6122,7 +6190,7 @@ var AssistantModalRoot = ({
6122
6190
  return /* @__PURE__ */ jsx53(ThreadConfigProvider, { config, children: /* @__PURE__ */ jsx53(assistantModal_exports.Root, { ...props }) });
6123
6191
  };
6124
6192
  AssistantModalRoot.displayName = "AssistantModalRoot";
6125
- var AssistantModalTrigger = forwardRef34((props, ref) => {
6193
+ var AssistantModalTrigger = forwardRef35((props, ref) => {
6126
6194
  return /* @__PURE__ */ jsx53(AssistantModalAnchor, { children: /* @__PURE__ */ jsx53(assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ jsx53(AssistantModalButton, { ...props, ref }) }) });
6127
6195
  });
6128
6196
  AssistantModalTrigger.displayName = "AssistantModalTrigger";
@@ -6134,7 +6202,7 @@ var ModalButtonStyled = withDefaults(TooltipIconButton, {
6134
6202
  variant: "default",
6135
6203
  className: "aui-modal-button"
6136
6204
  });
6137
- var AssistantModalButton = forwardRef34(({ "data-state": state, ...rest }, ref) => {
6205
+ var AssistantModalButton = forwardRef35(({ "data-state": state, ...rest }, ref) => {
6138
6206
  const {
6139
6207
  strings: {
6140
6208
  assistantModal: {
@@ -6156,7 +6224,7 @@ var AssistantModalButton = forwardRef34(({ "data-state": state, ...rest }, ref)
6156
6224
  "data-state": state,
6157
6225
  ...rest,
6158
6226
  ref,
6159
- children: rest.children ?? /* @__PURE__ */ jsxs14(Fragment8, { children: [
6227
+ children: rest.children ?? /* @__PURE__ */ jsxs15(Fragment8, { children: [
6160
6228
  /* @__PURE__ */ jsx53(
6161
6229
  BotIcon,
6162
6230
  {
@@ -6181,14 +6249,14 @@ var AssistantModalContent = withDefaults(assistantModal_exports.Content, {
6181
6249
  sideOffset: 16
6182
6250
  });
6183
6251
  AssistantModalContent.displayName = "AssistantModalContent";
6184
- var exports13 = {
6252
+ var exports12 = {
6185
6253
  Root: AssistantModalRoot,
6186
6254
  Trigger: AssistantModalTrigger,
6187
6255
  Content: AssistantModalContent,
6188
6256
  Button: AssistantModalButton,
6189
6257
  Anchor: AssistantModalAnchor
6190
6258
  };
6191
- var assistant_modal_default = Object.assign(AssistantModal, exports13);
6259
+ var assistant_modal_default = Object.assign(AssistantModal, exports12);
6192
6260
  export {
6193
6261
  actionBar_exports as ActionBarPrimitive,
6194
6262
  assistant_action_bar_default as AssistantActionBar,
@@ -6197,10 +6265,11 @@ export {
6197
6265
  assistantModal_exports as AssistantModalPrimitive,
6198
6266
  AssistantRuntimeProvider,
6199
6267
  attachment_exports as AttachmentPrimitive,
6268
+ attachment_default as AttachmentUI,
6200
6269
  branch_picker_default as BranchPicker,
6201
6270
  branchPicker_exports as BranchPickerPrimitive,
6202
6271
  composer_default as Composer,
6203
- composer_attachment_default as ComposerAttachment,
6272
+ attachment_default as ComposerAttachment,
6204
6273
  composer_exports as ComposerPrimitive,
6205
6274
  CompositeAttachmentAdapter,
6206
6275
  content_part_default as ContentPart,
@@ -6218,7 +6287,7 @@ export {
6218
6287
  thread_welcome_default as ThreadWelcome,
6219
6288
  user_action_bar_default as UserActionBar,
6220
6289
  user_message_default as UserMessage,
6221
- user_message_attachment_default as UserMessageAttachment,
6290
+ attachment_default as UserMessageAttachment,
6222
6291
  WebSpeechSynthesisAdapter,
6223
6292
  fromCoreMessage,
6224
6293
  fromCoreMessages,