@assistant-ui/react 0.5.52 → 0.5.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ZQNZLTZL.mjs → chunk-33TPUWEZ.mjs} +4 -3
- package/dist/{chunk-ZQNZLTZL.mjs.map → chunk-33TPUWEZ.mjs.map} +1 -1
- package/dist/{chunk-4LR4BB23.js → chunk-CWAZOKEW.js} +4 -3
- package/dist/{chunk-4LR4BB23.js.map → chunk-CWAZOKEW.js.map} +1 -1
- package/dist/edge.js +3 -2
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +3 -2
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +977 -76
- package/dist/index.d.ts +977 -76
- package/dist/index.js +608 -483
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +608 -483
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +3 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
var
|
13
|
+
var _chunkCWAZOKEWjs = require('./chunk-CWAZOKEW.js');
|
14
14
|
|
15
15
|
|
16
16
|
var _chunkDCHYNTHIjs = require('./chunk-DCHYNTHI.js');
|
@@ -23,56 +23,76 @@ var _react = require('react');
|
|
23
23
|
|
24
24
|
// src/context/react/AssistantContext.ts
|
25
25
|
|
26
|
-
var AssistantContext = _react.createContext.call(void 0,
|
27
|
-
null
|
28
|
-
);
|
29
|
-
function useAssistantContext(options) {
|
30
|
-
const context = _react.useContext.call(void 0, AssistantContext);
|
31
|
-
if (!_optionalChain([options, 'optionalAccess', _2 => _2.optional]) && !context)
|
32
|
-
throw new Error(
|
33
|
-
"This component must be used within an AssistantRuntimeProvider."
|
34
|
-
);
|
35
|
-
return context;
|
36
|
-
}
|
37
26
|
|
38
|
-
// src/context/
|
39
|
-
var _zustand = require('zustand');
|
27
|
+
// src/context/react/utils/createContextHook.ts
|
40
28
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
this._providers.add(provider);
|
49
|
-
return () => {
|
50
|
-
this._providers.delete(provider);
|
51
|
-
};
|
29
|
+
function createContextHook(context, providerName) {
|
30
|
+
function useContextHook(options) {
|
31
|
+
const contextValue = _react.useContext.call(void 0, context);
|
32
|
+
if (!_optionalChain([options, 'optionalAccess', _2 => _2.optional]) && !contextValue) {
|
33
|
+
throw new Error(`This component must be used within ${providerName}.`);
|
34
|
+
}
|
35
|
+
return contextValue;
|
52
36
|
}
|
53
|
-
|
37
|
+
return useContextHook;
|
38
|
+
}
|
54
39
|
|
55
|
-
// src/context/
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
return
|
40
|
+
// src/context/react/utils/createContextStoreHook.ts
|
41
|
+
function createContextStoreHook(contextHook, contextKey) {
|
42
|
+
function useStoreStoreHook(options) {
|
43
|
+
const context = contextHook(options);
|
44
|
+
if (!context) {
|
45
|
+
if (!_optionalChain([options, 'optionalAccess', _3 => _3.optional])) {
|
46
|
+
throw new Error(`This component must be used within a ${contextKey}.`);
|
47
|
+
}
|
48
|
+
return null;
|
64
49
|
}
|
65
|
-
|
66
|
-
}
|
50
|
+
return context[contextKey];
|
51
|
+
}
|
52
|
+
function useStoreHook(param) {
|
53
|
+
let optional = false;
|
54
|
+
let selector;
|
55
|
+
if (typeof param === "function") {
|
56
|
+
selector = param;
|
57
|
+
} else if (param && typeof param === "object") {
|
58
|
+
optional = !!param.optional;
|
59
|
+
selector = param.selector;
|
60
|
+
}
|
61
|
+
const store = useStoreStoreHook({
|
62
|
+
optional
|
63
|
+
});
|
64
|
+
if (!store) return null;
|
65
|
+
return selector ? store(selector) : store();
|
66
|
+
}
|
67
|
+
return {
|
68
|
+
[contextKey]: useStoreHook,
|
69
|
+
[`${contextKey}Store`]: useStoreStoreHook
|
70
|
+
};
|
71
|
+
}
|
67
72
|
|
68
|
-
// src/context/
|
73
|
+
// src/context/react/AssistantContext.ts
|
74
|
+
var AssistantContext = _react.createContext.call(void 0,
|
75
|
+
null
|
76
|
+
);
|
77
|
+
var useAssistantContext = createContextHook(
|
78
|
+
AssistantContext,
|
79
|
+
"AssistantRuntimeProvider"
|
80
|
+
);
|
81
|
+
var { useAssistantRuntime, useAssistantRuntimeStore } = createContextStoreHook(useAssistantContext, "useAssistantRuntime");
|
82
|
+
var { useToolUIs, useToolUIsStore } = createContextStoreHook(
|
83
|
+
useAssistantContext,
|
84
|
+
"useToolUIs"
|
85
|
+
);
|
86
|
+
var { useAssistantActions, useAssistantActionsStore } = createContextStoreHook(useAssistantContext, "useAssistantActions");
|
69
87
|
|
88
|
+
// src/context/stores/AssistantToolUIs.ts
|
89
|
+
var _zustand = require('zustand');
|
70
90
|
var makeAssistantToolUIsStore = () => _zustand.create.call(void 0, (set) => {
|
71
91
|
const renderers = /* @__PURE__ */ new Map();
|
72
92
|
return Object.freeze({
|
73
93
|
getToolUI: (name) => {
|
74
94
|
const arr = renderers.get(name);
|
75
|
-
const last = _optionalChain([arr, 'optionalAccess',
|
95
|
+
const last = _optionalChain([arr, 'optionalAccess', _4 => _4.at, 'call', _5 => _5(-1)]);
|
76
96
|
if (last) return last;
|
77
97
|
return null;
|
78
98
|
},
|
@@ -103,22 +123,34 @@ var makeAssistantToolUIsStore = () => _zustand.create.call(void 0, (set) => {
|
|
103
123
|
// src/context/react/ThreadContext.ts
|
104
124
|
|
105
125
|
var ThreadContext = _react.createContext.call(void 0, null);
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
var
|
126
|
+
var useThreadContext = createContextHook(
|
127
|
+
ThreadContext,
|
128
|
+
"AssistantRuntimeProvider"
|
129
|
+
);
|
130
|
+
var { useThreadRuntime, useThreadRuntimeStore } = createContextStoreHook(useThreadContext, "useThreadRuntime");
|
131
|
+
var { useThread, useThreadStore } = createContextStoreHook(
|
132
|
+
useThreadContext,
|
133
|
+
"useThread"
|
134
|
+
);
|
135
|
+
var { useThreadMessages, useThreadMessagesStore } = createContextStoreHook(useThreadContext, "useThreadMessages");
|
136
|
+
var { useThreadActions, useThreadActionsStore } = createContextStoreHook(useThreadContext, "useThreadActions");
|
137
|
+
var {
|
138
|
+
useComposer: useThreadComposer,
|
139
|
+
useComposerStore: useThreadComposerStore
|
140
|
+
} = createContextStoreHook(useThreadContext, "useComposer");
|
141
|
+
var {
|
142
|
+
useViewport: useThreadViewport,
|
143
|
+
useViewportStore: useThreadViewportStore
|
144
|
+
} = createContextStoreHook(useThreadContext, "useViewport");
|
145
|
+
|
146
|
+
// src/context/stores/ThreadComposer.ts
|
147
|
+
|
148
|
+
var makeThreadComposerStore = (useThreadRuntime2) => {
|
118
149
|
const focusListeners = /* @__PURE__ */ new Set();
|
119
150
|
return _zustand.create.call(void 0, )((_, get) => {
|
120
|
-
const runtime =
|
151
|
+
const runtime = useThreadRuntime2.getState();
|
121
152
|
return {
|
153
|
+
type: "thread",
|
122
154
|
get value() {
|
123
155
|
return get().text;
|
124
156
|
},
|
@@ -127,27 +159,27 @@ var makeComposerStore = (useThreadRuntime) => {
|
|
127
159
|
},
|
128
160
|
attachments: runtime.composer.attachments,
|
129
161
|
addAttachment: (file) => {
|
130
|
-
|
162
|
+
useThreadRuntime2.getState().composer.addAttachment(file);
|
131
163
|
},
|
132
164
|
removeAttachment: (attachmentId) => {
|
133
|
-
|
165
|
+
useThreadRuntime2.getState().composer.removeAttachment(attachmentId);
|
134
166
|
},
|
135
167
|
reset: () => {
|
136
|
-
|
168
|
+
useThreadRuntime2.getState().composer.reset();
|
137
169
|
},
|
138
170
|
text: runtime.composer.text,
|
139
171
|
setText: (text) => {
|
140
|
-
|
172
|
+
useThreadRuntime2.getState().composer.setText(text);
|
141
173
|
},
|
142
174
|
canCancel: runtime.capabilities.cancel,
|
143
175
|
isEditing: true,
|
144
176
|
isEmpty: runtime.composer.isEmpty,
|
145
177
|
send: () => {
|
146
|
-
const runtime2 =
|
178
|
+
const runtime2 = useThreadRuntime2.getState();
|
147
179
|
runtime2.composer.send();
|
148
180
|
},
|
149
181
|
cancel: () => {
|
150
|
-
|
182
|
+
useThreadRuntime2.getState().cancelRun();
|
151
183
|
},
|
152
184
|
focus: () => {
|
153
185
|
for (const listener of focusListeners) {
|
@@ -252,8 +284,8 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
252
284
|
|
253
285
|
|
254
286
|
// src/runtimes/core/BaseAssistantRuntime.tsx
|
255
|
-
var BaseAssistantRuntime = (
|
256
|
-
constructor(_thread) {;
|
287
|
+
var BaseAssistantRuntime = (_class = class {
|
288
|
+
constructor(_thread) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
257
289
|
this._thread = _thread;
|
258
290
|
this._thread = _thread;
|
259
291
|
}
|
@@ -264,15 +296,15 @@ var BaseAssistantRuntime = (_class2 = class {
|
|
264
296
|
this._thread = thread;
|
265
297
|
this.subscriptionHandler();
|
266
298
|
}
|
267
|
-
|
299
|
+
__init() {this._subscriptions = /* @__PURE__ */ new Set()}
|
268
300
|
subscribe(callback) {
|
269
301
|
this._subscriptions.add(callback);
|
270
302
|
return () => this._subscriptions.delete(callback);
|
271
303
|
}
|
272
|
-
|
304
|
+
__init2() {this.subscriptionHandler = () => {
|
273
305
|
for (const callback of this._subscriptions) callback();
|
274
306
|
}}
|
275
|
-
},
|
307
|
+
}, _class);
|
276
308
|
|
277
309
|
// src/internal.ts
|
278
310
|
var internal_exports = {};
|
@@ -289,13 +321,13 @@ _chunkDCHYNTHIjs.__export.call(void 0, internal_exports, {
|
|
289
321
|
});
|
290
322
|
|
291
323
|
// src/runtimes/utils/ThreadRuntimeComposer.tsx
|
292
|
-
var ThreadRuntimeComposer = (
|
293
|
-
constructor(runtime, notifySubscribers) {;
|
324
|
+
var ThreadRuntimeComposer = (_class2 = class {
|
325
|
+
constructor(runtime, notifySubscribers) {;_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
|
294
326
|
this.runtime = runtime;
|
295
327
|
this.notifySubscribers = notifySubscribers;
|
296
328
|
}
|
297
329
|
|
298
|
-
|
330
|
+
__init3() {this.attachmentAccept = "*"}
|
299
331
|
get isEmpty() {
|
300
332
|
return !this.text.trim() && !this.attachments.length;
|
301
333
|
}
|
@@ -308,7 +340,7 @@ var ThreadRuntimeComposer = (_class3 = class {
|
|
308
340
|
}
|
309
341
|
return false;
|
310
342
|
}
|
311
|
-
|
343
|
+
__init4() {this._attachments = []}
|
312
344
|
get attachments() {
|
313
345
|
return this._attachments;
|
314
346
|
}
|
@@ -329,7 +361,7 @@ var ThreadRuntimeComposer = (_class3 = class {
|
|
329
361
|
this._attachments = this._attachments.toSpliced(index, 1);
|
330
362
|
this.notifySubscribers();
|
331
363
|
}
|
332
|
-
|
364
|
+
__init5() {this._text = ""}
|
333
365
|
get text() {
|
334
366
|
return this._text;
|
335
367
|
}
|
@@ -356,6 +388,20 @@ var ThreadRuntimeComposer = (_class3 = class {
|
|
356
388
|
});
|
357
389
|
this.reset();
|
358
390
|
}
|
391
|
+
}, _class2);
|
392
|
+
|
393
|
+
// src/utils/ProxyConfigProvider.ts
|
394
|
+
var ProxyConfigProvider = (_class3 = class {constructor() { _class3.prototype.__init6.call(this); }
|
395
|
+
__init6() {this._providers = /* @__PURE__ */ new Set()}
|
396
|
+
getModelConfig() {
|
397
|
+
return _chunkCWAZOKEWjs.mergeModelConfigs.call(void 0, this._providers);
|
398
|
+
}
|
399
|
+
registerModelConfigProvider(provider) {
|
400
|
+
this._providers.add(provider);
|
401
|
+
return () => {
|
402
|
+
this._providers.delete(provider);
|
403
|
+
};
|
404
|
+
}
|
359
405
|
}, _class3);
|
360
406
|
|
361
407
|
// src/utils/idUtils.tsx
|
@@ -373,7 +419,8 @@ var fromCoreMessages = (message) => {
|
|
373
419
|
};
|
374
420
|
var fromCoreMessage = (message, {
|
375
421
|
id = generateId(),
|
376
|
-
status = { type: "complete", reason: "unknown" }
|
422
|
+
status = { type: "complete", reason: "unknown" },
|
423
|
+
attachments = []
|
377
424
|
} = {}) => {
|
378
425
|
const commonProps = {
|
379
426
|
id,
|
@@ -401,7 +448,7 @@ var fromCoreMessage = (message, {
|
|
401
448
|
...commonProps,
|
402
449
|
role,
|
403
450
|
content: message.content,
|
404
|
-
attachments
|
451
|
+
attachments
|
405
452
|
};
|
406
453
|
case "system":
|
407
454
|
return {
|
@@ -608,6 +655,7 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
608
655
|
|
609
656
|
// src/utils/smooth/useSmooth.tsx
|
610
657
|
|
658
|
+
var _reactusecallbackref = require('@radix-ui/react-use-callback-ref');
|
611
659
|
|
612
660
|
// src/utils/smooth/SmoothContext.tsx
|
613
661
|
|
@@ -617,6 +665,22 @@ var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__in
|
|
617
665
|
|
618
666
|
|
619
667
|
|
668
|
+
|
669
|
+
// src/context/react/ContentPartContext.ts
|
670
|
+
|
671
|
+
var ContentPartContext = _react.createContext.call(void 0,
|
672
|
+
null
|
673
|
+
);
|
674
|
+
var useContentPartContext = createContextHook(
|
675
|
+
ContentPartContext,
|
676
|
+
"a component passed to <MessagePrimitive.Content components={...}>"
|
677
|
+
);
|
678
|
+
var { useContentPart, useContentPartStore } = createContextStoreHook(
|
679
|
+
useContentPartContext,
|
680
|
+
"useContentPart"
|
681
|
+
);
|
682
|
+
|
683
|
+
// src/utils/smooth/SmoothContext.tsx
|
620
684
|
var _jsxruntime = require('react/jsx-runtime');
|
621
685
|
var SmoothContext = _react.createContext.call(void 0, null);
|
622
686
|
var makeSmoothContext = (initialState) => {
|
@@ -625,9 +689,9 @@ var makeSmoothContext = (initialState) => {
|
|
625
689
|
};
|
626
690
|
var SmoothContextProvider = ({ children }) => {
|
627
691
|
const outer = useSmoothContext({ optional: true });
|
628
|
-
const
|
692
|
+
const contentPartStore = useContentPartStore();
|
629
693
|
const [context] = _react.useState.call(void 0,
|
630
|
-
() => makeSmoothContext(
|
694
|
+
() => makeSmoothContext(contentPartStore.getState().status)
|
631
695
|
);
|
632
696
|
if (outer) return children;
|
633
697
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmoothContext.Provider, { value: context, children });
|
@@ -647,13 +711,17 @@ function useSmoothContext(options) {
|
|
647
711
|
);
|
648
712
|
return context;
|
649
713
|
}
|
650
|
-
var useSmoothStatus = (
|
651
|
-
|
652
|
-
|
714
|
+
var { useSmoothStatus, useSmoothStatusStore } = createContextStoreHook(
|
715
|
+
useSmoothContext,
|
716
|
+
"useSmoothStatus"
|
717
|
+
);
|
718
|
+
|
719
|
+
// src/context/ReadonlyStore.ts
|
720
|
+
var writableStore = (store) => {
|
721
|
+
return store;
|
653
722
|
};
|
654
723
|
|
655
724
|
// src/utils/smooth/useSmooth.tsx
|
656
|
-
var _reactusecallbackref = require('@radix-ui/react-use-callback-ref');
|
657
725
|
var TextStreamAnimator = (_class5 = class {
|
658
726
|
constructor(currentText, setText) {;_class5.prototype.__init10.call(this);_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);
|
659
727
|
this.currentText = currentText;
|
@@ -702,21 +770,28 @@ var SMOOTH_STATUS = Object.freeze({
|
|
702
770
|
type: "running"
|
703
771
|
});
|
704
772
|
var useSmooth = (state, smooth = false) => {
|
705
|
-
const { useSmoothStatus: useSmoothStatus2 } = _nullishCoalesce(useSmoothContext({ optional: true }), () => ( {}));
|
706
773
|
const {
|
707
774
|
part: { text }
|
708
775
|
} = state;
|
709
|
-
const { useMessage } = useMessageContext();
|
710
776
|
const id = useMessage((m) => m.message.id);
|
711
777
|
const idRef = _react.useRef.call(void 0, id);
|
712
778
|
const [displayedText, setDisplayedText] = _react.useState.call(void 0, text);
|
779
|
+
const smoothStatusStore = useSmoothStatusStore({ optional: true });
|
713
780
|
const setText = _reactusecallbackref.useCallbackRef.call(void 0, (text2) => {
|
714
781
|
setDisplayedText(text2);
|
715
|
-
|
782
|
+
if (smoothStatusStore) {
|
783
|
+
writableStore(smoothStatusStore).setState(
|
784
|
+
text2 !== state.part.text ? SMOOTH_STATUS : state.status
|
785
|
+
);
|
786
|
+
}
|
716
787
|
});
|
717
788
|
_react.useEffect.call(void 0, () => {
|
718
|
-
|
719
|
-
|
789
|
+
if (smoothStatusStore) {
|
790
|
+
writableStore(smoothStatusStore).setState(
|
791
|
+
text !== state.part.text ? SMOOTH_STATUS : state.status
|
792
|
+
);
|
793
|
+
}
|
794
|
+
}, [smoothStatusStore, text, displayedText, state.status, state.part.text]);
|
720
795
|
const [animatorRef] = _react.useState.call(void 0,
|
721
796
|
new TextStreamAnimator(text, setText)
|
722
797
|
);
|
@@ -909,7 +984,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
909
984
|
});
|
910
985
|
if (mergeRoundtrips) {
|
911
986
|
const previousMessage = messages[messages.length - 1];
|
912
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
987
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _31 => _31.role]) === "assistant") {
|
913
988
|
previousMessage.content.push(...newContent);
|
914
989
|
break;
|
915
990
|
}
|
@@ -922,7 +997,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
922
997
|
}
|
923
998
|
case "tool": {
|
924
999
|
const previousMessage = messages[messages.length - 1];
|
925
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
1000
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _32 => _32.role]) !== "assistant")
|
926
1001
|
throw new Error(
|
927
1002
|
"A tool message must be preceded by an assistant message."
|
928
1003
|
);
|
@@ -998,14 +1073,14 @@ function streamPartDecoderStream() {
|
|
998
1073
|
controller.enqueue(decodeStreamPart(chunk));
|
999
1074
|
}
|
1000
1075
|
});
|
1001
|
-
return new (0,
|
1076
|
+
return new (0, _chunkCWAZOKEWjs.PipeableTransformStream)((readable) => {
|
1002
1077
|
return readable.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(decodeStream);
|
1003
1078
|
});
|
1004
1079
|
}
|
1005
1080
|
|
1006
1081
|
// src/runtimes/edge/streams/utils/index.ts
|
1007
1082
|
var streamUtils = {
|
1008
|
-
streamPartEncoderStream:
|
1083
|
+
streamPartEncoderStream: _chunkCWAZOKEWjs.streamPartEncoderStream,
|
1009
1084
|
streamPartDecoderStream
|
1010
1085
|
};
|
1011
1086
|
|
@@ -1114,8 +1189,8 @@ var EdgeChatAdapter = class {
|
|
1114
1189
|
credentials: _nullishCoalesce(this.options.credentials, () => ( "same-origin")),
|
1115
1190
|
body: JSON.stringify({
|
1116
1191
|
system: config.system,
|
1117
|
-
messages:
|
1118
|
-
tools: config.tools ?
|
1192
|
+
messages: _chunkCWAZOKEWjs.toCoreMessages.call(void 0, messages),
|
1193
|
+
tools: config.tools ? _chunkCWAZOKEWjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
1119
1194
|
...config.callSettings,
|
1120
1195
|
...config.config,
|
1121
1196
|
...this.options.body
|
@@ -1125,7 +1200,7 @@ var EdgeChatAdapter = class {
|
|
1125
1200
|
if (result.status !== 200) {
|
1126
1201
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
1127
1202
|
}
|
1128
|
-
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(
|
1203
|
+
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkCWAZOKEWjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkCWAZOKEWjs.runResultStream.call(void 0, ));
|
1129
1204
|
let update;
|
1130
1205
|
for await (update of asAsyncIterable(stream)) {
|
1131
1206
|
yield update;
|
@@ -1151,7 +1226,7 @@ var useEdgeRuntime = ({
|
|
1151
1226
|
};
|
1152
1227
|
|
1153
1228
|
// src/runtimes/local/shouldContinue.tsx
|
1154
|
-
var shouldContinue = (result) => _optionalChain([result, 'access',
|
1229
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _33 => _33.status, 'optionalAccess', _34 => _34.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
1155
1230
|
|
1156
1231
|
// src/runtimes/local/LocalThreadRuntime.tsx
|
1157
1232
|
var LocalThreadRuntime = (_class6 = class {
|
@@ -1197,13 +1272,13 @@ var LocalThreadRuntime = (_class6 = class {
|
|
1197
1272
|
set options({ initialMessages, ...options }) {
|
1198
1273
|
this._options = options;
|
1199
1274
|
let hasUpdates = false;
|
1200
|
-
const canSpeak = _optionalChain([options, 'access',
|
1275
|
+
const canSpeak = _optionalChain([options, 'access', _35 => _35.adapters, 'optionalAccess', _36 => _36.speech]) !== void 0;
|
1201
1276
|
if (this.capabilities.speak !== canSpeak) {
|
1202
1277
|
this.capabilities.speak = canSpeak;
|
1203
1278
|
hasUpdates = true;
|
1204
1279
|
}
|
1205
|
-
this.composer.setAttachmentAdapter(_optionalChain([options, 'access',
|
1206
|
-
const canAttach = _optionalChain([options, 'access',
|
1280
|
+
this.composer.setAttachmentAdapter(_optionalChain([options, 'access', _37 => _37.adapters, 'optionalAccess', _38 => _38.attachments]));
|
1281
|
+
const canAttach = _optionalChain([options, 'access', _39 => _39.adapters, 'optionalAccess', _40 => _40.attachments]) !== void 0;
|
1207
1282
|
if (this.capabilities.attachments !== canAttach) {
|
1208
1283
|
this.capabilities.attachments = canAttach;
|
1209
1284
|
hasUpdates = true;
|
@@ -1218,20 +1293,16 @@ var LocalThreadRuntime = (_class6 = class {
|
|
1218
1293
|
this.notifySubscribers();
|
1219
1294
|
}
|
1220
1295
|
async append(message) {
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
createdAt: /* @__PURE__ */ new Date()
|
1232
|
-
};
|
1233
|
-
this.repository.addOrUpdateMessage(message.parentId, userMessage);
|
1234
|
-
await this.startRun(userMessageId);
|
1296
|
+
const newMessage = fromCoreMessage(message, {
|
1297
|
+
attachments: message.attachments
|
1298
|
+
});
|
1299
|
+
this.repository.addOrUpdateMessage(message.parentId, newMessage);
|
1300
|
+
if (message.role === "user") {
|
1301
|
+
await this.startRun(newMessage.id);
|
1302
|
+
} else {
|
1303
|
+
this.repository.resetHead(newMessage.id);
|
1304
|
+
this.notifySubscribers();
|
1305
|
+
}
|
1235
1306
|
}
|
1236
1307
|
async startRun(parentId) {
|
1237
1308
|
this.repository.resetHead(parentId);
|
@@ -1249,18 +1320,18 @@ var LocalThreadRuntime = (_class6 = class {
|
|
1249
1320
|
}
|
1250
1321
|
async performRoundtrip(parentId, message) {
|
1251
1322
|
const messages = this.repository.getMessages();
|
1252
|
-
_optionalChain([this, 'access',
|
1323
|
+
_optionalChain([this, 'access', _41 => _41.abortController, 'optionalAccess', _42 => _42.abort, 'call', _43 => _43()]);
|
1253
1324
|
this.abortController = new AbortController();
|
1254
1325
|
const initialContent = message.content;
|
1255
|
-
const initialRoundtrips = _optionalChain([message, 'access',
|
1256
|
-
const initalCustom = _optionalChain([message, 'access',
|
1326
|
+
const initialRoundtrips = _optionalChain([message, 'access', _44 => _44.metadata, 'optionalAccess', _45 => _45.roundtrips]);
|
1327
|
+
const initalCustom = _optionalChain([message, 'access', _46 => _46.metadata, 'optionalAccess', _47 => _47.custom]);
|
1257
1328
|
const updateMessage = (m) => {
|
1258
1329
|
message = {
|
1259
1330
|
...message,
|
1260
1331
|
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
1261
1332
|
status: _nullishCoalesce(m.status, () => ( message.status)),
|
1262
1333
|
// TODO deprecated, remove in v0.6
|
1263
|
-
..._optionalChain([m, 'access',
|
1334
|
+
..._optionalChain([m, 'access', _48 => _48.metadata, 'optionalAccess', _49 => _49.roundtrips]) ? {
|
1264
1335
|
roundtrips: [
|
1265
1336
|
..._nullishCoalesce(initialRoundtrips, () => ( [])),
|
1266
1337
|
...m.metadata.roundtrips
|
@@ -1275,7 +1346,7 @@ var LocalThreadRuntime = (_class6 = class {
|
|
1275
1346
|
...m.metadata.roundtrips
|
1276
1347
|
]
|
1277
1348
|
} : void 0,
|
1278
|
-
..._optionalChain([m, 'access',
|
1349
|
+
..._optionalChain([m, 'access', _50 => _50.metadata, 'optionalAccess', _51 => _51.custom]) ? {
|
1279
1350
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
1280
1351
|
} : void 0
|
1281
1352
|
}
|
@@ -1285,7 +1356,7 @@ var LocalThreadRuntime = (_class6 = class {
|
|
1285
1356
|
this.notifySubscribers();
|
1286
1357
|
};
|
1287
1358
|
const maxToolRoundtrips = _nullishCoalesce(this.options.maxToolRoundtrips, () => ( 1));
|
1288
|
-
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access',
|
1359
|
+
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _52 => _52.metadata, 'optionalAccess', _53 => _53.roundtrips, 'optionalAccess', _54 => _54.length]), () => ( 0));
|
1289
1360
|
if (toolRoundtrips > maxToolRoundtrips) {
|
1290
1361
|
updateMessage({
|
1291
1362
|
status: {
|
@@ -1353,7 +1424,9 @@ var LocalThreadRuntime = (_class6 = class {
|
|
1353
1424
|
toolCallId,
|
1354
1425
|
result
|
1355
1426
|
}) {
|
1356
|
-
|
1427
|
+
const messageData = this.repository.getMessage(messageId);
|
1428
|
+
const { parentId } = messageData;
|
1429
|
+
let { message } = messageData;
|
1357
1430
|
if (message.role !== "assistant")
|
1358
1431
|
throw new Error("Tried to add tool result to non-assistant message");
|
1359
1432
|
let added = false;
|
@@ -1382,7 +1455,7 @@ var LocalThreadRuntime = (_class6 = class {
|
|
1382
1455
|
// TODO lift utterance state to thread runtime
|
1383
1456
|
|
1384
1457
|
speak(messageId) {
|
1385
|
-
const adapter = _optionalChain([this, 'access',
|
1458
|
+
const adapter = _optionalChain([this, 'access', _55 => _55.options, 'access', _56 => _56.adapters, 'optionalAccess', _57 => _57.speech]);
|
1386
1459
|
if (!adapter) throw new Error("Speech adapter not configured");
|
1387
1460
|
const { message } = this.repository.getMessage(messageId);
|
1388
1461
|
if (this._utterance) {
|
@@ -1424,10 +1497,7 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
1424
1497
|
registerModelConfigProvider(provider) {
|
1425
1498
|
return this._proxyConfigProvider.registerModelConfigProvider(provider);
|
1426
1499
|
}
|
1427
|
-
|
1428
|
-
if (threadId) {
|
1429
|
-
throw new Error("LocalRuntime does not yet support switching threads");
|
1430
|
-
}
|
1500
|
+
switchToNewThread() {
|
1431
1501
|
const { initialMessages, ...options } = this.thread.options;
|
1432
1502
|
return this.thread = new LocalThreadRuntime(
|
1433
1503
|
this._proxyConfigProvider,
|
@@ -1435,6 +1505,12 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
1435
1505
|
options
|
1436
1506
|
);
|
1437
1507
|
}
|
1508
|
+
switchToThread(threadId) {
|
1509
|
+
if (threadId !== null) {
|
1510
|
+
throw new Error("LocalRuntime does not yet support switching threads");
|
1511
|
+
}
|
1512
|
+
this.switchToNewThread();
|
1513
|
+
}
|
1438
1514
|
reset({
|
1439
1515
|
initialMessages
|
1440
1516
|
} = {}) {
|
@@ -1443,7 +1519,7 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
1443
1519
|
const messages = fromCoreMessages(initialMessages);
|
1444
1520
|
this.thread.import({
|
1445
1521
|
messages: messages.map((m, idx) => ({
|
1446
|
-
parentId: _nullishCoalesce(_optionalChain([messages, 'access',
|
1522
|
+
parentId: _nullishCoalesce(_optionalChain([messages, 'access', _58 => _58[idx - 1], 'optionalAccess', _59 => _59.id]), () => ( null)),
|
1447
1523
|
message: m
|
1448
1524
|
}))
|
1449
1525
|
});
|
@@ -1572,7 +1648,7 @@ var getThreadMessageText = (message) => {
|
|
1572
1648
|
|
1573
1649
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
1574
1650
|
var hasUpcomingMessage = (isRunning, messages) => {
|
1575
|
-
return isRunning && _optionalChain([messages, 'access',
|
1651
|
+
return isRunning && _optionalChain([messages, 'access', _60 => _60[messages.length - 1], 'optionalAccess', _61 => _61.role]) !== "assistant";
|
1576
1652
|
};
|
1577
1653
|
var ExternalStoreThreadRuntime = (_class8 = class {
|
1578
1654
|
__init21() {this._subscriptions = /* @__PURE__ */ new Set()}
|
@@ -1618,11 +1694,11 @@ var ExternalStoreThreadRuntime = (_class8 = class {
|
|
1618
1694
|
reload: this._store.onReload !== void 0,
|
1619
1695
|
cancel: this._store.onCancel !== void 0,
|
1620
1696
|
speak: this._store.onSpeak !== void 0,
|
1621
|
-
unstable_copy: _optionalChain([this, 'access',
|
1697
|
+
unstable_copy: _optionalChain([this, 'access', _65 => _65._store, 'access', _66 => _66.unstable_capabilities, 'optionalAccess', _67 => _67.copy]) !== false,
|
1622
1698
|
// default true
|
1623
|
-
attachments: !!_optionalChain([this, 'access',
|
1699
|
+
attachments: !!_optionalChain([this, 'access', _68 => _68.store, 'access', _69 => _69.adapters, 'optionalAccess', _70 => _70.attachments])
|
1624
1700
|
};
|
1625
|
-
this.composer.setAttachmentAdapter(_optionalChain([this, 'access',
|
1701
|
+
this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _71 => _71._store, 'access', _72 => _72.adapters, 'optionalAccess', _73 => _73.attachments]));
|
1626
1702
|
if (oldStore) {
|
1627
1703
|
if (oldStore.convertMessage !== store.convertMessage) {
|
1628
1704
|
this.converter = new ThreadMessageConverter();
|
@@ -1648,7 +1724,7 @@ var ExternalStoreThreadRuntime = (_class8 = class {
|
|
1648
1724
|
for (let i = 0; i < messages.length; i++) {
|
1649
1725
|
const message = messages[i];
|
1650
1726
|
const parent = messages[i - 1];
|
1651
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
1727
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _74 => _74.id]), () => ( null)), message);
|
1652
1728
|
}
|
1653
1729
|
if (this.assistantOptimisticId) {
|
1654
1730
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -1656,7 +1732,7 @@ var ExternalStoreThreadRuntime = (_class8 = class {
|
|
1656
1732
|
}
|
1657
1733
|
if (hasUpcomingMessage(isRunning, messages)) {
|
1658
1734
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
1659
|
-
_nullishCoalesce(_optionalChain([messages, 'access',
|
1735
|
+
_nullishCoalesce(_optionalChain([messages, 'access', _75 => _75.at, 'call', _76 => _76(-1), 'optionalAccess', _77 => _77.id]), () => ( null)),
|
1660
1736
|
{
|
1661
1737
|
role: "assistant",
|
1662
1738
|
content: []
|
@@ -1664,7 +1740,7 @@ var ExternalStoreThreadRuntime = (_class8 = class {
|
|
1664
1740
|
);
|
1665
1741
|
}
|
1666
1742
|
this.repository.resetHead(
|
1667
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access',
|
1743
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _78 => _78.at, 'call', _79 => _79(-1), 'optionalAccess', _80 => _80.id]))), () => ( null))
|
1668
1744
|
);
|
1669
1745
|
this.messages = this.repository.getMessages();
|
1670
1746
|
this.notifySubscribers();
|
@@ -1682,7 +1758,7 @@ var ExternalStoreThreadRuntime = (_class8 = class {
|
|
1682
1758
|
this.updateMessages(this.repository.getMessages());
|
1683
1759
|
}
|
1684
1760
|
async append(message) {
|
1685
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
1761
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _81 => _81.messages, 'access', _82 => _82.at, 'call', _83 => _83(-1), 'optionalAccess', _84 => _84.id]), () => ( null)))) {
|
1686
1762
|
if (!this._store.onEdit)
|
1687
1763
|
throw new Error("Runtime does not support editing messages.");
|
1688
1764
|
await this._store.onEdit(message);
|
@@ -1705,7 +1781,7 @@ var ExternalStoreThreadRuntime = (_class8 = class {
|
|
1705
1781
|
}
|
1706
1782
|
let messages = this.repository.getMessages();
|
1707
1783
|
const previousMessage = messages[messages.length - 1];
|
1708
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
1784
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _85 => _85.role]) === "user" && previousMessage.id === _optionalChain([messages, 'access', _86 => _86.at, 'call', _87 => _87(-1), 'optionalAccess', _88 => _88.id])) {
|
1709
1785
|
this.repository.deleteMessage(previousMessage.id);
|
1710
1786
|
if (!this.composer.text.trim()) {
|
1711
1787
|
this.composer.setText(getThreadMessageText(previousMessage));
|
@@ -1734,7 +1810,7 @@ var ExternalStoreThreadRuntime = (_class8 = class {
|
|
1734
1810
|
return () => this._subscriptions.delete(callback);
|
1735
1811
|
}
|
1736
1812
|
__init27() {this.updateMessages = (messages) => {
|
1737
|
-
_optionalChain([this, 'access',
|
1813
|
+
_optionalChain([this, 'access', _89 => _89._store, 'access', _90 => _90.setMessages, 'optionalCall', _91 => _91(
|
1738
1814
|
messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
1739
1815
|
)]);
|
1740
1816
|
}}
|
@@ -1758,8 +1834,17 @@ var ExternalStoreRuntime = (_class9 = class extends BaseAssistantRuntime {
|
|
1758
1834
|
registerModelConfigProvider(provider) {
|
1759
1835
|
return this._proxyConfigProvider.registerModelConfigProvider(provider);
|
1760
1836
|
}
|
1837
|
+
async switchToNewThread() {
|
1838
|
+
if (!this.store.onNewThread)
|
1839
|
+
throw new Error("Runtime does not support switching to new threads.");
|
1840
|
+
this.thread = new ExternalStoreThreadRuntime({
|
1841
|
+
messages: [],
|
1842
|
+
onNew: this.store.onNew
|
1843
|
+
});
|
1844
|
+
await this.store.onNewThread();
|
1845
|
+
}
|
1761
1846
|
async switchToThread(threadId) {
|
1762
|
-
if (threadId) {
|
1847
|
+
if (threadId !== null) {
|
1763
1848
|
if (!this.store.onSwitchThread)
|
1764
1849
|
throw new Error("Runtime does not support switching threads.");
|
1765
1850
|
this.thread = new ExternalStoreThreadRuntime({
|
@@ -1768,13 +1853,7 @@ var ExternalStoreRuntime = (_class9 = class extends BaseAssistantRuntime {
|
|
1768
1853
|
});
|
1769
1854
|
this.store.onSwitchThread(threadId);
|
1770
1855
|
} else {
|
1771
|
-
|
1772
|
-
throw new Error("Runtime does not support switching to new threads.");
|
1773
|
-
this.thread = new ExternalStoreThreadRuntime({
|
1774
|
-
messages: [],
|
1775
|
-
onNew: this.store.onNew
|
1776
|
-
});
|
1777
|
-
await this.store.onNewThread();
|
1856
|
+
this.switchToNewThread();
|
1778
1857
|
}
|
1779
1858
|
}
|
1780
1859
|
}, _class9);
|
@@ -1945,18 +2024,18 @@ var DangerousInBrowserAdapter = class {
|
|
1945
2024
|
this.options = options;
|
1946
2025
|
}
|
1947
2026
|
async *run({ messages, abortSignal, config }) {
|
1948
|
-
const res = await
|
2027
|
+
const res = await _chunkCWAZOKEWjs.getEdgeRuntimeStream.call(void 0, {
|
1949
2028
|
options: this.options,
|
1950
2029
|
abortSignal,
|
1951
2030
|
requestData: {
|
1952
2031
|
system: config.system,
|
1953
|
-
messages:
|
1954
|
-
tools: config.tools ?
|
2032
|
+
messages: _chunkCWAZOKEWjs.toCoreMessages.call(void 0, messages),
|
2033
|
+
tools: config.tools ? _chunkCWAZOKEWjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
1955
2034
|
...config.callSettings,
|
1956
2035
|
...config.config
|
1957
2036
|
}
|
1958
2037
|
});
|
1959
|
-
const stream = res.pipeThrough(
|
2038
|
+
const stream = res.pipeThrough(_chunkCWAZOKEWjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunkCWAZOKEWjs.runResultStream.call(void 0, ));
|
1960
2039
|
for await (const update of asAsyncIterable(stream)) {
|
1961
2040
|
yield update;
|
1962
2041
|
}
|
@@ -2149,11 +2228,6 @@ var CompositeAttachmentAdapter = class {
|
|
2149
2228
|
}
|
2150
2229
|
};
|
2151
2230
|
|
2152
|
-
// src/context/ReadonlyStore.ts
|
2153
|
-
var writableStore = (store) => {
|
2154
|
-
return store;
|
2155
|
-
};
|
2156
|
-
|
2157
2231
|
// src/context/providers/ThreadProvider.tsx
|
2158
2232
|
|
2159
2233
|
var ThreadProvider = ({
|
@@ -2161,18 +2235,18 @@ var ThreadProvider = ({
|
|
2161
2235
|
provider
|
2162
2236
|
}) => {
|
2163
2237
|
const [context] = _react.useState.call(void 0, () => {
|
2164
|
-
const
|
2165
|
-
const
|
2166
|
-
const
|
2167
|
-
const
|
2238
|
+
const useThreadRuntime2 = makeThreadRuntimeStore(provider.thread);
|
2239
|
+
const useThread2 = makeThreadStore(useThreadRuntime2);
|
2240
|
+
const useThreadMessages2 = makeThreadMessagesStore(useThreadRuntime2);
|
2241
|
+
const useThreadActions2 = makeThreadActionStore(useThreadRuntime2);
|
2168
2242
|
const useViewport = makeThreadViewportStore();
|
2169
|
-
const
|
2243
|
+
const useComposer2 = makeThreadComposerStore(useThreadRuntime2);
|
2170
2244
|
return {
|
2171
|
-
useThread,
|
2172
|
-
useThreadRuntime,
|
2173
|
-
useThreadMessages,
|
2174
|
-
useThreadActions,
|
2175
|
-
useComposer,
|
2245
|
+
useThread: useThread2,
|
2246
|
+
useThreadRuntime: useThreadRuntime2,
|
2247
|
+
useThreadMessages: useThreadMessages2,
|
2248
|
+
useThreadActions: useThreadActions2,
|
2249
|
+
useComposer: useComposer2,
|
2176
2250
|
useViewport
|
2177
2251
|
};
|
2178
2252
|
});
|
@@ -2224,6 +2298,7 @@ var ThreadProvider = ({
|
|
2224
2298
|
var makeAssistantActionsStore = (runtimeRef) => _zustand.create.call(void 0,
|
2225
2299
|
() => Object.freeze({
|
2226
2300
|
switchToThread: () => runtimeRef.current.switchToThread(null),
|
2301
|
+
registerModelConfigProvider: (provider) => runtimeRef.current.registerModelConfigProvider(provider),
|
2227
2302
|
getRuntime: () => runtimeRef.current
|
2228
2303
|
})
|
2229
2304
|
);
|
@@ -2242,21 +2317,15 @@ var AssistantProvider = ({ children, runtime }) => {
|
|
2242
2317
|
runtimeRef.current = runtime;
|
2243
2318
|
});
|
2244
2319
|
const [context] = _react.useState.call(void 0, () => {
|
2245
|
-
const
|
2246
|
-
const
|
2247
|
-
const
|
2248
|
-
const useAssistantActions = makeAssistantActionsStore(runtimeRef);
|
2320
|
+
const useAssistantRuntime2 = makeAssistantRuntimeStore(runtime);
|
2321
|
+
const useToolUIs2 = makeAssistantToolUIsStore();
|
2322
|
+
const useAssistantActions2 = makeAssistantActionsStore(runtimeRef);
|
2249
2323
|
return {
|
2250
|
-
|
2251
|
-
|
2252
|
-
|
2253
|
-
useAssistantActions
|
2324
|
+
useToolUIs: useToolUIs2,
|
2325
|
+
useAssistantRuntime: useAssistantRuntime2,
|
2326
|
+
useAssistantActions: useAssistantActions2
|
2254
2327
|
};
|
2255
2328
|
});
|
2256
|
-
const getModelConfig = context.useModelConfig();
|
2257
|
-
_react.useEffect.call(void 0, () => {
|
2258
|
-
return runtime.registerModelConfigProvider(getModelConfig);
|
2259
|
-
}, [runtime, getModelConfig]);
|
2260
2329
|
_react.useEffect.call(void 0,
|
2261
2330
|
() => writableStore(context.useAssistantRuntime).setState(runtime, true),
|
2262
2331
|
[runtime, context]
|
@@ -2275,91 +2344,93 @@ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProvider
|
|
2275
2344
|
|
2276
2345
|
|
2277
2346
|
|
2278
|
-
// src/context/react/ContentPartContext.ts
|
2279
|
-
|
2280
|
-
var ContentPartContext = _react.createContext.call(void 0,
|
2281
|
-
null
|
2282
|
-
);
|
2283
|
-
function useContentPartContext(options) {
|
2284
|
-
const context = _react.useContext.call(void 0, ContentPartContext);
|
2285
|
-
if (!_optionalChain([options, 'optionalAccess', _96 => _96.optional]) && !context)
|
2286
|
-
throw new Error(
|
2287
|
-
"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
|
2288
|
-
);
|
2289
|
-
return context;
|
2290
|
-
}
|
2291
|
-
|
2292
|
-
// src/context/providers/TextContentPartProvider.tsx
|
2293
|
-
|
2294
2347
|
var TextContentPartProvider = ({ children, text }) => {
|
2295
2348
|
const [context] = _react.useState.call(void 0, () => {
|
2296
|
-
const
|
2349
|
+
const useContentPart2 = _zustand.create.call(void 0, () => ({
|
2297
2350
|
status: { type: "complete" },
|
2298
2351
|
part: { type: "text", text }
|
2299
2352
|
}));
|
2300
2353
|
return {
|
2301
|
-
useContentPart
|
2354
|
+
useContentPart: useContentPart2
|
2302
2355
|
};
|
2303
2356
|
});
|
2304
2357
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartContext.Provider, { value: context, children });
|
2305
2358
|
};
|
2306
2359
|
|
2307
|
-
// src/context/react/ComposerContext.ts
|
2308
|
-
|
2309
|
-
|
2310
2360
|
// src/context/react/MessageContext.ts
|
2311
2361
|
|
2312
2362
|
var MessageContext = _react.createContext.call(void 0, null);
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2363
|
+
var useMessageContext = createContextHook(
|
2364
|
+
MessageContext,
|
2365
|
+
"a component passed to <ThreadPrimitive.Messages components={...} />"
|
2366
|
+
);
|
2367
|
+
var { useMessage, useMessageStore } = createContextStoreHook(
|
2368
|
+
useMessageContext,
|
2369
|
+
"useMessage"
|
2370
|
+
);
|
2371
|
+
var { useMessageUtils, useMessageUtilsStore } = createContextStoreHook(
|
2372
|
+
useMessageContext,
|
2373
|
+
"useMessageUtils"
|
2374
|
+
);
|
2375
|
+
var { useEditComposer, useEditComposerStore } = createContextStoreHook(
|
2376
|
+
useMessageContext,
|
2377
|
+
"useEditComposer"
|
2378
|
+
);
|
2321
2379
|
|
2322
2380
|
// src/context/react/ComposerContext.ts
|
2381
|
+
|
2323
2382
|
var useComposerContext = () => {
|
2324
|
-
const { useComposer } = useThreadContext();
|
2325
|
-
const { useEditComposer } = _nullishCoalesce(useMessageContext({ optional: true }), () => ( {}));
|
2383
|
+
const { useComposer: useComposer2 } = useThreadContext();
|
2384
|
+
const { useEditComposer: useEditComposer2 } = _nullishCoalesce(useMessageContext({ optional: true }), () => ( {}));
|
2326
2385
|
return _react.useMemo.call(void 0,
|
2327
2386
|
() => ({
|
2328
|
-
useComposer: _nullishCoalesce(
|
2329
|
-
type:
|
2387
|
+
useComposer: _nullishCoalesce(useEditComposer2, () => ( useComposer2)),
|
2388
|
+
type: useEditComposer2 ? "edit" : "new"
|
2330
2389
|
}),
|
2331
|
-
[
|
2390
|
+
[useEditComposer2, useComposer2]
|
2332
2391
|
);
|
2333
2392
|
};
|
2393
|
+
var { useComposer, useComposerStore } = createContextStoreHook(
|
2394
|
+
useComposerContext,
|
2395
|
+
"useComposer"
|
2396
|
+
);
|
2334
2397
|
|
2335
2398
|
// src/hooks/useAppendMessage.tsx
|
2336
2399
|
|
2337
|
-
var toAppendMessage = (
|
2400
|
+
var toAppendMessage = (useThreadMessages2, message) => {
|
2338
2401
|
if (typeof message === "string") {
|
2339
2402
|
return {
|
2340
|
-
parentId: _nullishCoalesce(_optionalChain([
|
2403
|
+
parentId: _nullishCoalesce(_optionalChain([useThreadMessages2, 'access', _92 => _92.getState, 'call', _93 => _93(), 'access', _94 => _94.at, 'call', _95 => _95(-1), 'optionalAccess', _96 => _96.id]), () => ( null)),
|
2341
2404
|
role: "user",
|
2342
2405
|
content: [{ type: "text", text: message }],
|
2343
2406
|
attachments: []
|
2344
2407
|
};
|
2345
2408
|
}
|
2346
2409
|
return {
|
2347
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([
|
2410
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages2, 'access', _97 => _97.getState, 'call', _98 => _98(), 'access', _99 => _99.at, 'call', _100 => _100(-1), 'optionalAccess', _101 => _101.id]))), () => ( null)),
|
2348
2411
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
2349
2412
|
content: message.content,
|
2350
2413
|
attachments: _nullishCoalesce(message.attachments, () => ( []))
|
2351
2414
|
};
|
2352
2415
|
};
|
2353
2416
|
var useAppendMessage = () => {
|
2354
|
-
const
|
2417
|
+
const threadMessagesStore = useThreadMessagesStore();
|
2418
|
+
const threadActionsStore = useThreadActionsStore();
|
2419
|
+
const threadViewportStore = useThreadViewportStore();
|
2420
|
+
const threadComposerStore = useThreadComposerStore();
|
2355
2421
|
const append = _react.useCallback.call(void 0,
|
2356
2422
|
(message) => {
|
2357
|
-
const appendMessage = toAppendMessage(
|
2358
|
-
|
2359
|
-
|
2360
|
-
|
2423
|
+
const appendMessage = toAppendMessage(threadMessagesStore, message);
|
2424
|
+
threadActionsStore.getState().append(appendMessage);
|
2425
|
+
threadViewportStore.getState().scrollToBottom();
|
2426
|
+
threadComposerStore.getState().focus();
|
2361
2427
|
},
|
2362
|
-
[
|
2428
|
+
[
|
2429
|
+
threadMessagesStore,
|
2430
|
+
threadActionsStore,
|
2431
|
+
threadViewportStore,
|
2432
|
+
threadComposerStore
|
2433
|
+
]
|
2363
2434
|
);
|
2364
2435
|
return append;
|
2365
2436
|
};
|
@@ -2367,23 +2438,20 @@ var useAppendMessage = () => {
|
|
2367
2438
|
// src/hooks/useSwitchToNewThread.tsx
|
2368
2439
|
|
2369
2440
|
var useSwitchToNewThread = () => {
|
2370
|
-
const
|
2371
|
-
const
|
2441
|
+
const assistantActionsStore = useAssistantActionsStore();
|
2442
|
+
const threadComposerStore = useThreadComposerStore();
|
2372
2443
|
const switchToNewThread = _react.useCallback.call(void 0, () => {
|
2373
|
-
|
2374
|
-
|
2375
|
-
}, [
|
2444
|
+
assistantActionsStore.getState().switchToThread(null);
|
2445
|
+
threadComposerStore.getState().focus();
|
2446
|
+
}, [assistantActionsStore, threadComposerStore]);
|
2376
2447
|
return switchToNewThread;
|
2377
2448
|
};
|
2378
2449
|
|
2379
2450
|
// src/model-config/useAssistantTool.tsx
|
2380
2451
|
|
2381
2452
|
var useAssistantTool = (tool) => {
|
2382
|
-
const
|
2383
|
-
const
|
2384
|
-
(s) => s.registerModelConfigProvider
|
2385
|
-
);
|
2386
|
-
const setToolUI = useToolUIs((s) => s.setToolUI);
|
2453
|
+
const assistantActionsStore = useAssistantActionsStore();
|
2454
|
+
const toolUIsStore = useToolUIsStore();
|
2387
2455
|
_react.useEffect.call(void 0, () => {
|
2388
2456
|
const { toolName, render, ...rest } = tool;
|
2389
2457
|
const config = {
|
@@ -2391,15 +2459,15 @@ var useAssistantTool = (tool) => {
|
|
2391
2459
|
[tool.toolName]: rest
|
2392
2460
|
}
|
2393
2461
|
};
|
2394
|
-
const unsub1 = registerModelConfigProvider({
|
2462
|
+
const unsub1 = assistantActionsStore.getState().registerModelConfigProvider({
|
2395
2463
|
getModelConfig: () => config
|
2396
2464
|
});
|
2397
|
-
const unsub2 = render ? setToolUI(toolName, render) : void 0;
|
2465
|
+
const unsub2 = render ? toolUIsStore.getState().setToolUI(toolName, render) : void 0;
|
2398
2466
|
return () => {
|
2399
2467
|
unsub1();
|
2400
|
-
_optionalChain([unsub2, 'optionalCall',
|
2468
|
+
_optionalChain([unsub2, 'optionalCall', _102 => _102()]);
|
2401
2469
|
};
|
2402
|
-
}, [
|
2470
|
+
}, [assistantActionsStore, toolUIsStore, tool]);
|
2403
2471
|
};
|
2404
2472
|
|
2405
2473
|
// src/model-config/makeAssistantTool.tsx
|
@@ -2415,13 +2483,12 @@ var makeAssistantTool = (tool) => {
|
|
2415
2483
|
// src/model-config/useAssistantToolUI.tsx
|
2416
2484
|
|
2417
2485
|
var useAssistantToolUI = (tool) => {
|
2418
|
-
const
|
2419
|
-
const setToolUI = useToolUIs((s) => s.setToolUI);
|
2486
|
+
const toolUIsStore = useToolUIsStore();
|
2420
2487
|
_react.useEffect.call(void 0, () => {
|
2421
2488
|
if (!tool) return;
|
2422
2489
|
const { toolName, render } = tool;
|
2423
|
-
return setToolUI(toolName, render);
|
2424
|
-
}, [
|
2490
|
+
return toolUIsStore.getState().setToolUI(toolName, render);
|
2491
|
+
}, [toolUIsStore, tool]);
|
2425
2492
|
};
|
2426
2493
|
|
2427
2494
|
// src/model-config/makeAssistantToolUI.tsx
|
@@ -2437,16 +2504,13 @@ var makeAssistantToolUI = (tool) => {
|
|
2437
2504
|
// src/model-config/useAssistantInstructions.tsx
|
2438
2505
|
|
2439
2506
|
var useAssistantInstructions = (instruction) => {
|
2440
|
-
const
|
2441
|
-
const registerModelConfigProvider = useModelConfig(
|
2442
|
-
(s) => s.registerModelConfigProvider
|
2443
|
-
);
|
2507
|
+
const runtimeStore = useAssistantRuntimeStore();
|
2444
2508
|
_react.useEffect.call(void 0, () => {
|
2445
2509
|
const config = {
|
2446
2510
|
system: instruction
|
2447
2511
|
};
|
2448
|
-
return registerModelConfigProvider({ getModelConfig: () => config });
|
2449
|
-
}, [
|
2512
|
+
return runtimeStore.getState().registerModelConfigProvider({ getModelConfig: () => config });
|
2513
|
+
}, [runtimeStore, instruction]);
|
2450
2514
|
};
|
2451
2515
|
|
2452
2516
|
// src/primitive-hooks/actionBar/useActionBarCopy.tsx
|
@@ -2482,23 +2546,25 @@ var useCombinedStore = (stores, selector) => {
|
|
2482
2546
|
var useActionBarCopy = ({
|
2483
2547
|
copiedDuration = 3e3
|
2484
2548
|
} = {}) => {
|
2485
|
-
const
|
2549
|
+
const messageStore = useMessageStore();
|
2550
|
+
const messageUtilsStore = useMessageUtilsStore();
|
2551
|
+
const editComposerStore = useEditComposerStore();
|
2486
2552
|
const hasCopyableContent = useCombinedStore(
|
2487
|
-
[
|
2553
|
+
[messageStore, editComposerStore],
|
2488
2554
|
({ message }, c) => {
|
2489
2555
|
return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
2490
2556
|
}
|
2491
2557
|
);
|
2492
2558
|
const callback = _react.useCallback.call(void 0, () => {
|
2493
|
-
const { message } =
|
2494
|
-
const { setIsCopied } =
|
2495
|
-
const { isEditing, text: composerValue } =
|
2559
|
+
const { message } = messageStore.getState();
|
2560
|
+
const { setIsCopied } = messageUtilsStore.getState();
|
2561
|
+
const { isEditing, text: composerValue } = editComposerStore.getState();
|
2496
2562
|
const valueToCopy = isEditing ? composerValue : getThreadMessageText(message);
|
2497
2563
|
navigator.clipboard.writeText(valueToCopy).then(() => {
|
2498
2564
|
setIsCopied(true);
|
2499
2565
|
setTimeout(() => setIsCopied(false), copiedDuration);
|
2500
2566
|
});
|
2501
|
-
}, [
|
2567
|
+
}, [messageStore, messageUtilsStore, editComposerStore, copiedDuration]);
|
2502
2568
|
if (!hasCopyableContent) return null;
|
2503
2569
|
return callback;
|
2504
2570
|
};
|
@@ -2506,15 +2572,12 @@ var useActionBarCopy = ({
|
|
2506
2572
|
// src/primitive-hooks/actionBar/useActionBarEdit.tsx
|
2507
2573
|
|
2508
2574
|
var useActionBarEdit = () => {
|
2509
|
-
const
|
2510
|
-
const disabled =
|
2511
|
-
[useMessage, useEditComposer],
|
2512
|
-
(m, c) => m.message.role !== "user" || c.isEditing
|
2513
|
-
);
|
2575
|
+
const editComposerStore = useEditComposerStore();
|
2576
|
+
const disabled = useEditComposer((c) => c.isEditing);
|
2514
2577
|
const callback = _react.useCallback.call(void 0, () => {
|
2515
|
-
const { edit } =
|
2578
|
+
const { edit } = editComposerStore.getState();
|
2516
2579
|
edit();
|
2517
|
-
}, [
|
2580
|
+
}, [editComposerStore]);
|
2518
2581
|
if (disabled) return null;
|
2519
2582
|
return callback;
|
2520
2583
|
};
|
@@ -2522,18 +2585,26 @@ var useActionBarEdit = () => {
|
|
2522
2585
|
// src/primitive-hooks/actionBar/useActionBarReload.tsx
|
2523
2586
|
|
2524
2587
|
var useActionBarReload = () => {
|
2525
|
-
const
|
2526
|
-
const
|
2588
|
+
const messageStore = useMessageStore();
|
2589
|
+
const threadStore = useThreadStore();
|
2590
|
+
const threadActionsStore = useThreadActionsStore();
|
2591
|
+
const threadComposerStore = useThreadComposerStore();
|
2592
|
+
const threadViewportStore = useThreadViewportStore();
|
2527
2593
|
const disabled = useCombinedStore(
|
2528
|
-
[
|
2594
|
+
[threadStore, messageStore],
|
2529
2595
|
(t, m) => t.isRunning || t.isDisabled || m.message.role !== "assistant"
|
2530
2596
|
);
|
2531
2597
|
const callback = _react.useCallback.call(void 0, () => {
|
2532
|
-
const { parentId } =
|
2533
|
-
|
2534
|
-
|
2535
|
-
|
2536
|
-
}, [
|
2598
|
+
const { parentId } = messageStore.getState();
|
2599
|
+
threadActionsStore.getState().startRun(parentId);
|
2600
|
+
threadViewportStore.getState().scrollToBottom();
|
2601
|
+
threadComposerStore.getState().focus();
|
2602
|
+
}, [
|
2603
|
+
threadActionsStore,
|
2604
|
+
threadComposerStore,
|
2605
|
+
threadViewportStore,
|
2606
|
+
messageStore
|
2607
|
+
]);
|
2537
2608
|
if (disabled) return null;
|
2538
2609
|
return callback;
|
2539
2610
|
};
|
@@ -2541,19 +2612,21 @@ var useActionBarReload = () => {
|
|
2541
2612
|
// src/primitive-hooks/actionBar/useActionBarSpeak.tsx
|
2542
2613
|
|
2543
2614
|
var useActionBarSpeak = () => {
|
2544
|
-
const
|
2545
|
-
const
|
2615
|
+
const messageStore = useMessageStore();
|
2616
|
+
const editComposerStore = useEditComposerStore();
|
2617
|
+
const threadActionsStore = useThreadActionsStore();
|
2618
|
+
const messageUtilsStore = useMessageUtilsStore();
|
2546
2619
|
const hasSpeakableContent = useCombinedStore(
|
2547
|
-
[
|
2620
|
+
[messageStore, editComposerStore],
|
2548
2621
|
({ message }, c) => {
|
2549
2622
|
return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
2550
2623
|
}
|
2551
2624
|
);
|
2552
2625
|
const callback = _react.useCallback.call(void 0, async () => {
|
2553
|
-
const { message } =
|
2554
|
-
const utt =
|
2555
|
-
|
2556
|
-
}, [
|
2626
|
+
const { message } = messageStore.getState();
|
2627
|
+
const utt = threadActionsStore.getState().speak(message.id);
|
2628
|
+
messageUtilsStore.getState().addUtterance(utt);
|
2629
|
+
}, [threadActionsStore, messageStore, messageUtilsStore]);
|
2557
2630
|
if (!hasSpeakableContent) return null;
|
2558
2631
|
return callback;
|
2559
2632
|
};
|
@@ -2561,18 +2634,17 @@ var useActionBarSpeak = () => {
|
|
2561
2634
|
// src/primitive-hooks/actionBar/useActionBarStopSpeaking.tsx
|
2562
2635
|
|
2563
2636
|
var useActionBarStopSpeaking = () => {
|
2564
|
-
const
|
2637
|
+
const messageUtilsStore = useMessageUtilsStore();
|
2565
2638
|
const isSpeaking = useMessageUtils((u) => u.isSpeaking);
|
2566
2639
|
const callback = _react.useCallback.call(void 0, async () => {
|
2567
|
-
|
2568
|
-
}, [
|
2640
|
+
messageUtilsStore.getState().stopSpeaking();
|
2641
|
+
}, [messageUtilsStore]);
|
2569
2642
|
if (!isSpeaking) return null;
|
2570
2643
|
return callback;
|
2571
2644
|
};
|
2572
2645
|
|
2573
2646
|
// src/primitive-hooks/branchPicker/useBranchPickerCount.tsx
|
2574
2647
|
var useBranchPickerCount = () => {
|
2575
|
-
const { useMessage } = useMessageContext();
|
2576
2648
|
const branchCount = useMessage((s) => s.branches.length);
|
2577
2649
|
return branchCount;
|
2578
2650
|
};
|
@@ -2580,23 +2652,23 @@ var useBranchPickerCount = () => {
|
|
2580
2652
|
// src/primitive-hooks/branchPicker/useBranchPickerNext.tsx
|
2581
2653
|
|
2582
2654
|
var useBranchPickerNext = () => {
|
2583
|
-
const
|
2584
|
-
const
|
2655
|
+
const messageStore = useMessageStore();
|
2656
|
+
const editComposerStore = useEditComposerStore();
|
2657
|
+
const threadActionsStore = useThreadActionsStore();
|
2585
2658
|
const disabled = useCombinedStore(
|
2586
|
-
[
|
2659
|
+
[messageStore, editComposerStore],
|
2587
2660
|
(m, c) => c.isEditing || m.branches.indexOf(m.message.id) + 1 >= m.branches.length
|
2588
2661
|
);
|
2589
2662
|
const callback = _react.useCallback.call(void 0, () => {
|
2590
|
-
const { message, branches } =
|
2591
|
-
|
2592
|
-
}, [
|
2663
|
+
const { message, branches } = messageStore.getState();
|
2664
|
+
threadActionsStore.getState().switchToBranch(branches[branches.indexOf(message.id) + 1]);
|
2665
|
+
}, [threadActionsStore, messageStore]);
|
2593
2666
|
if (disabled) return null;
|
2594
2667
|
return callback;
|
2595
2668
|
};
|
2596
2669
|
|
2597
2670
|
// src/primitive-hooks/branchPicker/useBranchPickerNumber.tsx
|
2598
2671
|
var useBranchPickerNumber = () => {
|
2599
|
-
const { useMessage } = useMessageContext();
|
2600
2672
|
const branchIdx = useMessage((s) => s.branches.indexOf(s.message.id));
|
2601
2673
|
return branchIdx + 1;
|
2602
2674
|
};
|
@@ -2604,16 +2676,17 @@ var useBranchPickerNumber = () => {
|
|
2604
2676
|
// src/primitive-hooks/branchPicker/useBranchPickerPrevious.tsx
|
2605
2677
|
|
2606
2678
|
var useBranchPickerPrevious = () => {
|
2607
|
-
const
|
2608
|
-
const
|
2679
|
+
const messageStore = useMessageStore();
|
2680
|
+
const editComposerStore = useEditComposerStore();
|
2681
|
+
const threadActionsStore = useThreadActionsStore();
|
2609
2682
|
const disabled = useCombinedStore(
|
2610
|
-
[
|
2683
|
+
[messageStore, editComposerStore],
|
2611
2684
|
(m, c) => c.isEditing || m.branches.indexOf(m.message.id) <= 0
|
2612
2685
|
);
|
2613
2686
|
const callback = _react.useCallback.call(void 0, () => {
|
2614
|
-
const { message, branches } =
|
2615
|
-
|
2616
|
-
}, [
|
2687
|
+
const { message, branches } = messageStore.getState();
|
2688
|
+
threadActionsStore.getState().switchToBranch(branches[branches.indexOf(message.id) - 1]);
|
2689
|
+
}, [threadActionsStore, messageStore]);
|
2617
2690
|
if (disabled) return null;
|
2618
2691
|
return callback;
|
2619
2692
|
};
|
@@ -2621,19 +2694,18 @@ var useBranchPickerPrevious = () => {
|
|
2621
2694
|
// src/primitive-hooks/composer/useComposerCancel.tsx
|
2622
2695
|
|
2623
2696
|
var useComposerCancel = () => {
|
2624
|
-
const
|
2697
|
+
const composerStore = useComposerStore();
|
2625
2698
|
const disabled = useComposer((c) => !c.canCancel);
|
2626
2699
|
const callback = _react.useCallback.call(void 0, () => {
|
2627
|
-
const { cancel } =
|
2700
|
+
const { cancel } = composerStore.getState();
|
2628
2701
|
cancel();
|
2629
|
-
}, [
|
2702
|
+
}, [composerStore]);
|
2630
2703
|
if (disabled) return null;
|
2631
2704
|
return callback;
|
2632
2705
|
};
|
2633
2706
|
|
2634
2707
|
// src/primitive-hooks/composer/useComposerIf.tsx
|
2635
2708
|
var useComposerIf = (props) => {
|
2636
|
-
const { useComposer } = useComposerContext();
|
2637
2709
|
return useComposer((composer) => {
|
2638
2710
|
if (props.editing === true && !composer.isEditing) return false;
|
2639
2711
|
if (props.editing === false && composer.isEditing) return false;
|
@@ -2644,23 +2716,21 @@ var useComposerIf = (props) => {
|
|
2644
2716
|
// src/primitive-hooks/composer/useComposerSend.tsx
|
2645
2717
|
|
2646
2718
|
var useComposerSend = () => {
|
2647
|
-
const
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
} = useThreadContext();
|
2652
|
-
const { useComposer } = useComposerContext();
|
2719
|
+
const threadStore = useThreadStore();
|
2720
|
+
const threadViewportStore = useThreadViewportStore();
|
2721
|
+
const composerStore = useComposerStore();
|
2722
|
+
const threadComposerStore = useThreadComposerStore();
|
2653
2723
|
const disabled = useCombinedStore(
|
2654
|
-
[
|
2724
|
+
[threadStore, composerStore],
|
2655
2725
|
(t, c) => t.isRunning || !c.isEditing || c.isEmpty
|
2656
2726
|
);
|
2657
2727
|
const callback = _react.useCallback.call(void 0, () => {
|
2658
|
-
const composerState =
|
2728
|
+
const composerState = composerStore.getState();
|
2659
2729
|
if (!composerState.isEditing) return;
|
2660
2730
|
composerState.send();
|
2661
|
-
|
2662
|
-
|
2663
|
-
}, [
|
2731
|
+
threadViewportStore.getState().scrollToBottom();
|
2732
|
+
threadComposerStore.getState().focus();
|
2733
|
+
}, [threadComposerStore, composerStore, threadViewportStore]);
|
2664
2734
|
if (disabled) return null;
|
2665
2735
|
return callback;
|
2666
2736
|
};
|
@@ -2668,30 +2738,30 @@ var useComposerSend = () => {
|
|
2668
2738
|
// src/primitive-hooks/composer/useComposerAddAttachment.tsx
|
2669
2739
|
|
2670
2740
|
var useComposerAddAttachment = () => {
|
2671
|
-
const { useComposer, useThreadRuntime } = useThreadContext();
|
2672
2741
|
const disabled = useComposer((c) => !c.isEditing);
|
2742
|
+
const threadComposerStore = useThreadComposerStore();
|
2743
|
+
const threadRuntimeStore = useThreadRuntimeStore();
|
2673
2744
|
const callback = _react.useCallback.call(void 0, () => {
|
2674
|
-
const { addAttachment } =
|
2675
|
-
const { attachmentAccept } =
|
2745
|
+
const { addAttachment } = threadComposerStore.getState();
|
2746
|
+
const { attachmentAccept } = threadRuntimeStore.getState().composer;
|
2676
2747
|
const input = document.createElement("input");
|
2677
2748
|
input.type = "file";
|
2678
2749
|
if (attachmentAccept !== "*") {
|
2679
2750
|
input.accept = attachmentAccept;
|
2680
2751
|
}
|
2681
2752
|
input.onchange = (e) => {
|
2682
|
-
const file = _optionalChain([e, 'access',
|
2753
|
+
const file = _optionalChain([e, 'access', _103 => _103.target, 'access', _104 => _104.files, 'optionalAccess', _105 => _105[0]]);
|
2683
2754
|
if (!file) return;
|
2684
2755
|
addAttachment(file);
|
2685
2756
|
};
|
2686
2757
|
input.click();
|
2687
|
-
}, [
|
2758
|
+
}, [threadComposerStore, threadRuntimeStore]);
|
2688
2759
|
if (disabled) return null;
|
2689
2760
|
return callback;
|
2690
2761
|
};
|
2691
2762
|
|
2692
2763
|
// src/primitive-hooks/contentPart/useContentPartDisplay.tsx
|
2693
2764
|
var useContentPartDisplay = () => {
|
2694
|
-
const { useContentPart } = useContentPartContext();
|
2695
2765
|
const display = useContentPart((c) => {
|
2696
2766
|
if (c.part.type !== "ui")
|
2697
2767
|
throw new Error(
|
@@ -2704,7 +2774,6 @@ var useContentPartDisplay = () => {
|
|
2704
2774
|
|
2705
2775
|
// src/primitive-hooks/contentPart/useContentPartImage.tsx
|
2706
2776
|
var useContentPartImage = () => {
|
2707
|
-
const { useContentPart } = useContentPartContext();
|
2708
2777
|
const image = useContentPart((c) => {
|
2709
2778
|
if (c.part.type !== "image")
|
2710
2779
|
throw new Error(
|
@@ -2717,7 +2786,6 @@ var useContentPartImage = () => {
|
|
2717
2786
|
|
2718
2787
|
// src/primitive-hooks/contentPart/useContentPartText.tsx
|
2719
2788
|
var useContentPartText = () => {
|
2720
|
-
const { useContentPart } = useContentPartContext();
|
2721
2789
|
const text = useContentPart((c) => {
|
2722
2790
|
if (c.part.type !== "text")
|
2723
2791
|
throw new Error(
|
@@ -2730,9 +2798,10 @@ var useContentPartText = () => {
|
|
2730
2798
|
|
2731
2799
|
// src/primitive-hooks/message/useMessageIf.tsx
|
2732
2800
|
var useMessageIf = (props) => {
|
2733
|
-
const
|
2801
|
+
const messageStore = useMessageStore();
|
2802
|
+
const messageUtilsStore = useMessageUtilsStore();
|
2734
2803
|
return useCombinedStore(
|
2735
|
-
[
|
2804
|
+
[messageStore, messageUtilsStore],
|
2736
2805
|
({ message, branches, isLast }, { isCopied, isHovering, isSpeaking }) => {
|
2737
2806
|
if (props.hasBranches === true && branches.length < 2) return false;
|
2738
2807
|
if (props.user && message.role !== "user") return false;
|
@@ -2754,9 +2823,10 @@ var useMessageIf = (props) => {
|
|
2754
2823
|
|
2755
2824
|
// src/primitive-hooks/thread/useThreadIf.tsx
|
2756
2825
|
var useThreadIf = (props) => {
|
2757
|
-
const
|
2826
|
+
const threadStore = useThreadStore();
|
2827
|
+
const threadMessagesStore = useThreadMessagesStore();
|
2758
2828
|
return useCombinedStore(
|
2759
|
-
[
|
2829
|
+
[threadStore, threadMessagesStore],
|
2760
2830
|
(thread, messages) => {
|
2761
2831
|
if (props.empty === true && messages.length !== 0) return false;
|
2762
2832
|
if (props.empty === false && messages.length === 0) return false;
|
@@ -2777,12 +2847,13 @@ var useThreadEmpty = () => {
|
|
2777
2847
|
// src/primitive-hooks/thread/useThreadScrollToBottom.tsx
|
2778
2848
|
|
2779
2849
|
var useThreadScrollToBottom = () => {
|
2780
|
-
const
|
2781
|
-
const
|
2850
|
+
const isAtBottom = useThreadViewport((s) => s.isAtBottom);
|
2851
|
+
const threadViewportStore = useThreadViewportStore();
|
2852
|
+
const threadComposerStore = useThreadComposerStore();
|
2782
2853
|
const handleScrollToBottom = _react.useCallback.call(void 0, () => {
|
2783
|
-
|
2784
|
-
|
2785
|
-
}, [
|
2854
|
+
threadViewportStore.getState().scrollToBottom();
|
2855
|
+
threadComposerStore.getState().focus();
|
2856
|
+
}, [threadViewportStore, threadComposerStore]);
|
2786
2857
|
if (isAtBottom) return null;
|
2787
2858
|
return handleScrollToBottom;
|
2788
2859
|
};
|
@@ -2793,19 +2864,20 @@ var useThreadSuggestion = ({
|
|
2793
2864
|
prompt,
|
2794
2865
|
autoSend
|
2795
2866
|
}) => {
|
2796
|
-
const
|
2867
|
+
const threadStore = useThreadStore();
|
2868
|
+
const composerStore = useThreadComposerStore();
|
2797
2869
|
const append = useAppendMessage();
|
2798
2870
|
const disabled = useThread((t) => t.isDisabled);
|
2799
2871
|
const callback = _react.useCallback.call(void 0, () => {
|
2800
|
-
const thread =
|
2801
|
-
const composer =
|
2872
|
+
const thread = threadStore.getState();
|
2873
|
+
const composer = composerStore.getState();
|
2802
2874
|
if (autoSend && !thread.isRunning) {
|
2803
2875
|
append(prompt);
|
2804
2876
|
composer.setText("");
|
2805
2877
|
} else {
|
2806
2878
|
composer.setText(prompt);
|
2807
2879
|
}
|
2808
|
-
}, [
|
2880
|
+
}, [threadStore, composerStore, autoSend, append, prompt]);
|
2809
2881
|
if (disabled) return null;
|
2810
2882
|
return callback;
|
2811
2883
|
};
|
@@ -2831,10 +2903,11 @@ var useActionBarFloatStatus = ({
|
|
2831
2903
|
autohide,
|
2832
2904
|
autohideFloat
|
2833
2905
|
}) => {
|
2834
|
-
const
|
2835
|
-
const
|
2906
|
+
const threadStore = useThreadStore();
|
2907
|
+
const messageStore = useMessageStore();
|
2908
|
+
const messageUtilsStore = useMessageUtilsStore();
|
2836
2909
|
return useCombinedStore(
|
2837
|
-
[
|
2910
|
+
[threadStore, messageStore, messageUtilsStore],
|
2838
2911
|
(t, m, mu) => {
|
2839
2912
|
if (hideWhenRunning && t.isRunning) return "hidden" /* Hidden */;
|
2840
2913
|
const autohideEnabled = autohide === "always" || autohide === "not-last" && !m.isLast;
|
@@ -2892,7 +2965,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
2892
2965
|
ref: forwardedRef,
|
2893
2966
|
disabled: primitiveProps.disabled || !callback,
|
2894
2967
|
onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
|
2895
|
-
_optionalChain([callback, 'optionalCall',
|
2968
|
+
_optionalChain([callback, 'optionalCall', _106 => _106()]);
|
2896
2969
|
})
|
2897
2970
|
}
|
2898
2971
|
);
|
@@ -2948,11 +3021,12 @@ var ActionBarPrimitiveStopSpeaking = _react.forwardRef.call(void 0, (props, ref)
|
|
2948
3021
|
...props,
|
2949
3022
|
ref,
|
2950
3023
|
onClick: _primitive.composeEventHandlers.call(void 0, props.onClick, () => {
|
2951
|
-
_optionalChain([callback, 'optionalCall',
|
3024
|
+
_optionalChain([callback, 'optionalCall', _107 => _107()]);
|
2952
3025
|
})
|
2953
3026
|
}
|
2954
3027
|
);
|
2955
3028
|
});
|
3029
|
+
ActionBarPrimitiveStopSpeaking.displayName = "ActionBarPrimitive.StopSpeaking";
|
2956
3030
|
|
2957
3031
|
// src/primitives/assistantModal/index.ts
|
2958
3032
|
var assistantModal_exports = {};
|
@@ -2973,12 +3047,12 @@ var _reactpopover = require('@radix-ui/react-popover'); var PopoverPrimitive2 =
|
|
2973
3047
|
|
2974
3048
|
var useOnComposerFocus = (callback) => {
|
2975
3049
|
const callbackRef = _reactusecallbackref.useCallbackRef.call(void 0, callback);
|
2976
|
-
const
|
3050
|
+
const threadComposerStore = useThreadComposerStore();
|
2977
3051
|
_react.useEffect.call(void 0, () => {
|
2978
|
-
return
|
3052
|
+
return threadComposerStore.getState().onFocus(() => {
|
2979
3053
|
callbackRef();
|
2980
3054
|
});
|
2981
|
-
}, [
|
3055
|
+
}, [threadComposerStore, callbackRef]);
|
2982
3056
|
};
|
2983
3057
|
|
2984
3058
|
// src/primitives/assistantModal/scope.tsx
|
@@ -3160,10 +3234,10 @@ var useManagedRef = (callback) => {
|
|
3160
3234
|
var _reactcomposerefs = require('@radix-ui/react-compose-refs');
|
3161
3235
|
|
3162
3236
|
var useIsHoveringRef = () => {
|
3163
|
-
const
|
3237
|
+
const messageUtilsStore = useMessageUtilsStore();
|
3164
3238
|
const callbackRef = _react.useCallback.call(void 0,
|
3165
3239
|
(el) => {
|
3166
|
-
const setIsHovering =
|
3240
|
+
const setIsHovering = messageUtilsStore.getState().setIsHovering;
|
3167
3241
|
const handleMouseEnter = () => {
|
3168
3242
|
setIsHovering(true);
|
3169
3243
|
};
|
@@ -3178,14 +3252,14 @@ var useIsHoveringRef = () => {
|
|
3178
3252
|
setIsHovering(false);
|
3179
3253
|
};
|
3180
3254
|
},
|
3181
|
-
[
|
3255
|
+
[messageUtilsStore]
|
3182
3256
|
);
|
3183
3257
|
return useManagedRef(callbackRef);
|
3184
3258
|
};
|
3185
|
-
var MessagePrimitiveRoot = _react.forwardRef.call(void 0, (
|
3259
|
+
var MessagePrimitiveRoot = _react.forwardRef.call(void 0, (props, forwardRef30) => {
|
3186
3260
|
const isHoveringRef = useIsHoveringRef();
|
3187
3261
|
const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardRef30, isHoveringRef);
|
3188
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...
|
3262
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...props, ref });
|
3189
3263
|
});
|
3190
3264
|
MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
|
3191
3265
|
|
@@ -3225,7 +3299,7 @@ var toContentPartStatus = (message, partIndex, part) => {
|
|
3225
3299
|
return message.status;
|
3226
3300
|
};
|
3227
3301
|
var EMPTY_CONTENT = Object.freeze({ type: "text", text: "" });
|
3228
|
-
var getContentPartState = ({ message },
|
3302
|
+
var getContentPartState = ({ message }, useContentPart2, partIndex) => {
|
3229
3303
|
let part = message.content[partIndex];
|
3230
3304
|
if (!part) {
|
3231
3305
|
if (message.content.length === 0 && partIndex === 0) {
|
@@ -3233,20 +3307,22 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
|
|
3233
3307
|
} else {
|
3234
3308
|
return null;
|
3235
3309
|
}
|
3310
|
+
} else if (message.content.length === 1 && part.type === "text" && part.text.length === 0) {
|
3311
|
+
part = EMPTY_CONTENT;
|
3236
3312
|
}
|
3237
3313
|
const status = toContentPartStatus(message, partIndex, part);
|
3238
|
-
const currentState = _optionalChain([
|
3314
|
+
const currentState = _optionalChain([useContentPart2, 'optionalAccess', _108 => _108.getState, 'call', _109 => _109()]);
|
3239
3315
|
if (currentState && currentState.part === part && currentState.status === status)
|
3240
3316
|
return null;
|
3241
3317
|
return Object.freeze({ part, status });
|
3242
3318
|
};
|
3243
3319
|
var useContentPartContext2 = (partIndex) => {
|
3244
|
-
const
|
3320
|
+
const messageStore = useMessageStore();
|
3245
3321
|
const [context] = _react.useState.call(void 0, () => {
|
3246
|
-
const
|
3247
|
-
() => getContentPartState(
|
3322
|
+
const useContentPart2 = _zustand.create.call(void 0,
|
3323
|
+
() => getContentPartState(messageStore.getState(), void 0, partIndex)
|
3248
3324
|
);
|
3249
|
-
return { useContentPart };
|
3325
|
+
return { useContentPart: useContentPart2 };
|
3250
3326
|
});
|
3251
3327
|
_react.useEffect.call(void 0, () => {
|
3252
3328
|
const syncContentPart = (message) => {
|
@@ -3258,9 +3334,9 @@ var useContentPartContext2 = (partIndex) => {
|
|
3258
3334
|
if (!newState) return;
|
3259
3335
|
writableStore(context.useContentPart).setState(newState, true);
|
3260
3336
|
};
|
3261
|
-
syncContentPart(
|
3262
|
-
return
|
3263
|
-
}, [context,
|
3337
|
+
syncContentPart(messageStore.getState());
|
3338
|
+
return messageStore.subscribe(syncContentPart);
|
3339
|
+
}, [context, messageStore, partIndex]);
|
3264
3340
|
return context;
|
3265
3341
|
};
|
3266
3342
|
var ContentPartProvider = ({
|
@@ -3308,7 +3384,6 @@ ContentPartPrimitiveDisplay.displayName = "ContentPartPrimitive.Display";
|
|
3308
3384
|
|
3309
3385
|
// src/primitives/contentPart/ContentPartInProgress.tsx
|
3310
3386
|
var ContentPartPrimitiveInProgress = ({ children }) => {
|
3311
|
-
const { useContentPart } = useContentPartContext();
|
3312
3387
|
const isInProgress = useContentPart((c) => c.status.type === "running");
|
3313
3388
|
return isInProgress ? children : null;
|
3314
3389
|
};
|
@@ -3320,7 +3395,6 @@ var ToolUIDisplay = ({
|
|
3320
3395
|
UI,
|
3321
3396
|
...props
|
3322
3397
|
}) => {
|
3323
|
-
const { useToolUIs } = useAssistantContext();
|
3324
3398
|
const Render = _nullishCoalesce(useToolUIs((s) => s.getToolUI(props.part.toolName)), () => ( UI));
|
3325
3399
|
if (!Render) return null;
|
3326
3400
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Render, { ...props });
|
@@ -3335,24 +3409,24 @@ var defaultComponents = {
|
|
3335
3409
|
};
|
3336
3410
|
var MessageContentPartComponent = ({
|
3337
3411
|
components: {
|
3338
|
-
Empty = defaultComponents.Text,
|
3339
3412
|
Text: Text2 = defaultComponents.Text,
|
3413
|
+
Empty,
|
3340
3414
|
Image: Image2 = defaultComponents.Image,
|
3341
3415
|
UI = defaultComponents.UI,
|
3342
3416
|
tools: { by_name = {}, Fallback: Fallback2 = void 0 } = {}
|
3343
3417
|
} = {}
|
3344
3418
|
}) => {
|
3345
|
-
const
|
3346
|
-
const
|
3347
|
-
const addToolResult = useThreadActions((t) => t.addToolResult);
|
3348
|
-
const { useContentPart } = useContentPartContext();
|
3419
|
+
const messageStore = useMessageStore();
|
3420
|
+
const threadActionsStore = useThreadActionsStore();
|
3349
3421
|
const { part, status } = useContentPart();
|
3350
3422
|
const type = part.type;
|
3351
3423
|
switch (type) {
|
3352
3424
|
case "text":
|
3353
3425
|
if (status.type === "requires-action")
|
3354
3426
|
throw new Error("Encountered unexpected requires-action status");
|
3355
|
-
if (part === EMPTY_CONTENT
|
3427
|
+
if (part === EMPTY_CONTENT && !!Empty) {
|
3428
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Empty, { status });
|
3429
|
+
}
|
3356
3430
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text2, { part, status });
|
3357
3431
|
case "image":
|
3358
3432
|
if (status.type === "requires-action")
|
@@ -3364,8 +3438,8 @@ var MessageContentPartComponent = ({
|
|
3364
3438
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UI, { part, status });
|
3365
3439
|
case "tool-call": {
|
3366
3440
|
const Tool = by_name[part.toolName] || Fallback2;
|
3367
|
-
const addResult = (result) => addToolResult({
|
3368
|
-
messageId:
|
3441
|
+
const addResult = (result) => threadActionsStore.getState().addToolResult({
|
3442
|
+
messageId: messageStore.getState().message.id,
|
3369
3443
|
toolName: part.toolName,
|
3370
3444
|
toolCallId: part.toolCallId,
|
3371
3445
|
result
|
@@ -3393,12 +3467,11 @@ var MessageContentPartImpl = ({
|
|
3393
3467
|
};
|
3394
3468
|
var MessageContentPart = _react.memo.call(void 0,
|
3395
3469
|
MessageContentPartImpl,
|
3396
|
-
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access',
|
3470
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _110 => _110.components, 'optionalAccess', _111 => _111.Text]) === _optionalChain([next, 'access', _112 => _112.components, 'optionalAccess', _113 => _113.Text]) && _optionalChain([prev, 'access', _114 => _114.components, 'optionalAccess', _115 => _115.Image]) === _optionalChain([next, 'access', _116 => _116.components, 'optionalAccess', _117 => _117.Image]) && _optionalChain([prev, 'access', _118 => _118.components, 'optionalAccess', _119 => _119.UI]) === _optionalChain([next, 'access', _120 => _120.components, 'optionalAccess', _121 => _121.UI]) && _optionalChain([prev, 'access', _122 => _122.components, 'optionalAccess', _123 => _123.tools]) === _optionalChain([next, 'access', _124 => _124.components, 'optionalAccess', _125 => _125.tools])
|
3397
3471
|
);
|
3398
3472
|
var MessagePrimitiveContent = ({
|
3399
3473
|
components
|
3400
3474
|
}) => {
|
3401
|
-
const { useMessage } = useMessageContext();
|
3402
3475
|
const contentLength = useMessage((s) => s.message.content.length) || 1;
|
3403
3476
|
return Array.from({ length: contentLength }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPart, { partIndex: index, components }, index));
|
3404
3477
|
};
|
@@ -3420,42 +3493,64 @@ var AttachmentContext = _react.createContext.call(void 0,
|
|
3420
3493
|
);
|
3421
3494
|
function useAttachmentContext(options) {
|
3422
3495
|
const context = _react.useContext.call(void 0, AttachmentContext);
|
3423
|
-
if (_optionalChain([options, 'optionalAccess',
|
3496
|
+
if (!_optionalChain([options, 'optionalAccess', _126 => _126.optional]) && !context)
|
3424
3497
|
throw new Error(
|
3425
|
-
"This component must be used within a ComposerPrimitive.Attachments component."
|
3498
|
+
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
3426
3499
|
);
|
3427
|
-
|
3500
|
+
return context;
|
3501
|
+
}
|
3502
|
+
function useComposerAttachmentContext(options) {
|
3503
|
+
const context = useAttachmentContext(options);
|
3504
|
+
if (!context) return null;
|
3505
|
+
if (context.type !== "composer")
|
3428
3506
|
throw new Error(
|
3429
|
-
"This component must be used within a
|
3507
|
+
"This component must be used within a ComposerPrimitive.Attachments component."
|
3430
3508
|
);
|
3431
|
-
|
3509
|
+
return context;
|
3510
|
+
}
|
3511
|
+
function useMessageAttachmentContext(options) {
|
3512
|
+
const context = useAttachmentContext(options);
|
3513
|
+
if (!context) return null;
|
3514
|
+
if (context.type !== "message")
|
3432
3515
|
throw new Error(
|
3433
|
-
"This component must be used within a
|
3516
|
+
"This component must be used within a MessagePrimitive.Attachments component."
|
3434
3517
|
);
|
3435
3518
|
return context;
|
3436
3519
|
}
|
3520
|
+
var { useAttachment, useAttachmentStore } = createContextStoreHook(
|
3521
|
+
useAttachmentContext,
|
3522
|
+
"useAttachment"
|
3523
|
+
);
|
3524
|
+
var {
|
3525
|
+
useAttachment: useComposerAttachment,
|
3526
|
+
useAttachmentStore: useComposerAttachmentStore
|
3527
|
+
} = createContextStoreHook(useComposerAttachmentContext, "useAttachment");
|
3528
|
+
var {
|
3529
|
+
useAttachment: useMessageAttachment,
|
3530
|
+
useAttachmentStore: useMessageAttachmentStore
|
3531
|
+
} = createContextStoreHook(useMessageAttachmentContext, "useAttachment");
|
3437
3532
|
|
3438
3533
|
// src/context/providers/MessageAttachmentProvider.tsx
|
3439
3534
|
|
3440
3535
|
|
3441
3536
|
|
3442
|
-
var getAttachment = ({ message },
|
3537
|
+
var getAttachment = ({ message }, useAttachment2, partIndex) => {
|
3443
3538
|
if (message.role !== "user") return null;
|
3444
3539
|
const attachments = message.attachments;
|
3445
|
-
|
3540
|
+
const attachment = attachments[partIndex];
|
3446
3541
|
if (!attachment) return null;
|
3447
|
-
const currentState = _optionalChain([
|
3542
|
+
const currentState = _optionalChain([useAttachment2, 'optionalAccess', _127 => _127.getState, 'call', _128 => _128()]);
|
3448
3543
|
if (currentState && currentState.attachment === attachment) return null;
|
3449
3544
|
return Object.freeze({ attachment });
|
3450
3545
|
};
|
3451
|
-
var
|
3452
|
-
const
|
3546
|
+
var useMessageAttachmentContext2 = (partIndex) => {
|
3547
|
+
const messageStore = useMessageStore();
|
3453
3548
|
const [context] = _react.useState.call(void 0,
|
3454
3549
|
() => {
|
3455
|
-
const
|
3456
|
-
() => getAttachment(
|
3550
|
+
const useAttachment2 = _zustand.create.call(void 0,
|
3551
|
+
() => getAttachment(messageStore.getState(), void 0, partIndex)
|
3457
3552
|
);
|
3458
|
-
return { type: "message", useAttachment };
|
3553
|
+
return { type: "message", useAttachment: useAttachment2 };
|
3459
3554
|
}
|
3460
3555
|
);
|
3461
3556
|
_react.useEffect.call(void 0, () => {
|
@@ -3468,16 +3563,16 @@ var useMessageAttachmentContext = (partIndex) => {
|
|
3468
3563
|
if (!newState) return;
|
3469
3564
|
writableStore(context.useAttachment).setState(newState, true);
|
3470
3565
|
};
|
3471
|
-
syncAttachment(
|
3472
|
-
return
|
3473
|
-
}, [context,
|
3566
|
+
syncAttachment(messageStore.getState());
|
3567
|
+
return messageStore.subscribe(syncAttachment);
|
3568
|
+
}, [context, messageStore, partIndex]);
|
3474
3569
|
return context;
|
3475
3570
|
};
|
3476
3571
|
var MessageAttachmentProvider = ({
|
3477
3572
|
attachmentIndex: partIndex,
|
3478
3573
|
children
|
3479
3574
|
}) => {
|
3480
|
-
const context =
|
3575
|
+
const context = useMessageAttachmentContext2(partIndex);
|
3481
3576
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentContext.Provider, { value: context, children });
|
3482
3577
|
};
|
3483
3578
|
|
@@ -3487,19 +3582,18 @@ var getComponent = (components, attachment) => {
|
|
3487
3582
|
const type = attachment.type;
|
3488
3583
|
switch (type) {
|
3489
3584
|
case "image":
|
3490
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3585
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _129 => _129.Image]), () => ( _optionalChain([components, 'optionalAccess', _130 => _130.Attachment])));
|
3491
3586
|
case "document":
|
3492
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3587
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _131 => _131.Document]), () => ( _optionalChain([components, 'optionalAccess', _132 => _132.Attachment])));
|
3493
3588
|
case "file":
|
3494
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3589
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _133 => _133.File]), () => ( _optionalChain([components, 'optionalAccess', _134 => _134.Attachment])));
|
3495
3590
|
default:
|
3496
3591
|
const _exhaustiveCheck = type;
|
3497
3592
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
3498
3593
|
}
|
3499
3594
|
};
|
3500
3595
|
var AttachmentComponent = ({ components }) => {
|
3501
|
-
const
|
3502
|
-
const Component = useAttachment(
|
3596
|
+
const Component = useMessageAttachment(
|
3503
3597
|
(a) => getComponent(components, a.attachment)
|
3504
3598
|
);
|
3505
3599
|
if (!Component) return null;
|
@@ -3510,10 +3604,9 @@ var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
3510
3604
|
};
|
3511
3605
|
var MessageAttachment = _react.memo.call(void 0,
|
3512
3606
|
MessageAttachmentImpl,
|
3513
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
3607
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _135 => _135.components, 'optionalAccess', _136 => _136.Image]) === _optionalChain([next, 'access', _137 => _137.components, 'optionalAccess', _138 => _138.Image]) && _optionalChain([prev, 'access', _139 => _139.components, 'optionalAccess', _140 => _140.Document]) === _optionalChain([next, 'access', _141 => _141.components, 'optionalAccess', _142 => _142.Document]) && _optionalChain([prev, 'access', _143 => _143.components, 'optionalAccess', _144 => _144.File]) === _optionalChain([next, 'access', _145 => _145.components, 'optionalAccess', _146 => _146.File]) && _optionalChain([prev, 'access', _147 => _147.components, 'optionalAccess', _148 => _148.Attachment]) === _optionalChain([next, 'access', _149 => _149.components, 'optionalAccess', _150 => _150.Attachment])
|
3514
3608
|
);
|
3515
3609
|
var MessagePrimitiveAttachments = ({ components }) => {
|
3516
|
-
const { useMessage } = useMessageContext();
|
3517
3610
|
const attachmentsCount = useMessage(({ message }) => {
|
3518
3611
|
if (message.role !== "user") return 0;
|
3519
3612
|
return message.attachments.length;
|
@@ -3595,8 +3688,8 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
3595
3688
|
onKeyDown,
|
3596
3689
|
...rest
|
3597
3690
|
}, forwardedRef) => {
|
3598
|
-
const
|
3599
|
-
const
|
3691
|
+
const threadStore = useThreadStore();
|
3692
|
+
const composerStore = useComposerStore();
|
3600
3693
|
const value = useComposer((c) => {
|
3601
3694
|
if (!c.isEditing) return "";
|
3602
3695
|
return c.text;
|
@@ -3606,7 +3699,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
3606
3699
|
const textareaRef = _react.useRef.call(void 0, null);
|
3607
3700
|
const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardedRef, textareaRef);
|
3608
3701
|
_reactuseescapekeydown.useEscapeKeydown.call(void 0, (e) => {
|
3609
|
-
const composer =
|
3702
|
+
const composer = composerStore.getState();
|
3610
3703
|
if (composer.canCancel) {
|
3611
3704
|
composer.cancel();
|
3612
3705
|
e.preventDefault();
|
@@ -3616,10 +3709,10 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
3616
3709
|
if (isDisabled) return;
|
3617
3710
|
if (e.nativeEvent.isComposing) return;
|
3618
3711
|
if (e.key === "Enter" && e.shiftKey === false) {
|
3619
|
-
const { isRunning } =
|
3712
|
+
const { isRunning } = threadStore.getState();
|
3620
3713
|
if (!isRunning) {
|
3621
3714
|
e.preventDefault();
|
3622
|
-
_optionalChain([textareaRef, 'access',
|
3715
|
+
_optionalChain([textareaRef, 'access', _151 => _151.current, 'optionalAccess', _152 => _152.closest, 'call', _153 => _153("form"), 'optionalAccess', _154 => _154.requestSubmit, 'call', _155 => _155()]);
|
3623
3716
|
}
|
3624
3717
|
}
|
3625
3718
|
};
|
@@ -3635,7 +3728,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
3635
3728
|
}, [autoFocusEnabled]);
|
3636
3729
|
_react.useEffect.call(void 0, () => focus(), [focus]);
|
3637
3730
|
useOnComposerFocus(() => {
|
3638
|
-
if (type === "
|
3731
|
+
if (composerStore.getState().type === "thread") {
|
3639
3732
|
focus();
|
3640
3733
|
}
|
3641
3734
|
});
|
@@ -3648,7 +3741,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
3648
3741
|
ref,
|
3649
3742
|
disabled: isDisabled,
|
3650
3743
|
onChange: _primitive.composeEventHandlers.call(void 0, onChange, (e) => {
|
3651
|
-
const composerState =
|
3744
|
+
const composerState = composerStore.getState();
|
3652
3745
|
if (!composerState.isEditing) return;
|
3653
3746
|
return composerState.setText(e.target.value);
|
3654
3747
|
}),
|
@@ -3684,21 +3777,21 @@ var ComposerPrimitiveAddAttachment = createActionButton(
|
|
3684
3777
|
|
3685
3778
|
|
3686
3779
|
|
3687
|
-
var getAttachment2 = ({ attachments },
|
3688
|
-
|
3780
|
+
var getAttachment2 = ({ attachments }, useAttachment2, partIndex) => {
|
3781
|
+
const attachment = attachments[partIndex];
|
3689
3782
|
if (!attachment) return null;
|
3690
|
-
const currentState = _optionalChain([
|
3783
|
+
const currentState = _optionalChain([useAttachment2, 'optionalAccess', _156 => _156.getState, 'call', _157 => _157()]);
|
3691
3784
|
if (currentState && currentState.attachment === attachment) return null;
|
3692
3785
|
return Object.freeze({ attachment });
|
3693
3786
|
};
|
3694
|
-
var
|
3695
|
-
const
|
3787
|
+
var useComposerAttachmentContext2 = (partIndex) => {
|
3788
|
+
const threadComposerStore = useThreadComposerStore();
|
3696
3789
|
const [context] = _react.useState.call(void 0,
|
3697
3790
|
() => {
|
3698
|
-
const
|
3699
|
-
() => getAttachment2(
|
3791
|
+
const useAttachment2 = _zustand.create.call(void 0,
|
3792
|
+
() => getAttachment2(threadComposerStore.getState(), void 0, partIndex)
|
3700
3793
|
);
|
3701
|
-
return { type: "composer", useAttachment };
|
3794
|
+
return { type: "composer", useAttachment: useAttachment2 };
|
3702
3795
|
}
|
3703
3796
|
);
|
3704
3797
|
_react.useEffect.call(void 0, () => {
|
@@ -3711,13 +3804,13 @@ var useComposerAttachmentContext = (partIndex) => {
|
|
3711
3804
|
if (!newState) return;
|
3712
3805
|
writableStore(context.useAttachment).setState(newState, true);
|
3713
3806
|
};
|
3714
|
-
syncAttachment(
|
3715
|
-
return
|
3716
|
-
}, [context,
|
3807
|
+
syncAttachment(threadComposerStore.getState());
|
3808
|
+
return threadComposerStore.subscribe(syncAttachment);
|
3809
|
+
}, [context, threadComposerStore, partIndex]);
|
3717
3810
|
return context;
|
3718
3811
|
};
|
3719
3812
|
var ComposerAttachmentProvider = ({ attachmentIndex: partIndex, children }) => {
|
3720
|
-
const context =
|
3813
|
+
const context = useComposerAttachmentContext2(partIndex);
|
3721
3814
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentContext.Provider, { value: context, children });
|
3722
3815
|
};
|
3723
3816
|
|
@@ -3727,19 +3820,18 @@ var getComponent2 = (components, attachment) => {
|
|
3727
3820
|
const type = attachment.type;
|
3728
3821
|
switch (type) {
|
3729
3822
|
case "image":
|
3730
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3823
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _158 => _158.Image]), () => ( _optionalChain([components, 'optionalAccess', _159 => _159.Attachment])));
|
3731
3824
|
case "document":
|
3732
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3825
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _160 => _160.Document]), () => ( _optionalChain([components, 'optionalAccess', _161 => _161.Attachment])));
|
3733
3826
|
case "file":
|
3734
|
-
return _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3827
|
+
return _nullishCoalesce(_optionalChain([components, 'optionalAccess', _162 => _162.File]), () => ( _optionalChain([components, 'optionalAccess', _163 => _163.Attachment])));
|
3735
3828
|
default:
|
3736
3829
|
const _exhaustiveCheck = type;
|
3737
3830
|
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
3738
3831
|
}
|
3739
3832
|
};
|
3740
3833
|
var AttachmentComponent2 = ({ components }) => {
|
3741
|
-
const
|
3742
|
-
const Component = useAttachment(
|
3834
|
+
const Component = useComposerAttachment(
|
3743
3835
|
(a) => getComponent2(components, a.attachment)
|
3744
3836
|
);
|
3745
3837
|
if (!Component) return null;
|
@@ -3750,11 +3842,10 @@ var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
3750
3842
|
};
|
3751
3843
|
var ComposerAttachment = _react.memo.call(void 0,
|
3752
3844
|
ComposerAttachmentImpl,
|
3753
|
-
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access',
|
3845
|
+
(prev, next) => prev.attachmentIndex === next.attachmentIndex && _optionalChain([prev, 'access', _164 => _164.components, 'optionalAccess', _165 => _165.Image]) === _optionalChain([next, 'access', _166 => _166.components, 'optionalAccess', _167 => _167.Image]) && _optionalChain([prev, 'access', _168 => _168.components, 'optionalAccess', _169 => _169.Document]) === _optionalChain([next, 'access', _170 => _170.components, 'optionalAccess', _171 => _171.Document]) && _optionalChain([prev, 'access', _172 => _172.components, 'optionalAccess', _173 => _173.File]) === _optionalChain([next, 'access', _174 => _174.components, 'optionalAccess', _175 => _175.File]) && _optionalChain([prev, 'access', _176 => _176.components, 'optionalAccess', _177 => _177.Attachment]) === _optionalChain([next, 'access', _178 => _178.components, 'optionalAccess', _179 => _179.Attachment])
|
3754
3846
|
);
|
3755
3847
|
var ComposerPrimitiveAttachments = ({ components }) => {
|
3756
|
-
const
|
3757
|
-
const attachmentsCount = useComposer((s) => s.attachments.length);
|
3848
|
+
const attachmentsCount = useThreadComposer((s) => s.attachments.length);
|
3758
3849
|
return Array.from({ length: attachmentsCount }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
3759
3850
|
ComposerAttachment,
|
3760
3851
|
{
|
@@ -3879,12 +3970,12 @@ var useOnResizeContent = (callback) => {
|
|
3879
3970
|
|
3880
3971
|
var useOnScrollToBottom = (callback) => {
|
3881
3972
|
const callbackRef = _reactusecallbackref.useCallbackRef.call(void 0, callback);
|
3882
|
-
const
|
3973
|
+
const threadViewportStore = useThreadViewportStore();
|
3883
3974
|
_react.useEffect.call(void 0, () => {
|
3884
|
-
return
|
3975
|
+
return threadViewportStore.getState().onScrollToBottom(() => {
|
3885
3976
|
callbackRef();
|
3886
3977
|
});
|
3887
|
-
}, [
|
3978
|
+
}, [threadViewportStore, callbackRef]);
|
3888
3979
|
};
|
3889
3980
|
|
3890
3981
|
// src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
|
@@ -3892,7 +3983,7 @@ var useThreadViewportAutoScroll = ({
|
|
3892
3983
|
autoScroll = true
|
3893
3984
|
}) => {
|
3894
3985
|
const divRef = _react.useRef.call(void 0, null);
|
3895
|
-
const
|
3986
|
+
const threadViewportStore = useThreadViewportStore();
|
3896
3987
|
const lastScrollTop = _react.useRef.call(void 0, 0);
|
3897
3988
|
const isScrollingToBottomRef = _react.useRef.call(void 0, false);
|
3898
3989
|
const scrollToBottom = (behavior) => {
|
@@ -3904,7 +3995,7 @@ var useThreadViewportAutoScroll = ({
|
|
3904
3995
|
const handleScroll = () => {
|
3905
3996
|
const div = divRef.current;
|
3906
3997
|
if (!div) return;
|
3907
|
-
const isAtBottom =
|
3998
|
+
const isAtBottom = threadViewportStore.getState().isAtBottom;
|
3908
3999
|
const newIsAtBottom = div.scrollHeight - div.scrollTop <= div.clientHeight + 1;
|
3909
4000
|
if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {
|
3910
4001
|
} else {
|
@@ -3912,13 +4003,15 @@ var useThreadViewportAutoScroll = ({
|
|
3912
4003
|
isScrollingToBottomRef.current = false;
|
3913
4004
|
}
|
3914
4005
|
if (newIsAtBottom !== isAtBottom) {
|
3915
|
-
writableStore(
|
4006
|
+
writableStore(threadViewportStore).setState({
|
4007
|
+
isAtBottom: newIsAtBottom
|
4008
|
+
});
|
3916
4009
|
}
|
3917
4010
|
}
|
3918
4011
|
lastScrollTop.current = div.scrollTop;
|
3919
4012
|
};
|
3920
4013
|
const resizeRef = useOnResizeContent(() => {
|
3921
|
-
if (isScrollingToBottomRef.current ||
|
4014
|
+
if (isScrollingToBottomRef.current || threadViewportStore.getState().isAtBottom) {
|
3922
4015
|
scrollToBottom("instant");
|
3923
4016
|
}
|
3924
4017
|
handleScroll();
|
@@ -3938,7 +4031,7 @@ var useThreadViewportAutoScroll = ({
|
|
3938
4031
|
|
3939
4032
|
// src/primitives/thread/ThreadViewport.tsx
|
3940
4033
|
|
3941
|
-
var ThreadPrimitiveViewport = _react.forwardRef.call(void 0, ({ autoScroll,
|
4034
|
+
var ThreadPrimitiveViewport = _react.forwardRef.call(void 0, ({ autoScroll, children, ...rest }, forwardedRef) => {
|
3942
4035
|
const autoScrollRef = useThreadViewportAutoScroll({
|
3943
4036
|
autoScroll
|
3944
4037
|
});
|
@@ -3960,6 +4053,7 @@ var makeEditComposerStore = ({
|
|
3960
4053
|
onEdit,
|
3961
4054
|
onSend
|
3962
4055
|
}) => _zustand.create.call(void 0, )((set, get) => ({
|
4056
|
+
type: "edit",
|
3963
4057
|
get value() {
|
3964
4058
|
return get().text;
|
3965
4059
|
},
|
@@ -4007,7 +4101,7 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
|
4007
4101
|
},
|
4008
4102
|
isSpeaking: false,
|
4009
4103
|
stopSpeaking: () => {
|
4010
|
-
_optionalChain([utterance, 'optionalAccess',
|
4104
|
+
_optionalChain([utterance, 'optionalAccess', _180 => _180.cancel, 'call', _181 => _181()]);
|
4011
4105
|
},
|
4012
4106
|
addUtterance: (utt) => {
|
4013
4107
|
utterance = utt;
|
@@ -4022,15 +4116,15 @@ var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
|
4022
4116
|
// src/context/providers/MessageProvider.tsx
|
4023
4117
|
|
4024
4118
|
var getIsLast = (messages, message) => {
|
4025
|
-
return _optionalChain([messages, 'access',
|
4119
|
+
return _optionalChain([messages, 'access', _182 => _182[messages.length - 1], 'optionalAccess', _183 => _183.id]) === message.id;
|
4026
4120
|
};
|
4027
|
-
var getMessageState = (messages, getBranches,
|
4028
|
-
const parentId = _nullishCoalesce(_optionalChain([messages, 'access',
|
4121
|
+
var getMessageState = (messages, getBranches, useMessage2, messageIndex) => {
|
4122
|
+
const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _184 => _184[messageIndex - 1], 'optionalAccess', _185 => _185.id]), () => ( null));
|
4029
4123
|
const message = messages[messageIndex];
|
4030
4124
|
if (!message) return null;
|
4031
4125
|
const isLast = getIsLast(messages, message);
|
4032
4126
|
const branches = getBranches(message.id);
|
4033
|
-
const currentState = _optionalChain([
|
4127
|
+
const currentState = _optionalChain([useMessage2, 'optionalAccess', _186 => _186.getState, 'call', _187 => _187()]);
|
4034
4128
|
if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
|
4035
4129
|
return null;
|
4036
4130
|
return Object.freeze({
|
@@ -4041,62 +4135,55 @@ var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
|
4041
4135
|
});
|
4042
4136
|
};
|
4043
4137
|
var useMessageContext2 = (messageIndex) => {
|
4044
|
-
const
|
4138
|
+
const threadMessagesStore = useThreadMessagesStore();
|
4139
|
+
const threadActionsStore = useThreadActionsStore();
|
4045
4140
|
const [context] = _react.useState.call(void 0, () => {
|
4046
|
-
const
|
4141
|
+
const useMessage2 = _zustand.create.call(void 0,
|
4047
4142
|
() => getMessageState(
|
4048
|
-
|
4049
|
-
|
4143
|
+
threadMessagesStore.getState(),
|
4144
|
+
threadActionsStore.getState().getBranches,
|
4050
4145
|
void 0,
|
4051
4146
|
messageIndex
|
4052
4147
|
)
|
4053
4148
|
);
|
4054
|
-
const
|
4055
|
-
const
|
4149
|
+
const useMessageUtils2 = makeMessageUtilsStore();
|
4150
|
+
const useEditComposer2 = makeEditComposerStore({
|
4056
4151
|
onEdit: () => {
|
4057
|
-
const message =
|
4058
|
-
if (message.role !== "user")
|
4059
|
-
throw new Error(
|
4060
|
-
"Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui."
|
4061
|
-
);
|
4152
|
+
const message = useMessage2.getState().message;
|
4062
4153
|
const text = getThreadMessageText(message);
|
4063
4154
|
return text;
|
4064
4155
|
},
|
4065
4156
|
onSend: (text) => {
|
4066
|
-
const { message, parentId } =
|
4067
|
-
if (message.role !== "user")
|
4068
|
-
throw new Error(
|
4069
|
-
"Tried to edit a non-user message. Editing is only supported for user messages. This is likely an internal bug in assistant-ui."
|
4070
|
-
);
|
4157
|
+
const { message, parentId } = useMessage2.getState();
|
4071
4158
|
const previousText = getThreadMessageText(message);
|
4072
4159
|
if (previousText === text) return;
|
4073
4160
|
const nonTextParts = message.content.filter(
|
4074
4161
|
(part) => part.type !== "text" && part.type !== "ui"
|
4075
4162
|
);
|
4076
|
-
|
4163
|
+
threadActionsStore.getState().append({
|
4077
4164
|
parentId,
|
4078
|
-
role:
|
4165
|
+
role: message.role,
|
4079
4166
|
content: [{ type: "text", text }, ...nonTextParts],
|
4080
4167
|
attachments: message.attachments
|
4081
4168
|
});
|
4082
4169
|
}
|
4083
4170
|
});
|
4084
|
-
return { useMessage, useMessageUtils, useEditComposer };
|
4171
|
+
return { useMessage: useMessage2, useMessageUtils: useMessageUtils2, useEditComposer: useEditComposer2 };
|
4085
4172
|
});
|
4086
4173
|
_react.useEffect.call(void 0, () => {
|
4087
4174
|
const syncMessage = (thread) => {
|
4088
4175
|
const newState = getMessageState(
|
4089
4176
|
thread,
|
4090
|
-
|
4177
|
+
threadActionsStore.getState().getBranches,
|
4091
4178
|
context.useMessage,
|
4092
4179
|
messageIndex
|
4093
4180
|
);
|
4094
4181
|
if (!newState) return;
|
4095
4182
|
writableStore(context.useMessage).setState(newState, true);
|
4096
4183
|
};
|
4097
|
-
syncMessage(
|
4098
|
-
return
|
4099
|
-
}, [
|
4184
|
+
syncMessage(threadMessagesStore.getState());
|
4185
|
+
return threadMessagesStore.subscribe(syncMessage);
|
4186
|
+
}, [threadMessagesStore, threadActionsStore, context, messageIndex]);
|
4100
4187
|
return context;
|
4101
4188
|
};
|
4102
4189
|
var MessageProvider = ({
|
@@ -4109,37 +4196,56 @@ var MessageProvider = ({
|
|
4109
4196
|
|
4110
4197
|
// src/primitives/thread/ThreadMessages.tsx
|
4111
4198
|
|
4199
|
+
var isComponentsSame = (prev, next) => {
|
4200
|
+
return prev.Message === next.Message && prev.EditComposer === next.EditComposer && prev.UserEditComposer === next.UserEditComposer && prev.AssistantEditComposer === next.AssistantEditComposer && prev.SystemEditComposer === next.SystemEditComposer && prev.UserMessage === next.UserMessage && prev.AssistantMessage === next.AssistantMessage && prev.SystemMessage === next.SystemMessage;
|
4201
|
+
};
|
4112
4202
|
var DEFAULT_SYSTEM_MESSAGE = () => null;
|
4113
|
-
var
|
4114
|
-
|
4115
|
-
|
4116
|
-
|
4117
|
-
|
4118
|
-
|
4119
|
-
|
4203
|
+
var getComponent3 = (components, role, isEditing) => {
|
4204
|
+
switch (role) {
|
4205
|
+
case "user":
|
4206
|
+
if (isEditing) {
|
4207
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(components.UserEditComposer, () => ( components.EditComposer)), () => ( components.UserMessage)), () => ( components.Message));
|
4208
|
+
} else {
|
4209
|
+
return _nullishCoalesce(components.UserMessage, () => ( components.Message));
|
4210
|
+
}
|
4211
|
+
case "assistant":
|
4212
|
+
if (isEditing) {
|
4213
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(components.AssistantEditComposer, () => ( components.EditComposer)), () => ( components.AssistantMessage)), () => ( components.Message));
|
4214
|
+
} else {
|
4215
|
+
return _nullishCoalesce(components.AssistantMessage, () => ( components.Message));
|
4216
|
+
}
|
4217
|
+
case "system":
|
4218
|
+
if (isEditing) {
|
4219
|
+
return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(components.SystemEditComposer, () => ( components.EditComposer)), () => ( components.SystemMessage)), () => ( components.Message));
|
4220
|
+
} else {
|
4221
|
+
return _nullishCoalesce(components.SystemMessage, () => ( DEFAULT_SYSTEM_MESSAGE));
|
4222
|
+
}
|
4223
|
+
default:
|
4224
|
+
const _exhaustiveCheck = role;
|
4225
|
+
throw new Error(`Unknown message role: ${_exhaustiveCheck}`);
|
4226
|
+
}
|
4227
|
+
};
|
4228
|
+
var ThreadMessageComponent = ({
|
4229
|
+
components
|
4230
|
+
}) => {
|
4231
|
+
const role = useMessage((m) => m.message.role);
|
4232
|
+
const isEditing = useEditComposer((c) => c.isEditing);
|
4233
|
+
const Component = getComponent3(components, role, isEditing);
|
4234
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, {});
|
4120
4235
|
};
|
4121
4236
|
var ThreadMessageImpl = ({
|
4122
4237
|
messageIndex,
|
4123
4238
|
components
|
4124
4239
|
}) => {
|
4125
|
-
|
4126
|
-
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MessageProvider, { messageIndex, children: [
|
4127
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MessagePrimitiveIf, { user: true, children: [
|
4128
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessage2, {}) }),
|
4129
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposer2, {}) })
|
4130
|
-
] }),
|
4131
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessage2, {}) }),
|
4132
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { system: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SystemMessage2, {}) })
|
4133
|
-
] });
|
4240
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageProvider, { messageIndex, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessageComponent, { components }) });
|
4134
4241
|
};
|
4135
4242
|
var ThreadMessage = _react.memo.call(void 0,
|
4136
4243
|
ThreadMessageImpl,
|
4137
|
-
(prev, next) => prev.messageIndex === next.messageIndex && prev.components
|
4244
|
+
(prev, next) => prev.messageIndex === next.messageIndex && isComponentsSame(prev.components, next.components)
|
4138
4245
|
);
|
4139
4246
|
var ThreadPrimitiveMessagesImpl = ({
|
4140
4247
|
components
|
4141
4248
|
}) => {
|
4142
|
-
const { useThreadMessages } = useThreadContext();
|
4143
4249
|
const messagesLength = useThreadMessages((t) => t.length);
|
4144
4250
|
if (messagesLength === 0) return null;
|
4145
4251
|
return Array.from({ length: messagesLength }, (_, index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessage, { messageIndex: index, components }, index));
|
@@ -4147,7 +4253,7 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
4147
4253
|
ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
|
4148
4254
|
var ThreadPrimitiveMessages = _react.memo.call(void 0,
|
4149
4255
|
ThreadPrimitiveMessagesImpl,
|
4150
|
-
(prev, next) =>
|
4256
|
+
(prev, next) => isComponentsSame(prev.components, next.components)
|
4151
4257
|
);
|
4152
4258
|
|
4153
4259
|
// src/primitives/thread/ThreadScrollToBottom.tsx
|
@@ -4177,10 +4283,10 @@ var ThreadConfigProvider = ({
|
|
4177
4283
|
children,
|
4178
4284
|
config
|
4179
4285
|
}) => {
|
4180
|
-
const
|
4286
|
+
const hasAssistant = !!useAssistantRuntimeStore({ optional: true });
|
4181
4287
|
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 });
|
4182
|
-
if (!_optionalChain([config, 'optionalAccess',
|
4183
|
-
if (
|
4288
|
+
if (!_optionalChain([config, 'optionalAccess', _188 => _188.runtime])) return configProvider;
|
4289
|
+
if (hasAssistant) {
|
4184
4290
|
throw new Error(
|
4185
4291
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
4186
4292
|
);
|
@@ -4201,19 +4307,16 @@ var _lucidereact = require('lucide-react');
|
|
4201
4307
|
|
4202
4308
|
var useAllowCopy = (ensureCapability = false) => {
|
4203
4309
|
const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
|
4204
|
-
const { useThread } = useThreadContext();
|
4205
4310
|
const copySupported = useThread((t) => t.capabilities.unstable_copy);
|
4206
4311
|
return allowCopy && (!ensureCapability || copySupported);
|
4207
4312
|
};
|
4208
4313
|
var useAllowSpeak = (ensureCapability = false) => {
|
4209
4314
|
const { assistantMessage: { allowSpeak = true } = {} } = useThreadConfig();
|
4210
|
-
const { useThread } = useThreadContext();
|
4211
4315
|
const speakSupported = useThread((t) => t.capabilities.speak);
|
4212
4316
|
return allowSpeak && (!ensureCapability || speakSupported);
|
4213
4317
|
};
|
4214
4318
|
var useAllowReload = (ensureCapability = false) => {
|
4215
4319
|
const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();
|
4216
|
-
const { useThread } = useThreadContext();
|
4217
4320
|
const reloadSupported = useThread((t) => t.capabilities.reload);
|
4218
4321
|
return allowReload && (!ensureCapability || reloadSupported);
|
4219
4322
|
};
|
@@ -4313,7 +4416,6 @@ var assistant_action_bar_default = Object.assign(
|
|
4313
4416
|
|
4314
4417
|
var useAllowBranchPicker = (ensureCapability = false) => {
|
4315
4418
|
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
4316
|
-
const { useThread } = useThreadContext();
|
4317
4419
|
const branchPickerSupported = useThread((t) => t.capabilities.edit);
|
4318
4420
|
return allowBranchPicker && (!ensureCapability || branchPickerSupported);
|
4319
4421
|
};
|
@@ -4452,7 +4554,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
4452
4554
|
{
|
4453
4555
|
components: {
|
4454
4556
|
...componentsProp,
|
4455
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
4557
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _189 => _189.Text]), () => ( components.Text)), () => ( content_part_default.Text)),
|
4456
4558
|
tools: toolsComponents
|
4457
4559
|
}
|
4458
4560
|
}
|
@@ -4507,8 +4609,7 @@ var ComposerAttachmentRoot = withDefaults("div", {
|
|
4507
4609
|
});
|
4508
4610
|
ComposerAttachmentRoot.displayName = "ComposerAttachmentRoot";
|
4509
4611
|
var ComposerAttachment2 = () => {
|
4510
|
-
const
|
4511
|
-
const attachment = useAttachment((a) => a.attachment);
|
4612
|
+
const attachment = useComposerAttachment((a) => a.attachment);
|
4512
4613
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerAttachmentRoot, { children: [
|
4513
4614
|
".",
|
4514
4615
|
attachment.name.split(".").pop(),
|
@@ -4522,10 +4623,10 @@ var ComposerAttachmentRemove = _react.forwardRef.call(void 0, (props, ref) => {
|
|
4522
4623
|
composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {}
|
4523
4624
|
} = {}
|
4524
4625
|
} = useThreadConfig();
|
4525
|
-
const
|
4526
|
-
const
|
4626
|
+
const composerStore = useThreadComposerStore();
|
4627
|
+
const attachmentStore = useAttachmentStore();
|
4527
4628
|
const handleRemoveAttachment = () => {
|
4528
|
-
|
4629
|
+
composerStore.getState().removeAttachment(attachmentStore.getState().attachment.id);
|
4529
4630
|
};
|
4530
4631
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4531
4632
|
TooltipIconButton,
|
@@ -4554,7 +4655,6 @@ var composer_attachment_default = Object.assign(
|
|
4554
4655
|
|
4555
4656
|
var useAllowAttachments = (ensureCapability = false) => {
|
4556
4657
|
const { composer: { allowAttachments = true } = {} } = useThreadConfig();
|
4557
|
-
const { useThread } = useThreadContext();
|
4558
4658
|
const attachmentsSupported = useThread((t) => t.capabilities.attachments);
|
4559
4659
|
return allowAttachments && (!ensureCapability || attachmentsSupported);
|
4560
4660
|
};
|
@@ -4597,7 +4697,7 @@ var ComposerAttachments = ({ components }) => {
|
|
4597
4697
|
{
|
4598
4698
|
components: {
|
4599
4699
|
...components,
|
4600
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4700
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _190 => _190.Attachment]), () => ( composer_attachment_default))
|
4601
4701
|
}
|
4602
4702
|
}
|
4603
4703
|
) });
|
@@ -4626,7 +4726,6 @@ var ComposerAddAttachment = _react.forwardRef.call(void 0, (props, ref) => {
|
|
4626
4726
|
});
|
4627
4727
|
ComposerAddAttachment.displayName = "ComposerAddAttachment";
|
4628
4728
|
var useAllowCancel = () => {
|
4629
|
-
const { useThread } = useThreadContext();
|
4630
4729
|
const cancelSupported = useThread((t) => t.capabilities.cancel);
|
4631
4730
|
return cancelSupported;
|
4632
4731
|
};
|
@@ -4730,7 +4829,7 @@ var ThreadWelcomeSuggestion = ({
|
|
4730
4829
|
};
|
4731
4830
|
var ThreadWelcomeSuggestions = () => {
|
4732
4831
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
4733
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess',
|
4832
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _191 => _191.map, 'call', _192 => _192((suggestion, idx) => {
|
4734
4833
|
const key = `${suggestion.prompt}-${idx}`;
|
4735
4834
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
4736
4835
|
})]) });
|
@@ -4755,7 +4854,6 @@ var thread_welcome_default = Object.assign(ThreadWelcome, exports7);
|
|
4755
4854
|
|
4756
4855
|
var useAllowEdit = (ensureCapability = false) => {
|
4757
4856
|
const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
|
4758
|
-
const { useThread } = useThreadContext();
|
4759
4857
|
const editSupported = useThread((t) => t.capabilities.edit);
|
4760
4858
|
return allowEdit && (!ensureCapability || editSupported);
|
4761
4859
|
};
|
@@ -4790,7 +4888,6 @@ var UserMessageAttachmentRoot = withDefaults("div", {
|
|
4790
4888
|
});
|
4791
4889
|
UserMessageAttachmentRoot.displayName = "UserMessageAttachmentRoot";
|
4792
4890
|
var UserMessageAttachment = () => {
|
4793
|
-
const { useAttachment } = useAttachmentContext();
|
4794
4891
|
const attachment = useAttachment((a) => a.attachment);
|
4795
4892
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageAttachmentRoot, { children: [
|
4796
4893
|
".",
|
@@ -4831,7 +4928,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
|
|
4831
4928
|
{
|
4832
4929
|
components: {
|
4833
4930
|
...components,
|
4834
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4931
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _193 => _193.Text]), () => ( content_part_default.Text))
|
4835
4932
|
}
|
4836
4933
|
}
|
4837
4934
|
) });
|
@@ -4849,7 +4946,7 @@ var UserMessageAttachments = ({
|
|
4849
4946
|
{
|
4850
4947
|
components: {
|
4851
4948
|
...components,
|
4852
|
-
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4949
|
+
Attachment: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _194 => _194.Attachment]), () => ( user_message_attachment_default))
|
4853
4950
|
}
|
4854
4951
|
}
|
4855
4952
|
) }) });
|
@@ -4950,10 +5047,10 @@ var ThreadMessages = ({ components, ...rest }) => {
|
|
4950
5047
|
thread_exports.Messages,
|
4951
5048
|
{
|
4952
5049
|
components: {
|
4953
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4954
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4955
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4956
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
5050
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _195 => _195.UserMessage]), () => ( user_message_default)),
|
5051
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _196 => _196.EditComposer]), () => ( edit_composer_default)),
|
5052
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _197 => _197.AssistantMessage]), () => ( assistant_message_default)),
|
5053
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _198 => _198.SystemMessage]), () => ( SystemMessage))
|
4957
5054
|
},
|
4958
5055
|
...rest
|
4959
5056
|
}
|
@@ -5143,5 +5240,33 @@ var assistant_modal_default = Object.assign(AssistantModal, exports13);
|
|
5143
5240
|
|
5144
5241
|
|
5145
5242
|
|
5146
|
-
|
5243
|
+
|
5244
|
+
|
5245
|
+
|
5246
|
+
|
5247
|
+
|
5248
|
+
|
5249
|
+
|
5250
|
+
|
5251
|
+
|
5252
|
+
|
5253
|
+
|
5254
|
+
|
5255
|
+
|
5256
|
+
|
5257
|
+
|
5258
|
+
|
5259
|
+
|
5260
|
+
|
5261
|
+
|
5262
|
+
|
5263
|
+
|
5264
|
+
|
5265
|
+
|
5266
|
+
|
5267
|
+
|
5268
|
+
|
5269
|
+
|
5270
|
+
|
5271
|
+
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerAttachment = composer_attachment_default; exports.ComposerPrimitive = composer_exports; exports.CompositeAttachmentAdapter = CompositeAttachmentAdapter; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.SimpleImageAttachmentAdapter = SimpleImageAttachmentAdapter; exports.SimpleTextAttachmentAdapter = SimpleTextAttachmentAdapter; exports.TextContentPartProvider = TextContentPartProvider; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.UserMessageAttachment = user_message_attachment_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkCWAZOKEWjs.toCoreMessage; exports.toCoreMessages = _chunkCWAZOKEWjs.toCoreMessages; exports.toLanguageModelMessages = _chunkCWAZOKEWjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkCWAZOKEWjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantActions = useAssistantActions; exports.useAssistantActionsStore = useAssistantActionsStore; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantRuntime = useAssistantRuntime; exports.useAssistantRuntimeStore = useAssistantRuntimeStore; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposer = useComposer; exports.useComposerAddAttachment = useComposerAddAttachment; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useComposerStore = useComposerStore; exports.useContentPart = useContentPart; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartStore = useContentPartStore; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useEditComposer = useEditComposer; exports.useEditComposerStore = useEditComposerStore; exports.useExternalMessageConverter = useExternalMessageConverter; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessage = useMessage; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useMessageStore = useMessageStore; exports.useMessageUtils = useMessageUtils; exports.useMessageUtilsStore = useMessageUtilsStore; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThread = useThread; exports.useThreadActions = useThreadActions; exports.useThreadActionsStore = useThreadActionsStore; exports.useThreadComposer = useThreadComposer; exports.useThreadComposerStore = useThreadComposerStore; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadMessages = useThreadMessages; exports.useThreadMessagesStore = useThreadMessagesStore; exports.useThreadRuntime = useThreadRuntime; exports.useThreadRuntimeStore = useThreadRuntimeStore; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadStore = useThreadStore; exports.useThreadSuggestion = useThreadSuggestion; exports.useThreadViewport = useThreadViewport; exports.useThreadViewportStore = useThreadViewportStore; exports.useToolUIs = useToolUIs; exports.useToolUIsStore = useToolUIsStore;
|
5147
5272
|
//# sourceMappingURL=index.js.map
|