@assistant-ui/react 0.5.22 → 0.5.24
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +39 -25
- package/dist/index.d.ts +39 -25
- package/dist/index.js +132 -139
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -120
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -2144,6 +2144,13 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
2144
2144
|
}
|
2145
2145
|
}
|
2146
2146
|
if (operation !== "cut") {
|
2147
|
+
for (let current = newParent; current; current = current.prev) {
|
2148
|
+
if (current.current.id === child.current.id) {
|
2149
|
+
throw new Error(
|
2150
|
+
"MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui."
|
2151
|
+
);
|
2152
|
+
}
|
2153
|
+
}
|
2147
2154
|
newParentOrRoot.children = [
|
2148
2155
|
...newParentOrRoot.children,
|
2149
2156
|
child.current.id
|
@@ -2273,6 +2280,25 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
2273
2280
|
}
|
2274
2281
|
}
|
2275
2282
|
}
|
2283
|
+
export() {
|
2284
|
+
const exportItems = [];
|
2285
|
+
for (const [, message] of this.messages) {
|
2286
|
+
exportItems.push({
|
2287
|
+
message: message.current,
|
2288
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _84 => _84.prev, 'optionalAccess', _85 => _85.current, 'access', _86 => _86.id]), () => ( null))
|
2289
|
+
});
|
2290
|
+
}
|
2291
|
+
return {
|
2292
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _87 => _87.head, 'optionalAccess', _88 => _88.current, 'access', _89 => _89.id]), () => ( null)),
|
2293
|
+
messages: exportItems
|
2294
|
+
};
|
2295
|
+
}
|
2296
|
+
import({ headId, messages }) {
|
2297
|
+
for (const { message, parentId } of messages) {
|
2298
|
+
this.addOrUpdateMessage(parentId, message);
|
2299
|
+
}
|
2300
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access', _90 => _90.at, 'call', _91 => _91(-1), 'optionalAccess', _92 => _92.message, 'access', _93 => _93.id]))), () => ( null)));
|
2301
|
+
}
|
2276
2302
|
}, _class4);
|
2277
2303
|
|
2278
2304
|
// src/ui/base/tooltip-icon-button.tsx
|
@@ -2434,7 +2460,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
2434
2460
|
});
|
2435
2461
|
if (mergeRoundtrips) {
|
2436
2462
|
const previousMessage = messages[messages.length - 1];
|
2437
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
2463
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _94 => _94.role]) === "assistant") {
|
2438
2464
|
previousMessage.content.push(...newContent);
|
2439
2465
|
break;
|
2440
2466
|
}
|
@@ -2447,7 +2473,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
2447
2473
|
}
|
2448
2474
|
case "tool": {
|
2449
2475
|
const previousMessage = messages[messages.length - 1];
|
2450
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
2476
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _95 => _95.role]) !== "assistant")
|
2451
2477
|
throw new Error(
|
2452
2478
|
"A tool message must be preceded by an assistant message."
|
2453
2479
|
);
|
@@ -2651,7 +2677,7 @@ var useEdgeRuntime = ({
|
|
2651
2677
|
};
|
2652
2678
|
|
2653
2679
|
// src/runtimes/local/shouldContinue.tsx
|
2654
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
2680
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _96 => _96.status, 'optionalAccess', _97 => _97.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
2655
2681
|
|
2656
2682
|
// src/runtimes/local/LocalThreadRuntime.tsx
|
2657
2683
|
var CAPABILITIES = Object.freeze({
|
@@ -2666,7 +2692,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
2666
2692
|
this.configProvider = configProvider;
|
2667
2693
|
this.adapter = adapter;
|
2668
2694
|
this.options = options;
|
2669
|
-
if (_optionalChain([options, 'optionalAccess',
|
2695
|
+
if (_optionalChain([options, 'optionalAccess', _98 => _98.initialMessages])) {
|
2670
2696
|
let parentId = null;
|
2671
2697
|
const messages = fromCoreMessages(options.initialMessages);
|
2672
2698
|
for (const message of messages) {
|
@@ -2724,7 +2750,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
2724
2750
|
}
|
2725
2751
|
async performRoundtrip(parentId, message) {
|
2726
2752
|
const messages = this.repository.getMessages();
|
2727
|
-
_optionalChain([this, 'access',
|
2753
|
+
_optionalChain([this, 'access', _99 => _99.abortController, 'optionalAccess', _100 => _100.abort, 'call', _101 => _101()]);
|
2728
2754
|
this.abortController = new AbortController();
|
2729
2755
|
const initialContent = message.content;
|
2730
2756
|
const initialRoundtrips = message.roundtrips;
|
@@ -2733,13 +2759,13 @@ var LocalThreadRuntime = (_class5 = class {
|
|
2733
2759
|
...message,
|
2734
2760
|
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
2735
2761
|
status: _nullishCoalesce(m.status, () => ( message.status)),
|
2736
|
-
..._optionalChain([m, 'access',
|
2762
|
+
..._optionalChain([m, 'access', _102 => _102.roundtrips, 'optionalAccess', _103 => _103.length]) ? { roundtrips: [..._nullishCoalesce(initialRoundtrips, () => ( [])), ...m.roundtrips] } : void 0
|
2737
2763
|
};
|
2738
2764
|
this.repository.addOrUpdateMessage(parentId, message);
|
2739
2765
|
this.notifySubscribers();
|
2740
2766
|
};
|
2741
|
-
const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access',
|
2742
|
-
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access',
|
2767
|
+
const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access', _104 => _104.options, 'optionalAccess', _105 => _105.maxToolRoundtrips]), () => ( 1));
|
2768
|
+
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _106 => _106.roundtrips, 'optionalAccess', _107 => _107.length]), () => ( 0));
|
2743
2769
|
if (toolRoundtrips > maxToolRoundtrips) {
|
2744
2770
|
updateMessage({
|
2745
2771
|
status: {
|
@@ -2831,6 +2857,13 @@ var LocalThreadRuntime = (_class5 = class {
|
|
2831
2857
|
this.performRoundtrip(parentId, message);
|
2832
2858
|
}
|
2833
2859
|
}
|
2860
|
+
export() {
|
2861
|
+
return this.repository.export();
|
2862
|
+
}
|
2863
|
+
import(data) {
|
2864
|
+
this.repository.import(data);
|
2865
|
+
this.notifySubscribers();
|
2866
|
+
}
|
2834
2867
|
}, _class5);
|
2835
2868
|
|
2836
2869
|
// src/runtimes/local/LocalRuntime.tsx
|
@@ -2867,18 +2900,12 @@ var useLocalRuntime = (adapter, options) => {
|
|
2867
2900
|
return runtime;
|
2868
2901
|
};
|
2869
2902
|
|
2870
|
-
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
2871
|
-
|
2872
|
-
|
2873
2903
|
// src/runtimes/external-store/getExternalStoreMessage.tsx
|
2874
2904
|
var symbolInnerMessage = Symbol("innerMessage");
|
2875
2905
|
var getExternalStoreMessage = (message) => {
|
2876
2906
|
return message[symbolInnerMessage];
|
2877
2907
|
};
|
2878
2908
|
|
2879
|
-
// src/runtimes/external-store/useExternalStoreSync.tsx
|
2880
|
-
|
2881
|
-
|
2882
2909
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
2883
2910
|
var ThreadMessageConverter = (_class6 = class {constructor() { _class6.prototype.__init16.call(this); }
|
2884
2911
|
__init16() {this.cache = /* @__PURE__ */ new WeakMap()}
|
@@ -2899,6 +2926,7 @@ var AUTO_STATUS_COMPLETE = Object.freeze({
|
|
2899
2926
|
type: "complete",
|
2900
2927
|
reason: "unknown"
|
2901
2928
|
});
|
2929
|
+
var isAutoStatus = (status) => status === AUTO_STATUS_RUNNING || status === AUTO_STATUS_COMPLETE;
|
2902
2930
|
var getAutoStatus = (isLast, isRunning) => isLast && isRunning ? AUTO_STATUS_RUNNING : AUTO_STATUS_COMPLETE;
|
2903
2931
|
|
2904
2932
|
// src/runtimes/external-store/ThreadMessageLike.tsx
|
@@ -2969,106 +2997,114 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
2969
2997
|
}
|
2970
2998
|
};
|
2971
2999
|
|
2972
|
-
// src/runtimes/external-store/useExternalStoreSync.tsx
|
2973
|
-
var useExternalStoreSync = (adapter, updateData) => {
|
2974
|
-
const adapterRef = _react.useRef.call(void 0, adapter);
|
2975
|
-
_react.useInsertionEffect.call(void 0, () => {
|
2976
|
-
adapterRef.current = adapter;
|
2977
|
-
});
|
2978
|
-
const [converter, convertCallback] = _react.useMemo.call(void 0, () => {
|
2979
|
-
const converter2 = _nullishCoalesce(adapter.convertMessage, () => ( ((m) => m)));
|
2980
|
-
const convertCallback2 = (cache, m, idx) => {
|
2981
|
-
const autoStatus = getAutoStatus(
|
2982
|
-
adapterRef.current.messages.at(-1) === m,
|
2983
|
-
_nullishCoalesce(adapterRef.current.isRunning, () => ( false))
|
2984
|
-
);
|
2985
|
-
if (cache && (cache.role !== "assistant" || cache.status === autoStatus))
|
2986
|
-
return cache;
|
2987
|
-
const newMessage = fromThreadMessageLike(
|
2988
|
-
converter2(m, idx),
|
2989
|
-
idx.toString(),
|
2990
|
-
autoStatus
|
2991
|
-
);
|
2992
|
-
newMessage[symbolInnerMessage] = m;
|
2993
|
-
return newMessage;
|
2994
|
-
};
|
2995
|
-
return [new ThreadMessageConverter(), convertCallback2];
|
2996
|
-
}, [adapter.convertMessage]);
|
2997
|
-
_react.useEffect.call(void 0, () => {
|
2998
|
-
updateData(
|
2999
|
-
_nullishCoalesce(adapter.isDisabled, () => ( false)),
|
3000
|
-
_nullishCoalesce(adapter.isRunning, () => ( false)),
|
3001
|
-
converter.convertMessages(adapter.messages, convertCallback)
|
3002
|
-
);
|
3003
|
-
}, [
|
3004
|
-
updateData,
|
3005
|
-
converter,
|
3006
|
-
convertCallback,
|
3007
|
-
adapter.isDisabled,
|
3008
|
-
adapter.isRunning,
|
3009
|
-
adapter.messages
|
3010
|
-
]);
|
3011
|
-
};
|
3012
|
-
|
3013
3000
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
3014
3001
|
var hasUpcomingMessage = (isRunning, messages) => {
|
3015
|
-
return isRunning && _optionalChain([messages, 'access',
|
3002
|
+
return isRunning && _optionalChain([messages, 'access', _108 => _108[messages.length - 1], 'optionalAccess', _109 => _109.role]) !== "assistant";
|
3016
3003
|
};
|
3017
3004
|
var ExternalStoreThreadRuntime = (_class7 = class {
|
3018
|
-
constructor(store) {;_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);_class7.prototype.__init24.call(this);_class7.prototype.__init25.call(this);
|
3019
|
-
this.store = store;
|
3020
|
-
this.updateData(
|
3021
|
-
_nullishCoalesce(store.isDisabled, () => ( false)),
|
3022
|
-
_nullishCoalesce(store.isRunning, () => ( false)),
|
3023
|
-
store.messages
|
3024
|
-
);
|
3025
|
-
this.useStore = _zustand.create.call(void 0, () => ({
|
3026
|
-
store
|
3027
|
-
}));
|
3028
|
-
}
|
3029
3005
|
__init17() {this._subscriptions = /* @__PURE__ */ new Set()}
|
3030
3006
|
__init18() {this.repository = new MessageRepository()}
|
3031
3007
|
__init19() {this.assistantOptimisticId = null}
|
3032
|
-
|
3033
3008
|
get capabilities() {
|
3034
3009
|
return {
|
3035
|
-
switchToBranch: this.
|
3036
|
-
edit: this.
|
3037
|
-
reload: this.
|
3038
|
-
cancel: this.
|
3039
|
-
copy: this.
|
3010
|
+
switchToBranch: this._store.setMessages !== void 0,
|
3011
|
+
edit: this._store.onEdit !== void 0,
|
3012
|
+
reload: this._store.onReload !== void 0,
|
3013
|
+
cancel: this._store.onCancel !== void 0,
|
3014
|
+
copy: this._store.onCopy !== null
|
3040
3015
|
};
|
3041
3016
|
}
|
3042
3017
|
__init20() {this.messages = []}
|
3043
3018
|
__init21() {this.isDisabled = false}
|
3044
3019
|
__init22() {this.isRunning = false}
|
3020
|
+
__init23() {this.converter = new ThreadMessageConverter()}
|
3021
|
+
|
3022
|
+
constructor(store) {;_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);_class7.prototype.__init24.call(this);
|
3023
|
+
this.store = store;
|
3024
|
+
}
|
3025
|
+
set store(store) {
|
3026
|
+
const oldStore = this._store;
|
3027
|
+
if (oldStore) {
|
3028
|
+
if (oldStore.convertMessage !== store.convertMessage) {
|
3029
|
+
this.converter = new ThreadMessageConverter();
|
3030
|
+
} else if (oldStore.isDisabled === store.isDisabled && oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
|
3031
|
+
return;
|
3032
|
+
}
|
3033
|
+
}
|
3034
|
+
this._store = store;
|
3035
|
+
const isRunning = _nullishCoalesce(store.isRunning, () => ( false));
|
3036
|
+
const isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
|
3037
|
+
const convertCallback = (cache, m, idx) => {
|
3038
|
+
if (!store.convertMessage) return m;
|
3039
|
+
const isLast = idx === store.messages.length - 1;
|
3040
|
+
const autoStatus = getAutoStatus(isLast, isRunning);
|
3041
|
+
if (cache && (cache.role !== "assistant" || !isAutoStatus(cache.status) || cache.status === autoStatus))
|
3042
|
+
return cache;
|
3043
|
+
const newMessage = fromThreadMessageLike(
|
3044
|
+
store.convertMessage(m, idx),
|
3045
|
+
idx.toString(),
|
3046
|
+
autoStatus
|
3047
|
+
);
|
3048
|
+
newMessage[symbolInnerMessage] = m;
|
3049
|
+
return newMessage;
|
3050
|
+
};
|
3051
|
+
const messages = this.converter.convertMessages(
|
3052
|
+
store.messages,
|
3053
|
+
convertCallback
|
3054
|
+
);
|
3055
|
+
for (let i = 0; i < messages.length; i++) {
|
3056
|
+
const message = messages[i];
|
3057
|
+
const parent = messages[i - 1];
|
3058
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _113 => _113.id]), () => ( null)), message);
|
3059
|
+
}
|
3060
|
+
if (this.assistantOptimisticId) {
|
3061
|
+
this.repository.deleteMessage(this.assistantOptimisticId);
|
3062
|
+
this.assistantOptimisticId = null;
|
3063
|
+
}
|
3064
|
+
if (hasUpcomingMessage(isRunning, messages)) {
|
3065
|
+
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
3066
|
+
_nullishCoalesce(_optionalChain([messages, 'access', _114 => _114.at, 'call', _115 => _115(-1), 'optionalAccess', _116 => _116.id]), () => ( null)),
|
3067
|
+
{
|
3068
|
+
role: "assistant",
|
3069
|
+
content: []
|
3070
|
+
}
|
3071
|
+
);
|
3072
|
+
}
|
3073
|
+
this.repository.resetHead(
|
3074
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _117 => _117.at, 'call', _118 => _118(-1), 'optionalAccess', _119 => _119.id]))), () => ( null))
|
3075
|
+
);
|
3076
|
+
this.messages = this.repository.getMessages();
|
3077
|
+
this.isDisabled = isDisabled;
|
3078
|
+
this.isRunning = isRunning;
|
3079
|
+
for (const callback of this._subscriptions) callback();
|
3080
|
+
}
|
3045
3081
|
getBranches(messageId) {
|
3046
3082
|
return this.repository.getBranches(messageId);
|
3047
3083
|
}
|
3048
3084
|
switchToBranch(branchId) {
|
3049
|
-
if (!this.
|
3085
|
+
if (!this._store.setMessages)
|
3050
3086
|
throw new Error("Runtime does not support switching branches.");
|
3051
3087
|
this.repository.switchToBranch(branchId);
|
3052
3088
|
this.updateMessages(this.repository.getMessages());
|
3053
3089
|
}
|
3054
3090
|
async append(message) {
|
3055
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
3056
|
-
if (!this.
|
3091
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _120 => _120.messages, 'access', _121 => _121.at, 'call', _122 => _122(-1), 'optionalAccess', _123 => _123.id]), () => ( null)))) {
|
3092
|
+
if (!this._store.onEdit)
|
3057
3093
|
throw new Error("Runtime does not support editing messages.");
|
3058
|
-
await this.
|
3094
|
+
await this._store.onEdit(message);
|
3059
3095
|
} else {
|
3060
|
-
await this.
|
3096
|
+
await this._store.onNew(message);
|
3061
3097
|
}
|
3062
3098
|
}
|
3063
3099
|
async startRun(parentId) {
|
3064
|
-
if (!this.
|
3100
|
+
if (!this._store.onReload)
|
3065
3101
|
throw new Error("Runtime does not support reloading messages.");
|
3066
|
-
await this.
|
3102
|
+
await this._store.onReload(parentId);
|
3067
3103
|
}
|
3068
3104
|
cancelRun() {
|
3069
|
-
if (!this.
|
3105
|
+
if (!this._store.onCancel)
|
3070
3106
|
throw new Error("Runtime does not support cancelling runs.");
|
3071
|
-
this.
|
3107
|
+
this._store.onCancel();
|
3072
3108
|
if (this.assistantOptimisticId) {
|
3073
3109
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
3074
3110
|
this.assistantOptimisticId = null;
|
@@ -3082,67 +3118,27 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
3082
3118
|
this._subscriptions.add(callback);
|
3083
3119
|
return () => this._subscriptions.delete(callback);
|
3084
3120
|
}
|
3085
|
-
|
3086
|
-
_optionalChain([this, 'access',
|
3121
|
+
__init24() {this.updateMessages = (messages) => {
|
3122
|
+
_optionalChain([this, 'access', _124 => _124._store, 'access', _125 => _125.setMessages, 'optionalCall', _126 => _126(
|
3087
3123
|
messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
3088
3124
|
)]);
|
3089
3125
|
}}
|
3090
|
-
onStoreUpdated() {
|
3091
|
-
if (this.useStore.getState().store !== this.store) {
|
3092
|
-
this.useStore.setState({ store: this.store });
|
3093
|
-
}
|
3094
|
-
}
|
3095
|
-
__init24() {this.updateData = (isDisabled, isRunning, vm) => {
|
3096
|
-
for (let i = 0; i < vm.length; i++) {
|
3097
|
-
const message = vm[i];
|
3098
|
-
const parent = vm[i - 1];
|
3099
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _117 => _117.id]), () => ( null)), message);
|
3100
|
-
}
|
3101
|
-
if (this.assistantOptimisticId) {
|
3102
|
-
this.repository.deleteMessage(this.assistantOptimisticId);
|
3103
|
-
this.assistantOptimisticId = null;
|
3104
|
-
}
|
3105
|
-
if (hasUpcomingMessage(isRunning, vm)) {
|
3106
|
-
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
3107
|
-
_nullishCoalesce(_optionalChain([vm, 'access', _118 => _118.at, 'call', _119 => _119(-1), 'optionalAccess', _120 => _120.id]), () => ( null)),
|
3108
|
-
{
|
3109
|
-
role: "assistant",
|
3110
|
-
content: []
|
3111
|
-
}
|
3112
|
-
);
|
3113
|
-
}
|
3114
|
-
this.repository.resetHead(
|
3115
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([vm, 'access', _121 => _121.at, 'call', _122 => _122(-1), 'optionalAccess', _123 => _123.id]))), () => ( null))
|
3116
|
-
);
|
3117
|
-
this.messages = this.repository.getMessages();
|
3118
|
-
this.isDisabled = isDisabled;
|
3119
|
-
this.isRunning = isRunning;
|
3120
|
-
for (const callback of this._subscriptions) callback();
|
3121
|
-
}}
|
3122
|
-
__init25() {this.unstable_synchronizer = () => {
|
3123
|
-
const { store } = this.useStore();
|
3124
|
-
useExternalStoreSync(store, this.updateData);
|
3125
|
-
return null;
|
3126
|
-
}}
|
3127
3126
|
addToolResult(options) {
|
3128
|
-
if (!this.
|
3127
|
+
if (!this._store.onAddToolResult)
|
3129
3128
|
throw new Error("Runtime does not support tool results.");
|
3130
|
-
this.
|
3129
|
+
this._store.onAddToolResult(options);
|
3131
3130
|
}
|
3132
3131
|
}, _class7);
|
3133
3132
|
|
3134
3133
|
// src/runtimes/external-store/ExternalStoreRuntime.tsx
|
3135
3134
|
var ExternalStoreRuntime = (_class8 = class extends BaseAssistantRuntime {
|
3136
|
-
|
3135
|
+
__init25() {this._proxyConfigProvider = new ProxyConfigProvider()}
|
3137
3136
|
constructor(store) {
|
3138
|
-
super(new ExternalStoreThreadRuntime(store));_class8.prototype.
|
3137
|
+
super(new ExternalStoreThreadRuntime(store));_class8.prototype.__init25.call(this);;
|
3139
3138
|
}
|
3140
3139
|
set store(store) {
|
3141
3140
|
this.thread.store = store;
|
3142
3141
|
}
|
3143
|
-
onStoreUpdated() {
|
3144
|
-
return this.thread.onStoreUpdated();
|
3145
|
-
}
|
3146
3142
|
getModelConfig() {
|
3147
3143
|
return this._proxyConfigProvider.getModelConfig();
|
3148
3144
|
}
|
@@ -3169,9 +3165,6 @@ var useExternalStoreRuntime = (store) => {
|
|
3169
3165
|
_react.useInsertionEffect.call(void 0, () => {
|
3170
3166
|
runtime.store = store;
|
3171
3167
|
});
|
3172
|
-
_react.useEffect.call(void 0, () => {
|
3173
|
-
runtime.onStoreUpdated();
|
3174
|
-
});
|
3175
3168
|
return runtime;
|
3176
3169
|
};
|
3177
3170
|
|
@@ -3191,7 +3184,7 @@ var ThreadConfigProvider = ({
|
|
3191
3184
|
}) => {
|
3192
3185
|
const assistant = useAssistantContext({ optional: true });
|
3193
3186
|
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 });
|
3194
|
-
if (!_optionalChain([config, 'optionalAccess',
|
3187
|
+
if (!_optionalChain([config, 'optionalAccess', _127 => _127.runtime])) return configProvider;
|
3195
3188
|
if (assistant) {
|
3196
3189
|
throw new Error(
|
3197
3190
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -3407,7 +3400,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
3407
3400
|
{
|
3408
3401
|
components: {
|
3409
3402
|
...componentsProp,
|
3410
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
3403
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _128 => _128.Text]), () => ( components.Text)), () => ( content_part_default.Text))
|
3411
3404
|
}
|
3412
3405
|
}
|
3413
3406
|
) });
|
@@ -3582,7 +3575,7 @@ var ThreadWelcomeSuggestion = ({
|
|
3582
3575
|
};
|
3583
3576
|
var ThreadWelcomeSuggestions = () => {
|
3584
3577
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
3585
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess',
|
3578
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _129 => _129.map, 'call', _130 => _130((suggestion, idx) => {
|
3586
3579
|
const key = `${suggestion.prompt}-${idx}`;
|
3587
3580
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
3588
3581
|
})]) });
|
@@ -3660,7 +3653,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
|
|
3660
3653
|
{
|
3661
3654
|
components: {
|
3662
3655
|
...components,
|
3663
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3656
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _131 => _131.Text]), () => ( content_part_default.Text))
|
3664
3657
|
}
|
3665
3658
|
}
|
3666
3659
|
) });
|
@@ -3762,10 +3755,10 @@ var ThreadMessages = ({ components, ...rest }) => {
|
|
3762
3755
|
thread_exports.Messages,
|
3763
3756
|
{
|
3764
3757
|
components: {
|
3765
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3766
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3767
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3768
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3758
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _132 => _132.UserMessage]), () => ( user_message_default)),
|
3759
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _133 => _133.EditComposer]), () => ( edit_composer_default)),
|
3760
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _134 => _134.AssistantMessage]), () => ( assistant_message_default)),
|
3761
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _135 => _135.SystemMessage]), () => ( SystemMessage))
|
3769
3762
|
},
|
3770
3763
|
...rest
|
3771
3764
|
}
|