@assistant-ui/react 0.5.84 → 0.5.86
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +24 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -3061,7 +3061,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
3061
3061
|
};
|
3062
3062
|
|
3063
3063
|
// src/runtimes/local/useLocalRuntime.tsx
|
3064
|
-
import { useEffect as useEffect17, useMemo as useMemo11, useState as
|
3064
|
+
import { useEffect as useEffect17, useMemo as useMemo11, useState as useState12 } from "react";
|
3065
3065
|
|
3066
3066
|
// src/utils/ProxyConfigProvider.ts
|
3067
3067
|
var ProxyConfigProvider = class {
|
@@ -4101,9 +4101,6 @@ var streamUtils = {
|
|
4101
4101
|
streamPartDecoderStream
|
4102
4102
|
};
|
4103
4103
|
|
4104
|
-
// src/runtimes/edge/useEdgeRuntime.ts
|
4105
|
-
import { useState as useState12 } from "react";
|
4106
|
-
|
4107
4104
|
// src/runtimes/edge/streams/assistantDecoderStream.ts
|
4108
4105
|
function assistantDecoderStream() {
|
4109
4106
|
const toolCallNames = /* @__PURE__ */ new Map();
|
@@ -4283,8 +4280,10 @@ var splitLocalRuntimeOptions = (options) => {
|
|
4283
4280
|
// src/runtimes/edge/useEdgeRuntime.ts
|
4284
4281
|
var useEdgeRuntime = (options) => {
|
4285
4282
|
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
4286
|
-
|
4287
|
-
|
4283
|
+
return useLocalRuntime(
|
4284
|
+
new EdgeChatAdapter(otherOptions),
|
4285
|
+
localRuntimeOptions
|
4286
|
+
);
|
4288
4287
|
};
|
4289
4288
|
|
4290
4289
|
// src/runtimes/local/shouldContinue.tsx
|
@@ -4652,7 +4651,14 @@ var LocalThreadRuntimeCore = class extends BaseThreadRuntimeCore {
|
|
4652
4651
|
var LocalThreadManagerRuntimeCore = class {
|
4653
4652
|
constructor(_threadFactory) {
|
4654
4653
|
this._threadFactory = _threadFactory;
|
4655
|
-
|
4654
|
+
const threadId = generateId();
|
4655
|
+
this._threadData.set(threadId, {
|
4656
|
+
data: { messages: [] },
|
4657
|
+
metadata: { threadId },
|
4658
|
+
isArchived: false
|
4659
|
+
});
|
4660
|
+
this._threads = [{ threadId }];
|
4661
|
+
this._mainThread = this._threadFactory(threadId, { messages: [] });
|
4656
4662
|
}
|
4657
4663
|
_threadData = /* @__PURE__ */ new Map();
|
4658
4664
|
_threads = [];
|
@@ -4675,17 +4681,21 @@ var LocalThreadManagerRuntimeCore = class {
|
|
4675
4681
|
this._performThreadSwitch(thread);
|
4676
4682
|
}
|
4677
4683
|
switchToNewThread() {
|
4678
|
-
|
4679
|
-
|
4684
|
+
const threadId = generateId();
|
4685
|
+
this._threadData.set(threadId, {
|
4686
|
+
data: { messages: [] },
|
4687
|
+
metadata: { threadId },
|
4688
|
+
isArchived: false
|
4689
|
+
});
|
4690
|
+
this._threads = [{ threadId }];
|
4691
|
+
const thread = this._threadFactory(threadId, { messages: [] });
|
4680
4692
|
this._performThreadSwitch(thread);
|
4681
4693
|
}
|
4682
4694
|
_performThreadSwitch(newThreadCore) {
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
data.data = exprt;
|
4688
|
-
}
|
4695
|
+
const data = this._threadData.get(this._mainThread.threadId);
|
4696
|
+
if (!data) throw new Error("Thread not found");
|
4697
|
+
const exprt = this._mainThread.export();
|
4698
|
+
data.data = exprt;
|
4689
4699
|
this._mainThread._notifyEventSubscribers("switched-away");
|
4690
4700
|
this._mainThread = newThreadCore;
|
4691
4701
|
newThreadCore._notifyEventSubscribers("switched-to");
|
@@ -4823,7 +4833,7 @@ var useLocalRuntime = (adapter, options = {}) => {
|
|
4823
4833
|
chatModel: adapter
|
4824
4834
|
}
|
4825
4835
|
};
|
4826
|
-
const [runtime] =
|
4836
|
+
const [runtime] = useState12(() => new LocalRuntimeCore(opt));
|
4827
4837
|
useEffect17(() => {
|
4828
4838
|
runtime.setOptions(opt);
|
4829
4839
|
});
|
@@ -4831,7 +4841,7 @@ var useLocalRuntime = (adapter, options = {}) => {
|
|
4831
4841
|
};
|
4832
4842
|
|
4833
4843
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
4834
|
-
import { useEffect as useEffect18, useMemo as useMemo12, useState as
|
4844
|
+
import { useEffect as useEffect18, useMemo as useMemo12, useState as useState13 } from "react";
|
4835
4845
|
|
4836
4846
|
// src/runtimes/external-store/ExternalStoreThreadManagementAdapter.tsx
|
4837
4847
|
var EMPTY_ARRAY2 = Object.freeze([]);
|
@@ -5217,7 +5227,7 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
5217
5227
|
|
5218
5228
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
5219
5229
|
var useExternalStoreRuntime = (store) => {
|
5220
|
-
const [runtime] =
|
5230
|
+
const [runtime] = useState13(() => new ExternalStoreRuntimeCore(store));
|
5221
5231
|
useEffect18(() => {
|
5222
5232
|
runtime.setStore(store);
|
5223
5233
|
});
|
@@ -5374,7 +5384,7 @@ var shallowArrayEqual = (a, b) => {
|
|
5374
5384
|
};
|
5375
5385
|
|
5376
5386
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
5377
|
-
import { useState as
|
5387
|
+
import { useState as useState14 } from "react";
|
5378
5388
|
|
5379
5389
|
// src/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.ts
|
5380
5390
|
var DangerousInBrowserAdapter = class {
|
@@ -5403,7 +5413,7 @@ var DangerousInBrowserAdapter = class {
|
|
5403
5413
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
5404
5414
|
var useDangerousInBrowserRuntime = (options) => {
|
5405
5415
|
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
5406
|
-
const [adapter] =
|
5416
|
+
const [adapter] = useState14(() => new DangerousInBrowserAdapter(otherOptions));
|
5407
5417
|
return useLocalRuntime(adapter, localRuntimeOptions);
|
5408
5418
|
};
|
5409
5419
|
|
@@ -5990,7 +6000,7 @@ CircleStopIcon.displayName = "CircleStopIcon";
|
|
5990
6000
|
import {
|
5991
6001
|
forwardRef as forwardRef28,
|
5992
6002
|
useEffect as useEffect19,
|
5993
|
-
useState as
|
6003
|
+
useState as useState15
|
5994
6004
|
} from "react";
|
5995
6005
|
import { CircleXIcon, FileIcon } from "lucide-react";
|
5996
6006
|
|
@@ -6033,7 +6043,7 @@ var AttachmentRoot = withDefaults(attachment_exports.Root, {
|
|
6033
6043
|
});
|
6034
6044
|
AttachmentRoot.displayName = "AttachmentRoot";
|
6035
6045
|
var useFileSrc = (file) => {
|
6036
|
-
const [src, setSrc] =
|
6046
|
+
const [src, setSrc] = useState15(void 0);
|
6037
6047
|
useEffect19(() => {
|
6038
6048
|
if (!file) {
|
6039
6049
|
setSrc(void 0);
|
@@ -6058,7 +6068,7 @@ var useAttachmentSrc = () => {
|
|
6058
6068
|
return useFileSrc(file) ?? src;
|
6059
6069
|
};
|
6060
6070
|
var AttachmentPreview = ({ src }) => {
|
6061
|
-
const [isLoaded, setIsLoaded] =
|
6071
|
+
const [isLoaded, setIsLoaded] = useState15(false);
|
6062
6072
|
return (
|
6063
6073
|
// eslint-disable-next-line @next/next/no-img-element
|
6064
6074
|
/* @__PURE__ */ jsx46(
|