@assistant-ui/react 0.5.70 → 0.5.71
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/{edge-BhYWMe-K.d.mts → edge-DRioHVD9.d.mts} +6 -7
- package/dist/{edge-BhYWMe-K.d.ts → edge-DRioHVD9.d.ts} +6 -7
- package/dist/index.d.mts +284 -43
- package/dist/index.d.ts +284 -43
- package/dist/index.js +140 -102
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -88
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css +48 -3
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +12 -4
- package/dist/tailwindcss/index.js +2 -2
- package/dist/tailwindcss/index.js.map +1 -1
- package/dist/tailwindcss/index.mjs +1 -1
- package/dist/tailwindcss/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
@@ -288,7 +288,7 @@ var { useContentPart, useContentPartStore } = createContextStoreHook(
|
|
288
288
|
);
|
289
289
|
|
290
290
|
// src/api/ContentPartRuntime.ts
|
291
|
-
var
|
291
|
+
var ContentPartRuntimeImpl = class {
|
292
292
|
constructor(contentBinding, messageApi, threadApi) {
|
293
293
|
this.contentBinding = contentBinding;
|
294
294
|
this.messageApi = messageApi;
|
@@ -330,7 +330,7 @@ var TextContentPartProvider = ({ children, text, isRunning }) => {
|
|
330
330
|
const [context] = _react.useState.call(void 0, () => {
|
331
331
|
const useContentPartRuntime2 = _zustand.create.call(void 0,
|
332
332
|
// TODO
|
333
|
-
() => new
|
333
|
+
() => new ContentPartRuntimeImpl(null, null, null)
|
334
334
|
);
|
335
335
|
const useContentPart2 = _zustand.create.call(void 0, () => ({
|
336
336
|
status: isRunning ? RUNNING_STATUS : COMPLETE_STATUS,
|
@@ -1585,7 +1585,7 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
1585
1585
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
1586
1586
|
|
1587
1587
|
// src/api/AttachmentRuntime.ts
|
1588
|
-
var
|
1588
|
+
var AttachmentRuntimeImpl = class {
|
1589
1589
|
constructor(_core) {
|
1590
1590
|
this._core = _core;
|
1591
1591
|
}
|
@@ -1596,7 +1596,7 @@ var AttachmentRuntime = class {
|
|
1596
1596
|
return this._core.subscribe(callback);
|
1597
1597
|
}
|
1598
1598
|
};
|
1599
|
-
var ComposerAttachmentRuntime = class extends
|
1599
|
+
var ComposerAttachmentRuntime = class extends AttachmentRuntimeImpl {
|
1600
1600
|
constructor(core, _composerApi) {
|
1601
1601
|
super(core);
|
1602
1602
|
this._composerApi = _composerApi;
|
@@ -1607,17 +1607,17 @@ var ComposerAttachmentRuntime = class extends AttachmentRuntime {
|
|
1607
1607
|
return core.removeAttachment(this.getState().id);
|
1608
1608
|
}
|
1609
1609
|
};
|
1610
|
-
var
|
1610
|
+
var ThreadComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
|
1611
1611
|
get source() {
|
1612
1612
|
return "thread-composer";
|
1613
1613
|
}
|
1614
1614
|
};
|
1615
|
-
var
|
1615
|
+
var EditComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
|
1616
1616
|
get source() {
|
1617
1617
|
return "edit-composer";
|
1618
1618
|
}
|
1619
1619
|
};
|
1620
|
-
var
|
1620
|
+
var MessageAttachmentRuntimeImpl = class extends AttachmentRuntimeImpl {
|
1621
1621
|
get source() {
|
1622
1622
|
return "message";
|
1623
1623
|
}
|
@@ -1779,7 +1779,7 @@ var getEditComposerState = (runtime, beginEdit) => {
|
|
1779
1779
|
cancel: _nullishCoalesce(_optionalChain([runtime, 'optionalAccess', _62 => _62.cancel, 'access', _63 => _63.bind, 'call', _64 => _64(runtime)]), () => ( METHOD_NOT_SUPPORTED))
|
1780
1780
|
});
|
1781
1781
|
};
|
1782
|
-
var
|
1782
|
+
var ComposerRuntimeImpl = class {
|
1783
1783
|
constructor(_core) {
|
1784
1784
|
this._core = _core;
|
1785
1785
|
}
|
@@ -1838,9 +1838,9 @@ var ComposerRuntime = class {
|
|
1838
1838
|
if (!core) throw new Error("Composer is not available");
|
1839
1839
|
return core.addAttachment(file);
|
1840
1840
|
}
|
1841
|
-
|
1842
|
-
|
1843
|
-
|
1841
|
+
/**
|
1842
|
+
* @deprecated Use `getAttachmentById(id).removeAttachment()` instead. This will be removed in 0.6.0.
|
1843
|
+
*/
|
1844
1844
|
removeAttachment(attachmentId) {
|
1845
1845
|
const core = this._core.getState();
|
1846
1846
|
if (!core) throw new Error("Composer is not available");
|
@@ -1868,7 +1868,7 @@ var ComposerRuntime = class {
|
|
1868
1868
|
return this._core.subscribe(callback);
|
1869
1869
|
}
|
1870
1870
|
};
|
1871
|
-
var
|
1871
|
+
var ThreadComposerRuntimeImpl = (_class5 = class extends ComposerRuntimeImpl {
|
1872
1872
|
get type() {
|
1873
1873
|
return "thread";
|
1874
1874
|
}
|
@@ -1896,15 +1896,21 @@ var ThreadComposerRuntime = (_class5 = class extends ComposerRuntime {
|
|
1896
1896
|
}
|
1897
1897
|
// TODO replace with events
|
1898
1898
|
__init9() {this._focusListeners = /* @__PURE__ */ new Set()}
|
1899
|
+
/**
|
1900
|
+
* @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
|
1901
|
+
*/
|
1899
1902
|
focus() {
|
1900
1903
|
this._focusListeners.forEach((callback) => callback());
|
1901
1904
|
}
|
1905
|
+
/**
|
1906
|
+
* @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
|
1907
|
+
*/
|
1902
1908
|
onFocus(callback) {
|
1903
1909
|
this._focusListeners.add(callback);
|
1904
1910
|
return () => this._focusListeners.delete(callback);
|
1905
1911
|
}
|
1906
|
-
|
1907
|
-
return new
|
1912
|
+
getAttachmentByIndex(idx) {
|
1913
|
+
return new ThreadComposerAttachmentRuntimeImpl(
|
1908
1914
|
new ShallowMemoizeSubject({
|
1909
1915
|
getState: () => {
|
1910
1916
|
const attachments = this.getState().attachments;
|
@@ -1922,7 +1928,7 @@ var ThreadComposerRuntime = (_class5 = class extends ComposerRuntime {
|
|
1922
1928
|
);
|
1923
1929
|
}
|
1924
1930
|
}, _class5);
|
1925
|
-
var
|
1931
|
+
var EditComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
1926
1932
|
constructor(core, _beginEdit) {
|
1927
1933
|
const stateBinding = new LazyMemoizeSubject({
|
1928
1934
|
getState: () => getEditComposerState(core.getState(), this._beginEdit),
|
@@ -1951,8 +1957,8 @@ var EditComposerRuntime = class extends ComposerRuntime {
|
|
1951
1957
|
edit() {
|
1952
1958
|
this.beginEdit();
|
1953
1959
|
}
|
1954
|
-
|
1955
|
-
return new
|
1960
|
+
getAttachmentByIndex(idx) {
|
1961
|
+
return new EditComposerAttachmentRuntimeImpl(
|
1956
1962
|
new ShallowMemoizeSubject({
|
1957
1963
|
getState: () => {
|
1958
1964
|
const attachments = this.getState().attachments;
|
@@ -2036,12 +2042,12 @@ var getContentPartState = (message, partIndex) => {
|
|
2036
2042
|
const status = toContentPartStatus(message, partIndex, part);
|
2037
2043
|
return Object.freeze({ ...part, part, status });
|
2038
2044
|
};
|
2039
|
-
var
|
2045
|
+
var MessageRuntimeImpl = (_class6 = class {
|
2040
2046
|
constructor(_core, _threadBinding) {;_class6.prototype.__init10.call(this);
|
2041
2047
|
this._core = _core;
|
2042
2048
|
this._threadBinding = _threadBinding;
|
2043
2049
|
}
|
2044
|
-
__init10() {this.composer = new
|
2050
|
+
__init10() {this.composer = new EditComposerRuntimeImpl(
|
2045
2051
|
new NestedSubscriptionSubject({
|
2046
2052
|
getState: () => this._threadBinding.getState().getEditComposer(this._core.getState().id),
|
2047
2053
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
@@ -2051,15 +2057,6 @@ var MessageRuntime = (_class6 = class {
|
|
2051
2057
|
getState() {
|
2052
2058
|
return this._core.getState();
|
2053
2059
|
}
|
2054
|
-
// TODO improve type
|
2055
|
-
unstable_edit(message) {
|
2056
|
-
const state = this._core.getState();
|
2057
|
-
if (!state) throw new Error("Message is not available");
|
2058
|
-
this._threadBinding.getState().append({
|
2059
|
-
...message,
|
2060
|
-
parentId: state.parentId
|
2061
|
-
});
|
2062
|
-
}
|
2063
2060
|
reload() {
|
2064
2061
|
const state = this._core.getState();
|
2065
2062
|
if (!state) throw new Error("Message is not available");
|
@@ -2105,9 +2102,9 @@ var MessageRuntime = (_class6 = class {
|
|
2105
2102
|
subscribe(callback) {
|
2106
2103
|
return this._core.subscribe(callback);
|
2107
2104
|
}
|
2108
|
-
|
2105
|
+
getContentPartByIndex(idx) {
|
2109
2106
|
if (idx < 0) throw new Error("Message index must be >= 0");
|
2110
|
-
return new
|
2107
|
+
return new ContentPartRuntimeImpl(
|
2111
2108
|
new ShallowMemoizeSubject({
|
2112
2109
|
getState: () => {
|
2113
2110
|
return getContentPartState(this.getState(), idx);
|
@@ -2118,8 +2115,8 @@ var MessageRuntime = (_class6 = class {
|
|
2118
2115
|
this._threadBinding
|
2119
2116
|
);
|
2120
2117
|
}
|
2121
|
-
|
2122
|
-
return new
|
2118
|
+
getAttachmentByIndex(idx) {
|
2119
|
+
return new MessageAttachmentRuntimeImpl(
|
2123
2120
|
new ShallowMemoizeSubject({
|
2124
2121
|
getState: () => {
|
2125
2122
|
const attachments = this.getState().attachments;
|
@@ -2205,7 +2202,7 @@ var MessageContentPartImpl = ({
|
|
2205
2202
|
}) => {
|
2206
2203
|
const messageRuntime = useMessageRuntime();
|
2207
2204
|
const runtime = _react.useMemo.call(void 0,
|
2208
|
-
() => messageRuntime.
|
2205
|
+
() => messageRuntime.getContentPartByIndex(partIndex),
|
2209
2206
|
[messageRuntime, partIndex]
|
2210
2207
|
);
|
2211
2208
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPartComponent, { components }) });
|
@@ -2354,7 +2351,7 @@ var AttachmentComponent = ({ components }) => {
|
|
2354
2351
|
var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
2355
2352
|
const messageRuntime = useMessageRuntime();
|
2356
2353
|
const runtime = _react.useMemo.call(void 0,
|
2357
|
-
() => messageRuntime.
|
2354
|
+
() => messageRuntime.getAttachmentByIndex(attachmentIndex),
|
2358
2355
|
[messageRuntime, attachmentIndex]
|
2359
2356
|
);
|
2360
2357
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentComponent, { components }) });
|
@@ -2557,7 +2554,7 @@ var AttachmentComponent2 = ({ components }) => {
|
|
2557
2554
|
var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
2558
2555
|
const composerRuntime = useComposerRuntime();
|
2559
2556
|
const runtime = _react.useMemo.call(void 0,
|
2560
|
-
() => composerRuntime.
|
2557
|
+
() => composerRuntime.getAttachmentByIndex(attachmentIndex),
|
2561
2558
|
[composerRuntime, attachmentIndex]
|
2562
2559
|
);
|
2563
2560
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AttachmentComponent2, { components }) });
|
@@ -2891,7 +2888,7 @@ var ThreadMessageImpl = ({
|
|
2891
2888
|
}) => {
|
2892
2889
|
const threadRuntime = useThreadRuntime();
|
2893
2890
|
const runtime = _react.useMemo.call(void 0,
|
2894
|
-
() => threadRuntime.
|
2891
|
+
() => threadRuntime.getMesssageByIndex(messageIndex),
|
2895
2892
|
[threadRuntime, messageIndex]
|
2896
2893
|
);
|
2897
2894
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessageComponent, { components }) });
|
@@ -2975,12 +2972,12 @@ var BaseAssistantRuntimeCore = (_class7 = class {
|
|
2975
2972
|
// src/internal.ts
|
2976
2973
|
var internal_exports = {};
|
2977
2974
|
_chunkPZ5AY32Cjs.__export.call(void 0, internal_exports, {
|
2978
|
-
|
2975
|
+
AssistantRuntimeImpl: () => AssistantRuntimeImpl,
|
2979
2976
|
BaseAssistantRuntimeCore: () => BaseAssistantRuntimeCore,
|
2980
2977
|
DefaultThreadComposerRuntimeCore: () => DefaultThreadComposerRuntimeCore,
|
2981
2978
|
MessageRepository: () => MessageRepository,
|
2982
2979
|
ProxyConfigProvider: () => ProxyConfigProvider,
|
2983
|
-
|
2980
|
+
ThreadRuntimeImpl: () => ThreadRuntimeImpl,
|
2984
2981
|
TooltipIconButton: () => TooltipIconButton,
|
2985
2982
|
generateId: () => generateId,
|
2986
2983
|
useSmooth: () => useSmooth,
|
@@ -3468,7 +3465,7 @@ var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, sid
|
|
3468
3465
|
TooltipIconButton.displayName = "TooltipIconButton";
|
3469
3466
|
|
3470
3467
|
// src/api/AssistantRuntime.ts
|
3471
|
-
var
|
3468
|
+
var AssistantRuntimeImpl = class {
|
3472
3469
|
constructor(_core, CustomThreadRuntime) {
|
3473
3470
|
this._core = _core;
|
3474
3471
|
this.thread = new CustomThreadRuntime(
|
@@ -3524,10 +3521,12 @@ var getThreadState = (runtime) => {
|
|
3524
3521
|
capabilities: runtime.capabilities,
|
3525
3522
|
isDisabled: runtime.isDisabled,
|
3526
3523
|
isRunning: _optionalChain([lastMessage, 'optionalAccess', _178 => _178.role]) !== "assistant" ? false : lastMessage.status.type === "running",
|
3527
|
-
messages: runtime.messages
|
3524
|
+
messages: runtime.messages,
|
3525
|
+
suggestions: runtime.suggestions,
|
3526
|
+
extras: runtime.extras
|
3528
3527
|
});
|
3529
3528
|
};
|
3530
|
-
var
|
3529
|
+
var ThreadRuntimeImpl = (_class12 = class {
|
3531
3530
|
// public path = "assistant.threads[main]"; // TODO
|
3532
3531
|
/**
|
3533
3532
|
* @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
|
@@ -3553,6 +3552,18 @@ var ThreadRuntime = (_class12 = class {
|
|
3553
3552
|
get capabilities() {
|
3554
3553
|
return this.getState().capabilities;
|
3555
3554
|
}
|
3555
|
+
/**
|
3556
|
+
* @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
|
3557
|
+
*/
|
3558
|
+
get extras() {
|
3559
|
+
return this._threadBinding.getState().extras;
|
3560
|
+
}
|
3561
|
+
/**
|
3562
|
+
* @deprecated Use `getState().followupSuggestions` instead. This will be removed in 0.6.0.
|
3563
|
+
*/
|
3564
|
+
get suggestions() {
|
3565
|
+
return this._threadBinding.getState().suggestions;
|
3566
|
+
}
|
3556
3567
|
/**
|
3557
3568
|
* @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
|
3558
3569
|
*/
|
@@ -3574,7 +3585,7 @@ var ThreadRuntime = (_class12 = class {
|
|
3574
3585
|
subscribe: (callback) => threadBinding.subscribe(callback)
|
3575
3586
|
};
|
3576
3587
|
}
|
3577
|
-
__init23() {this.composer = new
|
3588
|
+
__init23() {this.composer = new ThreadComposerRuntimeImpl(
|
3578
3589
|
new NestedSubscriptionSubject({
|
3579
3590
|
getState: () => this._threadBinding.getState().composer,
|
3580
3591
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
@@ -3591,9 +3602,9 @@ var ThreadRuntime = (_class12 = class {
|
|
3591
3602
|
subscribe(callback) {
|
3592
3603
|
return this._threadBinding.subscribe(callback);
|
3593
3604
|
}
|
3594
|
-
|
3595
|
-
|
3596
|
-
|
3605
|
+
/**
|
3606
|
+
* @derprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
|
3607
|
+
*/
|
3597
3608
|
getBranches(messageId) {
|
3598
3609
|
return this._threadBinding.getState().getBranches(messageId);
|
3599
3610
|
}
|
@@ -3604,17 +3615,18 @@ var ThreadRuntime = (_class12 = class {
|
|
3604
3615
|
startRun(parentId) {
|
3605
3616
|
return this._threadBinding.getState().startRun(parentId);
|
3606
3617
|
}
|
3607
|
-
// TODO
|
3608
3618
|
cancelRun() {
|
3609
3619
|
this._threadBinding.getState().cancelRun();
|
3610
3620
|
}
|
3611
|
-
|
3612
|
-
|
3613
|
-
|
3621
|
+
/**
|
3622
|
+
* @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
|
3623
|
+
*/
|
3614
3624
|
addToolResult(options) {
|
3615
3625
|
this._threadBinding.getState().addToolResult(options);
|
3616
3626
|
}
|
3617
|
-
|
3627
|
+
/**
|
3628
|
+
* @deprecated Use `getMesssageById(id).switchToBranch({ options })` instead. This will be removed in 0.6.0.
|
3629
|
+
*/
|
3618
3630
|
switchToBranch(branchId) {
|
3619
3631
|
return this._threadBinding.getState().switchToBranch(branchId);
|
3620
3632
|
}
|
@@ -3631,13 +3643,13 @@ var ThreadRuntime = (_class12 = class {
|
|
3631
3643
|
return this._threadBinding.getState().submitFeedback(options);
|
3632
3644
|
}
|
3633
3645
|
/**
|
3634
|
-
* @deprecated Use `getMesssageById(id).
|
3646
|
+
* @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
|
3635
3647
|
*/
|
3636
3648
|
getEditComposer(messageId) {
|
3637
3649
|
return this._threadBinding.getState().getEditComposer(messageId);
|
3638
3650
|
}
|
3639
3651
|
/**
|
3640
|
-
* @deprecated Use `getMesssageById(id).
|
3652
|
+
* @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
|
3641
3653
|
*/
|
3642
3654
|
beginEdit(messageId) {
|
3643
3655
|
return this._threadBinding.getState().beginEdit(messageId);
|
@@ -3648,9 +3660,9 @@ var ThreadRuntime = (_class12 = class {
|
|
3648
3660
|
import(data) {
|
3649
3661
|
this._threadBinding.getState().import(data);
|
3650
3662
|
}
|
3651
|
-
|
3663
|
+
getMesssageByIndex(idx) {
|
3652
3664
|
if (idx < 0) throw new Error("Message index must be >= 0");
|
3653
|
-
return new
|
3665
|
+
return new MessageRuntimeImpl(
|
3654
3666
|
new ShallowMemoizeSubject({
|
3655
3667
|
getState: () => {
|
3656
3668
|
const messages2 = this.getState().messages;
|
@@ -3953,7 +3965,7 @@ var EdgeChatAdapter = class {
|
|
3953
3965
|
}),
|
3954
3966
|
signal: abortSignal
|
3955
3967
|
});
|
3956
|
-
if (result.
|
3968
|
+
if (!result.ok) {
|
3957
3969
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
3958
3970
|
}
|
3959
3971
|
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunk5KIEXJRKjs.toolResultStream.call(void 0, config.tools, abortSignal)).pipeThrough(_chunk5KIEXJRKjs.runResultStream.call(void 0, ));
|
@@ -4023,7 +4035,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
4023
4035
|
|
4024
4036
|
// src/runtimes/local/LocalThreadRuntimeCore.tsx
|
4025
4037
|
var LocalThreadRuntimeCore = (_class13 = class {
|
4026
|
-
constructor(configProvider, adapter, { initialMessages, ...options }) {;_class13.prototype.__init24.call(this);_class13.prototype.__init25.call(this);_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);_class13.prototype.__init28.call(this);_class13.prototype.__init29.call(this);_class13.prototype.__init30.call(this);
|
4038
|
+
constructor(configProvider, adapter, { initialMessages, ...options }) {;_class13.prototype.__init24.call(this);_class13.prototype.__init25.call(this);_class13.prototype.__init26.call(this);_class13.prototype.__init27.call(this);_class13.prototype.__init28.call(this);_class13.prototype.__init29.call(this);_class13.prototype.__init30.call(this);_class13.prototype.__init31.call(this);
|
4027
4039
|
this.configProvider = configProvider;
|
4028
4040
|
this.adapter = adapter;
|
4029
4041
|
this.threadId = generateId();
|
@@ -4052,10 +4064,11 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4052
4064
|
}}
|
4053
4065
|
|
4054
4066
|
__init28() {this.isDisabled = false}
|
4067
|
+
__init29() {this.suggestions = []}
|
4055
4068
|
get messages() {
|
4056
4069
|
return this.repository.getMessages();
|
4057
4070
|
}
|
4058
|
-
|
4071
|
+
__init30() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4059
4072
|
getModelConfig() {
|
4060
4073
|
return this.configProvider.getModelConfig();
|
4061
4074
|
}
|
@@ -4063,6 +4076,9 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4063
4076
|
get options() {
|
4064
4077
|
return this._options;
|
4065
4078
|
}
|
4079
|
+
get extras() {
|
4080
|
+
return void 0;
|
4081
|
+
}
|
4066
4082
|
set options({ initialMessages, ...options }) {
|
4067
4083
|
this._options = options;
|
4068
4084
|
let hasUpdates = false;
|
@@ -4084,7 +4100,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4084
4100
|
}
|
4085
4101
|
if (hasUpdates) this.notifySubscribers();
|
4086
4102
|
}
|
4087
|
-
|
4103
|
+
__init31() {this._editComposers = /* @__PURE__ */ new Map()}
|
4088
4104
|
getEditComposer(messageId) {
|
4089
4105
|
return this._editComposers.get(messageId);
|
4090
4106
|
}
|
@@ -4343,9 +4359,9 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4343
4359
|
};
|
4344
4360
|
|
4345
4361
|
// src/runtimes/local/useLocalRuntime.tsx
|
4346
|
-
var LocalRuntime = class extends
|
4362
|
+
var LocalRuntime = class extends AssistantRuntimeImpl {
|
4347
4363
|
constructor(core) {
|
4348
|
-
super(core,
|
4364
|
+
super(core, ThreadRuntimeImpl);
|
4349
4365
|
this.core = core;
|
4350
4366
|
}
|
4351
4367
|
reset(options) {
|
@@ -4371,8 +4387,8 @@ var getExternalStoreMessage = (message) => {
|
|
4371
4387
|
};
|
4372
4388
|
|
4373
4389
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
4374
|
-
var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.
|
4375
|
-
|
4390
|
+
var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.__init32.call(this); }
|
4391
|
+
__init32() {this.cache = /* @__PURE__ */ new WeakMap()}
|
4376
4392
|
convertMessages(messages2, converter) {
|
4377
4393
|
return messages2.map((m, idx) => {
|
4378
4394
|
const cached = this.cache.get(m);
|
@@ -4467,18 +4483,19 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
4467
4483
|
};
|
4468
4484
|
|
4469
4485
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
4486
|
+
var EMPTY_ARRAY2 = Object.freeze([]);
|
4470
4487
|
var hasUpcomingMessage = (isRunning, messages2) => {
|
4471
4488
|
return isRunning && _optionalChain([messages2, 'access', _215 => _215[messages2.length - 1], 'optionalAccess', _216 => _216.role]) !== "assistant";
|
4472
4489
|
};
|
4473
4490
|
var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
4474
|
-
constructor(configProvider, store) {;_class15.prototype.
|
4491
|
+
constructor(configProvider, store) {;_class15.prototype.__init33.call(this);_class15.prototype.__init34.call(this);_class15.prototype.__init35.call(this);_class15.prototype.__init36.call(this);_class15.prototype.__init37.call(this);_class15.prototype.__init38.call(this);_class15.prototype.__init39.call(this);_class15.prototype.__init40.call(this);_class15.prototype.__init41.call(this);_class15.prototype.__init42.call(this);
|
4475
4492
|
this.configProvider = configProvider;
|
4476
4493
|
this.store = store;
|
4477
4494
|
}
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4495
|
+
__init33() {this._subscriptions = /* @__PURE__ */ new Set()}
|
4496
|
+
__init34() {this.repository = new MessageRepository()}
|
4497
|
+
__init35() {this.assistantOptimisticId = null}
|
4498
|
+
__init36() {this._capabilities = {
|
4482
4499
|
switchToBranch: false,
|
4483
4500
|
edit: false,
|
4484
4501
|
reload: false,
|
@@ -4494,10 +4511,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4494
4511
|
|
4495
4512
|
|
4496
4513
|
|
4497
|
-
|
4514
|
+
__init37() {this.suggestions = []}
|
4515
|
+
__init38() {this.extras = void 0}
|
4516
|
+
__init39() {this._converter = new ThreadMessageConverter()}
|
4498
4517
|
|
4499
|
-
|
4500
|
-
|
4518
|
+
__init40() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4519
|
+
__init41() {this._editComposers = /* @__PURE__ */ new Map()}
|
4501
4520
|
getEditComposer(messageId) {
|
4502
4521
|
return this._editComposers.get(messageId);
|
4503
4522
|
}
|
@@ -4524,6 +4543,8 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4524
4543
|
this.isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
|
4525
4544
|
const oldStore = this._store;
|
4526
4545
|
this._store = store;
|
4546
|
+
this.extras = store.extras;
|
4547
|
+
this.suggestions = _nullishCoalesce(store.suggestions, () => ( EMPTY_ARRAY2));
|
4527
4548
|
this._capabilities = {
|
4528
4549
|
switchToBranch: this._store.setMessages !== void 0,
|
4529
4550
|
edit: this._store.onEdit !== void 0,
|
@@ -4538,13 +4559,13 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4538
4559
|
this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _229 => _229._store, 'access', _230 => _230.adapters, 'optionalAccess', _231 => _231.attachments]));
|
4539
4560
|
if (oldStore) {
|
4540
4561
|
if (oldStore.convertMessage !== store.convertMessage) {
|
4541
|
-
this.
|
4562
|
+
this._converter = new ThreadMessageConverter();
|
4542
4563
|
} else if (oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
|
4543
4564
|
this.notifySubscribers();
|
4544
4565
|
return;
|
4545
4566
|
}
|
4546
4567
|
}
|
4547
|
-
const messages2 = !store.convertMessage ? store.messages : this.
|
4568
|
+
const messages2 = !store.convertMessage ? store.messages : this._converter.convertMessages(store.messages, (cache, m, idx) => {
|
4548
4569
|
if (!store.convertMessage) return m;
|
4549
4570
|
const isLast = idx === store.messages.length - 1;
|
4550
4571
|
const autoStatus = getAutoStatus(isLast, isRunning);
|
@@ -4655,7 +4676,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4655
4676
|
this._subscriptions.add(callback);
|
4656
4677
|
return () => this._subscriptions.delete(callback);
|
4657
4678
|
}
|
4658
|
-
|
4679
|
+
__init42() {this.updateMessages = (messages2) => {
|
4659
4680
|
_optionalChain([this, 'access', _250 => _250._store, 'access', _251 => _251.setMessages, 'optionalCall', _252 => _252(
|
4660
4681
|
messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
4661
4682
|
)]);
|
@@ -4719,7 +4740,10 @@ var useExternalStoreRuntime = (store) => {
|
|
4719
4740
|
_react.useEffect.call(void 0, () => {
|
4720
4741
|
runtime.thread.store = store;
|
4721
4742
|
});
|
4722
|
-
return _react.useMemo.call(void 0,
|
4743
|
+
return _react.useMemo.call(void 0,
|
4744
|
+
() => new AssistantRuntimeImpl(runtime, ThreadRuntimeImpl),
|
4745
|
+
[runtime]
|
4746
|
+
);
|
4723
4747
|
};
|
4724
4748
|
|
4725
4749
|
// src/runtimes/external-store/external-message-converter.tsx
|
@@ -4946,8 +4970,8 @@ var WebSpeechSynthesisAdapter = class {
|
|
4946
4970
|
};
|
4947
4971
|
|
4948
4972
|
// src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
|
4949
|
-
var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.
|
4950
|
-
|
4973
|
+
var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init43.call(this); }
|
4974
|
+
__init43() {this.accept = "image/*"}
|
4951
4975
|
async add(state) {
|
4952
4976
|
return {
|
4953
4977
|
id: state.file.name,
|
@@ -4981,8 +5005,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
|
4981
5005
|
});
|
4982
5006
|
|
4983
5007
|
// src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
|
4984
|
-
var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.
|
4985
|
-
|
5008
|
+
var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init44.call(this); }
|
5009
|
+
__init44() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
|
4986
5010
|
async add(state) {
|
4987
5011
|
return {
|
4988
5012
|
id: state.file.name,
|
@@ -5700,19 +5724,13 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
|
|
5700
5724
|
var ThreadWelcomeSuggestion = ({
|
5701
5725
|
suggestion: { text, prompt }
|
5702
5726
|
}) => {
|
5703
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5704
|
-
ThreadWelcomeSuggestionStyled,
|
5705
|
-
{
|
5706
|
-
prompt,
|
5707
|
-
method: "replace",
|
5708
|
-
autoSend: true,
|
5709
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-thread-welcome-suggestion-text", children: _nullishCoalesce(text, () => ( prompt)) })
|
5710
|
-
}
|
5711
|
-
);
|
5727
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionStyled, { prompt, method: "replace", autoSend: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-thread-welcome-suggestion-text", children: _nullishCoalesce(text, () => ( prompt)) }) });
|
5712
5728
|
};
|
5713
5729
|
var ThreadWelcomeSuggestions = () => {
|
5730
|
+
const suggestions2 = useThread((t) => t.suggestions);
|
5714
5731
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5715
|
-
|
5732
|
+
const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
|
5733
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _256 => _256.map, 'call', _257 => _257((suggestion, idx) => {
|
5716
5734
|
const key = `${suggestion.prompt}-${idx}`;
|
5717
5735
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
5718
5736
|
})]) });
|
@@ -5898,12 +5916,14 @@ var edit_composer_default = Object.assign(EditComposer, exports11);
|
|
5898
5916
|
// src/ui/thread.tsx
|
5899
5917
|
|
5900
5918
|
var Thread = (config) => {
|
5919
|
+
const { components: { Composer: ComposerComponent = composer_default } = {} } = config;
|
5901
5920
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRoot, { config, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewport, { children: [
|
5902
5921
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_welcome_default, {}),
|
5903
5922
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessages, {}),
|
5923
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadFollowupSuggestions, {}),
|
5904
5924
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewportFooter, { children: [
|
5905
5925
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadScrollToBottom, {}),
|
5906
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5926
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerComponent, {})
|
5907
5927
|
] })
|
5908
5928
|
] }) });
|
5909
5929
|
};
|
@@ -5925,21 +5945,38 @@ var ThreadViewportFooter = withDefaults("div", {
|
|
5925
5945
|
});
|
5926
5946
|
ThreadViewportFooter.displayName = "ThreadViewportFooter";
|
5927
5947
|
var SystemMessage = () => null;
|
5928
|
-
var ThreadMessages = ({ components, ...rest }) => {
|
5929
|
-
return /* @__PURE__ */ _jsxruntime.
|
5930
|
-
|
5931
|
-
|
5932
|
-
|
5933
|
-
|
5934
|
-
|
5935
|
-
|
5936
|
-
|
5937
|
-
|
5938
|
-
|
5939
|
-
|
5940
|
-
|
5948
|
+
var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
|
5949
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
5950
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5951
|
+
thread_exports.Messages,
|
5952
|
+
{
|
5953
|
+
components: {
|
5954
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _260 => _260.UserMessage]), () => ( user_message_default)),
|
5955
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _261 => _261.EditComposer]), () => ( edit_composer_default)),
|
5956
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _262 => _262.AssistantMessage]), () => ( assistant_message_default)),
|
5957
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _263 => _263.SystemMessage]), () => ( SystemMessage))
|
5958
|
+
},
|
5959
|
+
...rest
|
5960
|
+
}
|
5961
|
+
),
|
5962
|
+
flexGrowDiv && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { flexGrow: 1 } }) })
|
5963
|
+
] });
|
5941
5964
|
};
|
5942
5965
|
ThreadMessages.displayName = "ThreadMessages";
|
5966
|
+
var ThreadFollowupSuggestions = () => {
|
5967
|
+
const suggestions = useThread((t) => t.suggestions);
|
5968
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "aui-thread-followup-suggestions", children: _optionalChain([suggestions, 'optionalAccess', _264 => _264.map, 'call', _265 => _265((suggestion, idx) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5969
|
+
thread_exports.Suggestion,
|
5970
|
+
{
|
5971
|
+
className: "aui-thread-followup-suggestion",
|
5972
|
+
prompt: suggestion.prompt,
|
5973
|
+
method: "replace",
|
5974
|
+
autoSend: true,
|
5975
|
+
children: suggestion.prompt
|
5976
|
+
},
|
5977
|
+
idx
|
5978
|
+
))]) }) });
|
5979
|
+
};
|
5943
5980
|
var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
|
5944
5981
|
variant: "outline",
|
5945
5982
|
className: "aui-thread-scroll-to-bottom"
|
@@ -5957,6 +5994,7 @@ var exports12 = {
|
|
5957
5994
|
Root: ThreadRoot,
|
5958
5995
|
Viewport: ThreadViewport,
|
5959
5996
|
Messages: ThreadMessages,
|
5997
|
+
FollowupSuggestions: ThreadFollowupSuggestions,
|
5960
5998
|
ScrollToBottom: ThreadScrollToBottom,
|
5961
5999
|
ViewportFooter: ThreadViewportFooter
|
5962
6000
|
};
|