@assistant-ui/react 0.5.70 → 0.5.72
Sign up to get free protection for your applications and to get access to all the features.
- 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.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, ));
|
@@ -3966,19 +3978,20 @@ var EdgeChatAdapter = class {
|
|
3966
3978
|
}
|
3967
3979
|
};
|
3968
3980
|
|
3981
|
+
// src/runtimes/local/LocalRuntimeOptions.tsx
|
3982
|
+
var splitLocalRuntimeOptions = (options) => {
|
3983
|
+
const { initialMessages, maxToolRoundtrips, adapters, ...rest } = options;
|
3984
|
+
return {
|
3985
|
+
localRuntimeOptions: { initialMessages, maxToolRoundtrips, adapters },
|
3986
|
+
otherOptions: rest
|
3987
|
+
};
|
3988
|
+
};
|
3989
|
+
|
3969
3990
|
// src/runtimes/edge/useEdgeRuntime.ts
|
3970
|
-
var useEdgeRuntime = ({
|
3971
|
-
|
3972
|
-
|
3973
|
-
|
3974
|
-
...options
|
3975
|
-
}) => {
|
3976
|
-
const [adapter] = _react.useState.call(void 0, () => new EdgeChatAdapter(options));
|
3977
|
-
return useLocalRuntime(adapter, {
|
3978
|
-
initialMessages,
|
3979
|
-
maxToolRoundtrips,
|
3980
|
-
adapters
|
3981
|
-
});
|
3991
|
+
var useEdgeRuntime = (options) => {
|
3992
|
+
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
3993
|
+
const [adapter] = _react.useState.call(void 0, () => new EdgeChatAdapter(otherOptions));
|
3994
|
+
return useLocalRuntime(adapter, localRuntimeOptions);
|
3982
3995
|
};
|
3983
3996
|
|
3984
3997
|
// src/runtimes/local/shouldContinue.tsx
|
@@ -4023,7 +4036,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
|
|
4023
4036
|
|
4024
4037
|
// src/runtimes/local/LocalThreadRuntimeCore.tsx
|
4025
4038
|
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);
|
4039
|
+
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
4040
|
this.configProvider = configProvider;
|
4028
4041
|
this.adapter = adapter;
|
4029
4042
|
this.threadId = generateId();
|
@@ -4052,10 +4065,11 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4052
4065
|
}}
|
4053
4066
|
|
4054
4067
|
__init28() {this.isDisabled = false}
|
4068
|
+
__init29() {this.suggestions = []}
|
4055
4069
|
get messages() {
|
4056
4070
|
return this.repository.getMessages();
|
4057
4071
|
}
|
4058
|
-
|
4072
|
+
__init30() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4059
4073
|
getModelConfig() {
|
4060
4074
|
return this.configProvider.getModelConfig();
|
4061
4075
|
}
|
@@ -4063,6 +4077,9 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4063
4077
|
get options() {
|
4064
4078
|
return this._options;
|
4065
4079
|
}
|
4080
|
+
get extras() {
|
4081
|
+
return void 0;
|
4082
|
+
}
|
4066
4083
|
set options({ initialMessages, ...options }) {
|
4067
4084
|
this._options = options;
|
4068
4085
|
let hasUpdates = false;
|
@@ -4084,7 +4101,7 @@ var LocalThreadRuntimeCore = (_class13 = class {
|
|
4084
4101
|
}
|
4085
4102
|
if (hasUpdates) this.notifySubscribers();
|
4086
4103
|
}
|
4087
|
-
|
4104
|
+
__init31() {this._editComposers = /* @__PURE__ */ new Map()}
|
4088
4105
|
getEditComposer(messageId) {
|
4089
4106
|
return this._editComposers.get(messageId);
|
4090
4107
|
}
|
@@ -4343,9 +4360,9 @@ var LocalRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
4343
4360
|
};
|
4344
4361
|
|
4345
4362
|
// src/runtimes/local/useLocalRuntime.tsx
|
4346
|
-
var LocalRuntime = class extends
|
4363
|
+
var LocalRuntime = class extends AssistantRuntimeImpl {
|
4347
4364
|
constructor(core) {
|
4348
|
-
super(core,
|
4365
|
+
super(core, ThreadRuntimeImpl);
|
4349
4366
|
this.core = core;
|
4350
4367
|
}
|
4351
4368
|
reset(options) {
|
@@ -4371,8 +4388,8 @@ var getExternalStoreMessage = (message) => {
|
|
4371
4388
|
};
|
4372
4389
|
|
4373
4390
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
4374
|
-
var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.
|
4375
|
-
|
4391
|
+
var ThreadMessageConverter = (_class14 = class {constructor() { _class14.prototype.__init32.call(this); }
|
4392
|
+
__init32() {this.cache = /* @__PURE__ */ new WeakMap()}
|
4376
4393
|
convertMessages(messages2, converter) {
|
4377
4394
|
return messages2.map((m, idx) => {
|
4378
4395
|
const cached = this.cache.get(m);
|
@@ -4467,18 +4484,19 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
4467
4484
|
};
|
4468
4485
|
|
4469
4486
|
// src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx
|
4487
|
+
var EMPTY_ARRAY2 = Object.freeze([]);
|
4470
4488
|
var hasUpcomingMessage = (isRunning, messages2) => {
|
4471
4489
|
return isRunning && _optionalChain([messages2, 'access', _215 => _215[messages2.length - 1], 'optionalAccess', _216 => _216.role]) !== "assistant";
|
4472
4490
|
};
|
4473
4491
|
var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
4474
|
-
constructor(configProvider, store) {;_class15.prototype.
|
4492
|
+
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
4493
|
this.configProvider = configProvider;
|
4476
4494
|
this.store = store;
|
4477
4495
|
}
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4496
|
+
__init33() {this._subscriptions = /* @__PURE__ */ new Set()}
|
4497
|
+
__init34() {this.repository = new MessageRepository()}
|
4498
|
+
__init35() {this.assistantOptimisticId = null}
|
4499
|
+
__init36() {this._capabilities = {
|
4482
4500
|
switchToBranch: false,
|
4483
4501
|
edit: false,
|
4484
4502
|
reload: false,
|
@@ -4494,10 +4512,12 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4494
4512
|
|
4495
4513
|
|
4496
4514
|
|
4497
|
-
|
4515
|
+
__init37() {this.suggestions = []}
|
4516
|
+
__init38() {this.extras = void 0}
|
4517
|
+
__init39() {this._converter = new ThreadMessageConverter()}
|
4498
4518
|
|
4499
|
-
|
4500
|
-
|
4519
|
+
__init40() {this.composer = new DefaultThreadComposerRuntimeCore(this)}
|
4520
|
+
__init41() {this._editComposers = /* @__PURE__ */ new Map()}
|
4501
4521
|
getEditComposer(messageId) {
|
4502
4522
|
return this._editComposers.get(messageId);
|
4503
4523
|
}
|
@@ -4524,6 +4544,8 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4524
4544
|
this.isDisabled = _nullishCoalesce(store.isDisabled, () => ( false));
|
4525
4545
|
const oldStore = this._store;
|
4526
4546
|
this._store = store;
|
4547
|
+
this.extras = store.extras;
|
4548
|
+
this.suggestions = _nullishCoalesce(store.suggestions, () => ( EMPTY_ARRAY2));
|
4527
4549
|
this._capabilities = {
|
4528
4550
|
switchToBranch: this._store.setMessages !== void 0,
|
4529
4551
|
edit: this._store.onEdit !== void 0,
|
@@ -4538,13 +4560,13 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4538
4560
|
this.composer.setAttachmentAdapter(_optionalChain([this, 'access', _229 => _229._store, 'access', _230 => _230.adapters, 'optionalAccess', _231 => _231.attachments]));
|
4539
4561
|
if (oldStore) {
|
4540
4562
|
if (oldStore.convertMessage !== store.convertMessage) {
|
4541
|
-
this.
|
4563
|
+
this._converter = new ThreadMessageConverter();
|
4542
4564
|
} else if (oldStore.isRunning === store.isRunning && oldStore.messages === store.messages) {
|
4543
4565
|
this.notifySubscribers();
|
4544
4566
|
return;
|
4545
4567
|
}
|
4546
4568
|
}
|
4547
|
-
const messages2 = !store.convertMessage ? store.messages : this.
|
4569
|
+
const messages2 = !store.convertMessage ? store.messages : this._converter.convertMessages(store.messages, (cache, m, idx) => {
|
4548
4570
|
if (!store.convertMessage) return m;
|
4549
4571
|
const isLast = idx === store.messages.length - 1;
|
4550
4572
|
const autoStatus = getAutoStatus(isLast, isRunning);
|
@@ -4655,7 +4677,7 @@ var ExternalStoreThreadRuntimeCore = (_class15 = class {
|
|
4655
4677
|
this._subscriptions.add(callback);
|
4656
4678
|
return () => this._subscriptions.delete(callback);
|
4657
4679
|
}
|
4658
|
-
|
4680
|
+
__init42() {this.updateMessages = (messages2) => {
|
4659
4681
|
_optionalChain([this, 'access', _250 => _250._store, 'access', _251 => _251.setMessages, 'optionalCall', _252 => _252(
|
4660
4682
|
messages2.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
4661
4683
|
)]);
|
@@ -4719,7 +4741,10 @@ var useExternalStoreRuntime = (store) => {
|
|
4719
4741
|
_react.useEffect.call(void 0, () => {
|
4720
4742
|
runtime.thread.store = store;
|
4721
4743
|
});
|
4722
|
-
return _react.useMemo.call(void 0,
|
4744
|
+
return _react.useMemo.call(void 0,
|
4745
|
+
() => new AssistantRuntimeImpl(runtime, ThreadRuntimeImpl),
|
4746
|
+
[runtime]
|
4747
|
+
);
|
4723
4748
|
};
|
4724
4749
|
|
4725
4750
|
// src/runtimes/external-store/external-message-converter.tsx
|
@@ -4896,12 +4921,10 @@ var DangerousInBrowserAdapter = class {
|
|
4896
4921
|
};
|
4897
4922
|
|
4898
4923
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
4899
|
-
var useDangerousInBrowserRuntime = ({
|
4900
|
-
|
4901
|
-
|
4902
|
-
|
4903
|
-
const [adapter] = _react.useState.call(void 0, () => new DangerousInBrowserAdapter(options));
|
4904
|
-
return useLocalRuntime(adapter, { initialMessages });
|
4924
|
+
var useDangerousInBrowserRuntime = (options) => {
|
4925
|
+
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
4926
|
+
const [adapter] = _react.useState.call(void 0, () => new DangerousInBrowserAdapter(otherOptions));
|
4927
|
+
return useLocalRuntime(adapter, localRuntimeOptions);
|
4905
4928
|
};
|
4906
4929
|
|
4907
4930
|
// src/runtimes/speech/WebSpeechSynthesisAdapter.ts
|
@@ -4946,8 +4969,8 @@ var WebSpeechSynthesisAdapter = class {
|
|
4946
4969
|
};
|
4947
4970
|
|
4948
4971
|
// src/runtimes/attachment/SimpleImageAttachmentAdapter.ts
|
4949
|
-
var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.
|
4950
|
-
|
4972
|
+
var SimpleImageAttachmentAdapter = (_class16 = class {constructor() { _class16.prototype.__init43.call(this); }
|
4973
|
+
__init43() {this.accept = "image/*"}
|
4951
4974
|
async add(state) {
|
4952
4975
|
return {
|
4953
4976
|
id: state.file.name,
|
@@ -4981,8 +5004,8 @@ var getFileDataURL = (file) => new Promise((resolve, reject) => {
|
|
4981
5004
|
});
|
4982
5005
|
|
4983
5006
|
// src/runtimes/attachment/SimpleTextAttachmentAdapter.ts
|
4984
|
-
var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.
|
4985
|
-
|
5007
|
+
var SimpleTextAttachmentAdapter = (_class17 = class {constructor() { _class17.prototype.__init44.call(this); }
|
5008
|
+
__init44() {this.accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css"}
|
4986
5009
|
async add(state) {
|
4987
5010
|
return {
|
4988
5011
|
id: state.file.name,
|
@@ -5700,19 +5723,13 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
|
|
5700
5723
|
var ThreadWelcomeSuggestion = ({
|
5701
5724
|
suggestion: { text, prompt }
|
5702
5725
|
}) => {
|
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
|
-
);
|
5726
|
+
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
5727
|
};
|
5713
5728
|
var ThreadWelcomeSuggestions = () => {
|
5729
|
+
const suggestions2 = useThread((t) => t.suggestions);
|
5714
5730
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
5715
|
-
|
5731
|
+
const finalSuggestions = suggestions2.length ? suggestions2 : suggestions;
|
5732
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([finalSuggestions, 'optionalAccess', _256 => _256.map, 'call', _257 => _257((suggestion, idx) => {
|
5716
5733
|
const key = `${suggestion.prompt}-${idx}`;
|
5717
5734
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
5718
5735
|
})]) });
|
@@ -5898,12 +5915,14 @@ var edit_composer_default = Object.assign(EditComposer, exports11);
|
|
5898
5915
|
// src/ui/thread.tsx
|
5899
5916
|
|
5900
5917
|
var Thread = (config) => {
|
5918
|
+
const { components: { Composer: ComposerComponent = composer_default } = {} } = config;
|
5901
5919
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRoot, { config, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewport, { children: [
|
5902
5920
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_welcome_default, {}),
|
5903
5921
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessages, {}),
|
5922
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadFollowupSuggestions, {}),
|
5904
5923
|
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewportFooter, { children: [
|
5905
5924
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadScrollToBottom, {}),
|
5906
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5925
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerComponent, {})
|
5907
5926
|
] })
|
5908
5927
|
] }) });
|
5909
5928
|
};
|
@@ -5925,21 +5944,38 @@ var ThreadViewportFooter = withDefaults("div", {
|
|
5925
5944
|
});
|
5926
5945
|
ThreadViewportFooter.displayName = "ThreadViewportFooter";
|
5927
5946
|
var SystemMessage = () => null;
|
5928
|
-
var ThreadMessages = ({ components, ...rest }) => {
|
5929
|
-
return /* @__PURE__ */ _jsxruntime.
|
5930
|
-
|
5931
|
-
|
5932
|
-
|
5933
|
-
|
5934
|
-
|
5935
|
-
|
5936
|
-
|
5937
|
-
|
5938
|
-
|
5939
|
-
|
5940
|
-
|
5947
|
+
var ThreadMessages = ({ components, unstable_flexGrowDiv: flexGrowDiv = true, ...rest }) => {
|
5948
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
5949
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
5950
|
+
thread_exports.Messages,
|
5951
|
+
{
|
5952
|
+
components: {
|
5953
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _260 => _260.UserMessage]), () => ( user_message_default)),
|
5954
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _261 => _261.EditComposer]), () => ( edit_composer_default)),
|
5955
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _262 => _262.AssistantMessage]), () => ( assistant_message_default)),
|
5956
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _263 => _263.SystemMessage]), () => ( SystemMessage))
|
5957
|
+
},
|
5958
|
+
...rest
|
5959
|
+
}
|
5960
|
+
),
|
5961
|
+
flexGrowDiv && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { empty: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { style: { flexGrow: 1 } }) })
|
5962
|
+
] });
|
5941
5963
|
};
|
5942
5964
|
ThreadMessages.displayName = "ThreadMessages";
|
5965
|
+
var ThreadFollowupSuggestions = () => {
|
5966
|
+
const suggestions = useThread((t) => t.suggestions);
|
5967
|
+
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,
|
5968
|
+
thread_exports.Suggestion,
|
5969
|
+
{
|
5970
|
+
className: "aui-thread-followup-suggestion",
|
5971
|
+
prompt: suggestion.prompt,
|
5972
|
+
method: "replace",
|
5973
|
+
autoSend: true,
|
5974
|
+
children: suggestion.prompt
|
5975
|
+
},
|
5976
|
+
idx
|
5977
|
+
))]) }) });
|
5978
|
+
};
|
5943
5979
|
var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
|
5944
5980
|
variant: "outline",
|
5945
5981
|
className: "aui-thread-scroll-to-bottom"
|
@@ -5957,6 +5993,7 @@ var exports12 = {
|
|
5957
5993
|
Root: ThreadRoot,
|
5958
5994
|
Viewport: ThreadViewport,
|
5959
5995
|
Messages: ThreadMessages,
|
5996
|
+
FollowupSuggestions: ThreadFollowupSuggestions,
|
5960
5997
|
ScrollToBottom: ThreadScrollToBottom,
|
5961
5998
|
ViewportFooter: ThreadViewportFooter
|
5962
5999
|
};
|