@assistant-ui/react 0.5.63 → 0.5.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;"use client";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;
2
2
 
3
3
 
4
4
 
@@ -9,18 +9,14 @@
9
9
 
10
10
 
11
11
 
12
+ var _chunk5KIEXJRKjs = require('./chunk-5KIEXJRK.js');
12
13
 
13
- var _chunkJ2V7Y7JXjs = require('./chunk-J2V7Y7JX.js');
14
14
 
15
-
16
- var _chunkDCHYNTHIjs = require('./chunk-DCHYNTHI.js');
15
+ var _chunkPZ5AY32Cjs = require('./chunk-PZ5AY32C.js');
17
16
 
18
17
  // src/context/providers/AssistantRuntimeProvider.tsx
19
18
  var _react = require('react');
20
19
 
21
- // src/context/providers/AssistantProvider.tsx
22
-
23
-
24
20
  // src/context/react/AssistantContext.ts
25
21
 
26
22
 
@@ -122,7 +118,7 @@ var makeAssistantToolUIsStore = () => _zustand.create.call(void 0, (set) => {
122
118
  });
123
119
  });
124
120
 
125
- // src/context/providers/ThreadProvider.tsx
121
+ // src/context/providers/ThreadRuntimeProvider.tsx
126
122
 
127
123
 
128
124
  // src/context/react/ThreadContext.ts
@@ -160,10 +156,9 @@ var {
160
156
 
161
157
  // src/context/stores/ThreadComposer.ts
162
158
 
163
- var makeThreadComposerStore = (useThreadRuntime2) => {
159
+ var makeThreadComposerStore = (runtime) => {
164
160
  const focusListeners = /* @__PURE__ */ new Set();
165
161
  return _zustand.create.call(void 0, )((_, get) => {
166
- const runtime = useThreadRuntime2.getState();
167
162
  return {
168
163
  type: "thread",
169
164
  get value() {
@@ -172,30 +167,27 @@ var makeThreadComposerStore = (useThreadRuntime2) => {
172
167
  setValue(value) {
173
168
  get().setText(value);
174
169
  },
175
- attachmentAccept: runtime.composer.attachmentAccept,
176
- attachments: runtime.composer.attachments,
170
+ ...runtime.getState(),
171
+ canCancel: false,
172
+ // "TODO",
173
+ isEditing: true,
177
174
  addAttachment: (file) => {
178
- useThreadRuntime2.getState().composer.addAttachment(file);
175
+ runtime.addAttachment(file);
179
176
  },
180
177
  removeAttachment: (attachmentId) => {
181
- useThreadRuntime2.getState().composer.removeAttachment(attachmentId);
178
+ runtime.removeAttachment(attachmentId);
182
179
  },
183
180
  reset: () => {
184
- useThreadRuntime2.getState().composer.reset();
181
+ runtime.reset();
185
182
  },
186
- text: runtime.composer.text,
187
183
  setText: (text) => {
188
- useThreadRuntime2.getState().composer.setText(text);
184
+ runtime.setText(text);
189
185
  },
190
- canCancel: runtime.capabilities.cancel,
191
- isEditing: true,
192
- isEmpty: runtime.composer.isEmpty,
193
186
  send: () => {
194
- const runtime2 = useThreadRuntime2.getState();
195
- runtime2.composer.send();
187
+ runtime.send();
196
188
  },
197
189
  cancel: () => {
198
- useThreadRuntime2.getState().cancelRun();
190
+ runtime.cancel();
199
191
  },
200
192
  focus: () => {
201
193
  for (const listener of focusListeners) {
@@ -212,22 +204,6 @@ var makeThreadComposerStore = (useThreadRuntime2) => {
212
204
  });
213
205
  };
214
206
 
215
- // src/context/stores/Thread.ts
216
-
217
- var getThreadStateFromRuntime = (runtime) => {
218
- const lastMessage = runtime.messages.at(-1);
219
- return Object.freeze({
220
- threadId: runtime.threadId,
221
- capabilities: runtime.capabilities,
222
- isDisabled: runtime.isDisabled,
223
- isRunning: _optionalChain([lastMessage, 'optionalAccess', _5 => _5.role]) !== "assistant" ? false : lastMessage.status.type === "running"
224
- });
225
- };
226
- var makeThreadStore = (runtimeRef) => {
227
- const runtime = runtimeRef.getState();
228
- return _zustand.create.call(void 0, () => getThreadStateFromRuntime(runtime));
229
- };
230
-
231
207
  // src/context/stores/ThreadViewport.tsx
232
208
 
233
209
  var makeThreadViewportStore = () => {
@@ -248,85 +224,65 @@ var makeThreadViewportStore = () => {
248
224
  }));
249
225
  };
250
226
 
251
- // src/context/stores/ThreadMessages.ts
252
-
253
- var makeThreadMessagesStore = (runtimeRef) => {
254
- return _zustand.create.call(void 0, () => runtimeRef.getState().messages);
255
- };
256
-
257
227
  // src/context/ReadonlyStore.ts
258
228
  var writableStore = (store) => {
259
229
  return store;
260
230
  };
261
231
 
262
- // src/context/providers/ThreadProvider.tsx
232
+ // src/context/providers/ThreadRuntimeProvider.tsx
263
233
 
264
234
  var _jsxruntime = require('react/jsx-runtime');
265
- var ThreadProvider = ({
266
- children,
267
- provider: thread
268
- }) => {
269
- const [context] = _react.useState.call(void 0, () => {
270
- const useThreadRuntime2 = _zustand.create.call(void 0, () => thread);
271
- const useThread2 = makeThreadStore(useThreadRuntime2);
272
- const useThreadMessages2 = makeThreadMessagesStore(useThreadRuntime2);
235
+ var useThreadRuntimeStore2 = (runtime) => {
236
+ const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime));
237
+ _react.useEffect.call(void 0, () => {
238
+ writableStore(store).setState(runtime, true);
239
+ }, [runtime, store]);
240
+ return store;
241
+ };
242
+ var useThreadStore2 = (runtime) => {
243
+ const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime.getState()));
244
+ _react.useEffect.call(void 0, () => {
245
+ const updateState = () => writableStore(store).setState(runtime.getState(), true);
246
+ updateState();
247
+ return runtime.subscribe(updateState);
248
+ }, [runtime, store]);
249
+ return store;
250
+ };
251
+ var useThreadMessagesStore2 = (runtime) => {
252
+ const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime.messages));
253
+ _react.useEffect.call(void 0, () => {
254
+ const updateState = () => writableStore(store).setState(runtime.messages, true);
255
+ updateState();
256
+ return runtime.subscribe(updateState);
257
+ }, [runtime, store]);
258
+ return store;
259
+ };
260
+ var useThreadComposerStore2 = (runtime) => {
261
+ const [store] = _react.useState.call(void 0, () => makeThreadComposerStore(runtime));
262
+ _react.useEffect.call(void 0, () => {
263
+ const updateState = () => writableStore(store).setState(runtime.getState());
264
+ updateState();
265
+ return runtime.subscribe(updateState);
266
+ }, [runtime, store]);
267
+ return store;
268
+ };
269
+ var ThreadRuntimeProvider = ({ children, runtime }) => {
270
+ const useThreadRuntime2 = useThreadRuntimeStore2(runtime);
271
+ const useThread2 = useThreadStore2(runtime);
272
+ const useThreadMessages2 = useThreadMessagesStore2(runtime);
273
+ const useThreadComposer2 = useThreadComposerStore2(runtime.composer);
274
+ const context = _react.useMemo.call(void 0, () => {
273
275
  const useViewport = makeThreadViewportStore();
274
- const useComposer2 = makeThreadComposerStore(useThreadRuntime2);
275
276
  return {
276
277
  useThread: useThread2,
277
278
  useThreadRuntime: useThreadRuntime2,
278
279
  useThreadMessages: useThreadMessages2,
279
280
  useThreadActions: useThreadRuntime2,
280
- useComposer: useComposer2,
281
+ useComposer: useThreadComposer2,
281
282
  useViewport
282
283
  };
283
- });
284
- _react.useEffect.call(void 0, () => {
285
- const onThreadUpdate = () => {
286
- const oldState = context.useThread.getState();
287
- const state = getThreadStateFromRuntime(thread);
288
- if (oldState.threadId !== state.threadId || oldState.isDisabled !== state.isDisabled || oldState.isRunning !== state.isRunning || oldState.capabilities !== state.capabilities) {
289
- writableStore(context.useThread).setState(state, true);
290
- }
291
- if (thread.messages !== context.useThreadMessages.getState()) {
292
- writableStore(context.useThreadMessages).setState(
293
- thread.messages,
294
- true
295
- );
296
- }
297
- const composerState = context.useComposer.getState();
298
- if (state.capabilities.cancel !== composerState.canCancel) {
299
- writableStore(context.useComposer).setState({
300
- canCancel: state.capabilities.cancel
301
- });
302
- }
303
- };
304
- onThreadUpdate();
305
- return thread.subscribe(onThreadUpdate);
306
- }, [thread, context]);
307
- _react.useEffect.call(void 0, () => {
308
- const onComposerUpdate = () => {
309
- const composer = thread.composer;
310
- const composerState = context.useComposer.getState();
311
- if (composer.isEmpty !== composerState.isEmpty || composer.text !== composerState.text || composer.attachmentAccept !== composerState.attachmentAccept || composer.attachments !== composerState.attachments) {
312
- writableStore(context.useComposer).setState({
313
- isEmpty: composer.isEmpty,
314
- text: composer.text,
315
- attachmentAccept: composer.attachmentAccept,
316
- attachments: composer.attachments
317
- });
318
- }
319
- };
320
- onComposerUpdate();
321
- return thread.composer.subscribe(onComposerUpdate);
322
- }, [thread, context]);
323
- _react.useEffect.call(void 0,
324
- () => thread.subscribe(() => {
325
- writableStore(context.useThreadRuntime).setState(thread, true);
326
- }),
327
- [thread, context]
328
- );
329
- const Synchronizer = context.useThreadRuntime(
284
+ }, [useThread2, useThreadRuntime2, useThreadMessages2, useThreadComposer2]);
285
+ const Synchronizer = context.useThread(
330
286
  (t) => t.unstable_synchronizer
331
287
  );
332
288
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadContext.Provider, { value: context, children: [
@@ -335,34 +291,30 @@ var ThreadProvider = ({
335
291
  ] });
336
292
  };
337
293
 
338
- // src/context/providers/AssistantProvider.tsx
294
+ // src/context/providers/AssistantRuntimeProvider.tsx
339
295
 
340
296
 
341
- var AssistantProvider = ({ children, runtime }) => {
342
- const runtimeRef = _react.useRef.call(void 0, runtime);
343
- _react.useInsertionEffect.call(void 0, () => {
344
- runtimeRef.current = runtime;
345
- });
346
- const [context] = _react.useState.call(void 0, () => {
347
- const useAssistantRuntime2 = _zustand.create.call(void 0, () => runtime);
348
- const useToolUIs2 = makeAssistantToolUIsStore();
297
+ var useAssistantRuntimeStore2 = (runtime) => {
298
+ const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime));
299
+ _react.useEffect.call(void 0, () => {
300
+ writableStore(store).setState(runtime, true);
301
+ }, [runtime, store]);
302
+ return store;
303
+ };
304
+ var useAssistantToolUIsStore = () => {
305
+ return _react.useMemo.call(void 0, () => makeAssistantToolUIsStore(), []);
306
+ };
307
+ var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
308
+ const useAssistantRuntime2 = useAssistantRuntimeStore2(runtime);
309
+ const useToolUIs2 = useAssistantToolUIsStore();
310
+ const context = _react.useMemo.call(void 0, () => {
349
311
  return {
350
312
  useToolUIs: useToolUIs2,
351
313
  useAssistantRuntime: useAssistantRuntime2,
352
314
  useAssistantActions: useAssistantRuntime2
353
315
  };
354
- });
355
- _react.useEffect.call(void 0,
356
- () => writableStore(context.useAssistantRuntime).setState(runtime, true),
357
- [runtime, context]
358
- );
359
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantContext.Provider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadProvider, { provider: runtime.thread, children }) });
360
- };
361
-
362
- // src/context/providers/AssistantRuntimeProvider.tsx
363
-
364
- var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
365
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantProvider, { runtime, children });
316
+ }, [useAssistantRuntime2, useToolUIs2]);
317
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantContext.Provider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRuntimeProvider, { runtime: runtime.thread, children }) });
366
318
  };
367
319
  var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProviderImpl);
368
320
 
@@ -427,6 +379,11 @@ var useMessageContext = createContextHook(
427
379
  MessageContext,
428
380
  "a component passed to <ThreadPrimitive.Messages components={...} />"
429
381
  );
