@assistant-ui/react 0.5.82 → 0.5.83

Sign up to get free protection for your applications and to get access to all the features.
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; var _class14; var _class15; var _class16;
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; var _class14; var _class15; var _class16; var _class17; var _class18;
2
2
 
3
3
 
4
4
 
@@ -85,6 +85,10 @@ var { useToolUIs, useToolUIsStore } = createContextStoreHook(
85
85
  useAssistantContext,
86
86
  "useToolUIs"
87
87
  );
88
+ var { useThreadManager } = createContextStoreHook(
89
+ useAssistantContext,
90
+ "useThreadManager"
91
+ );
88
92
 
89
93
  // src/context/stores/AssistantToolUIs.ts
90
94
  var _zustand = require('zustand');
@@ -259,16 +263,29 @@ var useAssistantRuntimeStore2 = (runtime) => {
259
263
  var useAssistantToolUIsStore = () => {
260
264
  return _react.useMemo.call(void 0, () => makeAssistantToolUIsStore(), []);
261
265
  };
266
+ var useThreadManagerStore = (runtime) => {
267
+ const [store] = _react.useState.call(void 0,
268
+ () => _zustand.create.call(void 0, () => runtime.threadManager.getState())
269
+ );
270
+ _react.useEffect.call(void 0, () => {
271
+ const updateState = () => writableStore(store).setState(runtime.threadManager.getState(), true);
272
+ updateState();
273
+ return runtime.threadManager.subscribe(updateState);
274
+ }, [runtime, store]);
275
+ return store;
276
+ };
262
277
  var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
263
278
  const useAssistantRuntime2 = useAssistantRuntimeStore2(runtime);
264
279
  const useToolUIs2 = useAssistantToolUIsStore();
280
+ const useThreadManager2 = useThreadManagerStore(runtime);
265
281
  const context = _react.useMemo.call(void 0, () => {
266
282
  return {
267
283
  useToolUIs: useToolUIs2,
268
284
  useAssistantRuntime: useAssistantRuntime2,
269
- useAssistantActions: useAssistantRuntime2
285
+ useAssistantActions: useAssistantRuntime2,
286
+ useThreadManager: useThreadManager2
270
287
  };
271
- }, [useAssistantRuntime2, useToolUIs2]);
288
+ }, [useAssistantRuntime2, useToolUIs2, useThreadManager2]);
272
289
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantContext.Provider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRuntimeProvider, { runtime: runtime.thread, children }) });
273
290
  };
274
291
  var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProviderImpl);
