@assistant-ui/react 0.5.70 → 0.5.72
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 +286 -45
- package/dist/index.d.ts +286 -45
- package/dist/index.js +157 -120
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -106
- 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.mjs
CHANGED
|
@@ -289,7 +289,7 @@ var { useContentPart, useContentPartStore } = createContextStoreHook(
|
|
|
289
289
|
);
|
|
290
290
|
|
|
291
291
|
// src/api/ContentPartRuntime.ts
|
|
292
|
-
var
|
|
292
|
+
var ContentPartRuntimeImpl = class {
|
|
293
293
|
constructor(contentBinding, messageApi, threadApi) {
|
|
294
294
|
this.contentBinding = contentBinding;
|
|
295
295
|
this.messageApi = messageApi;
|
|
@@ -331,7 +331,7 @@ var TextContentPartProvider = ({ children, text, isRunning }) => {
|
|
|
331
331
|
const [context] = useState3(() => {
|
|
332
332
|
const useContentPartRuntime2 = create5(
|
|
333
333
|
// TODO
|
|
334
|
-
() => new
|
|
334
|
+
() => new ContentPartRuntimeImpl(null, null, null)
|
|
335
335
|
);
|
|
336
336
|
const useContentPart2 = create5(() => ({
|
|
337
337
|
status: isRunning ? RUNNING_STATUS : COMPLETE_STATUS,
|
|
@@ -1586,7 +1586,7 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
|
1586
1586
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
|
1587
1587
|
|
|
1588
1588
|
// src/api/AttachmentRuntime.ts
|
|
1589
|
-
var
|
|
1589
|
+
var AttachmentRuntimeImpl = class {
|
|
1590
1590
|
constructor(_core) {
|
|
1591
1591
|
this._core = _core;
|
|
1592
1592
|
}
|
|
@@ -1597,7 +1597,7 @@ var AttachmentRuntime = class {
|
|
|
1597
1597
|
return this._core.subscribe(callback);
|
|
1598
1598
|
}
|
|
1599
1599
|
};
|
|
1600
|
-
var ComposerAttachmentRuntime = class extends
|
|
1600
|
+
var ComposerAttachmentRuntime = class extends AttachmentRuntimeImpl {
|
|
1601
1601
|
constructor(core, _composerApi) {
|
|
1602
1602
|
super(core);
|
|
1603
1603
|
this._composerApi = _composerApi;
|
|
@@ -1608,17 +1608,17 @@ var ComposerAttachmentRuntime = class extends AttachmentRuntime {
|
|
|
1608
1608
|
return core.removeAttachment(this.getState().id);
|
|
1609
1609
|
}
|
|
1610
1610
|
};
|
|
1611
|
-
var
|
|
1611
|
+
var ThreadComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
|
|
1612
1612
|
get source() {
|
|
1613
1613
|
return "thread-composer";
|
|
1614
1614
|
}
|
|
1615
1615
|
};
|
|
1616
|
-
var
|
|
1616
|
+
var EditComposerAttachmentRuntimeImpl = class extends ComposerAttachmentRuntime {
|
|
1617
1617
|
get source() {
|
|
1618
1618
|
return "edit-composer";
|
|
1619
1619
|
}
|
|
1620
1620
|
};
|
|
1621
|
-
var
|
|
1621
|
+
var MessageAttachmentRuntimeImpl = class extends AttachmentRuntimeImpl {
|
|
1622
1622
|
get source() {
|
|
1623
1623
|
return "message";
|
|
1624
1624
|
}
|
|
@@ -1780,7 +1780,7 @@ var getEditComposerState = (runtime, beginEdit) => {
|
|
|
1780
1780
|
cancel: runtime?.cancel.bind(runtime) ?? METHOD_NOT_SUPPORTED
|
|
1781
1781
|
});
|
|
1782
1782
|
};
|
|
1783
|
-
var
|
|
1783
|
+
var ComposerRuntimeImpl = class {
|
|
1784
1784
|
constructor(_core) {
|
|
1785
1785
|
this._core = _core;
|
|
1786
1786
|
}
|
|
@@ -1839,9 +1839,9 @@ var ComposerRuntime = class {
|
|
|
1839
1839
|
if (!core) throw new Error("Composer is not available");
|
|
1840
1840
|
return core.addAttachment(file);
|
|
1841
1841
|
}
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1842
|
+
/**
|
|
1843
|
+
* @deprecated Use `getAttachmentById(id).removeAttachment()` instead. This will be removed in 0.6.0.
|
|
1844
|
+
*/
|
|
1845
1845
|
removeAttachment(attachmentId) {
|
|
1846
1846
|
const core = this._core.getState();
|
|
1847
1847
|
if (!core) throw new Error("Composer is not available");
|
|
@@ -1869,7 +1869,7 @@ var ComposerRuntime = class {
|
|
|
1869
1869
|
return this._core.subscribe(callback);
|
|
1870
1870
|
}
|
|
1871
1871
|
};
|
|
1872
|
-
var
|
|
1872
|
+
var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
|
1873
1873
|
get type() {
|
|
1874
1874
|
return "thread";
|
|
1875
1875
|
}
|
|
@@ -1897,15 +1897,21 @@ var ThreadComposerRuntime = class extends ComposerRuntime {
|
|
|
1897
1897
|
}
|
|
1898
1898
|
// TODO replace with events
|
|
1899
1899
|
_focusListeners = /* @__PURE__ */ new Set();
|
|
1900
|
+
/**
|
|
1901
|
+
* @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
|
|
1902
|
+
*/
|
|
1900
1903
|
focus() {
|
|
1901
1904
|
this._focusListeners.forEach((callback) => callback());
|
|
1902
1905
|
}
|
|
1906
|
+
/**
|
|
1907
|
+
* @deprecated This feature is being removed in 0.6.0. Submit feedback if you need it.
|
|
1908
|
+
*/
|
|
1903
1909
|
onFocus(callback) {
|
|
1904
1910
|
this._focusListeners.add(callback);
|
|
1905
1911
|
return () => this._focusListeners.delete(callback);
|
|
1906
1912
|
}
|
|
1907
|
-
|
|
1908
|
-
return new
|
|
1913
|
+
getAttachmentByIndex(idx) {
|
|
1914
|
+
return new ThreadComposerAttachmentRuntimeImpl(
|
|
1909
1915
|
new ShallowMemoizeSubject({
|
|
1910
1916
|
getState: () => {
|
|
1911
1917
|
const attachments = this.getState().attachments;
|
|
@@ -1923,7 +1929,7 @@ var ThreadComposerRuntime = class extends ComposerRuntime {
|
|
|
1923
1929
|
);
|
|
1924
1930
|
}
|
|
1925
1931
|
};
|
|
1926
|
-
var
|
|
1932
|
+
var EditComposerRuntimeImpl = class extends ComposerRuntimeImpl {
|
|
1927
1933
|
constructor(core, _beginEdit) {
|
|
1928
1934
|
const stateBinding = new LazyMemoizeSubject({
|
|
1929
1935
|
getState: () => getEditComposerState(core.getState(), this._beginEdit),
|
|
@@ -1952,8 +1958,8 @@ var EditComposerRuntime = class extends ComposerRuntime {
|
|
|
1952
1958
|
edit() {
|
|
1953
1959
|
this.beginEdit();
|
|
1954
1960
|
}
|
|
1955
|
-
|
|
1956
|
-
return new
|
|
1961
|
+
getAttachmentByIndex(idx) {
|
|
1962
|
+
return new EditComposerAttachmentRuntimeImpl(
|
|
1957
1963
|
new ShallowMemoizeSubject({
|
|
1958
1964
|
getState: () => {
|
|
1959
1965
|
const attachments = this.getState().attachments;
|
|
@@ -2037,12 +2043,12 @@ var getContentPartState = (message, partIndex) => {
|
|
|
2037
2043
|
const status = toContentPartStatus(message, partIndex, part);
|
|
2038
2044
|
return Object.freeze({ ...part, part, status });
|
|
2039
2045
|
};
|
|
2040
|
-
var
|
|
2046
|
+
var MessageRuntimeImpl = class {
|
|
2041
2047
|
constructor(_core, _threadBinding) {
|
|
2042
2048
|
this._core = _core;
|
|
2043
2049
|
this._threadBinding = _threadBinding;
|
|
2044
2050
|
}
|
|
2045
|
-
composer = new
|
|
2051
|
+
composer = new EditComposerRuntimeImpl(
|
|
2046
2052
|
new NestedSubscriptionSubject({
|
|
2047
2053
|
getState: () => this._threadBinding.getState().getEditComposer(this._core.getState().id),
|
|
2048
2054
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
|
@@ -2052,15 +2058,6 @@ var MessageRuntime = class {
|
|
|
2052
2058
|
getState() {
|
|
2053
2059
|
return this._core.getState();
|
|
2054
2060
|
}
|
|
2055
|
-
// TODO improve type
|
|
2056
|
-
unstable_edit(message) {
|
|
2057
|
-
const state = this._core.getState();
|
|
2058
|
-
if (!state) throw new Error("Message is not available");
|
|
2059
|
-
this._threadBinding.getState().append({
|
|
2060
|
-
...message,
|
|
2061
|
-
parentId: state.parentId
|
|
2062
|
-
});
|
|
2063
|
-
}
|
|
2064
2061
|
reload() {
|
|
2065
2062
|
const state = this._core.getState();
|
|
2066
2063
|
if (!state) throw new Error("Message is not available");
|
|
@@ -2106,9 +2103,9 @@ var MessageRuntime = class {
|
|
|
2106
2103
|
subscribe(callback) {
|
|
2107
2104
|
return this._core.subscribe(callback);
|
|
2108
2105
|
}
|
|
2109
|
-
|
|
2106
|
+
getContentPartByIndex(idx) {
|
|
2110
2107
|
if (idx < 0) throw new Error("Message index must be >= 0");
|
|
2111
|
-
return new
|
|
2108
|
+
return new ContentPartRuntimeImpl(
|
|
2112
2109
|
new ShallowMemoizeSubject({
|
|
2113
2110
|
getState: () => {
|
|
2114
2111
|
return getContentPartState(this.getState(), idx);
|
|
@@ -2119,8 +2116,8 @@ var MessageRuntime = class {
|
|
|
2119
2116
|
this._threadBinding
|
|
2120
2117
|
);
|
|
2121
2118
|
}
|
|
2122
|
-
|
|
2123
|
-
return new
|
|
2119
|
+
getAttachmentByIndex(idx) {
|
|
2120
|
+
return new MessageAttachmentRuntimeImpl(
|
|
2124
2121
|
new ShallowMemoizeSubject({
|
|
2125
2122
|
getState: () => {
|
|
2126
2123
|
const attachments = this.getState().attachments;
|
|
@@ -2206,7 +2203,7 @@ var MessageContentPartImpl = ({
|
|
|
2206
2203
|
}) => {
|
|
2207
2204
|
const messageRuntime = useMessageRuntime();
|
|
2208
2205
|
const runtime = useMemo6(
|
|
2209
|
-
() => messageRuntime.
|
|
2206
|
+
() => messageRuntime.getContentPartByIndex(partIndex),
|
|
2210
2207
|
[messageRuntime, partIndex]
|
|
2211
2208
|
);
|
|
2212
2209
|
return /* @__PURE__ */ jsx21(ContentPartRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx21(MessageContentPartComponent, { components }) });
|
|
@@ -2355,7 +2352,7 @@ var AttachmentComponent = ({ components }) => {
|
|
|
2355
2352
|
var MessageAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2356
2353
|
const messageRuntime = useMessageRuntime();
|
|
2357
2354
|
const runtime = useMemo8(
|
|
2358
|
-
() => messageRuntime.
|
|
2355
|
+
() => messageRuntime.getAttachmentByIndex(attachmentIndex),
|
|
2359
2356
|
[messageRuntime, attachmentIndex]
|
|
2360
2357
|
);
|
|
2361
2358
|
return /* @__PURE__ */ jsx23(AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx23(AttachmentComponent, { components }) });
|
|
@@ -2558,7 +2555,7 @@ var AttachmentComponent2 = ({ components }) => {
|
|
|
2558
2555
|
var ComposerAttachmentImpl = ({ components, attachmentIndex }) => {
|
|
2559
2556
|
const composerRuntime = useComposerRuntime();
|
|
2560
2557
|
const runtime = useMemo9(
|
|
2561
|
-
() => composerRuntime.
|
|
2558
|
+
() => composerRuntime.getAttachmentByIndex(attachmentIndex),
|
|
2562
2559
|
[composerRuntime, attachmentIndex]
|
|
2563
2560
|
);
|
|
2564
2561
|
return /* @__PURE__ */ jsx27(AttachmentRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx27(AttachmentComponent2, { components }) });
|
|
@@ -2892,7 +2889,7 @@ var ThreadMessageImpl = ({
|
|
|
2892
2889
|
}) => {
|
|
2893
2890
|
const threadRuntime = useThreadRuntime();
|
|
2894
2891
|
const runtime = useMemo10(
|
|
2895
|
-
() => threadRuntime.
|
|
2892
|
+
() => threadRuntime.getMesssageByIndex(messageIndex),
|
|
2896
2893
|
[threadRuntime, messageIndex]
|
|
2897
2894
|
);
|
|
2898
2895
|
return /* @__PURE__ */ jsx31(MessageRuntimeProvider, { runtime, children: /* @__PURE__ */ jsx31(ThreadMessageComponent, { components }) });
|
|
@@ -2976,12 +2973,12 @@ var BaseAssistantRuntimeCore = class {
|
|
|
2976
2973
|
// src/internal.ts
|
|
2977
2974
|
var internal_exports = {};
|
|
2978
2975
|
__export(internal_exports, {
|
|
2979
|
-
|
|
2976
|
+
AssistantRuntimeImpl: () => AssistantRuntimeImpl,
|
|
2980
2977
|
BaseAssistantRuntimeCore: () => BaseAssistantRuntimeCore,
|
|
2981
2978
|
DefaultThreadComposerRuntimeCore: () => DefaultThreadComposerRuntimeCore,
|
|
2982
2979
|
MessageRepository: () => MessageRepository,
|
|
2983
2980
|
ProxyConfigProvider: () => ProxyConfigProvider,
|
|
2984
|
-
|
|
2981
|
+
ThreadRuntimeImpl: () => ThreadRuntimeImpl,
|
|
2985
2982
|
TooltipIconButton: () => TooltipIconButton,
|
|
2986
2983
|
generateId: () => generateId,
|
|
2987
2984
|
useSmooth: () => useSmooth,
|
|
@@ -3469,7 +3466,7 @@ var TooltipIconButton = forwardRef21(({ children, tooltip, side = "bottom", ...r
|
|
|
3469
3466
|
TooltipIconButton.displayName = "TooltipIconButton";
|
|
3470
3467
|
|
|
3471
3468
|
// src/api/AssistantRuntime.ts
|
|
3472
|
-
var
|
|
3469
|
+
var AssistantRuntimeImpl = class {
|
|
3473
3470
|
constructor(_core, CustomThreadRuntime) {
|
|
3474
3471
|
this._core = _core;
|
|
3475
3472
|
this.thread = new CustomThreadRuntime(
|
|
@@ -3525,10 +3522,12 @@ var getThreadState = (runtime) => {
|
|
|
3525
3522
|
capabilities: runtime.capabilities,
|
|
3526
3523
|
isDisabled: runtime.isDisabled,
|
|
3527
3524
|
isRunning: lastMessage?.role !== "assistant" ? false : lastMessage.status.type === "running",
|
|
3528
|
-
messages: runtime.messages
|
|
3525
|
+
messages: runtime.messages,
|
|
3526
|
+
suggestions: runtime.suggestions,
|
|
3527
|
+
extras: runtime.extras
|
|
3529
3528
|
});
|
|
3530
3529
|
};
|
|
3531
|
-
var
|
|
3530
|
+
var ThreadRuntimeImpl = class {
|
|
3532
3531
|
// public path = "assistant.threads[main]"; // TODO
|
|
3533
3532
|
/**
|
|
3534
3533
|
* @deprecated Use `getState().threadId` instead. This will be removed in 0.6.0.
|
|
@@ -3554,6 +3553,18 @@ var ThreadRuntime = class {
|
|
|
3554
3553
|
get capabilities() {
|
|
3555
3554
|
return this.getState().capabilities;
|
|
3556
3555
|
}
|
|
3556
|
+
/**
|
|
3557
|
+
* @deprecated Use `getState().extras` instead. This will be removed in 0.6.0.
|
|
3558
|
+
*/
|
|
3559
|
+
get extras() {
|
|
3560
|
+
return this._threadBinding.getState().extras;
|
|
3561
|
+
}
|
|
3562
|
+
/**
|
|
3563
|
+
* @deprecated Use `getState().followupSuggestions` instead. This will be removed in 0.6.0.
|
|
3564
|
+
*/
|
|
3565
|
+
get suggestions() {
|
|
3566
|
+
return this._threadBinding.getState().suggestions;
|
|
3567
|
+
}
|
|
3557
3568
|
/**
|
|
3558
3569
|
* @deprecated Use `getState().messages` instead. This will be removed in 0.6.0.
|
|
3559
3570
|
*/
|
|
@@ -3575,7 +3586,7 @@ var ThreadRuntime = class {
|
|
|
3575
3586
|
subscribe: (callback) => threadBinding.subscribe(callback)
|
|
3576
3587
|
};
|
|
3577
3588
|
}
|
|
3578
|
-
composer = new
|
|
3589
|
+
composer = new ThreadComposerRuntimeImpl(
|
|
3579
3590
|
new NestedSubscriptionSubject({
|
|
3580
3591
|
getState: () => this._threadBinding.getState().composer,
|
|
3581
3592
|
subscribe: (callback) => this._threadBinding.subscribe(callback)
|
|
@@ -3592,9 +3603,9 @@ var ThreadRuntime = class {
|
|
|
3592
3603
|
subscribe(callback) {
|
|
3593
3604
|
return this._threadBinding.subscribe(callback);
|
|
3594
3605
|
}
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3606
|
+
/**
|
|
3607
|
+
* @derprecated Use `getMesssageById(id).getState().branchNumber` / `getMesssageById(id).getState().branchCount` instead. This will be removed in 0.6.0.
|
|
3608
|
+
*/
|
|
3598
3609
|
getBranches(messageId) {
|
|
3599
3610
|
return this._threadBinding.getState().getBranches(messageId);
|
|
3600
3611
|
}
|
|
@@ -3605,17 +3616,18 @@ var ThreadRuntime = class {
|
|
|
3605
3616
|
startRun(parentId) {
|
|
3606
3617
|
return this._threadBinding.getState().startRun(parentId);
|
|
3607
3618
|
}
|
|
3608
|
-
// TODO
|
|
3609
3619
|
cancelRun() {
|
|
3610
3620
|
this._threadBinding.getState().cancelRun();
|
|
3611
3621
|
}
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3622
|
+
/**
|
|
3623
|
+
* @deprecated Use `getMesssageById(id).getContentPartByToolCallId(toolCallId).addToolResult({ result })` instead. This will be removed in 0.6.0.
|
|
3624
|
+
*/
|
|
3615
3625
|
addToolResult(options) {
|
|
3616
3626
|
this._threadBinding.getState().addToolResult(options);
|
|
3617
3627
|
}
|
|
3618
|
-
|
|
3628
|
+
/**
|
|
3629
|
+
* @deprecated Use `getMesssageById(id).switchToBranch({ options })` instead. This will be removed in 0.6.0.
|
|
3630
|
+
*/
|
|
3619
3631
|
switchToBranch(branchId) {
|
|
3620
3632
|
return this._threadBinding.getState().switchToBranch(branchId);
|
|
3621
3633
|
}
|
|
@@ -3632,13 +3644,13 @@ var ThreadRuntime = class {
|
|
|
3632
3644
|
return this._threadBinding.getState().submitFeedback(options);
|
|
3633
3645
|
}
|
|
3634
3646
|
/**
|
|
3635
|
-
* @deprecated Use `getMesssageById(id).
|
|
3647
|
+
* @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer` instead. This will be removed in 0.6.0.
|
|
3636
3648
|
*/
|
|
3637
3649
|
getEditComposer(messageId) {
|
|
3638
3650
|
return this._threadBinding.getState().getEditComposer(messageId);
|
|
3639
3651
|
}
|
|
3640
3652
|
/**
|
|
3641
|
-
* @deprecated Use `getMesssageById(id).
|
|
3653
|
+
* @deprecated Use `getMesssageById(id).getMessageByIndex(idx).composer.beginEdit()` instead. This will be removed in 0.6.0.
|
|
3642
3654
|
*/
|
|
3643
3655
|
beginEdit(messageId) {
|
|
3644
3656
|
return this._threadBinding.getState().beginEdit(messageId);
|
|
@@ -3649,9 +3661,9 @@ var ThreadRuntime = class {
|
|
|
3649
3661
|
import(data) {
|
|
3650
3662
|
this._threadBinding.getState().import(data);
|
|
3651
3663
|
}
|
|
3652
|
-
|
|
3664
|
+
getMesssageByIndex(idx) {
|
|
3653
3665
|
if (idx < 0) throw new Error("Message index must be >= 0");
|
|
3654
|
-
return new
|
|
3666
|
+
return new MessageRuntimeImpl(
|
|
3655
3667
|
new ShallowMemoizeSubject({
|
|
3656
3668
|
getState: () => {
|
|
3657
3669
|
const messages2 = this.getState().messages;
|
|
@@ -3954,7 +3966,7 @@ var EdgeChatAdapter = class {
|
|
|
3954
3966
|
}),
|
|
3955
3967
|
signal: abortSignal
|
|
3956
3968
|
});
|
|
3957
|
-
if (result.
|
|
3969
|
+
if (!result.ok) {
|
|
3958
3970
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
|
3959
3971
|
}
|
|
3960
3972
|
const stream = result.body.pipeThrough(streamPartDecoderStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools, abortSignal)).pipeThrough(runResultStream());
|
|
@@ -3967,19 +3979,20 @@ var EdgeChatAdapter = class {
|
|
|
3967
3979
|
}
|
|
3968
3980
|
};
|
|
3969
3981
|
|
|
3982
|
+
// src/runtimes/local/LocalRuntimeOptions.tsx
|
|
3983
|
+
var splitLocalRuntimeOptions = (options) => {
|
|
3984
|
+
const { initialMessages, maxToolRoundtrips, adapters, ...rest } = options;
|
|
3985
|
+
return {
|
|
3986
|
+
localRuntimeOptions: { initialMessages, maxToolRoundtrips, adapters },
|
|
3987
|
+
otherOptions: rest
|
|
3988
|
+
};
|
|
3989
|
+
};
|
|
3990
|
+
|
|
3970
3991
|
// src/runtimes/edge/useEdgeRuntime.ts
|
|
3971
|
-
var useEdgeRuntime = ({
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
...options
|
|
3976
|
-
}) => {
|
|
3977
|
-
const [adapter] = useState10(() => new EdgeChatAdapter(options));
|
|
3978
|
-
return useLocalRuntime(adapter, {
|
|
3979
|
-
initialMessages,
|
|
3980
|
-
maxToolRoundtrips,
|
|
3981
|
-
adapters
|
|
3982
|
-
});
|
|
3992
|
+
var useEdgeRuntime = (options) => {
|
|
3993
|
+
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
|
3994
|
+
const [adapter] = useState10(() => new EdgeChatAdapter(otherOptions));
|
|
3995
|
+
return useLocalRuntime(adapter, localRuntimeOptions);
|
|
3983
3996
|
};
|
|
3984
3997
|
|
|
3985
3998
|
// src/runtimes/local/shouldContinue.tsx
|
|
@@ -4053,6 +4066,7 @@ var LocalThreadRuntimeCore = class {
|
|
|
4053
4066
|
};
|
|
4054
4067
|
threadId;
|
|
4055
4068
|
isDisabled = false;
|
|
4069
|
+
suggestions = [];
|
|
4056
4070
|
get messages() {
|
|
4057
4071
|
return this.repository.getMessages();
|
|
4058
4072
|
}
|
|
@@ -4064,6 +4078,9 @@ var LocalThreadRuntimeCore = class {
|
|
|
4064
4078
|
get options() {
|
|
4065
4079
|
return this._options;
|
|
4066
4080
|
}
|
|
4081
|
+
get extras() {
|
|
4082
|
+
return void 0;
|
|
4083
|
+
}
|
|
4067
4084
|
set options({ initialMessages, ...options }) {
|
|
4068
4085
|
this._options = options;
|
|
4069
4086
|
let hasUpdates = false;
|
|
@@ -4344,9 +4361,9 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
|
4344
4361
|
};
|
|
4345
4362
|
|
|
4346
4363
|
// src/runtimes/local/useLocalRuntime.tsx
|
|
4347
|
-
var LocalRuntime = class extends
|
|
4364
|
+
var LocalRuntime = class extends AssistantRuntimeImpl {
|
|
4348
4365
|
constructor(core) {
|
|
4349
|
-
super(core,
|
|
4366
|
+
super(core, ThreadRuntimeImpl);
|
|
4350
4367
|
this.core = core;
|
|
4351
4368
|
}
|
|
4352
4369
|
reset(options) {
|
|
@@ -4468,6 +4485,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
|
4468
4485
|
};
|
|
4469
4486
|
|
|
4470
4487
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
|
4488
|
+
var EMPTY_ARRAY2 = Object.freeze([]);
|
|
4471
4489
|
var hasUpcomingMessage = (isRunning, messages2) => {
|
|
4472
4490
|
return isRunning && messages2[messages2.length - 1]?.role !== "assistant";
|
|
4473
4491
|
};
|
|
@@ -4495,7 +4513,9 @@ var ExternalStoreThreadRuntimeCore = class {
|
|
|
4495
4513
|
threadId;
|
|
4496
4514
|
messages;
|
|
4497
4515
|
isDisabled;
|
|
4498
|
-
|
|
4516
|
+
suggestions = [];
|
|
4517
|
+
extras = void 0;
|
|
4518
|
+
_converter = new ThreadMessageConverter();
|
|
4499
4519
|
_store;
|
|
4500
4520
|
composer = new DefaultThreadComposerRuntimeCore(this);
|
|
4501
4521
|
_editComposers = /* @__PURE__ */ new Map();
|
|
@@ -4525,6 +4545,8 @@ var ExternalStoreThreadRuntimeCore = class {
|
|
|
4525
4545
|
this.isDisabled = store.isDisabled ?? false;
|
|
4526
4546
|
const oldStore = this._store;
|
|
4527
4547
|
this._store = store;
|
|
4548
|
+
this.extras = store.extras;
|
|
4549
|
+
this.suggestions = store.suggestions ?? EMPTY_ARRAY2;
|
|
4528
4550
|
this._capabilities = {
|
|
4529
4551
|
switchToBranch: this._store.setMessages !== void 0,
|
|
4530
4552
|
edit: this._store.onEdit !== void 0,
|
|
@@ -4539,13 +4561,13 @@ var ExternalStoreThreadRuntimeCore = class {
|
|
|
4539
4561
|
this.composer.setAttachmentAdapter(this._store.adapters?.attachments);
|
|
4540
4562
|
if (oldStore) {
|
|
4541
4563
|
if (oldStore.convertMessage !== store.convertMessage) {
|
|
4542
|
-
this.
|
|
4564
|
+
this._converter = new ThreadMessageConverter();
|
|
4543
4565
|
} else if (oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
|
|
4544
4566
|
this.notifySubscribers();
|
|
4545
4567
|
return;
|
|
4546
4568
|
}
|
|
4547
4569
|
}
|
|
4548
|
-
const messages2 = !store.convertMessage ? store.messages : this.
|
|
4570
|
+
const messages2 = !store.convertMessage ? store.messages : this._converter.convertMessages(store.messages, (cache, m, idx) => {
|
|
4549
4571
|
if (!store.convertMessage) return m;
|
|
4550
4572
|
const isLast = idx === store.messages.length - 1;
|
|
4551
4573
|
const autoStatus = getAutoStatus(isLast, isRunning);
|
|
@@ -4720,7 +4742,10 @@ var useExternalStoreRuntime = (store) => {
|
|
|
4720
4742
|
useEffect14(() => {
|
|
4721
4743
|
runtime.thread.store = store;
|
|
4722
4744
|
});
|
|
4723
|
-
return useMemo12(
|
|
4745
|
+
return useMemo12(
|
|
4746
|
+
() => new AssistantRuntimeImpl(runtime, ThreadRuntimeImpl),
|
|
4747
|
+
[runtime]
|
|
4748
|
+
);
|
|
4724
4749
|
};
|
|
4725
4750
|
|
|
4726
4751
|
// src/runtimes/external-store/external-message-converter.tsx
|
|
@@ -4897,12 +4922,10 @@ var DangerousInBrowserAdapter = class {
|
|
|
4897
4922
|
};
|
|
4898
4923
|
|
|
4899
4924
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
|
4900
|
-
var useDangerousInBrowserRuntime = ({
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
const [adapter] = useState13(() => new DangerousInBrowserAdapter(options));
|
|
4905
|
-
return useLocalRuntime(adapter, { initialMessages });
|
|
4925
|
+
var useDangerousInBrowserRuntime = (options) => {
|
|
4926
|
+
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
|
4927
|
+
const [adapter] = useState13(() => new DangerousInBrowserAdapter(otherOptions));
|
|
4928
|
+
return useLocalRuntime(adapter, localRuntimeOptions);
|
|
4906
4929
|
};
|
|
4907
4930
|
|
|
4908
4931
|
// src/runtimes/speech/WebSpeechSynthesisAdapter.ts
|
|
@@ -5701,19 +5724,13 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
|
|
|
5701
5724
|
var ThreadWelcomeSuggestion = ({
|
|
5702
5725
|
suggestion: { text, prompt }
|
|
5703
5726
|
}) => {
|
|
5704
|
-
return /* @__PURE__ */ jsx45(
|
|
5705
|
-
ThreadWelcomeSuggestionStyled,
|
|
5706
|
-
{
|
|
5707
|
-
prompt,
|
|
5708
|
-
method: "replace",
|
|
5709
|
-
autoSend: true,
|
|
5710
|
-
children: /* @__PURE__ */ jsx45("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt })
|
|
5711
|
-
}
|
|
5712
|
-
);
|
|
5727
|
+
return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestionStyled, { prompt, method: "replace", autoSend: true, children: /* @__PURE__ */ jsx45("span", { className: "aui-thread-welcome-suggestion-text", children: text ?? prompt }) });
|
|
5713
5728
|
};
|
|
5714
5729
|
var ThreadWelcomeSuggestions = () => {
|
|
5730
|
+
const suggestions2 = useThread((t) => t.suggestions);
|
|
5715
5731
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
|
5716
|
-
|
|
5732
|
+
const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
|
|
5733
|
+
return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestionContainer, { children: finalSuggestions?.map((suggestion, idx) => {
|
|
5717
5734
|
const key = `${suggestion.prompt}-${idx}`;
|
|
5718
5735
|
return /* @__PURE__ */ jsx45(ThreadWelcomeSuggestion, { suggestion }, key);
|
|
5719
5736
|
}) });
|
|
@@ -5897,14 +5914,16 @@ var exports11 = {
|
|
|
5897
5914
|
var edit_composer_default = Object.assign(EditComposer, exports11);
|
|
5898
5915
|
|
|
5899
5916
|
// src/ui/thread.tsx
|
|
5900
|
-
import { jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
5917
|
+
import { Fragment as Fragment6, jsx as jsx49, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
5901
5918
|
var Thread = (config) => {
|
|
5919
|
+
const { components: { Composer: ComposerComponent = composer_default } = {} } = config;
|
|
5902
5920
|
return /* @__PURE__ */ jsx49(ThreadRoot, { config, children: /* @__PURE__ */ jsxs13(ThreadViewport, { children: [
|
|
5903
5921
|
/* @__PURE__ */ jsx49(thread_welcome_default, {}),
|
|
5904
5922
|
/* @__PURE__ */ jsx49(ThreadMessages, {}),
|
|
5923
|
+
/* @__PURE__ */ jsx49(ThreadFollowupSuggestions, {}),
|
|
5905
5924
|
/* @__PURE__ */ jsxs13(ThreadViewportFooter, { children: [
|
|
5906
5925
|
/* @__PURE__ */ jsx49(ThreadScrollToBottom, {}),
|
|
5907
|
-
/* @__PURE__ */ jsx49(
|
|
5926
|
+
/* @__PURE__ */ jsx49(ComposerComponent, {})
|
|
5908
5927
|
] })
|
|
5909
5928
|
] }) });
|
|
5910
5929
|
};
|
|
@@ -5926,21 +5945,38 @@ var ThreadViewportFooter = withDefaults("div", {
|
|
|
5926
5945
|
});
|
|
5927
5946
|
ThreadViewportFooter.displayName = "ThreadViewportFooter";
|
|
5928
5947
|
var SystemMessage = () => null;
|
|
5929
|
-
var ThreadMessages = ({ components, ...rest }) => {
|
|
5930
|
-
return /* @__PURE__ */
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5948
|
+
var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
|
|
5949
|
+
return /* @__PURE__ */ jsxs13(Fragment6, { children: [
|
|
5950
|
+
/* @__PURE__ */ jsx49(
|
|
5951
|
+
thread_exports.Messages,
|
|
5952
|
+
{
|
|
5953
|
+
components: {
|
|
5954
|
+
UserMessage: components?.UserMessage ?? user_message_default,
|
|
5955
|
+
EditComposer: components?.EditComposer ?? edit_composer_default,
|
|
5956
|
+
AssistantMessage: components?.AssistantMessage ?? assistant_message_default,
|
|
5957
|
+
SystemMessage: components?.SystemMessage ?? SystemMessage
|
|
5958
|
+
},
|
|
5959
|
+
...rest
|
|
5960
|
+
}
|
|
5961
|
+
),
|
|
5962
|
+
flexGrowDiv && /* @__PURE__ */ jsx49(thread_exports.If, { empty: false, children: /* @__PURE__ */ jsx49("div", { style: { flexGrow: 1 } }) })
|
|
5963
|
+
] });
|
|
5942
5964
|
};
|
|
5943
5965
|
ThreadMessages.displayName = "ThreadMessages";
|
|
5966
|
+
var ThreadFollowupSuggestions = () => {
|
|
5967
|
+
const suggestions = useThread((t) => t.suggestions);
|
|
5968
|
+
return /* @__PURE__ */ jsx49(thread_exports.If, { empty: false, running: false, children: /* @__PURE__ */ jsx49("div", { className: "aui-thread-followup-suggestions", children: suggestions?.map((suggestion, idx) => /* @__PURE__ */ jsx49(
|
|
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
|
+
};
|
|
5944
5980
|
var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
|
|
5945
5981
|
variant: "outline",
|
|
5946
5982
|
className: "aui-thread-scroll-to-bottom"
|
|
@@ -5958,13 +5994,14 @@ var exports12 = {
|
|
|
5958
5994
|
Root: ThreadRoot,
|
|
5959
5995
|
Viewport: ThreadViewport,
|
|
5960
5996
|
Messages: ThreadMessages,
|
|
5997
|
+
FollowupSuggestions: ThreadFollowupSuggestions,
|
|
5961
5998
|
ScrollToBottom: ThreadScrollToBottom,
|
|
5962
5999
|
ViewportFooter: ThreadViewportFooter
|
|
5963
6000
|
};
|
|
5964
6001
|
var thread_default = Object.assign(Thread, exports12);
|
|
5965
6002
|
|
|
5966
6003
|
// src/ui/assistant-modal.tsx
|
|
5967
|
-
import { Fragment as
|
|
6004
|
+
import { Fragment as Fragment7, jsx as jsx50, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
5968
6005
|
var AssistantModal = (config) => {
|
|
5969
6006
|
return /* @__PURE__ */ jsxs14(AssistantModalRoot, { config, children: [
|
|
5970
6007
|
/* @__PURE__ */ jsx50(AssistantModalTrigger, {}),
|
|
@@ -6010,7 +6047,7 @@ var AssistantModalButton = forwardRef32(({ "data-state": state, ...rest }, ref)
|
|
|
6010
6047
|
"data-state": state,
|
|
6011
6048
|
...rest,
|
|
6012
6049
|
ref,
|
|
6013
|
-
children: rest.children ?? /* @__PURE__ */ jsxs14(
|
|
6050
|
+
children: rest.children ?? /* @__PURE__ */ jsxs14(Fragment7, { children: [
|
|
6014
6051
|
/* @__PURE__ */ jsx50(
|
|
6015
6052
|
BotIcon,
|
|
6016
6053
|
{
|