382
+ function useMessageRuntime(options) {
383
+ const context = useMessageContext(options);
384
+ if (!context) return null;
385
+ return context.useMessageRuntime();
386
+ }
430
387
  var { useMessage, useMessageStore } = createContextStoreHook(
431
388
  useMessageContext,
432
389
  "useMessage"
@@ -460,40 +417,17 @@ var { useComposer, useComposerStore } = createContextStoreHook(
460
417
 
461
418
  // src/hooks/useAppendMessage.tsx
462
419
 
463
- var toAppendMessage = (useThreadMessages2, message) => {
464
- if (typeof message === "string") {
465
- return {
466
- parentId: _nullishCoalesce(_optionalChain([useThreadMessages2, 'access', _6 => _6.getState, 'call', _7 => _7(), 'access', _8 => _8.at, 'call', _9 => _9(-1), 'optionalAccess', _10 => _10.id]), () => ( null)),
467
- role: "user",
468
- content: [{ type: "text", text: message }],
469
- attachments: []
470
- };
471
- }
472
- return {
473
- parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages2, 'access', _11 => _11.getState, 'call', _12 => _12(), 'access', _13 => _13.at, 'call', _14 => _14(-1), 'optionalAccess', _15 => _15.id]))), () => ( null)),
474
- role: _nullishCoalesce(message.role, () => ( "user")),
475
- content: message.content,
476
- attachments: _nullishCoalesce(message.attachments, () => ( []))
477
- };
478
- };
479
420
  var useAppendMessage = () => {
480
- const threadMessagesStore = useThreadMessagesStore();
481
421
  const threadRuntime = useThreadRuntime();
482
422
  const threadViewportStore = useThreadViewportStore();
483
423
  const threadComposerStore = useThreadComposerStore();
484
424
  const append = _react.useCallback.call(void 0,
485
425
  (message) => {
486
- const appendMessage = toAppendMessage(threadMessagesStore, message);
487
- threadRuntime.append(appendMessage);
426
+ threadRuntime.append(message);
488
427
  threadViewportStore.getState().scrollToBottom();
489
428
  threadComposerStore.getState().focus();
490
429
  },
491
- [
492
- threadMessagesStore,
493
- threadRuntime,
494
- threadViewportStore,
495
- threadComposerStore
496
- ]
430
+ [threadRuntime, threadViewportStore, threadComposerStore]
497
431
  );
498
432
  return append;
499
433
  };
@@ -528,7 +462,7 @@ var useAssistantTool = (tool) => {
528
462
  const unsub2 = render ? toolUIsStore.getState().setToolUI(toolName, render) : void 0;
529
463
  return () => {
530
464
  unsub1();
531
- _optionalChain([unsub2, 'optionalCall', _16 => _16()]);
465
+ _optionalChain([unsub2, 'optionalCall', _5 => _5()]);
532
466
  };
533
467
  }, [assistantRuntime, toolUIsStore, tool]);
534
468
  };