@@ -3017,13 +3034,13 @@ var subscribeToMainThread = (runtime, callback) => {
3017
3034
  let cleanup;
3018
3035
  const inner = () => {
3019
3036
  _optionalChain([cleanup, 'optionalCall', _154 => _154()]);
3020
- cleanup = runtime.thread.subscribe(callback);
3037
+ cleanup = runtime.threadManager.mainThread.subscribe(callback);
3021
3038
  if (!first) {
3022
3039
  callback();
3023
3040
  }
3024
3041
  first = false;
3025
3042
  };
3026
- const unsubscribe = runtime.subscribe(inner);
3043
+ const unsubscribe = runtime.threadManager.mainThread.subscribe(inner);
3027
3044
  inner();
3028
3045
  return () => {
3029
3046
  unsubscribe();
@@ -3034,29 +3051,44 @@ var subscribeToMainThread = (runtime, callback) => {
3034
3051
  // src/runtimes/local/useLocalRuntime.tsx
3035
3052
 
3036
3053
 
3037
- // src/runtimes/core/BaseAssistantRuntimeCore.tsx
3038
- var BaseAssistantRuntimeCore = (_class5 = class {
3039
- constructor(_thread) {;_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);
3040
- this._thread = _thread;
3041
- this._thread = _thread;
3054
+ // src/utils/ProxyConfigProvider.ts
3055
+ var ProxyConfigProvider = (_class5 = class {constructor() { _class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this); }
3056
+ __init9() {this._providers = /* @__PURE__ */ new Set()}
3057
+ getModelConfig() {
3058
+ return _chunkC6UZOY5Ajs.mergeModelConfigs.call(void 0, this._providers);
3042
3059
  }
3043
- get thread() {
3044
- return this._thread;
3060
+ registerModelConfigProvider(provider) {
3061
+ this._providers.add(provider);
3062
+ const unsubscribe = _optionalChain([provider, 'access', _156 => _156.subscribe, 'optionalCall', _157 => _157(() => {
3063
+ this.notifySubscribers();
3064
+ })]);
3065
+ this.notifySubscribers();
3066
+ return () => {
3067
+ this._providers.delete(provider);
3068
+ _optionalChain([unsubscribe, 'optionalCall', _158 => _158()]);
3069
+ this.notifySubscribers();
3070
+ };
3045
3071
  }
3046
- set thread(thread) {
3047
- this._thread = thread;
3048
- this.subscriptionHandler();
3072
+ __init10() {this._subscribers = /* @__PURE__ */ new Set()}
3073
+ notifySubscribers() {
3074
+ for (const callback of this._subscribers) callback();
3049
3075
  }
3050
- __init9() {this._subscriptions = /* @__PURE__ */ new Set()}
3051
3076
  subscribe(callback) {
3052
- this._subscriptions.add(callback);
3053
- return () => this._subscriptions.delete(callback);
3077
+ this._subscribers.add(callback);
3078
+ return () => this._subscribers.delete(callback);
3054
3079
  }
3055
- __init10() {this.subscriptionHandler = () => {
3056
- for (const callback of this._subscriptions) callback();
3057
- }}
3058
3080
  }, _class5);
3059
3081
 
3082
+ // src/runtimes/core/BaseAssistantRuntimeCore.tsx
3083
+ var BaseAssistantRuntimeCore = (_class6 = class {
3084
+ __init11() {this._proxyConfigProvider = new ProxyConfigProvider()}
3085
+ constructor() {;_class6.prototype.__init11.call(this);
3086
+ }
3087
+ registerModelConfigProvider(provider) {
3088
+ return this._proxyConfigProvider.registerModelConfigProvider(provider);
3089
+ }
3090
+ }, _class6);
3091
+
3060
3092
  // src/internal.ts
3061
3093
  var internal_exports = {};
3062
3094
  _chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
@@ -3075,12 +3107,12 @@ _chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
3075
3107
 
3076
3108
  // src/runtimes/composer/BaseComposerRuntimeCore.tsx
3077
3109
  var isAttachmentComplete = (a) => a.status.type === "complete";
3078
- var BaseComposerRuntimeCore = (_class6 = class {constructor() { _class6.prototype.__init11.call(this);_class6.prototype.__init12.call(this);_class6.prototype.__init13.call(this);_class6.prototype.__init14.call(this); }
3079
- __init11() {this.isEditing = true}
3110
+ var BaseComposerRuntimeCore = (_class7 = class {constructor() { _class7.prototype.__init12.call(this);_class7.prototype.__init13.call(this);_class7.prototype.__init14.call(this);_class7.prototype.__init15.call(this); }
3111
+ __init12() {this.isEditing = true}
3080
3112
  getAttachmentAccept() {
3081
- return _nullishCoalesce(_optionalChain([this, 'access', _156 => _156.getAttachmentAdapter, 'call', _157 => _157(), 'optionalAccess', _158 => _158.accept]), () => ( "*"));
3113
+ return _nullishCoalesce(_optionalChain([this, 'access', _159 => _159.getAttachmentAdapter, 'call', _160 => _160(), 'optionalAccess', _161 => _161.accept]), () => ( "*"));
3082
3114
  }
3083
- __init12() {this._attachments = []}
3115
+ __init13() {this._attachments = []}
3084
3116
  set attachments(value) {
3085
3117
  this._attachments = value;
3086
3118
  this.notifySubscribers();
@@ -3091,7 +3123,7 @@ var BaseComposerRuntimeCore = (_class6 = class {constructor() { _class6.prototyp
3091
3123
  get isEmpty() {
3092
3124
  return !this.text.trim() && !this.attachments.length;
3093
3125
  }
3094
- __init13() {this._text = ""}
3126
+ __init14() {this._text = ""}
3095
3127
  get text() {
3096
3128
  return this._text;
3097
3129
  }
@@ -3110,7 +3142,7 @@ var BaseComposerRuntimeCore = (_class6 = class {constructor() { _class6.prototyp
3110
3142
  this.attachments.map(async (a) => {
3111
3143
  if (isAttachmentComplete(a)) return a;
3112
3144
  const result = await adapter.send(a);
3113
- if (_optionalChain([result, 'access', _159 => _159.status, 'optionalAccess', _160 => _160.type]) !== "complete") {
3145
+ if (_optionalChain([result, 'access', _162 => _162.status, 'optionalAccess', _163 => _163.type]) !== "complete") {
3114
3146
  result.status = { type: "complete" };
3115
3147
  }
3116
3148
  return result;
@@ -3144,7 +3176,7 @@ var BaseComposerRuntimeCore = (_class6 = class {constructor() { _class6.prototyp
3144
3176
  this._attachments = this._attachments.toSpliced(index, 1);
3145
3177
  this.notifySubscribers();
3146
3178
  }
3147
- __init14() {this._subscriptions = /* @__PURE__ */ new Set()}
3179
+ __init15() {this._subscriptions = /* @__PURE__ */ new Set()}
3148
3180
  notifySubscribers() {
3149
3181
  for (const callback of this._subscriptions) callback();
3150
3182
  }
@@ -3152,16 +3184,16 @@ var BaseComposerRuntimeCore = (_class6 = class {constructor() { _class6.prototyp
3152
3184
  this._subscriptions.add(callback);
3153
3185
  return () => this._subscriptions.delete(callback);
3154
3186
  }
3155
- }, _class6);
3187
+ }, _class7);
3156
3188
 
3157
3189
  // src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx
3158
- var DefaultThreadComposerRuntimeCore = (_class7 = class extends BaseComposerRuntimeCore {
3190
+ var DefaultThreadComposerRuntimeCore = (_class8 = class extends BaseComposerRuntimeCore {
3159
3191
  constructor(runtime) {
3160
- super();_class7.prototype.__init15.call(this);;
3192
+ super();_class8.prototype.__init16.call(this);;
3161
3193
  this.runtime = runtime;
3162
3194
  this.connect();
3163
3195
  }
3164
- __init15() {this._canCancel = false}
3196
+ __init16() {this._canCancel = false}
3165
3197
  get canCancel() {
3166
3198
  return this._canCancel;
3167
3199
  }
@@ -3169,7 +3201,7 @@ var DefaultThreadComposerRuntimeCore = (_class7 = class extends BaseComposerRunt
3169
3201
  return super.attachments;
3170
3202
  }
3171
3203
  getAttachmentAdapter() {
3172
- return _optionalChain([this, 'access', _161 => _161.runtime, 'access', _162 => _162.adapters, 'optionalAccess', _163 => _163.attachments]);
3204
+ return _optionalChain([this, 'access', _164 => _164.runtime, 'access', _165 => _165.adapters, 'optionalAccess', _166 => _166.attachments]);
3173
3205
  }
3174
3206
  connect() {
3175
3207
  return this.runtime.subscribe(() => {
@@ -3182,40 +3214,12 @@ var DefaultThreadComposerRuntimeCore = (_class7 = class extends BaseComposerRunt
3182
3214
  async handleSend(message) {
3183
3215
  this.runtime.append({
3184
3216
  ...message,
3185
- parentId: _nullishCoalesce(_optionalChain([this, 'access', _164 => _164.runtime, 'access', _165 => _165.messages, 'access', _166 => _166.at, 'call', _167 => _167(-1), 'optionalAccess', _168 => _168.id]), () => ( null))
3217
+ parentId: _nullishCoalesce(_optionalChain([this, 'access', _167 => _167.runtime, 'access', _168 => _168.messages, 'access', _169 => _169.at, 'call', _170 => _170(-1), 'optionalAccess', _171 => _171.id]), () => ( null))
3186
3218
  });
3187
3219
  }
3188
3220
  async cancel() {
3189
3221
  this.runtime.cancelRun();
3190
3222
  }
3191
- }, _class7);
3192
-
3193
- // src/utils/ProxyConfigProvider.ts
3194
- var ProxyConfigProvider = (_class8 = class {constructor() { _class8.prototype.__init16.call(this);_class8.prototype.__init17.call(this); }
3195
- __init16() {this._providers = /* @__PURE__ */ new Set()}
3196
- getModelConfig() {
3197
- return _chunkC6UZOY5Ajs.mergeModelConfigs.call(void 0, this._providers);
3198
- }
3199
- registerModelConfigProvider(provider) {
3200
- this._providers.add(provider);
3201
- const unsubscribe = _optionalChain([provider, 'access', _169 => _169.subscribe, 'optionalCall', _170 => _170(() => {
3202
- this.notifySubscribers();
3203
- })]);
3204
- this.notifySubscribers();
3205
- return () => {
3206
- this._providers.delete(provider);
3207
- _optionalChain([unsubscribe, 'optionalCall', _171 => _171()]);
3208
- this.notifySubscribers();
3209
- };
3210
- }
3211
- __init17() {this._subscribers = /* @__PURE__ */ new Set()}
3212
- notifySubscribers() {
3213
- for (const callback of this._subscribers) callback();
3214
- }
3215
- subscribe(callback) {
3216
- this._subscribers.add(callback);
3217
- return () => this._subscribers.delete(callback);
3218
- }
3219
3223
  }, _class8);
3220
3224
 
3221
3225
  // src/utils/idUtils.tsx
@@ -3283,11 +3287,11 @@ var findHead = (message) => {
3283
3287
  if ("current" in message) return message;
3284
3288
  return null;
3285
3289
  };
3286
- var MessageRepository = (_class9 = class {constructor() { _class9.prototype.__init18.call(this);_class9.prototype.__init19.call(this);_class9.prototype.__init20.call(this); }
3287
- __init18() {this.messages = /* @__PURE__ */ new Map()}
3290
+ var MessageRepository = (_class9 = class {constructor() { _class9.prototype.__init17.call(this);_class9.prototype.__init18.call(this);_class9.prototype.__init19.call(this); }
3291
+ __init17() {this.messages = /* @__PURE__ */ new Map()}
3288
3292
  // message_id -> item
3289
- __init19() {this.head = null}
3290
- __init20() {this.root = {
3293
+ __init18() {this.head = null}
3294
+ __init19() {this.root = {
3291
3295
  children: [],
3292
3296
  next: null
3293
3297
  }}
@@ -3652,7 +3656,7 @@ var ThreadRuntimeImpl = (_class10 = class {
3652
3656
  return this._threadBinding.getState();
3653
3657
  }
3654
3658
 
3655
- constructor(threadBinding) {;_class10.prototype.__init21.call(this);
3659
+ constructor(threadBinding) {;_class10.prototype.__init20.call(this);
3656
3660
  const stateBinding = new LazyMemoizeSubject({
3657
3661
  path: threadBinding.path,
3658
3662
  getState: () => getThreadState(threadBinding.getState()),
@@ -3810,7 +3814,7 @@ var ThreadRuntimeImpl = (_class10 = class {
3810
3814
  this._threadBinding
3811
3815
  );
3812
3816
  }
3813
- __init21() {this._eventListenerNestedSubscriptions = /* @__PURE__ */ new Map()}
3817
+ __init20() {this._eventListenerNestedSubscriptions = /* @__PURE__ */ new Map()}
3814
3818
  unstable_on(event, callback) {
3815
3819
  let subject = this._eventListenerNestedSubscriptions.get(event);
3816
3820
  if (!subject) {
@@ -3827,20 +3831,67 @@ var ThreadRuntimeImpl = (_class10 = class {
3827
3831
  }
3828
3832
  }, _class10);
3829
3833
 
3834
+ // src/api/ThreadManagerRuntime.ts
3835
+ var getThreadManagerState = (threadManager) => {
3836
+ return {
3837
+ threads: threadManager.threads,
3838
+ archivedThreads: threadManager.archivedThreads
3839
+ };
3840
+ };
3841
+ var THREAD_MANAGER_PATH = {
3842
+ ref: "threadManager"
3843
+ };
3844
+ var ThreadManagerRuntimeImpl = class {
3845
+ constructor(_core) {
3846
+ this._core = _core;
3847
+ const stateBinding = new LazyMemoizeSubject({
3848
+ path: THREAD_MANAGER_PATH,
3849
+ getState: () => getThreadManagerState(_core),
3850
+ subscribe: (callback) => _core.subscribe(callback)
3851
+ });
3852
+ this._getState = stateBinding.getState.bind(stateBinding);
3853
+ }
3854
+ get path() {
3855
+ return THREAD_MANAGER_PATH;
3856
+ }
3857
+
3858
+ getState() {
3859
+ return this._getState();
3860
+ }
3861
+ rename(threadId, newTitle) {
3862
+ return this._core.rename(threadId, newTitle);
3863
+ }
3864
+ archive(threadId) {
3865
+ return this._core.archive(threadId);
3866
+ }
3867
+ unarchive(threadId) {
3868
+ return this._core.unarchive(threadId);
3869
+ }
3870
+ delete(threadId) {
3871
+ return this._core.delete(threadId);
3872
+ }
3873
+ subscribe(callback) {
3874
+ return this._core.subscribe(callback);
3875
+ }
3876
+ };
3877
+
3830
3878
  // src/api/AssistantRuntime.ts
3831
3879
  var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
3832
3880
  constructor(_core, _thread) {
3833
3881
  this._core = _core;
3834
3882
  this._thread = _thread;
3883
+ this.threadManager = new ThreadManagerRuntimeImpl(_core.threadManager);
3835
3884
  }
3885
+
3836
3886
  get thread() {
3837
3887
  return this._thread;
3838
3888
  }
3839
3889
  switchToNewThread() {
3840
- return this._core.switchToNewThread();
3890
+ return this._core.threadManager.switchToNewThread();
3841
3891
  }
3842
3892
  switchToThread(threadId) {
3843
- return this._core.switchToThread(threadId);
3893
+ if (threadId === null) return this.switchToNewThread();
3894
+ return this._core.threadManager.switchToThread(threadId);
3844
3895
  }
3845
3896
  registerModelConfigProvider(provider) {
3846
3897
  return this._core.registerModelConfigProvider(provider);
@@ -3848,8 +3899,9 @@ var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
3848
3899
  /**
3849
3900
  * @deprecated Thread is now static and never gets updated. This will be removed in 0.6.0.
3850
3901
  */
3851
- subscribe(callback) {
3852
- return this._core.subscribe(callback);
3902
+ subscribe() {
3903
+ return () => {
3904
+ };
3853
3905
  }
3854
3906
  static createMainThreadRuntime(_core, CustomThreadRuntime = ThreadRuntimeImpl) {
3855
3907
  return new CustomThreadRuntime(
@@ -3858,8 +3910,8 @@ var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
3858
3910
  ref: "threads.main",
3859
3911
  threadSelector: { type: "main" }
3860
3912
  },
3861
- getState: () => _core.thread,
3862
- subscribe: (callback) => _core.subscribe(callback)
3913
+ getState: () => _core.threadManager.mainThread,
3914
+ subscribe: (callback) => _core.threadManager.subscribe(callback)
3863
3915
  })
3864
3916
  );
3865
3917
  }
@@ -4269,22 +4321,19 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
4269
4321
 
4270
4322
  // src/runtimes/core/BaseThreadRuntimeCore.tsx
4271
4323
  var BaseThreadRuntimeCore = (_class11 = class {
4272
- constructor(configProvider) {;_class11.prototype.__init22.call(this);_class11.prototype.__init23.call(this);_class11.prototype.__init24.call(this);_class11.prototype.__init25.call(this);_class11.prototype.__init26.call(this);_class11.prototype.__init27.call(this);
4324
+ constructor(configProvider) {;_class11.prototype.__init21.call(this);_class11.prototype.__init22.call(this);_class11.prototype.__init23.call(this);_class11.prototype.__init24.call(this);_class11.prototype.__init25.call(this);_class11.prototype.__init26.call(this);
4273
4325
  this.configProvider = configProvider;
4274
- _optionalChain([this, 'access', _208 => _208.configProvider, 'access', _209 => _209.subscribe, 'optionalCall', _210 => _210(() => {
4275
- this._notifyEventSubscribers("model-config-update");
4276
- })]);
4277
4326
  }
4278
- __init22() {this._subscriptions = /* @__PURE__ */ new Set()}
4279
- __init23() {this.repository = new MessageRepository()}
4327
+ __init21() {this._subscriptions = /* @__PURE__ */ new Set()}
4328
+ __init22() {this.repository = new MessageRepository()}
4280
4329
  get messages() {
4281
4330
  return this.repository.getMessages();
4282
4331
  }
4283
- __init24() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4332
+ __init23() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
4284
4333
  getModelConfig() {
4285
4334
  return this.configProvider.getModelConfig();
4286
4335
  }
4287
- __init25() {this._editComposers = /* @__PURE__ */ new Map()}
4336
+ __init24() {this._editComposers = /* @__PURE__ */ new Map()}
4288
4337
  getEditComposer(messageId) {
4289
4338
  return this._editComposers.get(messageId);
4290
4339
  }
@@ -4323,12 +4372,12 @@ var BaseThreadRuntimeCore = (_class11 = class {
4323
4372
  this._subscriptions.add(callback);
4324
4373
  return () => this._subscriptions.delete(callback);
4325
4374
  }
4326
- __init26() {this._submittedFeedback = {}}
4375
+ __init25() {this._submittedFeedback = {}}
4327
4376
  getSubmittedFeedback(messageId) {
4328
4377
  return this._submittedFeedback[messageId];
4329
4378
  }
4330
4379
  submitFeedback({ messageId, type }) {
4331
- const adapter = _optionalChain([this, 'access', _211 => _211.adapters, 'optionalAccess', _212 => _212.feedback]);
4380
+ const adapter = _optionalChain([this, 'access', _208 => _208.adapters, 'optionalAccess', _209 => _209.feedback]);
4332
4381
  if (!adapter) throw new Error("Feedback adapter not configured");
4333
4382
  const { message } = this.repository.getMessage(messageId);
4334
4383
  adapter.submit({ message, type });
@@ -4338,10 +4387,10 @@ var BaseThreadRuntimeCore = (_class11 = class {
4338
4387
 
4339
4388
 
4340
4389
  speak(messageId) {
4341
- const adapter = _optionalChain([this, 'access', _213 => _213.adapters, 'optionalAccess', _214 => _214.speech]);
4390
+ const adapter = _optionalChain([this, 'access', _210 => _210.adapters, 'optionalAccess', _211 => _211.speech]);
4342
4391
  if (!adapter) throw new Error("Speech adapter not configured");
4343
4392
  const { message } = this.repository.getMessage(messageId);
4344
- _optionalChain([this, 'access', _215 => _215._stopSpeaking, 'optionalCall', _216 => _216()]);
4393
+ _optionalChain([this, 'access', _212 => _212._stopSpeaking, 'optionalCall', _213 => _213()]);
4345
4394
  const utterance = adapter.speak(getThreadMessageText(message));
4346
4395
  const unsub = utterance.subscribe(() => {
4347
4396
  if (utterance.status.type === "ended") {
@@ -4373,8 +4422,12 @@ var BaseThreadRuntimeCore = (_class11 = class {
4373
4422
  this.repository.import(data);
4374
4423
  this._notifySubscribers();
4375
4424
  }
4376
- __init27() {this._eventSubscribers = /* @__PURE__ */ new Map()}
4425
+ __init26() {this._eventSubscribers = /* @__PURE__ */ new Map()}
4377
4426
  unstable_on(event, callback) {
4427
+ if (event === "model-config-update") {
4428
+ return _nullishCoalesce(_optionalChain([this, 'access', _214 => _214.configProvider, 'access', _215 => _215.subscribe, 'optionalCall', _216 => _216(callback)]), () => ( (() => {
4429
+ })));
4430
+ }
4378
4431
  const subscribers = this._eventSubscribers.get(event);
4379
4432
  if (!subscribers) {
4380
4433
  this._eventSubscribers.set(event, /* @__PURE__ */ new Set([callback]));
@@ -4390,21 +4443,12 @@ var BaseThreadRuntimeCore = (_class11 = class {
4390
4443
 
4391
4444
  // src/runtimes/local/LocalThreadRuntimeCore.tsx
4392
4445
  var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
4393
- constructor(configProvider, adapter, { initialMessages, ...options }) {
4394
- super(configProvider);_class12.prototype.__init28.call(this);_class12.prototype.__init29.call(this);_class12.prototype.__init30.call(this);_class12.prototype.__init31.call(this);;
4395
- this.adapter = adapter;
4396
- this.threadId = generateId();
4397
- this.options = options;
4398
- if (initialMessages) {
4399
- let parentId = null;
4400
- const messages2 = fromCoreMessages(initialMessages);
4401
- for (const message of messages2) {
4402
- this.repository.addOrUpdateMessage(parentId, message);
4403
- parentId = message.id;
4404
- }
4405
- }
4446
+ constructor(configProvider, threadId, options) {
4447
+ super(configProvider);_class12.prototype.__init27.call(this);_class12.prototype.__init28.call(this);_class12.prototype.__init29.call(this);_class12.prototype.__init30.call(this);;
4448
+ this.threadId = threadId;
4449
+ this._options = options;
4406
4450
  }
4407
- __init28() {this.capabilities = {
4451
+ __init27() {this.capabilities = {
4408
4452
  switchToBranch: true,
4409
4453
  edit: true,
4410
4454
  reload: true,
@@ -4414,21 +4458,18 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
4414
4458
  attachments: false,
4415
4459
  feedback: false
4416
4460
  }}
4417
- __init29() {this.abortController = null}
4418
-
4419
- __init30() {this.isDisabled = false}
4420
- __init31() {this.suggestions = []}
4461
+ __init28() {this.abortController = null}
4462
+ __init29() {this.isDisabled = false}
4463
+ __init30() {this.suggestions = []}
4421
4464
  get adapters() {
4422
- return this.options.adapters;
4465
+ return this._options.adapters;
4423
4466
  }
4424
4467
 
4425
- get options() {
4426
- return this._options;
4427
- }
4428
4468
  get extras() {
4429
4469
  return void 0;
4430
4470
  }
4431
- set options({ initialMessages, ...options }) {
4471
+ setOptions(options) {
4472
+ if (this._options === options) return;
4432
4473
  this._options = options;
4433
4474
  let hasUpdates = false;
4434
4475
  const canSpeak = _optionalChain([options, 'access', _217 => _217.adapters, 'optionalAccess', _218 => _218.speech]) !== void 0;
@@ -4504,7 +4545,7 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
4504
4545
  this.repository.addOrUpdateMessage(parentId, message);
4505
4546
  this._notifySubscribers();
4506
4547
  };
4507
- const maxSteps = this.options.maxSteps ? this.options.maxSteps : (_nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1))) + 1;
4548
+ const maxSteps = this._options.maxSteps ? this._options.maxSteps : (_nullishCoalesce(this._options.maxToolRoundtrips, () => ( 1))) + 1;
4508
4549
  const steps = _nullishCoalesce(_optionalChain([message, 'access', _236 => _236.metadata, 'optionalAccess', _237 => _237.steps, 'optionalAccess', _238 => _238.length]), () => ( 0));
4509
4550
  if (steps >= maxSteps) {
4510
4551
  updateMessage({
@@ -4522,7 +4563,7 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
4522
4563
  });
4523
4564
  }
4524
4565
  try {
4525
- const promiseOrGenerator = this.adapter.run({
4566
+ const promiseOrGenerator = this.adapters.chatModel.run({
4526
4567
  messages: messages2,
4527
4568
  abortSignal: this.abortController.signal,
4528
4569
  config: this.getModelConfig(),
@@ -4595,44 +4636,154 @@ var LocalThreadRuntimeCore = (_class12 = class extends BaseThreadRuntimeCore {
4595
4636
  }
4596
4637
  }, _class12);
4597
4638
 
4598
- // src/runtimes/local/LocalRuntimeCore.tsx
4599
- var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4639
+ // src/runtimes/local/LocalThreadManagerRuntimeCore.tsx
4640
+ var LocalThreadManagerRuntimeCore = (_class13 = class {
4641
+ constructor(_threadFactory) {;_class13.prototype.__init31.call(this);_class13.prototype.__init32.call(this);_class13.prototype.__init33.call(this);_class13.prototype.__init34.call(this);
4642
+ this._threadFactory = _threadFactory;
4643
+ this._mainThread = this._threadFactory(generateId(), { messages: [] });
4644
+ }
4645
+ __init31() {this._threadData = /* @__PURE__ */ new Map()}
4646
+ __init32() {this._threads = []}
4647
+ __init33() {this._archivedThreads = []}
4648
+ get threads() {
4649
+ return this._threads;
4650
+ }
4651
+ get archivedThreads() {
4652
+ return this._archivedThreads;
4653
+ }
4600
4654
 
4601
- constructor(adapter, options) {
4602
- const proxyConfigProvider = new ProxyConfigProvider();
4603
- super(new LocalThreadRuntimeCore(proxyConfigProvider, adapter, options));
4604
- this._proxyConfigProvider = proxyConfigProvider;
4655
+ get mainThread() {
4656
+ return this._mainThread;
4605
4657
  }
4606
- registerModelConfigProvider(provider) {
4607
- return this._proxyConfigProvider.registerModelConfigProvider(provider);
4658
+ switchToThread(threadId) {
4659
+ if (this._mainThread.threadId === threadId) return;
4660
+ const data = this._threadData.get(threadId);
4661
+ if (!data) throw new Error("Thread not found");
4662
+ const thread = this._threadFactory(threadId, data.data);
4663
+ this._performThreadSwitch(thread);
4608
4664
  }
4609
4665
  switchToNewThread() {
4610
- const { initialMessages, ...options } = this.thread.options;
4611
- this.thread = new LocalThreadRuntimeCore(
4612
- this._proxyConfigProvider,
4613
- this.thread.adapter,
4614
- options
4615
- );
4616
- this.thread._notifyEventSubscribers("switched-to");
4666
+ if (!this._mainThread) return;
4667
+ const thread = this._threadFactory(generateId(), { messages: [] });
4668
+ this._performThreadSwitch(thread);
4669
+ }
4670
+ _performThreadSwitch(newThreadCore) {
4671
+ if (this._mainThread) {
4672
+ const data = this._threadData.get(this._mainThread.threadId);
4673
+ if (!data) throw new Error("Thread not found");
4674
+ const exprt = this._mainThread.export();
4675
+ data.data = exprt;
4676
+ }
4677
+ this._mainThread._notifyEventSubscribers("switched-away");
4678
+ this._mainThread = newThreadCore;
4679
+ newThreadCore._notifyEventSubscribers("switched-to");
4680
+ this._notifySubscribers();
4617
4681
  }
4618
- switchToThread(threadId) {
4619
- if (threadId !== null) {
4620
- throw new Error("LocalRuntime does not yet support switching threads");
4682
+ _performMoveOp(threadId, operation) {
4683
+ const data = this._threadData.get(threadId);
4684
+ if (!data) throw new Error("Thread not found");
4685
+ if (operation === "archive" && data.isArchived) return;
4686
+ if (operation === "unarchive" && !data.isArchived) return;
4687
+ if (operation === "archive") {
4688
+ data.isArchived = true;
4689
+ this._archivedThreads = [...this._archivedThreads, data.metadata];
4690
+ }
4691
+ if (operation === "unarchive") {
4692
+ data.isArchived = false;
4693
+ this._threads = [...this._threads, data.metadata];
4694
+ }
4695
+ if (operation === "delete") {
4696
+ this._threadData.delete(threadId);
4697
+ }
4698
+ if (operation === "archive" || operation === "delete" && data.isArchived) {
4699
+ this._archivedThreads = this._archivedThreads.filter(
4700
+ (t) => t.threadId !== threadId
4701
+ );
4702
+ }
4703
+ if (operation === "unarchive" || operation === "delete" && !data.isArchived) {
4704
+ this._threads = this._threads.filter((t) => t.threadId !== threadId);
4705
+ }
4706
+ this._notifySubscribers();
4707
+ }
4708
+ async rename(threadId, newTitle) {
4709
+ const data = this._threadData.get(threadId);
4710
+ if (!data) throw new Error("Thread not found");
4711
+ data.metadata = {
4712
+ ...data.metadata,
4713
+ title: newTitle
4714
+ };
4715
+ const threadList = data.isArchived ? this.archivedThreads : this.threads;
4716
+ const idx = threadList.findIndex((t) => t.threadId === threadId);
4717
+ const updatedThreadList = threadList.toSpliced(idx, 1, data.metadata);
4718
+ if (data.isArchived) {
4719
+ this._archivedThreads = updatedThreadList;
4720
+ } else {
4721
+ this._threads = updatedThreadList;
4722
+ }
4723
+ this._notifySubscribers();
4724
+ }
4725
+ async archive(threadId) {
4726
+ this._performMoveOp(threadId, "archive");
4727
+ }
4728
+ async unarchive(threadId) {
4729
+ this._performMoveOp(threadId, "unarchive");
4730
+ }
4731
+ async delete(threadId) {
4732
+ this._performMoveOp(threadId, "delete");
4733
+ }
4734
+ __init34() {this._subscriptions = /* @__PURE__ */ new Set()}
4735
+ subscribe(callback) {
4736
+ this._subscriptions.add(callback);
4737
+ return () => this._subscriptions.delete(callback);
4738
+ }
4739
+ _notifySubscribers() {
4740
+ for (const callback of this._subscriptions) callback();
4741
+ }
4742
+ }, _class13);
4743
+
4744
+ // src/runtimes/local/LocalRuntimeCore.tsx
4745
+ var getExportFromInitialMessages = (initialMessages) => {
4746
+ const messages2 = fromCoreMessages(initialMessages);
4747
+ return {
4748
+ messages: messages2.map((m, idx) => ({
4749
+ parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _242 => _242[idx - 1], 'optionalAccess', _243 => _243.id]), () => ( null)),
4750
+ message: m
4751
+ }))
4752
+ };
4753
+ };
4754
+ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
4755
+
4756
+
4757
+ constructor(options, initialMessages) {
4758
+ super();
4759
+ this._options = options;
4760
+ this.threadManager = new LocalThreadManagerRuntimeCore((threadId, data) => {
4761
+ const thread = new LocalThreadRuntimeCore(
4762
+ this._proxyConfigProvider,
4763
+ threadId,
4764
+ this._options
4765
+ );
4766
+ thread.import(data);
4767
+ return thread;
4768
+ });
4769
+ if (initialMessages) {
4770
+ this.threadManager.mainThread.import(
4771
+ getExportFromInitialMessages(initialMessages)
4772
+ );
4621
4773
  }
4622
- this.switchToNewThread();
4774
+ }
4775
+ setOptions(options) {
4776
+ this._options = options;
4777
+ this.threadManager.mainThread.setOptions(options);
4623
4778
  }
4624
4779
  reset({
4625
4780
  initialMessages
4626
4781
  } = {}) {
4627
- this.switchToThread(null);
4782
+ this.threadManager.switchToNewThread();
4628
4783
  if (!initialMessages) return;
4629
- const messages2 = fromCoreMessages(initialMessages);
4630
- this.thread.import({
4631
- messages: messages2.map((m, idx) => ({
4632
- parentId: _nullishCoalesce(_optionalChain([messages2, 'access', _242 => _242[idx - 1], 'optionalAccess', _243 => _243.id]), () => ( null)),
4633
- message: m
4634
- }))
4635
- });
4784
+ this.threadManager.mainThread.import(
4785
+ getExportFromInitialMessages(initialMessages)
4786
+ );
4636
4787
  }
4637
4788
  };
4638
4789
 
@@ -4653,10 +4804,16 @@ var LocalRuntimeImpl = class _LocalRuntimeImpl extends AssistantRuntimeImpl {
4653
4804
  }
4654
4805
  };
4655
4806
  var useLocalRuntime = (adapter, options = {}) => {
4656
- const [runtime] = _react.useState.call(void 0, () => new LocalRuntimeCore(adapter, options));
4657
- _react.useInsertionEffect.call(void 0, () => {
4658
- runtime.thread.adapter = adapter;
4659
- runtime.thread.options = options;
4807
+ const opt = {
4808
+ ...options,
4809
+ adapters: {
4810
+ ...options.adapters,
4811
+ chatModel: adapter
4812
+ }
4813
+ };
4814
+ const [runtime] = _react.useState.call(void 0, () => new LocalRuntimeCore(opt));
4815
+ _react.useEffect.call(void 0, () => {
4816
+ runtime.setOptions(opt);
4660
4817
  });
4661
4818
  return _react.useMemo.call(void 0, () => LocalRuntimeImpl.create(runtime), [runtime]);
4662
4819
  };
@@ -4664,6 +4821,92 @@ var useLocalRuntime = (adapter, options = {}) => {
4664
4821
  // src/runtimes/external-store/useExternalStoreRuntime.tsx
4665
4822
 
4666
4823
 
4824
+ // src/runtimes/external-store/ExternalStoreThreadManagementAdapter.tsx
4825
+ var EMPTY_ARRAY2 = Object.freeze([]);
4826
+ var DEFAULT_THREAD_ID = "DEFAULT_THREAD_ID";
4827
+ var ExternalStoreThreadManagerRuntimeCore = (_class14 = class {
4828
+ constructor(adapter = {}, threadFactory) {;_class14.prototype.__init35.call(this);
4829
+ this.adapter = adapter;
4830
+ this.threadFactory = threadFactory;
4831
+ this._mainThread = this.threadFactory(DEFAULT_THREAD_ID);
4832
+ }
4833
+ get threads() {
4834
+ return _nullishCoalesce(this.adapter.threads, () => ( EMPTY_ARRAY2));
4835
+ }
4836
+ get archivedThreads() {
4837
+ return _nullishCoalesce(this.adapter.archivedThreads, () => ( EMPTY_ARRAY2));
4838
+ }
4839
+
4840
+ get mainThread() {
4841
+ return this._mainThread;
4842
+ }
4843
+ setAdapter(adapter) {
4844
+ const previousAdapter = this.adapter;
4845
+ this.adapter = adapter;
4846
+ const newThreadId = _nullishCoalesce(adapter.threadId, () => ( DEFAULT_THREAD_ID));
4847
+ const newThreads = _nullishCoalesce(adapter.threads, () => ( EMPTY_ARRAY2));
4848
+ const newArchivedThreads = _nullishCoalesce(adapter.archivedThreads, () => ( EMPTY_ARRAY2));
4849
+ if (previousAdapter.threadId === newThreadId && previousAdapter.threads === newThreads && previousAdapter.archivedThreads === newArchivedThreads) {
4850
+ return;
4851
+ }
4852
+ if (previousAdapter.threadId !== newThreadId) {
4853
+ this._mainThread._notifyEventSubscribers("switched-away");
4854
+ this._mainThread = this.threadFactory(newThreadId);
4855
+ this._mainThread._notifyEventSubscribers("switched-to");
4856
+ }
4857
+ this._notifySubscribers();
4858
+ }
4859
+ switchToThread(threadId) {
4860
+ if (_optionalChain([this, 'access', _244 => _244._mainThread, 'optionalAccess', _245 => _245.threadId]) === threadId) return;
4861
+ const onSwitchToThread = this.adapter.onSwitchToThread;
4862
+ if (!onSwitchToThread)
4863
+ throw new Error(
4864
+ "External store adapter does not support switching to thread"
4865
+ );
4866
+ onSwitchToThread(threadId);
4867
+ }
4868
+ switchToNewThread() {
4869
+ const onSwitchToNewThread = this.adapter.onSwitchToNewThread;
4870
+ if (!onSwitchToNewThread)
4871
+ throw new Error(
4872
+ "External store adapter does not support switching to new thread"
4873
+ );
4874
+ onSwitchToNewThread();
4875
+ }
4876
+ async rename(threadId, newTitle) {
4877
+ const onRename = this.adapter.onRename;
4878
+ if (!onRename)
4879
+ throw new Error("External store adapter does not support renaming");
4880
+ onRename(threadId, newTitle);
4881
+ }
4882
+ async archive(threadId) {
4883
+ const onArchive = this.adapter.onArchive;
4884
+ if (!onArchive)
4885
+ throw new Error("External store adapter does not support archiving");
4886
+ onArchive(threadId);
4887
+ }
4888
+ async unarchive(threadId) {
4889
+ const onUnarchive = this.adapter.onUnarchive;
4890
+ if (!onUnarchive)
4891
+ throw new Error("External store adapter does not support unarchiving");
4892
+ onUnarchive(threadId);
4893
+ }
4894
+ async delete(threadId) {
4895
+ const onDelete = this.adapter.onDelete;
4896
+ if (!onDelete)
4897
+ throw new Error("External store adapter does not support deleting");
4898
+ onDelete(threadId);
4899
+ }
4900
+ __init35() {this._subscriptions = /* @__PURE__ */ new Set()}
4901
+ subscribe(callback) {
4902
+ this._subscriptions.add(callback);
4903
+ return () => this._subscriptions.delete(callback);
4904
+ }
4905
+ _notifySubscribers() {
4906
+ for (const callback of this._subscriptions) callback();
4907
+ }
4908
+ }, _class14);
4909
+
4667
4910
  // src/runtimes/external-store/getExternalStoreMessage.tsx
4668
4911
  var symbolInnerMessage = Symbol("innerMessage");
4669
4912
  var getExternalStoreMessage = (message) => {
@@ -4671,8 +4914,8 @@ var getExternalStoreMessage = (message) => {
4671
4914
  };
4672
4915
 
4673
4916
  // src/runtimes/external-store/ThreadMessageConverter.ts
4674
- var ThreadMessageConverter = (_class13 = class {constructor() { _class13.prototype.__init32.call(this); }
4675
- __init32() {this.cache = /* @__PURE__ */ new WeakMap()}
4917
+ var ThreadMessageConverter = (_class15 = class {constructor() { _class15.prototype.__init36.call(this); }
4918
+ __init36() {this.cache = /* @__PURE__ */ new WeakMap()}
4676
4919
  convertMessages(messages2, converter) {
4677
4920
  return messages2.map((m, idx) => {
4678
4921
  const cached = this.cache.get(m);
@@ -4681,7 +4924,7 @@ var ThreadMessageConverter = (_class13 = class {constructor() { _class13.prototy
4681
4924
  return newMessage;
4682
4925
  });
4683
4926
  }
4684
- }, _class13);
4927
+ }, _class15);
4685
4928
 
4686
4929
  // src/runtimes/external-store/auto-status.tsx
4687
4930
  var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
@@ -4767,13 +5010,13 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
4767
5010
  };
4768
5011
 
4769
5012
  // src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
4770
- var EMPTY_ARRAY2 = Object.freeze([]);
5013
+ var EMPTY_ARRAY3 = Object.freeze([]);
4771
5014
  var hasUpcomingMessage = (isRunning, messages2) => {
4772
- return isRunning && _optionalChain([messages2, 'access', _244 => _244[messages2.length - 1], 'optionalAccess', _245 => _245.role]) !== "assistant";
5015
+ return isRunning && _optionalChain([messages2, 'access', _246 => _246[messages2.length - 1], 'optionalAccess', _247 => _247.role]) !== "assistant";
4773
5016
  };
4774
- var ExternalStoreThreadRuntimeCore = (_class14 = class extends BaseThreadRuntimeCore {
4775
- __init33() {this.assistantOptimisticId = null}
4776
- __init34() {this._capabilities = {
5017
+ var ExternalStoreThreadRuntimeCore = (_class16 = class extends BaseThreadRuntimeCore {
5018
+ __init37() {this.assistantOptimisticId = null}
5019
+ __init38() {this._capabilities = {
4777
5020
  switchToBranch: false,
4778
5021
  edit: false,
4779
5022
  reload: false,
@@ -4795,41 +5038,38 @@ var ExternalStoreThreadRuntimeCore = (_class14 = class extends BaseThreadRuntime
4795
5038
  get adapters() {
4796
5039
  return this._store.adapters;
4797
5040
  }
4798
- __init35() {this.suggestions = []}
4799
- __init36() {this.extras = void 0}
4800
- __init37() {this._converter = new ThreadMessageConverter()}
5041
+ __init39() {this.suggestions = []}
5042
+ __init40() {this.extras = void 0}
5043
+ __init41() {this._converter = new ThreadMessageConverter()}
4801
5044
 
4802
5045
  beginEdit(messageId) {
4803
- if (!this.store.onEdit)
5046
+ if (!this._store.onEdit)
4804
5047
  throw new Error("Runtime does not support editing.");
4805
5048
  super.beginEdit(messageId);
4806
5049
  }
4807
- constructor(configProvider, store) {
4808
- super(configProvider);_class14.prototype.__init33.call(this);_class14.prototype.__init34.call(this);_class14.prototype.__init35.call(this);_class14.prototype.__init36.call(this);_class14.prototype.__init37.call(this);_class14.prototype.__init38.call(this);;
4809
- this.store = store;
4810
- }
4811
- get store() {
4812
- return this._store;
5050
+ constructor(configProvider, threadId, store) {
5051
+ super(configProvider);_class16.prototype.__init37.call(this);_class16.prototype.__init38.call(this);_class16.prototype.__init39.call(this);_class16.prototype.__init40.call(this);_class16.prototype.__init41.call(this);_class16.prototype.__init42.call(this);;
5052
+ this.threadId = threadId;
5053
+ this.setStore(store);
4813
5054
  }
4814
- set store(store) {
5055
+ setStore(store) {
4815
5056
  if (this._store === store) return;
4816
- this.threadId = _nullishCoalesce(_nullishCoalesce(store.threadId, () => ( this.threadId)), () => ( generateId()));
4817
5057
  const isRunning = _nullishCoalesce(store.isRunning, () => ( false));
4818
5058
  this.isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
4819
5059
  const oldStore = this._store;
4820
5060
  this._store = store;
4821
5061
  this.extras = store.extras;
4822
- this.suggestions = _nullishCoalesce(store.suggestions, () => ( EMPTY_ARRAY2));
5062
+ this.suggestions = _nullishCoalesce(store.suggestions, () => ( EMPTY_ARRAY3));
4823
5063
  this._capabilities = {
4824
5064
  switchToBranch: this._store.setMessages !== void 0,
4825
5065
  edit: this._store.onEdit !== void 0,
4826
5066
  reload: this._store.onReload !== void 0,
4827
5067
  cancel: this._store.onCancel !== void 0,
4828
- speech: _optionalChain([this, 'access', _249 => _249._store, 'access', _250 => _250.adapters, 'optionalAccess', _251 => _251.speech]) !== void 0,
4829
- unstable_copy: _optionalChain([this, 'access', _252 => _252._store, 'access', _253 => _253.unstable_capabilities, 'optionalAccess', _254 => _254.copy]) !== false,
5068
+ speech: _optionalChain([this, 'access', _251 => _251._store, 'access', _252 => _252.adapters, 'optionalAccess', _253 => _253.speech]) !== void 0,
5069
+ unstable_copy: _optionalChain([this, 'access', _254 => _254._store, 'access', _255 => _255.unstable_capabilities, 'optionalAccess', _256 => _256.copy]) !== false,
4830
5070
  // default true
4831
- attachments: !!_optionalChain([this, 'access', _255 => _255.store, 'access', _256 => _256.adapters, 'optionalAccess', _257 => _257.attachments]),
4832
- feedback: !!_optionalChain([this, 'access', _258 => _258.store, 'access', _259 => _259.adapters, 'optionalAccess', _260 => _260.feedback])
5071
+ attachments: !!_optionalChain([this, 'access', _257 => _257._store, 'access', _258 => _258.adapters, 'optionalAccess', _259 => _259.attachments]),
5072
+ feedback: !!_optionalChain([this, 'access', _260 => _260._store, 'access', _261 => _261.adapters, 'optionalAccess', _262 => _262.feedback])
4833
5073
  };
4834
5074
  if (oldStore) {
4835
5075
  if (oldStore.convertMessage !== store.convertMessage) {
@@ -4856,7 +5096,7 @@ var ExternalStoreThreadRuntimeCore = (_class14 = class extends BaseThreadRuntime
4856
5096
  for (let i = 0; i < messages2.length; i++) {
4857
5097
  const message = messages2[i];
4858
5098
  const parent = messages2[i - 1];
4859
- this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _261 => _261.id]), () => ( null)), message);
5099
+ this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _263 => _263.id]), () => ( null)), message);
4860
5100
  }
4861
5101
  if (this.assistantOptimisticId) {
4862
5102
  this.repository.deleteMessage(this.assistantOptimisticId);
@@ -4864,7 +5104,7 @@ var ExternalStoreThreadRuntimeCore = (_class14 = class extends BaseThreadRuntime
4864
5104
  }
4865
5105
  if (hasUpcomingMessage(isRunning, messages2)) {
4866
5106
  this.assistantOptimisticId = this.repository.appendOptimisticMessage(
4867
- _nullishCoalesce(_optionalChain([messages2, 'access', _262 => _262.at, 'call', _263 => _263(-1), 'optionalAccess', _264 => _264.id]), () => ( null)),
5107
+ _nullishCoalesce(_optionalChain([messages2, 'access', _264 => _264.at, 'call', _265 => _265(-1), 'optionalAccess', _266 => _266.id]), () => ( null)),
4868
5108
  {
4869
5109
  role: "assistant",
4870
5110
  content: []
@@ -4872,7 +5112,7 @@ var ExternalStoreThreadRuntimeCore = (_class14 = class extends BaseThreadRuntime
4872
5112
  );
4873
5113
  }
4874
5114
  this.repository.resetHead(
4875
- _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _265 => _265.at, 'call', _266 => _266(-1), 'optionalAccess', _267 => _267.id]))), () => ( null))
5115
+ _nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages2, 'access', _267 => _267.at, 'call', _268 => _268(-1), 'optionalAccess', _269 => _269.id]))), () => ( null))
4876
5116
  );
4877
5117
  this._messages = this.repository.getMessages();
4878
5118
  this._notifySubscribers();
@@ -4884,7 +5124,7 @@ var ExternalStoreThreadRuntimeCore = (_class14 = class extends BaseThreadRuntime
4884
5124
  this.updateMessages(this.repository.getMessages());
4885
5125
  }
4886
5126
  async append(message) {
4887
- if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _268 => _268.messages, 'access', _269 => _269.at, 'call', _270 => _270(-1), 'optionalAccess', _271 => _271.id]), () => ( null)))) {
5127
+ if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _270 => _270.messages, 'access', _271 => _271.at, 'call', _272 => _272(-1), 'optionalAccess', _273 => _273.id]), () => ( null)))) {
4888
5128
  if (!this._store.onEdit)
4889
5129
  throw new Error("Runtime does not support editing messages.");
4890
5130
  await this._store.onEdit(message);
@@ -4907,7 +5147,7 @@ var ExternalStoreThreadRuntimeCore = (_class14 = class extends BaseThreadRuntime
4907
5147
  }
4908
5148
  let messages2 = this.repository.getMessages();
4909
5149
  const previousMessage = messages2[messages2.length - 1];
4910
- if (_optionalChain([previousMessage, 'optionalAccess', _272 => _272.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _273 => _273.at, 'call', _274 => _274(-1), 'optionalAccess', _275 => _275.id])) {
5150
+ if (_optionalChain([previousMessage, 'optionalAccess', _274 => _274.role]) === "user" && previousMessage.id === _optionalChain([messages2, 'access', _275 => _275.at, 'call', _276 => _276(-1), 'optionalAccess', _277 => _277.id])) {
4911
5151
  this.repository.deleteMessage(previousMessage.id);
4912
5152
  if (!this.composer.text.trim()) {
4913
5153
  this.composer.setText(getThreadMessageText(previousMessage));
@@ -4925,57 +5165,41 @@ var ExternalStoreThreadRuntimeCore = (_class14 = class extends BaseThreadRuntime
4925
5165
  throw new Error("Runtime does not support tool results.");
4926
5166
  this._store.onAddToolResult(options);
4927
5167
  }
4928
- __init38() {this.updateMessages = (messages2) => {
4929
- _optionalChain([this, 'access', _276 => _276._store, 'access', _277 => _277.setMessages, 'optionalCall', _278 => _278(
5168
+ __init42() {this.updateMessages = (messages2) => {
5169
+ _optionalChain([this, 'access', _278 => _278._store, 'access', _279 => _279.setMessages, 'optionalCall', _280 => _280(
4930
5170
  messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
4931
5171
  )]);
4932
5172
  }}
4933
- }, _class14);
5173
+ }, _class16);
4934
5174
 
4935
5175
  // src/runtimes/external-store/ExternalStoreRuntimeCore.tsx
5176
+ var getThreadManagerAdapter = (store) => {
5177
+ return {
5178
+ threadId: store.threadId,
5179
+ onSwitchToNewThread: store.onSwitchToNewThread,
5180
+ onSwitchToThread: store.onSwitchToThread,
5181
+ ..._optionalChain([store, 'access', _281 => _281.adapters, 'optionalAccess', _282 => _282.threadManager])
5182
+ };
5183
+ };
4936
5184
  var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
4937
5185
 
5186
+
4938
5187
  constructor(store) {
4939
- const provider = new ProxyConfigProvider();
4940
- super(new ExternalStoreThreadRuntimeCore(provider, store));
4941
- this._proxyConfigProvider = provider;
4942
- }
4943
- getModelConfig() {
4944
- return this._proxyConfigProvider.getModelConfig();
4945
- }
4946
- registerModelConfigProvider(provider) {
4947
- return this._proxyConfigProvider.registerModelConfigProvider(provider);
4948
- }
4949
- async switchToNewThread() {
4950
- if (!this.thread.store.onSwitchToNewThread)
4951
- throw new Error("Runtime does not support switching to new threads.");
4952
- this.thread = new ExternalStoreThreadRuntimeCore(
4953
- this._proxyConfigProvider,
4954
- {
4955
- ...this.thread.store,
4956
- messages: []
4957
- }
4958
- );
4959
- await this.thread.store.onSwitchToNewThread();
4960
- this.thread._notifyEventSubscribers("switched-to");
4961
- }
4962
- async switchToThread(threadId) {
4963
- if (threadId !== null) {
4964
- if (!this.thread.store.onSwitchToThread)
4965
- throw new Error("Runtime does not support switching threads.");
4966
- this.thread = new ExternalStoreThreadRuntimeCore(
5188
+ super();
5189
+ this._store = store;
5190
+ this.threadManager = new ExternalStoreThreadManagerRuntimeCore(
5191
+ getThreadManagerAdapter(store),
5192
+ (threadId) => new ExternalStoreThreadRuntimeCore(
4967
5193
  this._proxyConfigProvider,
4968
- {
4969
- ...this.thread.store,
4970
- messages: []
4971
- // ignore messages until rerender
4972
- }
4973
- );
4974
- await this.thread.store.onSwitchToThread(threadId);
4975
- this.thread._notifyEventSubscribers("switched-to");
4976
- } else {
4977
- this.switchToNewThread();
4978
- }
5194
+ threadId,
5195
+ this._store
5196
+ )
5197
+ );
5198
+ }
5199
+ setStore(store) {
5200
+ this._store = store;
5201
+ this.threadManager.setAdapter(getThreadManagerAdapter(store));
5202
+ this.threadManager.mainThread.setStore(store);
4979
5203
  }
4980
5204
  };
4981
5205
 
@@ -4983,7 +5207,7 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
4983
5207
  var useExternalStoreRuntime = (store) => {
4984
5208
  const [runtime] = _react.useState.call(void 0, () => new ExternalStoreRuntimeCore(store));
4985
5209
  _react.useEffect.call(void 0, () => {
4986
- runtime.thread.store = store;
5210
+ runtime.setStore(store);
4987
5211
  });
4988
5212
  return _react.useMemo.call(void 0,
4989
5213
  () => AssistantRuntimeImpl.create(runtime, ThreadRuntimeImpl),
@@ -5212,8 +5436,8 @@ var WebSpeechSynthesisAdapter = class {
5212
5436
  };
5213
5437
 
5214
5438
  // src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
5215
- var SimpleImageAttachmentAdapter = (_class15 = class {constructor() { _class15.prototype.__init39.call(this); }
5216
- __init39() {this.accept = "image/*"}
5439
+ var SimpleImageAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init43.call(this); }
5440
+ __init43() {this.accept = "image/*"}
5217
5441
  async add(state) {
5218
5442
  return {
5219
5443
  id: state.file.name,
@@ -5238,7 +5462,7 @@ var SimpleImageAttachmentAdapter = (_class15 = class {constructor() { _class15.p
5238
5462
  }
5239
5463
  async remove() {
5240
5464
  }
5241
- }, _class15);
5465
+ }, _class17);
5242
5466
  var getFileDataURL = (file) => new Promise((resolve, reject) => {
5243
5467
  const reader = new FileReader();
5244
5468
  reader.onload = () => resolve(reader.result);
@@ -5247,8 +5471,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
5247
5471
  });
5248
5472
 
5249
5473
  // src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
5250
- var SimpleTextAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init40.call(this); }
5251
- __init40() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
5474
+ var SimpleTextAttachmentAdapter = (_class18 = class {constructor() { _class18.prototype.__init44.call(this); }
5475
+ __init44() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
5252
5476
  async add(state) {
5253
5477
  return {
5254
5478
  id: state.file.name,
@@ -5275,7 +5499,7 @@ ${await getFileText(attachment.file)}
5275
5499
  }
5276
5500
  async remove() {
5277
5501
  }
5278
- }, _class16);
5502
+ }, _class18);
5279
5503
  var getFileText = (file) => new Promise((resolve, reject) => {
5280
5504
  const reader = new FileReader();
5281
5505
  reader.onload = () => resolve(reader.result);
@@ -5376,7 +5600,7 @@ var ThreadConfigProvider = ({
5376
5600
  }) => {
5377
5601
  const hasAssistant = !!useAssistantRuntime({ optional: true });
5378
5602
  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 });
5379
- if (!_optionalChain([config, 'optionalAccess', _279 => _279.runtime])) return configProvider;
5603
+ if (!_optionalChain([config, 'optionalAccess', _283 => _283.runtime])) return configProvider;
5380
5604
  if (hasAssistant) {
5381
5605
  throw new Error(
5382
5606
  "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
@@ -5704,7 +5928,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
5704
5928
  {
5705
5929
  components: {
5706
5930
  ...componentsProp,
5707
- Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _280 => _280.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
5931
+ Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _284 => _284.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
5708
5932
  tools: toolsComponents
5709
5933
  }
5710
5934
  }
@@ -5815,7 +6039,7 @@ var useAttachmentSrc = () => {
5815
6039
  const { file, src } = useAttachment((a) => {
5816
6040
  if (a.type !== "image") return {};
5817
6041
  if (a.file) return { file: a.file };
5818
- const src2 = _optionalChain([a, 'access', _281 => _281.content, 'optionalAccess', _282 => _282.filter, 'call', _283 => _283((c) => c.type === "image"), 'access', _284 => _284[0], 'optionalAccess', _285 => _285.image]);
6042
+ const src2 = _optionalChain([a, 'access', _285 => _285.content, 'optionalAccess', _286 => _286.filter, 'call', _287 => _287((c) => c.type === "image"), 'access', _288 => _288[0], 'optionalAccess', _289 => _289.image]);
5819
6043
  if (!src2) return {};
5820
6044
  return { src: src2 };
5821
6045
  });
@@ -5959,7 +6183,7 @@ var ComposerAttachments = ({ components }) => {
5959
6183
  {
5960
6184
  components: {
5961
6185
  ...components,
5962
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _286 => _286.Attachment]), () => ( attachment_default))
6186
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _290 => _290.Attachment]), () => ( attachment_default))
5963
6187
  }
5964
6188
  }
5965
6189
  ) });
@@ -6068,8 +6292,13 @@ var ThreadWelcomeMessageStyled = withDefaults("p", {
6068
6292
  className: "aui-thread-welcome-message"
6069
6293
  });
6070
6294
  var ThreadWelcomeMessage = _react.forwardRef.call(void 0, ({ message: messageProp, ...rest }, ref) => {
6071
- const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
6072
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeMessageStyled, { ...rest, ref, children: _nullishCoalesce(messageProp, () => ( message)) });
6295
+ const {
6296
+ welcome: { message } = {},
6297
+ strings: {
6298
+ welcome: { message: defaultMessage = "How can I help you today?" } = {}
6299
+ } = {}
6300
+ } = useThreadConfig();
6301
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeMessageStyled, { ...rest, ref, children: _nullishCoalesce(_nullishCoalesce(messageProp, () => ( message)), () => ( defaultMessage)) });
6073
6302
  });
6074
6303
  ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
6075
6304
  var ThreadWelcomeSuggestionContainer = withDefaults("div", {
@@ -6087,7 +6316,7 @@ var ThreadWelcomeSuggestions = () => {
6087
6316
  const suggestions2 = useThread((t) => t.suggestions);
6088
6317
  const { welcome: { suggestions } = {} } = useThreadConfig();
6089
6318
  const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
6090
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _287 => _287.map, 'call', _288 => _288((suggestion, idx) => {
6319
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _291 => _291.map, 'call', _292 => _292((suggestion, idx) => {
6091
6320
  const key = `${suggestion.prompt}-${idx}`;
6092
6321
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
6093
6322
  })]) });
@@ -6165,7 +6394,7 @@ var UserMessageContent = _react.forwardRef.call(void 0, ({ components, ...props
6165
6394
  {
6166
6395
  components: {
6167
6396
  ...components,
6168
- Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _289 => _289.Text]), () => ( content_part_default.Text))
6397
+ Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _293 => _293.Text]), () => ( content_part_default.Text))
6169
6398
  }
6170
6399
  }
6171
6400
  ) });
@@ -6182,7 +6411,7 @@ var UserMessageAttachments = ({
6182
6411
  {
6183
6412
  components: {
6184
6413
  ...components,
6185
- Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _290 => _290.Attachment]), () => ( attachment_default))
6414
+ Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _294 => _294.Attachment]), () => ( attachment_default))
6186
6415
  }
6187
6416
  }
6188
6417
  ) }) });
@@ -6285,10 +6514,10 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
6285
6514
  thread_exports.Messages,
6286
6515
  {
6287
6516
  components: {
6288
- UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _291 => _291.UserMessage]), () => ( user_message_default)),
6289
- EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _292 => _292.EditComposer]), () => ( edit_composer_default)),
6290
- AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _293 => _293.AssistantMessage]), () => ( assistant_message_default)),
6291
- SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _294 => _294.SystemMessage]), () => ( SystemMessage))
6517
+ UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _295 => _295.UserMessage]), () => ( user_message_default)),
6518
+ EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _296 => _296.EditComposer]), () => ( edit_composer_default)),
6519
+ AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _297 => _297.AssistantMessage]), () => ( assistant_message_default)),
6520
+ SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _298 => _298.SystemMessage]), () => ( SystemMessage))
6292
6521
  },
6293
6522
  ...rest
6294
6523
  }
@@ -6299,7 +6528,7 @@ var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ..
6299
6528
  ThreadMessages.displayName = "ThreadMessages";
6300
6529
  var ThreadFollowupSuggestions = () => {
6301
6530
  const suggestions = useThread((t) => t.suggestions);
6302
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _295 => _295.map, 'call', _296 => _296((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6531
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _299 => _299.map, 'call', _300 => _300((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
6303
6532
  thread_exports.Suggestion,
6304
6533
  {
6305
6534
  className: "aui-thread-followup-suggestion",
@@ -6533,5 +6762,6 @@ var assistant_modal_default = Object.assign(AssistantModal, exports12);
6533
6762
 
6534
6763
 
6535
6764
 
6536
- 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.AttachmentPrimitive = attachment_exports; exports.AttachmentUI = attachment_default; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = 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 = 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 = _chunkC6UZOY5Ajs.toCoreMessage; exports.toCoreMessages = _chunkC6UZOY5Ajs.toCoreMessages; exports.toLanguageModelMessages = _chunkC6UZOY5Ajs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkC6UZOY5Ajs.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.useComposerRuntime = useComposerRuntime; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartRuntime = useContentPartRuntime; 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.useThreadModelConfig = useThreadModelConfig; 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;
6765
+
6766
+ 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.AttachmentPrimitive = attachment_exports; exports.AttachmentUI = attachment_default; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = 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 = 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 = _chunkC6UZOY5Ajs.toCoreMessage; exports.toCoreMessages = _chunkC6UZOY5Ajs.toCoreMessages; exports.toLanguageModelMessages = _chunkC6UZOY5Ajs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkC6UZOY5Ajs.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.useComposerRuntime = useComposerRuntime; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartRuntime = useContentPartRuntime; 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.useThreadManager = useThreadManager; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadModelConfig = useThreadModelConfig; 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;
6537
6767
  //# sourceMappingURL=index.js.map