@@ -624,12 +558,12 @@ var useActionBarCopy = ({
624
558
  const editComposerStore = useEditComposerStore();
625
559
  const hasCopyableContent = useCombinedStore(
626
560
  [messageStore, editComposerStore],
627
- ({ message }, c) => {
561
+ (message, c) => {
628
562
  return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
629
563
  }
630
564
  );
631
565
  const callback = _react.useCallback.call(void 0, () => {
632
- const { message } = messageStore.getState();
566
+ const message = messageStore.getState();
633
567
  const { setIsCopied } = messageUtilsStore.getState();
634
568
  const { isEditing, text: composerValue } = editComposerStore.getState();
635
569
  const valueToCopy = isEditing ? composerValue : getThreadMessageText(message);
@@ -665,7 +599,7 @@ var useActionBarReload = () => {
665
599
  const threadViewportStore = useThreadViewportStore();
666
600
  const disabled = useCombinedStore(
667
601
  [threadStore, messageStore],
668
- (t, m) => t.isRunning || t.isDisabled || m.message.role !== "assistant"
602
+ (t, m) => t.isRunning || t.isDisabled || m.role !== "assistant"
669
603
  );
670
604
  const callback = _react.useCallback.call(void 0, () => {
671
605
  const { parentId } = messageStore.getState();
@@ -719,7 +653,7 @@ var useActionBarFeedbackPositive = () => {
719
653
  const messageUtilsStore = useMessageUtilsStore();
720
654
  const callback = _react.useCallback.call(void 0, () => {
721
655
  threadRuntime.submitFeedback({
722
- messageId: messageStore.getState().message.id,
656
+ messageId: messageStore.getState().id,
723
657
  type: "positive"
724
658
  });
725
659
  messageUtilsStore.getState().setSubmittedFeedback("positive");
@@ -735,7 +669,7 @@ var useActionBarFeedbackNegative = () => {
735
669
  const messageUtilsStore = useMessageUtilsStore();
736
670
  const callback = _react.useCallback.call(void 0, () => {
737
671
  threadRuntime.submitFeedback({
738
- messageId: messageStore.getState().message.id,
672
+ messageId: messageStore.getState().id,
739
673
  type: "negative"
740
674
  });
741
675
  messageUtilsStore.getState().setSubmittedFeedback("negative");
@@ -745,48 +679,46 @@ var useActionBarFeedbackNegative = () => {
745
679
 
746
680
  // src/primitive-hooks/branchPicker/useBranchPickerCount.tsx
747
681
  var useBranchPickerCount = () => {
748
- const branchCount = useMessage((s) => s.branches.length);
682
+ const branchCount = useMessage((s) => s.branchCount);
749
683
  return branchCount;
750
684
  };
751
685
 
752
686
  // src/primitive-hooks/branchPicker/useBranchPickerNext.tsx
753
687
 
754
688
  var useBranchPickerNext = () => {
689
+ const messageRuntime = useMessageRuntime();
755
690
  const messageStore = useMessageStore();
756
691
  const editComposerStore = useEditComposerStore();
757
- const threadRuntime = useThreadRuntime();
758
692
  const disabled = useCombinedStore(
759
693
  [messageStore, editComposerStore],
760
- (m, c) => c.isEditing || m.branches.indexOf(m.message.id) + 1 >= m.branches.length
694
+ (m, c) => c.isEditing || m.branchNumber >= m.branchCount
761
695
  );
762
696
  const callback = _react.useCallback.call(void 0, () => {
763
- const { message, branches } = messageStore.getState();
764
- threadRuntime.switchToBranch(branches[branches.indexOf(message.id) + 1]);
765
- }, [threadRuntime, messageStore]);
697
+ messageRuntime.switchToBranch({ position: "next" });
698
+ }, [messageRuntime]);
766
699
  if (disabled) return null;
767
700
  return callback;
768
701
  };
769
702
 
770
703
  // src/primitive-hooks/branchPicker/useBranchPickerNumber.tsx
771
704
  var useBranchPickerNumber = () => {
772
- const branchIdx = useMessage((s) => s.branches.indexOf(s.message.id));
773
- return branchIdx + 1;
705
+ const branchNumber = useMessage((s) => s.branchNumber);
706
+ return branchNumber;
774
707
  };
775
708
 
776
709
  // src/primitive-hooks/branchPicker/useBranchPickerPrevious.tsx
777
710
 
778
711
  var useBranchPickerPrevious = () => {
712
+ const messageRuntime = useMessageRuntime();
779
713
  const messageStore = useMessageStore();
780
714
  const editComposerStore = useEditComposerStore();
781
- const threadRuntime = useThreadRuntime();
782
715
  const disabled = useCombinedStore(
783
716
  [messageStore, editComposerStore],
784
- (m, c) => c.isEditing || m.branches.indexOf(m.message.id) <= 0
717
+ (m, c) => c.isEditing || m.branchNumber <= 1
785
718
  );
786
719
  const callback = _react.useCallback.call(void 0, () => {
787
- const { message, branches } = messageStore.getState();
788
- threadRuntime.switchToBranch(branches[branches.indexOf(message.id) - 1]);
789
- }, [threadRuntime, messageStore]);
720
+ messageRuntime.switchToBranch({ position: "previous" });
721
+ }, [messageRuntime]);
790
722
  if (disabled) return null;
791
723
  return callback;
792
724
  };
@@ -850,7 +782,7 @@ var useComposerAddAttachment = () => {
850
782
  input.accept = attachmentAccept;
851
783
  }
852
784
  input.onchange = (e) => {
853
- const file = _optionalChain([e, 'access', _17 => _17.target, 'access', _18 => _18.files, 'optionalAccess', _19 => _19[0]]);
785
+ const file = _optionalChain([e, 'access', _6 => _6.target, 'access', _7 => _7.files, 'optionalAccess', _8 => _8[0]]);
854
786
  if (!file) return;
855
787
  addAttachment(file);
856
788
  };
@@ -902,19 +834,19 @@ var useMessageIf = (props) => {
902
834
  const messageUtilsStore = useMessageUtilsStore();
903
835
  return useCombinedStore(
904
836
  [messageStore, messageUtilsStore],
905
- ({ message, branches, isLast }, { isCopied, isHovering, isSpeaking, submittedFeedback }) => {
906
- if (props.hasBranches === true && branches.length < 2) return false;
907
- if (props.user && message.role !== "user") return false;
908
- if (props.assistant && message.role !== "assistant") return false;
909
- if (props.system && message.role !== "system") return false;
837
+ ({ role, attachments, branchCount, isLast }, { isCopied, isHovering, isSpeaking, submittedFeedback }) => {
838
+ if (props.hasBranches === true && branchCount < 2) return false;
839
+ if (props.user && role !== "user") return false;
840
+ if (props.assistant && role !== "assistant") return false;
841
+ if (props.system && role !== "system") return false;
910
842
  if (props.lastOrHover === true && !isHovering && !isLast) return false;
911
843
  if (props.copied === true && !isCopied) return false;
912
844
  if (props.copied === false && isCopied) return false;
913
845
  if (props.speaking === true && !isSpeaking) return false;
914
846
  if (props.speaking === false && isSpeaking) return false;
915
- if (props.hasAttachments === true && (message.role !== "user" || !message.attachments.length))
847
+ if (props.hasAttachments === true && (role !== "user" || !attachments.length))
916
848
  return false;
917
- if (props.hasAttachments === false && message.role === "user" && !!message.attachments.length)
849
+ if (props.hasAttachments === false && role === "user" && !!attachments.length)
918
850
  return false;
919
851
  if (props.submittedFeedback !== void 0 && submittedFeedback !== props.submittedFeedback)
920
852
  return false;
@@ -986,7 +918,7 @@ var useThreadSuggestion = ({
986
918
 
987
919
  // src/primitives/actionBar/index.ts
988
920
  var actionBar_exports = {};
989
- _chunkDCHYNTHIjs.__export.call(void 0, actionBar_exports, {
921
+ _chunkPZ5AY32Cjs.__export.call(void 0, actionBar_exports, {
990
922
  Copy: () => ActionBarPrimitiveCopy,
991
923
  Edit: () => ActionBarPrimitiveEdit,
992
924
  FeedbackNegative: () => ActionBarPrimitiveFeedbackNegative,
@@ -1061,7 +993,7 @@ var ActionBarPrimitiveCopy = _react.forwardRef.call(void 0, ({ copiedDuration, o
1061
993
  ref: forwardedRef,
1062
994
  disabled: disabled || !callback,
1063
995
  onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
1064
- _optionalChain([callback, 'optionalCall', _20 => _20()]);
996
+ _optionalChain([callback, 'optionalCall', _9 => _9()]);
1065
997
  })
1066
998
  }
1067
999
  );
@@ -1093,7 +1025,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
1093
1025
  ref: forwardedRef,
1094
1026
  disabled: primitiveProps.disabled || !callback,
1095
1027
  onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
1096
- _optionalChain([callback, 'optionalCall', _21 => _21()]);
1028
+ _optionalChain([callback, 'optionalCall', _10 => _10()]);
1097
1029
  })
1098
1030
  }
1099
1031
  );
@@ -1142,7 +1074,7 @@ var ActionBarPrimitiveStopSpeaking = _react.forwardRef.call(void 0, (props, ref)
1142
1074
  ...props,
1143
1075
  ref,
1144
1076
  onClick: _primitive.composeEventHandlers.call(void 0, props.onClick, () => {
1145
- _optionalChain([callback, 'optionalCall', _22 => _22()]);
1077
+ _optionalChain([callback, 'optionalCall', _11 => _11()]);
1146
1078
  })
1147
1079
  }
1148
1080
  );
@@ -1168,7 +1100,7 @@ var ActionBarPrimitiveFeedbackPositive = _react.forwardRef.call(void 0, ({ onCli
1168
1100
  ref: forwardedRef,
1169
1101
  disabled: disabled || !callback,
1170
1102
  onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
1171
- _optionalChain([callback, 'optionalCall', _23 => _23()]);
1103
+ _optionalChain([callback, 'optionalCall', _12 => _12()]);
1172
1104
  })
1173
1105
  }
1174
1106
  );
@@ -1194,7 +1126,7 @@ var ActionBarPrimitiveFeedbackNegative = _react.forwardRef.call(void 0, ({ onCli
1194
1126
  ref: forwardedRef,
1195
1127
  disabled: disabled || !callback,
1196
1128
  onClick: _primitive.composeEventHandlers.call(void 0, onClick, () => {
1197
- _optionalChain([callback, 'optionalCall', _24 => _24()]);
1129
+ _optionalChain([callback, 'optionalCall', _13 => _13()]);
1198
1130
  })
1199
1131
  }
1200
1132
  );
@@ -1203,7 +1135,7 @@ ActionBarPrimitiveFeedbackNegative.displayName = "ActionBarPrimitive.FeedbackNeg
1203
1135
 
1204
1136
  // src/primitives/assistantModal/index.ts
1205
1137
  var assistantModal_exports = {};
1206
- _chunkDCHYNTHIjs.__export.call(void 0, assistantModal_exports, {
1138
+ _chunkPZ5AY32Cjs.__export.call(void 0, assistantModal_exports, {
1207
1139
  Anchor: () => AssistantModalPrimitiveAnchor,
1208
1140
  Content: () => AssistantModalPrimitiveContent,
1209
1141
  Root: () => AssistantModalPrimitiveRoot,
@@ -1328,7 +1260,7 @@ AssistantModalPrimitiveAnchor.displayName = "AssistantModalPrimitive.Anchor";
1328
1260
 
1329
1261
  // src/primitives/branchPicker/index.ts
1330
1262
  var branchPicker_exports = {};
1331
- _chunkDCHYNTHIjs.__export.call(void 0, branchPicker_exports, {
1263
+ _chunkPZ5AY32Cjs.__export.call(void 0, branchPicker_exports, {
1332
1264
  Count: () => BranchPickerPrimitiveCount,
1333
1265
  Next: () => BranchPickerPrimitiveNext,
1334
1266
  Number: () => BranchPickerPrimitiveNumber,
@@ -1370,7 +1302,7 @@ BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
1370
1302
 
1371
1303
  // src/primitives/message/index.ts
1372
1304
  var message_exports = {};
1373
- _chunkDCHYNTHIjs.__export.call(void 0, message_exports, {
1305
+ _chunkPZ5AY32Cjs.__export.call(void 0, message_exports, {
1374
1306
  Attachments: () => MessagePrimitiveAttachments,
1375
1307
  Content: () => MessagePrimitiveContent,
1376
1308
  If: () => MessagePrimitiveIf,
@@ -1484,7 +1416,7 @@ var getContentPartState = ({ message }, useContentPart2, partIndex) => {
1484
1416
  part = EMPTY_CONTENT;
1485
1417
  }
1486
1418
  const status = toContentPartStatus(message, partIndex, part);
1487
- const currentState = _optionalChain([useContentPart2, 'optionalAccess', _25 => _25.getState, 'call', _26 => _26()]);
1419
+ const currentState = _optionalChain([useContentPart2, 'optionalAccess', _14 => _14.getState, 'call', _15 => _15()]);
1488
1420
  if (currentState && currentState.part === part && currentState.status === status)
1489
1421
  return null;
1490
1422
  return Object.freeze({ part, status });
@@ -1561,7 +1493,7 @@ var withSmoothContextProvider = (Component) => {
1561
1493
  };
1562
1494
  function useSmoothContext(options) {
1563
1495
  const context = _react.useContext.call(void 0, SmoothContext);
1564
- if (!_optionalChain([options, 'optionalAccess', _27 => _27.optional]) && !context)
1496
+ if (!_optionalChain([options, 'optionalAccess', _16 => _16.optional]) && !context)
1565
1497
  throw new Error(
1566
1498
  "This component must be used within a SmoothContextProvider."
1567
1499
  );
@@ -1626,7 +1558,7 @@ var useSmooth = (state, smooth = false) => {
1626
1558
  } = state;
1627
1559
  const id = useMessage({
1628
1560
  optional: true,
1629
- selector: (m) => m.message.id
1561
+ selector: (m) => m.id
1630
1562
  });
1631
1563
  const idRef = _react.useRef.call(void 0, id);
1632
1564
  const [displayedText, setDisplayedText] = _react.useState.call(void 0, text);
@@ -1768,7 +1700,7 @@ var MessageContentPartComponent = ({
1768
1700
  case "tool-call": {
1769
1701
  const Tool = by_name[part.toolName] || Fallback2;
1770
1702
  const addResult = (result) => threadRuntime.addToolResult({
1771
- messageId: messageStore.getState().message.id,
1703
+ messageId: messageStore.getState().id,
1772
1704
  toolName: part.toolName,
1773
1705
  toolCallId: part.toolCallId,
1774
1706
  result
@@ -1796,12 +1728,12 @@ var MessageContentPartImpl = ({
1796
1728
  };
1797
1729
  var MessageContentPart = _react.memo.call(void 0,
1798
1730
  MessageContentPartImpl,
1799
- (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _28 => _28.components, 'optionalAccess', _29 => _29.Text]) === _optionalChain([next, 'access', _30 => _30.components, 'optionalAccess', _31 => _31.Text]) && _optionalChain([prev, 'access', _32 => _32.components, 'optionalAccess', _33 => _33.Image]) === _optionalChain([next, 'access', _34 => _34.components, 'optionalAccess', _35 => _35.Image]) && _optionalChain([prev, 'access', _36 => _36.components, 'optionalAccess', _37 => _37.UI]) === _optionalChain([next, 'access', _38 => _38.components, 'optionalAccess', _39 => _39.UI]) && _optionalChain([prev, 'access', _40 => _40.components, 'optionalAccess', _41 => _41.tools]) === _optionalChain([next, 'access', _42 => _42.components, 'optionalAccess', _43 => _43.tools])
1731
+ (prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _17 => _17.components, 'optionalAccess', _18 => _18.Text]) === _optionalChain([next, 'access', _19 => _19.components, 'optionalAccess', _20 => _20.Text]) && _optionalChain([prev, 'access', _21 => _21.components, 'optionalAccess', _22 => _22.Image]) === _optionalChain([next, 'access', _23 => _23.components, 'optionalAccess', _24 => _24.Image]) && _optionalChain([prev, 'access', _25 => _25.components, 'optionalAccess', _26 => _26.UI]) === _optionalChain([next, 'access', _27 => _27.components, 'optionalAccess', _28 => _28.UI]) && _optionalChain([prev, 'access', _29 => _29.components, 'optionalAccess', _30 => _30.tools]) === _optionalChain([next, 'access', _31 => _31.components, 'optionalAccess', _32 => _32.tools])
1800
1732
  );
1801
1733
  var MessagePrimitiveContent = ({
1802
1734
  components
1803
1735
  }) => {
1804
- const contentLength = useMessage((s) => s.message.content.length) || 1;
1736
+ const contentLength = useMessage((s) => s.content.length) || 1;
1805
1737
  return Array.from({ length: contentLength }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPart, { partIndex: index, components }, index));
1806
1738
  };
1807
1739
  MessagePrimitiveContent.displayName = "MessagePrimitive.Content";
@@ -1822,7 +1754,7 @@ var AttachmentContext = _react.createContext.call(void 0,
1822
1754
  );
1823
1755
  function useAttachmentContext(options) {
1824
1756
  const context = _react.useContext.call(void 0, AttachmentContext);
1825
- if (!_optionalChain([options, 'optionalAccess', _44 => _44.optional]) && !context)
1757
+ if (!_optionalChain([options, 'optionalAccess', _33 => _33.optional]) && !context)
1826
1758
  throw new Error(
1827
1759
  "This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
1828
1760
  );
@@ -1863,12 +1795,12 @@ var {
1863
1795
 
1864
1796
 
1865
1797
 
1866
- var getAttachment = ({ message }, useAttachment2, partIndex) => {
1798
+ var getAttachment = (message, useAttachment2, partIndex) => {
1867
1799
  if (message.role !== "user") return null;
1868
1800
  const attachments = message.attachments;
1869
1801
  const attachment = attachments[partIndex];
1870
1802
  if (!attachment) return null;
1871
- const currentState = _optionalChain([useAttachment2, 'optionalAccess', _45 => _45.getState, 'call', _46 => _46()]);
1803
+ const currentState = _optionalChain([useAttachment2, 'optionalAccess', _34 => _34.getState, 'call', _35 => _35()]);
1872
1804
  if (currentState && currentState.attachment === attachment) return null;
1873
1805
  return Object.freeze({ attachment });
1874
1806
  };
@@ -1911,11 +1843,11 @@ var getComponent = (components, attachment) => {
1911
1843
  const type = attachment.type;
1912
1844
  switch (type) {
1913
1845
  case "image":
1914
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _47 => _47.Image]), () => ( _optionalChain([components, 'optionalAccess', _48 => _48.Attachment])));
1846
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _36 => _36.Image]), () => ( _optionalChain([components, 'optionalAccess', _37 => _37.Attachment])));
1915
1847
  case "document":
1916
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _49 => _49.Document]), () => ( _optionalChain([components, 'optionalAccess', _50 => _50.Attachment])));
1848
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _38 => _38.Document]), () => ( _optionalChain([components, 'optionalAccess', _39 => _39.Attachment])));
1917
1849
  case "file":
1918
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _51 => _51.File]), () => ( _optionalChain([components, 'optionalAccess', _52 => _52.Attachment])));
1850
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _40 => _40.File]), () => ( _optionalChain([components, 'optionalAccess', _41 => _41.Attachment])));
1919
1851
  default:
1920
1852
  const _exhaustiveCheck = type;
1921
1853
  throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
@@ -1933,7 +1865,7 @@ var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
1933
1865
  };
1934
1866
  var MessageAttachment = _react.memo.call(void 0,
1935
1867
  MessageAttachmentImpl,
1936
- (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _53 => _53.components, 'optionalAccess', _54 => _54.Image]) === _optionalChain([next, 'access', _55 => _55.components, 'optionalAccess', _56 => _56.Image]) && _optionalChain([prev, 'access', _57 => _57.components, 'optionalAccess', _58 => _58.Document]) === _optionalChain([next, 'access', _59 => _59.components, 'optionalAccess', _60 => _60.Document]) && _optionalChain([prev, 'access', _61 => _61.components, 'optionalAccess', _62 => _62.File]) === _optionalChain([next, 'access', _63 => _63.components, 'optionalAccess', _64 => _64.File]) && _optionalChain([prev, 'access', _65 => _65.components, 'optionalAccess', _66 => _66.Attachment]) === _optionalChain([next, 'access', _67 => _67.components, 'optionalAccess', _68 => _68.Attachment])
1868
+ (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _42 => _42.components, 'optionalAccess', _43 => _43.Image]) === _optionalChain([next, 'access', _44 => _44.components, 'optionalAccess', _45 => _45.Image]) && _optionalChain([prev, 'access', _46 => _46.components, 'optionalAccess', _47 => _47.Document]) === _optionalChain([next, 'access', _48 => _48.components, 'optionalAccess', _49 => _49.Document]) && _optionalChain([prev, 'access', _50 => _50.components, 'optionalAccess', _51 => _51.File]) === _optionalChain([next, 'access', _52 => _52.components, 'optionalAccess', _53 => _53.File]) && _optionalChain([prev, 'access', _54 => _54.components, 'optionalAccess', _55 => _55.Attachment]) === _optionalChain([next, 'access', _56 => _56.components, 'optionalAccess', _57 => _57.Attachment])
1937
1869
  );
1938
1870
  var MessagePrimitiveAttachments = ({ components }) => {
1939
1871
  const attachmentsCount = useMessage(({ message }) => {
@@ -1960,7 +1892,7 @@ BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
1960
1892
 
1961
1893
  // src/primitives/composer/index.ts
1962
1894
  var composer_exports = {};
1963
- _chunkDCHYNTHIjs.__export.call(void 0, composer_exports, {
1895
+ _chunkPZ5AY32Cjs.__export.call(void 0, composer_exports, {
1964
1896
  AddAttachment: () => ComposerPrimitiveAddAttachment,
1965
1897
  Attachments: () => ComposerPrimitiveAttachments,
1966
1898
  Cancel: () => ComposerPrimitiveCancel,
@@ -2044,7 +1976,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
2044
1976
  const { isRunning } = threadStore.getState();
2045
1977
  if (!isRunning) {
2046
1978
  e.preventDefault();
2047
- _optionalChain([textareaRef, 'access', _69 => _69.current, 'optionalAccess', _70 => _70.closest, 'call', _71 => _71("form"), 'optionalAccess', _72 => _72.requestSubmit, 'call', _73 => _73()]);
1979
+ _optionalChain([textareaRef, 'access', _58 => _58.current, 'optionalAccess', _59 => _59.closest, 'call', _60 => _60("form"), 'optionalAccess', _61 => _61.requestSubmit, 'call', _62 => _62()]);
2048
1980
  }
2049
1981
  }
2050
1982
  };
@@ -2112,7 +2044,7 @@ var ComposerPrimitiveAddAttachment = createActionButton(
2112
2044
  var getAttachment2 = ({ attachments }, useAttachment2, partIndex) => {
2113
2045
  const attachment = attachments[partIndex];
2114
2046
  if (!attachment) return null;
2115
- const currentState = _optionalChain([useAttachment2, 'optionalAccess', _74 => _74.getState, 'call', _75 => _75()]);
2047
+ const currentState = _optionalChain([useAttachment2, 'optionalAccess', _63 => _63.getState, 'call', _64 => _64()]);
2116
2048
  if (currentState && currentState.attachment === attachment) return null;
2117
2049
  return Object.freeze({ attachment });
2118
2050
  };
@@ -2152,11 +2084,11 @@ var getComponent2 = (components, attachment) => {
2152
2084
  const type = attachment.type;
2153
2085
  switch (type) {
2154
2086
  case "image":
2155
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _76 => _76.Image]), () => ( _optionalChain([components, 'optionalAccess', _77 => _77.Attachment])));
2087
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _65 => _65.Image]), () => ( _optionalChain([components, 'optionalAccess', _66 => _66.Attachment])));
2156
2088
  case "document":
2157
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _78 => _78.Document]), () => ( _optionalChain([components, 'optionalAccess', _79 => _79.Attachment])));
2089
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _67 => _67.Document]), () => ( _optionalChain([components, 'optionalAccess', _68 => _68.Attachment])));
2158
2090
  case "file":
2159
- return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _80 => _80.File]), () => ( _optionalChain([components, 'optionalAccess', _81 => _81.Attachment])));
2091
+ return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _69 => _69.File]), () => ( _optionalChain([components, 'optionalAccess', _70 => _70.Attachment])));
2160
2092
  default:
2161
2093
  const _exhaustiveCheck = type;
2162
2094
  throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
@@ -2174,7 +2106,7 @@ var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
2174
2106
  };
2175
2107
  var ComposerAttachment = _react.memo.call(void 0,
2176
2108
  ComposerAttachmentImpl,
2177
- (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _82 => _82.components, 'optionalAccess', _83 => _83.Image]) === _optionalChain([next, 'access', _84 => _84.components, 'optionalAccess', _85 => _85.Image]) && _optionalChain([prev, 'access', _86 => _86.components, 'optionalAccess', _87 => _87.Document]) === _optionalChain([next, 'access', _88 => _88.components, 'optionalAccess', _89 => _89.Document]) && _optionalChain([prev, 'access', _90 => _90.components, 'optionalAccess', _91 => _91.File]) === _optionalChain([next, 'access', _92 => _92.components, 'optionalAccess', _93 => _93.File]) && _optionalChain([prev, 'access', _94 => _94.components, 'optionalAccess', _95 => _95.Attachment]) === _optionalChain([next, 'access', _96 => _96.components, 'optionalAccess', _97 => _97.Attachment])
2109
+ (prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _71 => _71.components, 'optionalAccess', _72 => _72.Image]) === _optionalChain([next, 'access', _73 => _73.components, 'optionalAccess', _74 => _74.Image]) && _optionalChain([prev, 'access', _75 => _75.components, 'optionalAccess', _76 => _76.Document]) === _optionalChain([next, 'access', _77 => _77.components, 'optionalAccess', _78 => _78.Document]) && _optionalChain([prev, 'access', _79 => _79.components, 'optionalAccess', _80 => _80.File]) === _optionalChain([next, 'access', _81 => _81.components, 'optionalAccess', _82 => _82.File]) && _optionalChain([prev, 'access', _83 => _83.components, 'optionalAccess', _84 => _84.Attachment]) === _optionalChain([next, 'access', _85 => _85.components, 'optionalAccess', _86 => _86.Attachment])
2178
2110
  );
2179
2111
  var ComposerPrimitiveAttachments = ({ components }) => {
2180
2112
  const attachmentsCount = useThreadComposer((s) => s.attachments.length);
@@ -2201,7 +2133,7 @@ ComposerPrimitiveIf.displayName = "ComposerPrimitive.If";
2201
2133
 
2202
2134
  // src/primitives/contentPart/index.ts
2203
2135
  var contentPart_exports = {};
2204
- _chunkDCHYNTHIjs.__export.call(void 0, contentPart_exports, {
2136
+ _chunkPZ5AY32Cjs.__export.call(void 0, contentPart_exports, {
2205
2137
  Display: () => ContentPartPrimitiveDisplay,
2206
2138
  Image: () => ContentPartPrimitiveImage,
2207
2139
  InProgress: () => ContentPartPrimitiveInProgress,
@@ -2210,7 +2142,7 @@ _chunkDCHYNTHIjs.__export.call(void 0, contentPart_exports, {
2210
2142
 
2211
2143
  // src/primitives/thread/index.ts
2212
2144
  var thread_exports = {};
2213
- _chunkDCHYNTHIjs.__export.call(void 0, thread_exports, {
2145
+ _chunkPZ5AY32Cjs.__export.call(void 0, thread_exports, {
2214
2146
  Empty: () => ThreadPrimitiveEmpty,
2215
2147
  If: () => ThreadPrimitiveIf,
2216
2148
  Messages: () => ThreadPrimitiveMessages,
@@ -2375,7 +2307,7 @@ ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
2375
2307
  // src/primitives/thread/ThreadMessages.tsx
2376
2308
 
2377
2309
 
2378
- // src/context/providers/MessageProvider.tsx
2310
+ // src/context/providers/MessageRuntimeProvider.tsx
2379
2311
 
2380
2312
 
2381
2313
 
@@ -2433,7 +2365,7 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
2433
2365
  },
2434
2366
  isSpeaking: false,
2435
2367
  stopSpeaking: () => {
2436
- _optionalChain([utterance, 'optionalAccess', _98 => _98.cancel, 'call', _99 => _99()]);
2368
+ _optionalChain([utterance, 'optionalAccess', _87 => _87.cancel, 'call', _88 => _88()]);
2437
2369
  },
2438
2370
  addUtterance: (utt) => {
2439
2371
  utterance = utt;
@@ -2449,84 +2381,65 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
2449
2381
  };
2450
2382
  });
2451
2383
 
2452
- // src/context/providers/MessageProvider.tsx
2384
+ // src/context/providers/MessageRuntimeProvider.tsx
2453
2385
 
2454
- var getIsLast = (messages, message) => {
2455
- return _optionalChain([messages, 'access', _100 => _100[messages.length - 1], 'optionalAccess', _101 => _101.id]) === message.id;
2386
+ var useMessageRuntimeStore = (runtime) => {
2387
+ const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime));
2388
+ _react.useEffect.call(void 0, () => {
2389
+ writableStore(store).setState(runtime, true);
2390
+ }, [runtime, store]);
2391
+ return store;
2456
2392
  };
2457
- var getMessageState = (messages, getBranches, useMessage2, messageIndex) => {
2458
- const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _102 => _102[messageIndex - 1], 'optionalAccess', _103 => _103.id]), () => ( null));
2459
- const message = messages[messageIndex];
2460
- if (!message) return null;
2461
- const isLast = getIsLast(messages, message);
2462
- const branches = getBranches(message.id);
2463
- const currentState = _optionalChain([useMessage2, 'optionalAccess', _104 => _104.getState, 'call', _105 => _105()]);
2464
- if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
2465
- return null;
2466
- return Object.freeze({
2467
- message,
2468
- parentId,
2469
- branches,
2470
- isLast
2471
- });
2393
+ var useMessageStore2 = (runtime) => {
2394
+ const [store] = _react.useState.call(void 0, () => _zustand.create.call(void 0, () => runtime.getState()));
2395
+ _react.useEffect.call(void 0, () => {
2396
+ const updateState = () => writableStore(store).setState(runtime.getState(), true);
2397
+ updateState();
2398
+ return runtime.subscribe(updateState);
2399
+ }, [runtime, store]);
2400
+ return store;
2472
2401
  };
2473
- var useMessageContext2 = (messageIndex) => {
2474
- const threadMessagesStore = useThreadMessagesStore();
2475
- const threadRuntime = useThreadRuntime();
2476
- const [context] = _react.useState.call(void 0, () => {
2477
- const useMessage2 = _zustand.create.call(void 0,
2478
- () => getMessageState(
2479
- threadMessagesStore.getState(),
2480
- threadRuntime.getBranches.bind(threadRuntime),
2481
- void 0,
2482
- messageIndex
2483
- )
2484
- );
2485
- const useMessageUtils2 = makeMessageUtilsStore();
2486
- const useEditComposer2 = makeEditComposerStore({
2402
+ var useMessageUtilsStore2 = () => {
2403
+ const [store] = _react.useState.call(void 0, () => makeMessageUtilsStore());
2404
+ return store;
2405
+ };
2406
+ var useEditComposerStore2 = (useMessageRuntime2) => {
2407
+ const [store] = _react.useState.call(void 0,
2408
+ () => makeEditComposerStore({
2487
2409
  onEdit: () => {
2488
- const message = useMessage2.getState().message;
2489
- const text = getThreadMessageText(message);
2410
+ const text = getThreadMessageText(
2411
+ useMessageRuntime2.getState().getState()
2412
+ );
2490
2413
  return text;
2491
2414
  },
2492
2415
  onSend: (text) => {
2493
- const { message, parentId } = useMessage2.getState();
2416
+ const message = useMessageRuntime2.getState().getState();
2494
2417
  const previousText = getThreadMessageText(message);
2495
2418
  if (previousText === text) return;
2496
2419
  const nonTextParts = message.content.filter(
2497
2420
  (part) => part.type !== "text" && part.type !== "ui"
2498
2421
  );
2499
- threadRuntime.append({
2500
- parentId,
2422
+ useMessageRuntime2.getState().edit({
2501
2423
  role: message.role,
2502
2424
  content: [{ type: "text", text }, ...nonTextParts],
2503
- attachments: message.attachments
2425
+ attachments: _nullishCoalesce(message.attachments, () => ( []))
2504
2426
  });
2505
2427
  }
2506
- });
2507
- return { useMessage: useMessage2, useMessageUtils: useMessageUtils2, useEditComposer: useEditComposer2 };
2508
- });
2509
- _react.useEffect.call(void 0, () => {
2510
- const syncMessage = (thread) => {
2511
- const newState = getMessageState(
2512
- thread,
2513
- threadRuntime.getBranches.bind(threadRuntime),
2514
- context.useMessage,
2515
- messageIndex
2516
- );
2517
- if (!newState) return;
2518
- writableStore(context.useMessage).setState(newState, true);
2519
- };
2520
- syncMessage(threadMessagesStore.getState());
2521
- return threadMessagesStore.subscribe(syncMessage);
2522
- }, [threadMessagesStore, threadRuntime, context, messageIndex]);
2523
- return context;
2428
+ })
2429
+ );
2430
+ return store;
2524
2431
  };
2525
- var MessageProvider = ({
2526
- messageIndex,
2432
+ var MessageRuntimeProvider = ({
2433
+ runtime,
2527
2434
  children
2528
2435
  }) => {
2529
- const context = useMessageContext2(messageIndex);
2436
+ const useMessageRuntime2 = useMessageRuntimeStore(runtime);
2437
+ const useMessage2 = useMessageStore2(runtime);
2438
+ const useMessageUtils2 = useMessageUtilsStore2();
2439
+ const useEditComposer2 = useEditComposerStore2(useMessageRuntime2);
2440
+ const [context] = _react.useState.call(void 0, () => {
2441
+ return { useMessageRuntime: useMessageRuntime2, useMessage: useMessage2, useMessageUtils: useMessageUtils2, useEditComposer: useEditComposer2 };
2442
+ });
2530
2443
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContext.Provider, { value: context, children });
2531
2444
  };
2532
2445
 
@@ -2564,7 +2477,7 @@ var getComponent3 = (components, role, isEditing) => {
2564
2477
  var ThreadMessageComponent = ({
2565
2478
  components
2566
2479
  }) => {
2567
- const role = useMessage((m) => m.message.role);
2480
+ const role = useMessage((m) => m.role);
2568
2481
  const isEditing = useEditComposer((c) => c.isEditing);
2569
2482
  const Component = getComponent3(components, role, isEditing);
2570
2483
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {});
@@ -2573,7 +2486,12 @@ var ThreadMessageImpl = ({
2573
2486
  messageIndex,
2574
2487
  components
2575
2488
  }) => {
2576
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageProvider, { messageIndex, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessageComponent, { components }) });
2489
+ const threadRuntime = useThreadRuntime();
2490
+ const runtime = _react.useMemo.call(void 0,
2491
+ () => threadRuntime.unstable_getMesssageByIndex(messageIndex),
2492
+ [threadRuntime, messageIndex]
2493
+ );
2494
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessageComponent, { components }) });
2577
2495
  };
2578
2496
  var ThreadMessage = _react.memo.call(void 0,
2579
2497
  ThreadMessageImpl,
@@ -2610,7 +2528,7 @@ var subscribeToMainThread = (runtime, callback) => {
2610
2528
  let first = true;
2611
2529
  let cleanup;
2612
2530
  const inner = () => {
2613
- _optionalChain([cleanup, 'optionalCall', _106 => _106()]);
2531
+ _optionalChain([cleanup, 'optionalCall', _89 => _89()]);
2614
2532
  cleanup = runtime.thread.subscribe(callback);
2615
2533
  if (!first) {
2616
2534
  callback();
@@ -2621,7 +2539,7 @@ var subscribeToMainThread = (runtime, callback) => {
2621
2539
  inner();
2622
2540
  return () => {
2623
2541
  unsubscribe();
2624
- _optionalChain([cleanup, 'optionalCall', _107 => _107()]);
2542
+ _optionalChain([cleanup, 'optionalCall', _90 => _90()]);
2625
2543
  };
2626
2544
  };
2627
2545
 
@@ -2653,10 +2571,10 @@ var BaseAssistantRuntimeCore = (_class2 = class {
2653
2571
 
2654
2572
  // src/internal.ts
2655
2573
  var internal_exports = {};
2656
- _chunkDCHYNTHIjs.__export.call(void 0, internal_exports, {
2574
+ _chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
2657
2575
  AssistantRuntime: () => AssistantRuntime,
2658
2576
  BaseAssistantRuntimeCore: () => BaseAssistantRuntimeCore,
2659
- BaseThreadRuntimeComposerCore: () => BaseThreadComposerRuntimeCore,
2577
+ BaseThreadComposerRuntimeCore: () => BaseThreadComposerRuntimeCore,
2660
2578
  MessageRepository: () => MessageRepository,
2661
2579
  ProxyConfigProvider: () => ProxyConfigProvider,
2662
2580
  ThreadRuntime: () => ThreadRuntime,
@@ -2669,24 +2587,37 @@ _chunkDCHYNTHIjs.__export.call(void 0, internal_exports, {
2669
2587
 
2670
2588
  // src/runtimes/utils/BaseThreadComposerRuntimeCore.tsx
2671
2589
  var BaseThreadComposerRuntimeCore = (_class3 = class {
2672
- constructor(runtime) {;_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this);
2590
+ constructor(runtime) {;_class3.prototype.__init7.call(this);_class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this);_class3.prototype.__init11.call(this);
2673
2591
  this.runtime = runtime;
2592
+ this.connect();
2674
2593
  }
2675
2594
 
2676
2595
  __init7() {this.attachmentAccept = "*"}
2677
2596
  get isEmpty() {
2678
2597
  return !this.text.trim() && !this.attachments.length;
2679
2598
  }
2599
+ __init8() {this._canCancel = false}
2600
+ get canCancel() {
2601
+ return this._canCancel;
2602
+ }
2603
+ connect() {
2604
+ return this.runtime.subscribe(() => {
2605
+ if (this.canCancel !== this.runtime.capabilities.cancel) {
2606
+ this._canCancel = this.runtime.capabilities.cancel;
2607
+ this.notifySubscribers();
2608
+ }
2609
+ });
2610
+ }
2680
2611
  setAttachmentAdapter(adapter) {
2681
2612
  this._attachmentAdapter = adapter;
2682
- const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess', _108 => _108.accept]), () => ( "*"));
2613
+ const accept = _nullishCoalesce(_optionalChain([adapter, 'optionalAccess', _91 => _91.accept]), () => ( "*"));
2683
2614
  if (this.attachmentAccept !== accept) {
2684
2615
  this.attachmentAccept = accept;
2685
2616
  return true;
2686
2617
  }
2687
2618
  return false;
2688
2619
  }
2689
- __init8() {this._attachments = []}
2620
+ __init9() {this._attachments = []}
2690
2621
  get attachments() {
2691
2622
  return this._attachments;
2692
2623
  }
@@ -2707,7 +2638,7 @@ var BaseThreadComposerRuntimeCore = (_class3 = class {
2707
2638
  this._attachments = this._attachments.toSpliced(index, 1);
2708
2639
  this.notifySubscribers();
2709
2640
  }
2710
- __init9() {this._text = ""}
2641
+ __init10() {this._text = ""}
2711
2642
  get text() {
2712
2643
  return this._text;
2713
2644
  }
@@ -2727,14 +2658,17 @@ var BaseThreadComposerRuntimeCore = (_class3 = class {
2727
2658
  )
2728
2659
  ) : [];
2729
2660
  this.runtime.append({
2730
- parentId: _nullishCoalesce(_optionalChain([this, 'access', _109 => _109.runtime, 'access', _110 => _110.messages, 'access', _111 => _111.at, 'call', _112 => _112(-1), 'optionalAccess', _113 => _113.id]), () => ( null)),
2661
+ parentId: _nullishCoalesce(_optionalChain([this, 'access', _92 => _92.runtime, 'access', _93 => _93.messages, 'access', _94 => _94.at, 'call', _95 => _95(-1), 'optionalAccess', _96 => _96.id]), () => ( null)),
2731
2662
  role: "user",
2732
2663
  content: this.text ? [{ type: "text", text: this.text }] : [],
2733
2664
  attachments
2734
2665
  });
2735
2666
  this.reset();
2736
2667
  }
2737
- __init10() {this._subscriptions = /* @__PURE__ */ new Set()}
2668
+ async cancel() {
2669
+ this.runtime.cancelRun();
2670
+ }
2671
+ __init11() {this._subscriptions = /* @__PURE__ */ new Set()}
2738
2672
  notifySubscribers() {
2739
2673
  for (const callback of this._subscriptions) callback();
2740
2674
  }
@@ -2745,10 +2679,10 @@ var BaseThreadComposerRuntimeCore = (_class3 = class {
2745
2679
  }, _class3);
2746
2680
 
2747
2681
  // src/utils/ProxyConfigProvider.ts
2748
- var ProxyConfigProvider = (_class4 = class {constructor() { _class4.prototype.__init11.call(this); }
2749
- __init11() {this._providers = /* @__PURE__ */ new Set()}
2682
+ var ProxyConfigProvider = (_class4 = class {constructor() { _class4.prototype.__init12.call(this); }
2683
+ __init12() {this._providers = /* @__PURE__ */ new Set()}
2750
2684
  getModelConfig() {
2751
- return _chunkJ2V7Y7JXjs.mergeModelConfigs.call(void 0, this._providers);
2685
+ return _chunk5KIEXJRKjs.mergeModelConfigs.call(void 0, this._providers);
2752
2686
  }
2753
2687
  registerModelConfigProvider(provider) {
2754
2688
  this._providers.add(provider);
@@ -2823,11 +2757,11 @@ var findHead = (message) => {
2823
2757
  if ("current" in message) return message;
2824
2758
  return null;
2825
2759
  };
2826
- var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this); }
2827
- __init12() {this.messages = /* @__PURE__ */ new Map()}
2760
+ var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this); }
2761
+ __init13() {this.messages = /* @__PURE__ */ new Map()}
2828
2762
  // message_id -> item
2829
- __init13() {this.head = null}
2830
- __init14() {this.root = {
2763
+ __init14() {this.head = null}
2764
+ __init15() {this.root = {
2831
2765
  children: [],
2832
2766
  next: null
2833
2767
  }}
@@ -2869,7 +2803,7 @@ var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__in
2869
2803
  }
2870
2804
  }
2871
2805
  getMessages() {
2872
- const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access', _114 => _114.head, 'optionalAccess', _115 => _115.level]), () => ( 0)));
2806
+ const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access', _97 => _97.head, 'optionalAccess', _98 => _98.level]), () => ( 0)));
2873
2807
  for (let current = this.head; current; current = current.prev) {
2874
2808
  messages[current.level] = current.current;
2875
2809
  }
@@ -2907,7 +2841,7 @@ var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__in
2907
2841
  "MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
2908
2842
  );
2909
2843
  return {
2910
- parentId: _nullishCoalesce(_optionalChain([message, 'access', _116 => _116.prev, 'optionalAccess', _117 => _117.current, 'access', _118 => _118.id]), () => ( null)),
2844
+ parentId: _nullishCoalesce(_optionalChain([message, 'access', _99 => _99.prev, 'optionalAccess', _100 => _100.current, 'access', _101 => _101.id]), () => ( null)),
2911
2845
  message: message.current
2912
2846
  };
2913
2847
  }
@@ -2991,11 +2925,11 @@ var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__in
2991
2925
  for (const [, message] of this.messages) {
2992
2926
  exportItems.push({
2993
2927
  message: message.current,
2994
- parentId: _nullishCoalesce(_optionalChain([message, 'access', _119 => _119.prev, 'optionalAccess', _120 => _120.current, 'access', _121 => _121.id]), () => ( null))
2928
+ parentId: _nullishCoalesce(_optionalChain([message, 'access', _102 => _102.prev, 'optionalAccess', _103 => _103.current, 'access', _104 => _104.id]), () => ( null))
2995
2929
  });
2996
2930
  }
2997
2931
  return {
2998
- headId: _nullishCoalesce(_optionalChain([this, 'access', _122 => _122.head, 'optionalAccess', _123 => _123.current, 'access', _124 => _124.id]), () => ( null)),
2932
+ headId: _nullishCoalesce(_optionalChain([this, 'access', _105 => _105.head, 'optionalAccess', _106 => _106.current, 'access', _107 => _107.id]), () => ( null)),
2999
2933
  messages: exportItems
3000
2934
  };
3001
2935
  }
@@ -3003,7 +2937,7 @@ var MessageRepository = (_class5 = class {constructor() { _class5.prototype.__in
3003
2937
  for (const { message, parentId } of messages) {
3004
2938
  this.addOrUpdateMessage(parentId, message);
3005
2939
  }
3006
- this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access', _125 => _125.at, 'call', _126 => _126(-1), 'optionalAccess', _127 => _127.message, 'access', _128 => _128.id]))), () => ( null)));
2940
+ this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access', _108 => _108.at, 'call', _109 => _109(-1), 'optionalAccess', _110 => _110.message, 'access', _111 => _111.id]))), () => ( null)));
3007
2941
  }
3008
2942
  }, _class5);
3009
2943
 
@@ -3104,8 +3038,8 @@ var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, sid
3104
3038
  TooltipIconButton.displayName = "TooltipIconButton";
3105
3039
 
3106
3040
  // src/api/subscribable/BaseSubject.ts
3107
- var BaseSubject = (_class6 = class {constructor() { _class6.prototype.__init15.call(this); }
3108
- __init15() {this._subscriptions = /* @__PURE__ */ new Set()}
3041
+ var BaseSubject = (_class6 = class {constructor() { _class6.prototype.__init16.call(this); }
3042
+ __init16() {this._subscriptions = /* @__PURE__ */ new Set()}
3109
3043
 
3110
3044
  get isConnected() {
3111
3045
  return !!this._connection;
@@ -3118,7 +3052,7 @@ var BaseSubject = (_class6 = class {constructor() { _class6.prototype.__init15.c
3118
3052
  if (this._connection) return;
3119
3053
  this._connection = this._connect();
3120
3054
  } else {
3121
- _optionalChain([this, 'access', _129 => _129._connection, 'optionalCall', _130 => _130()]);
3055
+ _optionalChain([this, 'access', _112 => _112._connection, 'optionalCall', _113 => _113()]);
3122
3056
  this._connection = void 0;
3123
3057
  }
3124
3058
  }
@@ -3151,13 +3085,13 @@ var NestedSubscriptionSubject = class extends BaseSubject {
3151
3085
  const newState = this.binding.getState();
3152
3086
  if (newState === lastState) return;
3153
3087
  lastState = newState;
3154
- _optionalChain([innerUnsubscribe, 'optionalCall', _131 => _131()]);
3088
+ _optionalChain([innerUnsubscribe, 'optionalCall', _114 => _114()]);
3155
3089
  innerUnsubscribe = this.binding.getState().subscribe(callback);
3156
3090
  callback();
3157
3091
  };
3158
3092
  const outerUnsubscribe = this.binding.subscribe(onRuntimeUpdate);
3159
3093
  return () => {
3160
- _optionalChain([outerUnsubscribe, 'optionalCall', _132 => _132()]);
3094
+ _optionalChain([outerUnsubscribe, 'optionalCall', _115 => _115()]);
3161
3095
  innerUnsubscribe();
3162
3096
  };
3163
3097
  }
@@ -3213,7 +3147,7 @@ var ContentPartRuntime = class {
3213
3147
  const toolName = state.part.toolName;
3214
3148
  const toolCallId = state.part.toolCallId;
3215
3149
  this.threadApi.getState().addToolResult({
3216
- messageId: message.message.id,
3150
+ messageId: message.id,
3217
3151
  toolName,
3218
3152
  toolCallId,
3219
3153
  result
@@ -3237,7 +3171,7 @@ function shallowEqual(objA, objB) {
3237
3171
  // src/api/subscribable/ShallowMemoizeSubject.ts
3238
3172
  var ShallowMemoizeSubject = (_class7 = class extends BaseSubject {
3239
3173
  constructor(binding) {
3240
- super();_class7.prototype.__init16.call(this);;
3174
+ super();_class7.prototype.__init17.call(this);;
3241
3175
  this.binding = binding;
3242
3176
  const state = binding.getState();
3243
3177
  if (state === void 0)
@@ -3245,7 +3179,7 @@ var ShallowMemoizeSubject = (_class7 = class extends BaseSubject {
3245
3179
  this._previousState = state;
3246
3180
  }
3247
3181
 
3248
- __init16() {this.getState = () => {
3182
+ __init17() {this.getState = () => {
3249
3183
  if (!this.isConnected) this._syncState();
3250
3184
  return this._previousState;
3251
3185
  }}
@@ -3267,60 +3201,13 @@ var ShallowMemoizeSubject = (_class7 = class extends BaseSubject {
3267
3201
  }, _class7);
3268
3202
 
3269
3203
  // src/api/MessageRuntime.ts
3270
- var MessageState = class {
3271
- constructor(snapshot) {
3272
- this.snapshot = snapshot;
3273
- }
3274
- /**
3275
- * @deprecated Replace `.message.content` with `.content` etc. This will be removed in 0.6.0.
3276
- */
3277
- get message() {
3278
- return this.snapshot.message;
3279
- }
3280
- get id() {
3281
- return this.snapshot.message.id;
3282
- }
3283
- get createdAt() {
3284
- return this.snapshot.message.createdAt;
3285
- }
3286
- get role() {
3287
- return this.snapshot.message.role;
3288
- }
3289
- get content() {
3290
- return this.snapshot.message.content;
3291
- }
3292
- get attachments() {
3293
- return this.snapshot.message.attachments;
3294
- }
3295
- get metadata() {
3296
- return this.snapshot.message.metadata;
3297
- }
3298
- get status() {
3299
- return this.snapshot.message.status;
3300
- }
3301
- get parentId() {
3302
- return this.snapshot.parentId;
3303
- }
3304
- get isLast() {
3305
- return this.snapshot.isLast;
3306
- }
3307
- get branches() {
3308
- return this.snapshot.branches;
3309
- }
3310
- get branchNumber() {
3311
- return this.snapshot.branchNumber;
3312
- }
3313
- get branchCount() {
3314
- return this.snapshot.branchCount;
3315
- }
3316
- };
3317
3204
  var MessageRuntime = class {
3318
3205
  constructor(_core, _threadBinding) {
3319
3206
  this._core = _core;
3320
3207
  this._threadBinding = _threadBinding;
3321
3208
  }
3322
3209
  getState() {
3323
- return new MessageState(this._core.getState());
3210
+ return this._core.getState();
3324
3211
  }
3325
3212
  // TODO improve type
3326
3213
  edit(message) {
@@ -3339,13 +3226,13 @@ var MessageRuntime = class {
3339
3226
  speak() {
3340
3227
  const state = this._core.getState();
3341
3228
  if (!state) throw new Error("Message is not available");
3342
- this._threadBinding.getState().speak(state.message.id);
3229
+ this._threadBinding.getState().speak(state.id);
3343
3230
  }
3344
3231
  submitFeedback({ type }) {
3345
3232
  const state = this._core.getState();
3346
3233
  if (!state) throw new Error("Message is not available");
3347
3234
  this._threadBinding.getState().submitFeedback({
3348
- messageId: state.message.id,
3235
+ messageId: state.id,
3349
3236
  type
3350
3237
  });
3351
3238
  }
@@ -3361,7 +3248,7 @@ var MessageRuntime = class {
3361
3248
  throw new Error("Must specify either branchId or position");
3362
3249
  }
3363
3250
  const thread = this._threadBinding.getState();
3364
- const branches = thread.getBranches(state.message.id);
3251
+ const branches = thread.getBranches(state.id);
3365
3252
  let targetBranch = branchId;
3366
3253
  if (position === "previous") {
3367
3254
  targetBranch = branches[state.branchNumber - 2];
@@ -3398,27 +3285,18 @@ var MessageRuntime = class {
3398
3285
  };
3399
3286
 
3400
3287
  // src/api/ThreadComposerRuntime.ts
3401
- var ComposerState = class {
3402
- constructor(_composerBinding) {
3403
- this._composerBinding = _composerBinding;
3404
- }
3405
- get isEmpty() {
3406
- return this._composerBinding.getState().isEmpty;
3407
- }
3408
- get text() {
3409
- return this._composerBinding.getState().text;
3410
- }
3411
- get attachmentAccept() {
3412
- return this._composerBinding.getState().attachmentAccept;
3413
- }
3414
- get attachments() {
3415
- return this._composerBinding.getState().attachments;
3416
- }
3288
+ var getThreadComposerState = (runtime) => {
3289
+ return Object.freeze({
3290
+ canCancel: runtime.canCancel,
3291
+ isEmpty: runtime.isEmpty,
3292
+ text: runtime.text,
3293
+ attachments: runtime.attachments,
3294
+ attachmentAccept: runtime.attachmentAccept
3295
+ });
3417
3296
  };
3418
3297
  var ThreadComposerRuntime = class {
3419
3298
  constructor(_core) {
3420
3299
  this._core = _core;
3421
- this._state = new ComposerState(_core);
3422
3300
  }
3423
3301
  /**
3424
3302
  * @deprecated Use `getState().isEmpty` instead. This will be removed in 0.6.0.
@@ -3426,6 +3304,12 @@ var ThreadComposerRuntime = class {
3426
3304
  get isEmpty() {
3427
3305
  return this._core.getState().isEmpty;
3428
3306
  }
3307
+ /**
3308
+ * @deprecated Use `getState().canCancel` instead. This will be removed in 0.6.0.
3309
+ */
3310
+ get canCancel() {
3311
+ return this._core.getState().canCancel;
3312
+ }
3429
3313
  /**
3430
3314
  * @deprecated Use `getState().text` instead. This will be removed in 0.6.0.
3431
3315
  */
@@ -3445,9 +3329,8 @@ var ThreadComposerRuntime = class {
3445
3329
  get attachments() {
3446
3330
  return this._core.getState().attachments;
3447
3331
  }
3448
-
3449
3332
  getState() {
3450
- return this._state;
3333
+ return getThreadComposerState(this._core.getState());
3451
3334
  }
3452
3335
  setText(text) {
3453
3336
  this._core.getState().setText(text);
@@ -3470,33 +3353,46 @@ var ThreadComposerRuntime = class {
3470
3353
  send() {
3471
3354
  this._core.getState().send();
3472
3355
  }
3356
+ cancel() {
3357
+ this._core.getState().cancel();
3358
+ }
3473
3359
  subscribe(callback) {
3474
3360
  return this._core.subscribe(callback);
3475
3361
  }
3476
3362
  };
3477
3363
 
3478
3364
  // src/api/ThreadRuntime.ts
3479
- var ThreadState = class {
3480
- constructor(_core) {
3481
- this._core = _core;
3482
- }
3483
- get threadId() {
3484
- return this._core.threadId;
3485
- }
3486
- get isDisabled() {
3487
- return this._core.isDisabled;
3488
- }
3489
- get isRunning() {
3490
- const messages = this._core.messages;
3491
- const lastMessage = messages[messages.length - 1];
3492
- return _optionalChain([lastMessage, 'optionalAccess', _133 => _133.role]) !== "assistant" ? false : lastMessage.status.type === "running";
3365
+ var toAppendMessage = (messages, message) => {
3366
+ if (typeof message === "string") {
3367
+ return {
3368
+ parentId: _nullishCoalesce(_optionalChain([messages, 'access', _116 => _116.at, 'call', _117 => _117(-1), 'optionalAccess', _118 => _118.id]), () => ( null)),
3369
+ role: "user",
3370
+ content: [{ type: "text", text: message }],
3371
+ attachments: []
3372
+ };
3493
3373
  }
3494
- get capabilities() {
3495
- return this._core.capabilities;
3374
+ if (message.role && message.parentId && message.attachments) {
3375
+ return message;
3496
3376
  }
3377
+ return {
3378
+ parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([messages, 'access', _119 => _119.at, 'call', _120 => _120(-1), 'optionalAccess', _121 => _121.id]))), () => ( null)),
3379
+ role: _nullishCoalesce(message.role, () => ( "user")),
3380
+ content: message.content,
3381
+ attachments: _nullishCoalesce(message.attachments, () => ( []))
3382
+ };
3383
+ };
3384
+ var getThreadState = (runtime) => {
3385
+ const lastMessage = runtime.messages.at(-1);
3386
+ return Object.freeze({
3387
+ threadId: runtime.threadId,
3388
+ capabilities: runtime.capabilities,
3389
+ isDisabled: runtime.isDisabled,
3390
+ isRunning: _optionalChain([lastMessage, 'optionalAccess', _122 => _122.role]) !== "assistant" ? false : lastMessage.status.type === "running",
3391
+ unstable_synchronizer: runtime.unstable_synchronizer
3392
+ });
3497
3393
  };
3498
3394
  var ThreadRuntime = (_class8 = class {
3499
- constructor(_threadBinding) {;_class8.prototype.__init17.call(this);
3395
+ constructor(_threadBinding) {;_class8.prototype.__init18.call(this);
3500
3396
  this._threadBinding = _threadBinding;
3501
3397
  }
3502
3398
  // public path = "assistant.threads[main]"; // TODO
@@ -3531,17 +3427,19 @@ var ThreadRuntime = (_class8 = class {
3531
3427
  unstable_getCore() {
3532
3428
  return this._threadBinding.getState();
3533
3429
  }
3534
- __init17() {this.composer = new ThreadComposerRuntime(
3430
+ __init18() {this.composer = new ThreadComposerRuntime(
3535
3431
  new NestedSubscriptionSubject({
3536
3432
  getState: () => this._threadBinding.getState().composer,
3537
3433
  subscribe: (callback) => this._threadBinding.subscribe(callback)
3538
3434
  })
3539
3435
  )}
3540
3436
  getState() {
3541
- return new ThreadState(this._threadBinding.getState());
3437
+ return getThreadState(this._threadBinding.getState());
3542
3438
  }
3543
3439
  append(message) {
3544
- this._threadBinding.getState().append(message);
3440
+ this._threadBinding.getState().append(
3441
+ toAppendMessage(this._threadBinding.getState().messages, message)
3442
+ );
3545
3443
  }
3546
3444
  subscribe(callback) {
3547
3445
  return this._threadBinding.subscribe(callback);
@@ -3601,9 +3499,10 @@ var ThreadRuntime = (_class8 = class {
3601
3499
  if (!message) return void 0;
3602
3500
  const branches = this._threadBinding.getState().getBranches(message.id);
3603
3501
  return {
3502
+ ...message,
3604
3503
  message,
3605
3504
  isLast: idx === messages.length - 1,
3606
- parentId: _nullishCoalesce(_optionalChain([messages, 'access', _134 => _134[idx - 1], 'optionalAccess', _135 => _135.id]), () => ( null)),
3505
+ parentId: _nullishCoalesce(_optionalChain([messages, 'access', _123 => _123[idx - 1], 'optionalAccess', _124 => _124.id]), () => ( null)),
3607
3506
  branches,
3608
3507
  branchNumber: branches.indexOf(message.id) + 1,
3609
3508
  branchCount: branches.length
@@ -3679,7 +3578,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
3679
3578
  });
3680
3579
  if (mergeRoundtrips) {
3681
3580
  const previousMessage = messages[messages.length - 1];
3682
- if (_optionalChain([previousMessage, 'optionalAccess', _136 => _136.role]) === "assistant") {
3581
+ if (_optionalChain([previousMessage, 'optionalAccess', _125 => _125.role]) === "assistant") {
3683
3582
  previousMessage.content.push(...newContent);
3684
3583
  break;
3685
3584
  }
@@ -3692,7 +3591,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
3692
3591
  }
3693
3592
  case "tool": {
3694
3593
  const previousMessage = messages[messages.length - 1];
3695
- if (_optionalChain([previousMessage, 'optionalAccess', _137 => _137.role]) !== "assistant")
3594
+ if (_optionalChain([previousMessage, 'optionalAccess', _126 => _126.role]) !== "assistant")
3696
3595
  throw new Error(
3697
3596
  "A tool message must be preceded by an assistant message."
3698
3597
  );
@@ -3768,14 +3667,14 @@ function streamPartDecoderStream() {
3768
3667
  controller.enqueue(decodeStreamPart(chunk));
3769
3668
  }
3770
3669
  });
3771
- return new (0, _chunkJ2V7Y7JXjs.PipeableTransformStream)((readable) => {
3670
+ return new (0, _chunk5KIEXJRKjs.PipeableTransformStream)((readable) => {
3772
3671
  return readable.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(decodeStream);
3773
3672
  });
3774
3673
  }
3775
3674
 
3776
3675
  // src/runtimes/edge/streams/utils/index.ts
3777
3676
  var streamUtils = {
3778
- streamPartEncoderStream: _chunkJ2V7Y7JXjs.streamPartEncoderStream,
3677
+ streamPartEncoderStream: _chunk5KIEXJRKjs.streamPartEncoderStream,
3779
3678
  streamPartDecoderStream
3780
3679
  };
3781
3680
 
@@ -3884,8 +3783,8 @@ var EdgeChatAdapter = class {
3884
3783
  credentials: _nullishCoalesce(this.options.credentials, () => ( "same-origin")),
3885
3784
  body: JSON.stringify({
3886
3785
  system: config.system,
3887
- messages: _chunkJ2V7Y7JXjs.toCoreMessages.call(void 0, messages),
3888
- tools: config.tools ? _chunkJ2V7Y7JXjs.toLanguageModelTools.call(void 0, config.tools) : [],
3786
+ messages: _chunk5KIEXJRKjs.toCoreMessages.call(void 0, messages),
3787
+ tools: config.tools ? _chunk5KIEXJRKjs.toLanguageModelTools.call(void 0, config.tools) : [],
3889
3788
  ...config.callSettings,
3890
3789
  ...config.config,
3891
3790
  ...this.options.body
@@ -3895,7 +3794,7 @@ var EdgeChatAdapter = class {
3895
3794
  if (result.status !== 200) {
3896
3795
  throw new Error(`Status ${result.status}: ${await result.text()}`);
3897
3796
  }
3898
- const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkJ2V7Y7JXjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkJ2V7Y7JXjs.runResultStream.call(void 0, ));
3797
+ const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunk5KIEXJRKjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunk5KIEXJRKjs.runResultStream.call(void 0, ));
3899
3798
  let update;
3900
3799
  for await (update of asAsyncIterable(stream)) {
3901
3800
  yield update;
@@ -3921,11 +3820,11 @@ var useEdgeRuntime = ({
3921
3820
  };
3922
3821
 
3923
3822
  // src/runtimes/local/shouldContinue.tsx
3924
- var shouldContinue = (result) => _optionalChain([result, 'access', _138 => _138.status, 'optionalAccess', _139 => _139.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
3823
+ var shouldContinue = (result) => _optionalChain([result, 'access', _127 => _127.status, 'optionalAccess', _128 => _128.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
3925
3824
 
3926
3825
  // src/runtimes/local/LocalThreadRuntimeCore.tsx
3927
3826
  var LocalThreadRuntimeCore = (_class9 = class {
3928
- constructor(configProvider, adapter, { initialMessages, ...options }) {;_class9.prototype.__init18.call(this);_class9.prototype.__init19.call(this);_class9.prototype.__init20.call(this);_class9.prototype.__init21.call(this);_class9.prototype.__init22.call(this);_class9.prototype.__init23.call(this);
3827
+ constructor(configProvider, adapter, { initialMessages, ...options }) {;_class9.prototype.__init19.call(this);_class9.prototype.__init20.call(this);_class9.prototype.__init21.call(this);_class9.prototype.__init22.call(this);_class9.prototype.__init23.call(this);_class9.prototype.__init24.call(this);
3929
3828
  this.configProvider = configProvider;
3930
3829
  this.adapter = adapter;
3931
3830
  this.threadId = generateId();
@@ -3939,10 +3838,10 @@ var LocalThreadRuntimeCore = (_class9 = class {
3939
3838
  }
3940
3839
  }
3941
3840
  }
3942
- __init18() {this._subscriptions = /* @__PURE__ */ new Set()}
3943
- __init19() {this.abortController = null}
3944
- __init20() {this.repository = new MessageRepository()}
3945
- __init21() {this.capabilities = {
3841
+ __init19() {this._subscriptions = /* @__PURE__ */ new Set()}
3842
+ __init20() {this.abortController = null}
3843
+ __init21() {this.repository = new MessageRepository()}
3844
+ __init22() {this.capabilities = {
3946
3845
  switchToBranch: true,
3947
3846
  edit: true,
3948
3847
  reload: true,
@@ -3953,11 +3852,11 @@ var LocalThreadRuntimeCore = (_class9 = class {
3953
3852
  feedback: false
3954
3853
  }}
3955
3854
 
3956
- __init22() {this.isDisabled = false}
3855
+ __init23() {this.isDisabled = false}
3957
3856
  get messages() {
3958
3857
  return this.repository.getMessages();
3959
3858
  }
3960
- __init23() {this.composer = new BaseThreadComposerRuntimeCore(this)}
3859
+ __init24() {this.composer = new BaseThreadComposerRuntimeCore(this)}
3961
3860
  getModelConfig() {
3962
3861
  return this.configProvider.getModelConfig();
3963
3862
  }
@@ -3968,18 +3867,18 @@ var LocalThreadRuntimeCore = (_class9 = class {
3968
3867
  set options({ initialMessages, ...options }) {
3969
3868
  this._options = options;
3970
3869
  let hasUpdates = false;
3971
- const canSpeak = _optionalChain([options, 'access', _140 => _140.adapters, 'optionalAccess', _141 => _141.speech]) !== void 0;
3870
+ const canSpeak = _optionalChain([options, 'access', _129 => _129.adapters, 'optionalAccess', _130 => _130.speech]) !== void 0;
3972
3871
  if (this.capabilities.speak !== canSpeak) {
3973
3872
  this.capabilities.speak = canSpeak;
3974
3873
  hasUpdates = true;
3975
3874
  }
3976
- this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _142 => _142.adapters, 'optionalAccess', _143 => _143.attachments]));
3977
- const canAttach = _optionalChain([options, 'access', _144 => _144.adapters, 'optionalAccess', _145 => _145.attachments]) !== void 0;
3875
+ this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _131 => _131.adapters, 'optionalAccess', _132 => _132.attachments]));
3876
+ const canAttach = _optionalChain([options, 'access', _133 => _133.adapters, 'optionalAccess', _134 => _134.attachments]) !== void 0;
3978
3877
  if (this.capabilities.attachments !== canAttach) {
3979
3878
  this.capabilities.attachments = canAttach;
3980
3879
  hasUpdates = true;
3981
3880
  }
3982
- const canFeedback = _optionalChain([options, 'access', _146 => _146.adapters, 'optionalAccess', _147 => _147.feedback]) !== void 0;
3881
+ const canFeedback = _optionalChain([options, 'access', _135 => _135.adapters, 'optionalAccess', _136 => _136.feedback]) !== void 0;
3983
3882
  if (this.capabilities.feedback !== canFeedback) {
3984
3883
  this.capabilities.feedback = canFeedback;
3985
3884
  hasUpdates = true;
@@ -4021,18 +3920,18 @@ var LocalThreadRuntimeCore = (_class9 = class {
4021
3920
  }
4022
3921
  async performRoundtrip(parentId, message) {
4023
3922
  const messages = this.repository.getMessages();
4024
- _optionalChain([this, 'access', _148 => _148.abortController, 'optionalAccess', _149 => _149.abort, 'call', _150 => _150()]);
3923
+ _optionalChain([this, 'access', _137 => _137.abortController, 'optionalAccess', _138 => _138.abort, 'call', _139 => _139()]);
4025
3924
  this.abortController = new AbortController();
4026
3925
  const initialContent = message.content;
4027
- const initialRoundtrips = _optionalChain([message, 'access', _151 => _151.metadata, 'optionalAccess', _152 => _152.roundtrips]);
4028
- const initalCustom = _optionalChain([message, 'access', _153 => _153.metadata, 'optionalAccess', _154 => _154.custom]);
3926
+ const initialRoundtrips = _optionalChain([message, 'access', _140 => _140.metadata, 'optionalAccess', _141 => _141.roundtrips]);
3927
+ const initalCustom = _optionalChain([message, 'access', _142 => _142.metadata, 'optionalAccess', _143 => _143.custom]);
4029
3928
  const updateMessage = (m) => {
4030
3929
  message = {
4031
3930
  ...message,
4032
3931
  ...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
4033
3932
  status: _nullishCoalesce(m.status, () => ( message.status)),
4034
3933
  // TODO deprecated, remove in v0.6
4035
- ..._optionalChain([m, 'access', _155 => _155.metadata, 'optionalAccess', _156 => _156.roundtrips]) ? {
3934
+ ..._optionalChain([m, 'access', _144 => _144.metadata, 'optionalAccess', _145 => _145.roundtrips]) ? {
4036
3935
  roundtrips: [
4037
3936
  ..._nullishCoalesce(initialRoundtrips, () => ( [])),
4038
3937
  ...m.metadata.roundtrips
@@ -4047,7 +3946,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
4047
3946
  ...m.metadata.roundtrips
4048
3947
  ]
4049
3948
  } : void 0,
4050
- ..._optionalChain([m, 'access', _157 => _157.metadata, 'optionalAccess', _158 => _158.custom]) ? {
3949
+ ..._optionalChain([m, 'access', _146 => _146.metadata, 'optionalAccess', _147 => _147.custom]) ? {
4051
3950
  custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
4052
3951
  } : void 0
4053
3952
  }
@@ -4057,7 +3956,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
4057
3956
  this.notifySubscribers();
4058
3957
  };
4059
3958
  const maxToolRoundtrips = _nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1));
4060
- const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _159 => _159.metadata, 'optionalAccess', _160 => _160.roundtrips, 'optionalAccess', _161 => _161.length]), () => ( 0));
3959
+ const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _148 => _148.metadata, 'optionalAccess', _149 => _149.roundtrips, 'optionalAccess', _150 => _150.length]), () => ( 0));
4061
3960
  if (toolRoundtrips > maxToolRoundtrips) {
4062
3961
  updateMessage({
4063
3962
  status: {
@@ -4156,7 +4055,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
4156
4055
  // TODO lift utterance state to thread runtime
4157
4056
 
4158
4057
  speak(messageId) {
4159
- const adapter = _optionalChain([this, 'access', _162 => _162.options, 'access', _163 => _163.adapters, 'optionalAccess', _164 => _164.speech]);
4058
+ const adapter = _optionalChain([this, 'access', _151 => _151.options, 'access', _152 => _152.adapters, 'optionalAccess', _153 => _153.speech]);
4160
4059
  if (!adapter) throw new Error("Speech adapter not configured");
4161
4060
  const { message } = this.repository.getMessage(messageId);
4162
4061
  if (this._utterance) {
@@ -4173,7 +4072,7 @@ var LocalThreadRuntimeCore = (_class9 = class {
4173
4072
  return this._utterance;
4174
4073
  }
4175
4074
  submitFeedback({ messageId, type }) {
4176
- const adapter = _optionalChain([this, 'access', _165 => _165.options, 'access', _166 => _166.adapters, 'optionalAccess', _167 => _167.feedback]);
4075
+ const adapter = _optionalChain([this, 'access', _154 => _154.options, 'access', _155 => _155.adapters, 'optionalAccess', _156 => _156.feedback]);
4177
4076
  if (!adapter) throw new Error("Feedback adapter not configured");
4178
4077
  const { message } = this.repository.getMessage(messageId);
4179
4078
  adapter.submit({ message, type });
@@ -4220,7 +4119,7 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4220
4119
  const messages = fromCoreMessages(initialMessages);
4221
4120
  this.thread.import({
4222
4121
  messages: messages.map((m, idx) => ({
4223
- parentId: _nullishCoalesce(_optionalChain([messages, 'access', _168 => _168[idx - 1], 'optionalAccess', _169 => _169.id]), () => ( null)),
4122
+ parentId: _nullishCoalesce(_optionalChain([messages, 'access', _157 => _157[idx - 1], 'optionalAccess', _158 => _158.id]), () => ( null)),
4224
4123
  message: m
4225
4124
  }))
4226
4125
  });
@@ -4256,8 +4155,8 @@ var getExternalStoreMessage = (message) => {
4256
4155
  };
4257
4156
 
4258
4157
  // src/runtimes/external-store/ThreadMessageConverter.ts
4259
- var ThreadMessageConverter = (_class10 = class {constructor() { _class10.prototype.__init24.call(this); }
4260
- __init24() {this.cache = /* @__PURE__ */ new WeakMap()}
4158
+ var ThreadMessageConverter = (_class10 = class {constructor() { _class10.prototype.__init25.call(this); }
4159
+ __init25() {this.cache = /* @__PURE__ */ new WeakMap()}
4261
4160
  convertMessages(messages, converter) {
4262
4161
  return messages.map((m, idx) => {
4263
4162
  const cached = this.cache.get(m);
@@ -4353,17 +4252,17 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
4353
4252
 
4354
4253
  // src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
4355
4254
  var hasUpcomingMessage = (isRunning, messages) => {
4356
- return isRunning && _optionalChain([messages, 'access', _170 => _170[messages.length - 1], 'optionalAccess', _171 => _171.role]) !== "assistant";
4255
+ return isRunning && _optionalChain([messages, 'access', _159 => _159[messages.length - 1], 'optionalAccess', _160 => _160.role]) !== "assistant";
4357
4256
  };
4358
4257
  var ExternalStoreThreadRuntimeCore = (_class11 = class {
4359
- constructor(configProvider, store) {;_class11.prototype.__init25.call(this);_class11.prototype.__init26.call(this);_class11.prototype.__init27.call(this);_class11.prototype.__init28.call(this);_class11.prototype.__init29.call(this);_class11.prototype.__init30.call(this);_class11.prototype.__init31.call(this);
4258
+ constructor(configProvider, store) {;_class11.prototype.__init26.call(this);_class11.prototype.__init27.call(this);_class11.prototype.__init28.call(this);_class11.prototype.__init29.call(this);_class11.prototype.__init30.call(this);_class11.prototype.__init31.call(this);_class11.prototype.__init32.call(this);
4360
4259
  this.configProvider = configProvider;
4361
4260
  this.store = store;
4362
4261
  }
4363
- __init25() {this._subscriptions = /* @__PURE__ */ new Set()}
4364
- __init26() {this.repository = new MessageRepository()}
4365
- __init27() {this.assistantOptimisticId = null}
4366
- __init28() {this._capabilities = {
4262
+ __init26() {this._subscriptions = /* @__PURE__ */ new Set()}
4263
+ __init27() {this.repository = new MessageRepository()}
4264
+ __init28() {this.assistantOptimisticId = null}
4265
+ __init29() {this._capabilities = {
4367
4266
  switchToBranch: false,
4368
4267
  edit: false,
4369
4268
  reload: false,
@@ -4379,9 +4278,9 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4379
4278
 
4380
4279
 
4381
4280
 
4382
- __init29() {this.converter = new ThreadMessageConverter()}
4281
+ __init30() {this.converter = new ThreadMessageConverter()}
4383
4282
 
4384
- __init30() {this.composer = new BaseThreadComposerRuntimeCore(this)}
4283
+ __init31() {this.composer = new BaseThreadComposerRuntimeCore(this)}
4385
4284
  get store() {
4386
4285
  return this._store;
4387
4286
  }
@@ -4398,12 +4297,12 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4398
4297
  reload: this._store.onReload !== void 0,
4399
4298
  cancel: this._store.onCancel !== void 0,
4400
4299
  speak: this._store.onSpeak !== void 0,
4401
- unstable_copy: _optionalChain([this, 'access', _175 => _175._store, 'access', _176 => _176.unstable_capabilities, 'optionalAccess', _177 => _177.copy]) !== false,
4300
+ unstable_copy: _optionalChain([this, 'access', _164 => _164._store, 'access', _165 => _165.unstable_capabilities, 'optionalAccess', _166 => _166.copy]) !== false,
4402
4301
  // default true
4403
- attachments: !!_optionalChain([this, 'access', _178 => _178.store, 'access', _179 => _179.adapters, 'optionalAccess', _180 => _180.attachments]),
4404
- feedback: !!_optionalChain([this, 'access', _181 => _181.store, 'access', _182 => _182.adapters, 'optionalAccess', _183 => _183.feedback])
4302
+ attachments: !!_optionalChain([this, 'access', _167 => _167.store, 'access', _168 => _168.adapters, 'optionalAccess', _169 => _169.attachments]),
4303
+ feedback: !!_optionalChain([this, 'access', _170 => _170.store, 'access', _171 => _171.adapters, 'optionalAccess', _172 => _172.feedback])
4405
4304
  };
4406
- this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _184 => _184._store, 'access', _185 => _185.adapters, 'optionalAccess', _186 => _186.attachments]));
4305
+ this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _173 => _173._store, 'access', _174 => _174.adapters, 'optionalAccess', _175 => _175.attachments]));
4407
4306
  if (oldStore) {
4408
4307
  if (oldStore.convertMessage !== store.convertMessage) {
4409
4308
  this.converter = new ThreadMessageConverter();
@@ -4429,7 +4328,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4429
4328
  for (let i = 0; i < messages.length; i++) {
4430
4329
  const message = messages[i];
4431
4330
  const parent = messages[i - 1];
4432
- this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _187 => _187.id]), () => ( null)), message);
4331
+ this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _176 => _176.id]), () => ( null)), message);
4433
4332
  }
4434
4333
  if (this.assistantOptimisticId) {
4435
4334
  this.repository.deleteMessage(this.assistantOptimisticId);
@@ -4437,7 +4336,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4437
4336
  }
4438
4337
  if (hasUpcomingMessage(isRunning, messages)) {
4439
4338
  this.assistantOptimisticId = this.repository.appendOptimisticMessage(
4440
- _nullishCoalesce(_optionalChain([messages, 'access', _188 => _188.at, 'call', _189 => _189(-1), 'optionalAccess', _190 => _190.id]), () => ( null)),
4339
+ _nullishCoalesce(_optionalChain([messages, 'access', _177 => _177.at, 'call', _178 => _178(-1), 'optionalAccess', _179 => _179.id]), () => ( null)),
4441
4340
  {
4442
4341
  role: "assistant",
4443
4342
  content: []
@@ -4445,7 +4344,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4445
4344
  );
4446
4345
  }
4447
4346
  this.repository.resetHead(
4448
- _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _191 => _191.at, 'call', _192 => _192(-1), 'optionalAccess', _193 => _193.id]))), () => ( null))
4347
+ _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _180 => _180.at, 'call', _181 => _181(-1), 'optionalAccess', _182 => _182.id]))), () => ( null))
4449
4348
  );
4450
4349
  this.messages = this.repository.getMessages();
4451
4350
  this.notifySubscribers();
@@ -4466,7 +4365,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4466
4365
  this.updateMessages(this.repository.getMessages());
4467
4366
  }
4468
4367
  async append(message) {
4469
- if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _194 => _194.messages, 'access', _195 => _195.at, 'call', _196 => _196(-1), 'optionalAccess', _197 => _197.id]), () => ( null)))) {
4368
+ if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _183 => _183.messages, 'access', _184 => _184.at, 'call', _185 => _185(-1), 'optionalAccess', _186 => _186.id]), () => ( null)))) {
4470
4369
  if (!this._store.onEdit)
4471
4370
  throw new Error("Runtime does not support editing messages.");
4472
4371
  await this._store.onEdit(message);
@@ -4489,7 +4388,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4489
4388
  }
4490
4389
  let messages = this.repository.getMessages();
4491
4390
  const previousMessage = messages[messages.length - 1];
4492
- if (_optionalChain([previousMessage, 'optionalAccess', _198 => _198.role]) === "user" && previousMessage.id === _optionalChain([messages, 'access', _199 => _199.at, 'call', _200 => _200(-1), 'optionalAccess', _201 => _201.id])) {
4391
+ if (_optionalChain([previousMessage, 'optionalAccess', _187 => _187.role]) === "user" && previousMessage.id === _optionalChain([messages, 'access', _188 => _188.at, 'call', _189 => _189(-1), 'optionalAccess', _190 => _190.id])) {
4493
4392
  this.repository.deleteMessage(previousMessage.id);
4494
4393
  if (!this.composer.text.trim()) {
4495
4394
  this.composer.setText(getThreadMessageText(previousMessage));
@@ -4514,7 +4413,7 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4514
4413
  return this._store.onSpeak(message);
4515
4414
  }
4516
4415
  submitFeedback({ messageId, type }) {
4517
- const adapter = _optionalChain([this, 'access', _202 => _202._store, 'access', _203 => _203.adapters, 'optionalAccess', _204 => _204.feedback]);
4416
+ const adapter = _optionalChain([this, 'access', _191 => _191._store, 'access', _192 => _192.adapters, 'optionalAccess', _193 => _193.feedback]);
4518
4417
  if (!adapter) throw new Error("Feedback adapter not configured");
4519
4418
  const { message } = this.repository.getMessage(messageId);
4520
4419
  adapter.submit({ message, type });
@@ -4523,8 +4422,8 @@ var ExternalStoreThreadRuntimeCore = (_class11 = class {
4523
4422
  this._subscriptions.add(callback);
4524
4423
  return () => this._subscriptions.delete(callback);
4525
4424
  }
4526
- __init31() {this.updateMessages = (messages) => {
4527
- _optionalChain([this, 'access', _205 => _205._store, 'access', _206 => _206.setMessages, 'optionalCall', _207 => _207(
4425
+ __init32() {this.updateMessages = (messages) => {
4426
+ _optionalChain([this, 'access', _194 => _194._store, 'access', _195 => _195.setMessages, 'optionalCall', _196 => _196(
4528
4427
  messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
4529
4428
  )]);
4530
4429
  }}
@@ -4620,19 +4519,18 @@ var joinExternalMessages = (messages) => {
4620
4519
  );
4621
4520
  }
4622
4521
  } else {
4623
- const content = output.content;
4624
4522
  const role = output.role;
4625
4523
  switch (role) {
4626
4524
  case "system":
4627
4525
  case "user":
4628
- return { role, content };
4526
+ return output;
4629
4527
  case "assistant":
4630
4528
  if (assistantMessage.content.length === 0) {
4631
4529
  assistantMessage.id = output.id;
4632
4530
  assistantMessage.createdAt ??= output.createdAt;
4633
4531
  assistantMessage.status ??= output.status;
4634
4532
  }
4635
- assistantMessage.content.push(...content);
4533
+ assistantMessage.content.push(...output.content);
4636
4534
  break;
4637
4535
  default: {
4638
4536
  const unsupportedRole = role;
@@ -4746,18 +4644,18 @@ var DangerousInBrowserAdapter = class {
4746
4644
  this.options = options;
4747
4645
  }
4748
4646
  async *run({ messages, abortSignal, config }) {
4749
- const res = await _chunkJ2V7Y7JXjs.getEdgeRuntimeStream.call(void 0, {
4647
+ const res = await _chunk5KIEXJRKjs.getEdgeRuntimeStream.call(void 0, {
4750
4648
  options: this.options,
4751
4649
  abortSignal,
4752
4650
  requestData: {
4753
4651
  system: config.system,
4754
- messages: _chunkJ2V7Y7JXjs.toCoreMessages.call(void 0, messages),
4755
- tools: config.tools ? _chunkJ2V7Y7JXjs.toLanguageModelTools.call(void 0, config.tools) : [],
4652
+ messages: _chunk5KIEXJRKjs.toCoreMessages.call(void 0, messages),
4653
+ tools: config.tools ? _chunk5KIEXJRKjs.toLanguageModelTools.call(void 0, config.tools) : [],
4756
4654
  ...config.callSettings,
4757
4655
  ...config.config
4758
4656
  }
4759
4657
  });
4760
- const stream = res.pipeThrough(_chunkJ2V7Y7JXjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkJ2V7Y7JXjs.runResultStream.call(void 0, ));
4658
+ const stream = res.pipeThrough(_chunk5KIEXJRKjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunk5KIEXJRKjs.runResultStream.call(void 0, ));
4761
4659
  for await (const update of asAsyncIterable(stream)) {
4762
4660
  yield update;
4763
4661
  }
@@ -4815,8 +4713,8 @@ var WebSpeechSynthesisAdapter = class {
4815
4713
  };
4816
4714
 
4817
4715
  // src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
4818
- var SimpleImageAttachmentAdapter = (_class12 = class {constructor() { _class12.prototype.__init32.call(this); }
4819
- __init32() {this.accept = "image/*"}
4716
+ var SimpleImageAttachmentAdapter = (_class12 = class {constructor() { _class12.prototype.__init33.call(this); }
4717
+ __init33() {this.accept = "image/*"}
4820
4718
  async add(state) {
4821
4719
  return {
4822
4720
  id: state.file.name,
@@ -4847,8 +4745,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
4847
4745
  });
4848
4746
 
4849
4747
  // src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
4850
- var SimpleTextAttachmentAdapter = (_class13 = class {constructor() { _class13.prototype.__init33.call(this); }
4851
- __init33() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
4748
+ var SimpleTextAttachmentAdapter = (_class13 = class {constructor() { _class13.prototype.__init34.call(this); }
4749
+ __init34() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
4852
4750
  async add(state) {
4853
4751
  return {
4854
4752
  id: state.file.name,
@@ -4966,7 +4864,7 @@ var ThreadConfigProvider = ({
4966
4864
  }) => {
4967
4865
  const hasAssistant = !!useAssistantRuntime({ optional: true });
4968
4866
  const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
4969
- if (!_optionalChain([config, 'optionalAccess', _208 => _208.runtime])) return configProvider;
4867
+ if (!_optionalChain([config, 'optionalAccess', _197 => _197.runtime])) return configProvider;
4970
4868
  if (hasAssistant) {
4971
4869
  throw new Error(
4972
4870
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
@@ -5294,7 +5192,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
5294
5192
  {
5295
5193
  components: {
5296
5194
  ...componentsProp,
5297
- Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _209 => _209.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
5195
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _198 => _198.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
5298
5196
  tools: toolsComponents
5299
5197
  }
5300
5198
  }
@@ -5437,7 +5335,7 @@ var ComposerAttachments = ({ components }) => {
5437
5335
  {
5438
5336
  components: {
5439
5337
  ...components,
5440
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _210 => _210.Attachment]), () => ( composer_attachment_default))
5338
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _199 => _199.Attachment]), () => ( composer_attachment_default))
5441
5339
  }
5442
5340
  }
5443
5341
  ) });
@@ -5569,7 +5467,7 @@ var ThreadWelcomeSuggestion = ({
5569
5467
  };
5570
5468
  var ThreadWelcomeSuggestions = () => {
5571
5469
  const { welcome: { suggestions } = {} } = useThreadConfig();
5572
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _211 => _211.map, 'call', _212 => _212((suggestion, idx) => {
5470
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _200 => _200.map, 'call', _201 => _201((suggestion, idx) => {
5573
5471
  const key = `${suggestion.prompt}-${idx}`;
5574
5472
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
5575
5473
  })]) });
@@ -5668,7 +5566,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
5668
5566
  {
5669
5567
  components: {
5670
5568
  ...components,
5671
- Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _213 => _213.Text]), () => ( content_part_default.Text))
5569
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _202 => _202.Text]), () => ( content_part_default.Text))
5672
5570
  }
5673
5571
  }
5674
5572
  ) });
@@ -5686,7 +5584,7 @@ var UserMessageAttachments = ({
5686
5584
  {
5687
5585
  components: {
5688
5586
  ...components,
5689
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _214 => _214.Attachment]), () => ( user_message_attachment_default))
5587
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _203 => _203.Attachment]), () => ( user_message_attachment_default))
5690
5588
  }
5691
5589
  }
5692
5590
  ) }) });
@@ -5787,10 +5685,10 @@ var ThreadMessages = ({ components, ...rest }) => {
5787
5685
  thread_exports.Messages,
5788
5686
  {
5789
5687
  components: {
5790
- UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _215 => _215.UserMessage]), () => ( user_message_default)),
5791
- EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _216 => _216.EditComposer]), () => ( edit_composer_default)),
5792
- AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _217 => _217.AssistantMessage]), () => ( assistant_message_default)),
5793
- SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _218 => _218.SystemMessage]), () => ( SystemMessage))
5688
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _204 => _204.UserMessage]), () => ( user_message_default)),
5689
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _205 => _205.EditComposer]), () => ( edit_composer_default)),
5690
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _206 => _206.AssistantMessage]), () => ( assistant_message_default)),
5691
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _207 => _207.SystemMessage]), () => ( SystemMessage))
5794
5692
  },
5795
5693
  ...rest
5796
5694
  }
@@ -6009,5 +5907,6 @@ var assistant_modal_default = Object.assign(AssistantModal, exports13);
6009
5907
 
6010
5908
 
6011
5909
 
6012
- exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkJ2V7Y7JXjs.toCoreMessage; exports.toCoreMessages = _chunkJ2V7Y7JXjs.toCoreMessages; exports.toLanguageModelMessages = _chunkJ2V7Y7JXjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkJ2V7Y7JXjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarFeedbackNegative = useActionBarFeedbackNegative; exports.useActionBarFeedbackPositive = useActionBarFeedbackPositive; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantActions = useAssistantActions; exports.useAssistantActionsStore = useAssistantActionsStore; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantRuntime = useAssistantRuntime; exports.useAssistantRuntimeStore = useAssistantRuntimeStore; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposer = useComposer; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartStore = useContentPartStore; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useEditComposer = useEditComposer; exports.useEditComposerStore = useEditComposerStore; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessage = useMessage; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useMessageStore = useMessageStore; exports.useMessageUtils = useMessageUtils; exports.useMessageUtilsStore = useMessageUtilsStore; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThread = useThread; exports.useThreadActions = useThreadActions; exports.useThreadActionsStore = useThreadActionsStore; exports.useThreadComposer = useThreadComposer; exports.useThreadComposerStore = useThreadComposerStore; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadRuntime = useThreadRuntime; exports.useThreadRuntimeStore = useThreadRuntimeStore; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadStore = useThreadStore; exports.useThreadSuggestion = useThreadSuggestion; exports.useThreadViewport = useThreadViewport; exports.useThreadViewportStore = useThreadViewportStore; exports.useToolUIs = useToolUIs; exports.useToolUIsStore = useToolUIsStore;
5910
+
5911
+ exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunk5KIEXJRKjs.toCoreMessage; exports.toCoreMessages = _chunk5KIEXJRKjs.toCoreMessages; exports.toLanguageModelMessages = _chunk5KIEXJRKjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunk5KIEXJRKjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarFeedbackNegative = useActionBarFeedbackNegative; exports.useActionBarFeedbackPositive = useActionBarFeedbackPositive; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantActions = useAssistantActions; exports.useAssistantActionsStore = useAssistantActionsStore; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantRuntime = useAssistantRuntime; exports.useAssistantRuntimeStore = useAssistantRuntimeStore; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposer = useComposer; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartStore = useContentPartStore; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useEditComposer = useEditComposer; exports.useEditComposerStore = useEditComposerStore; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessage = useMessage; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useMessageRuntime = useMessageRuntime; exports.useMessageStore = useMessageStore; exports.useMessageUtils = useMessageUtils; exports.useMessageUtilsStore = useMessageUtilsStore; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThread = useThread; exports.useThreadActions = useThreadActions; exports.useThreadActionsStore = useThreadActionsStore; exports.useThreadComposer = useThreadComposer; exports.useThreadComposerStore = useThreadComposerStore; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadRuntime = useThreadRuntime; exports.useThreadRuntimeStore = useThreadRuntimeStore; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadStore = useThreadStore; exports.useThreadSuggestion = useThreadSuggestion; exports.useThreadViewport = useThreadViewport; exports.useThreadViewportStore = useThreadViewportStore; exports.useToolUIs = useToolUIs; exports.useToolUIsStore = useToolUIsStore;
6013
5912
  //# sourceMappingURL=index.js.map