@assistant-ui/react 0.5.39 → 0.5.41
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +75 -17
- package/dist/index.d.ts +75 -17
- package/dist/index.js +292 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +485 -279
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
@@ -204,7 +204,8 @@ var makeThreadActionStore = (runtimeStore) => {
|
|
204
204
|
startRun: (parentId) => runtimeStore.getState().startRun(parentId),
|
205
205
|
append: (message) => runtimeStore.getState().append(message),
|
206
206
|
cancelRun: () => runtimeStore.getState().cancelRun(),
|
207
|
-
addToolResult: (options) => runtimeStore.getState().addToolResult(options)
|
207
|
+
addToolResult: (options) => runtimeStore.getState().addToolResult(options),
|
208
|
+
speak: (messageId) => runtimeStore.getState().speak(messageId)
|
208
209
|
})
|
209
210
|
);
|
210
211
|
};
|
@@ -1056,31 +1057,78 @@ var EdgeChatAdapter = class {
|
|
1056
1057
|
// src/runtimes/edge/useEdgeRuntime.ts
|
1057
1058
|
var useEdgeRuntime = ({
|
1058
1059
|
initialMessages,
|
1060
|
+
maxToolRoundtrips,
|
1061
|
+
adapters,
|
1059
1062
|
...options
|
1060
1063
|
}) => {
|
1061
1064
|
const [adapter] = _react.useState.call(void 0, () => new EdgeChatAdapter(options));
|
1062
|
-
return useLocalRuntime(adapter, {
|
1065
|
+
return useLocalRuntime(adapter, {
|
1066
|
+
initialMessages,
|
1067
|
+
maxToolRoundtrips,
|
1068
|
+
adapters
|
1069
|
+
});
|
1063
1070
|
};
|
1064
1071
|
|
1065
1072
|
// src/runtimes/local/shouldContinue.tsx
|
1066
1073
|
var shouldContinue = (result) => _optionalChain([result, 'access', _33 => _33.status, 'optionalAccess', _34 => _34.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
1067
1074
|
|
1075
|
+
// src/utils/getThreadMessageText.tsx
|
1076
|
+
var getThreadMessageText = (message) => {
|
1077
|
+
const textParts = message.content.filter(
|
1078
|
+
(part) => part.type === "text"
|
1079
|
+
);
|
1080
|
+
return textParts.map((part) => part.text).join("\n\n");
|
1081
|
+
};
|
1082
|
+
|
1083
|
+
// src/runtimes/speech/WebSpeechSynthesisAdapter.ts
|
1084
|
+
var WebSpeechSynthesisAdapter = class {
|
1085
|
+
speak(message) {
|
1086
|
+
const text = getThreadMessageText(message);
|
1087
|
+
const utterance = new SpeechSynthesisUtterance(text);
|
1088
|
+
let ended = false;
|
1089
|
+
const endHandlers = /* @__PURE__ */ new Set();
|
1090
|
+
const handleEnd = () => {
|
1091
|
+
if (ended) return;
|
1092
|
+
ended = true;
|
1093
|
+
endHandlers.forEach((handler) => handler());
|
1094
|
+
};
|
1095
|
+
utterance.addEventListener("end", handleEnd);
|
1096
|
+
utterance.addEventListener("error", handleEnd);
|
1097
|
+
window.speechSynthesis.speak(utterance);
|
1098
|
+
return {
|
1099
|
+
stop: () => {
|
1100
|
+
window.speechSynthesis.cancel();
|
1101
|
+
handleEnd();
|
1102
|
+
},
|
1103
|
+
onEnd: (callback) => {
|
1104
|
+
if (ended) {
|
1105
|
+
let cancelled = false;
|
1106
|
+
queueMicrotask(() => {
|
1107
|
+
if (!cancelled) callback();
|
1108
|
+
});
|
1109
|
+
return () => {
|
1110
|
+
cancelled = true;
|
1111
|
+
};
|
1112
|
+
} else {
|
1113
|
+
endHandlers.add(callback);
|
1114
|
+
return () => {
|
1115
|
+
endHandlers.delete(callback);
|
1116
|
+
};
|
1117
|
+
}
|
1118
|
+
}
|
1119
|
+
};
|
1120
|
+
}
|
1121
|
+
};
|
1122
|
+
|
1068
1123
|
// src/runtimes/local/LocalThreadRuntime.tsx
|
1069
|
-
var CAPABILITIES = Object.freeze({
|
1070
|
-
switchToBranch: true,
|
1071
|
-
edit: true,
|
1072
|
-
reload: true,
|
1073
|
-
cancel: true,
|
1074
|
-
copy: true
|
1075
|
-
});
|
1076
1124
|
var LocalThreadRuntime = (_class5 = class {
|
1077
|
-
constructor(configProvider, adapter, options) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);
|
1125
|
+
constructor(configProvider, adapter, { initialMessages, ...options }) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);_class5.prototype.__init16.call(this);
|
1078
1126
|
this.configProvider = configProvider;
|
1079
1127
|
this.adapter = adapter;
|
1080
1128
|
this.options = options;
|
1081
|
-
if (
|
1129
|
+
if (initialMessages) {
|
1082
1130
|
let parentId = null;
|
1083
|
-
const messages = fromCoreMessages(
|
1131
|
+
const messages = fromCoreMessages(initialMessages);
|
1084
1132
|
for (const message of messages) {
|
1085
1133
|
this.repository.addOrUpdateMessage(parentId, message);
|
1086
1134
|
parentId = message.id;
|
@@ -1090,7 +1138,14 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1090
1138
|
__init11() {this._subscriptions = /* @__PURE__ */ new Set()}
|
1091
1139
|
__init12() {this.abortController = null}
|
1092
1140
|
__init13() {this.repository = new MessageRepository()}
|
1093
|
-
__init14() {this.capabilities =
|
1141
|
+
__init14() {this.capabilities = {
|
1142
|
+
switchToBranch: true,
|
1143
|
+
edit: true,
|
1144
|
+
reload: true,
|
1145
|
+
cancel: true,
|
1146
|
+
unstable_copy: true,
|
1147
|
+
speak: false
|
1148
|
+
}}
|
1094
1149
|
__init15() {this.isDisabled = false}
|
1095
1150
|
get messages() {
|
1096
1151
|
return this.repository.getMessages();
|
@@ -1102,6 +1157,15 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1102
1157
|
this.notifySubscribers();
|
1103
1158
|
}
|
1104
1159
|
}}
|
1160
|
+
|
1161
|
+
set options({ initialMessages, ...options }) {
|
1162
|
+
this._options = options;
|
1163
|
+
const canSpeak = _optionalChain([options, 'access', _35 => _35.adapters, 'optionalAccess', _36 => _36.speech]) !== void 0;
|
1164
|
+
if (this.capabilities.speak !== canSpeak) {
|
1165
|
+
this.capabilities.speak = canSpeak;
|
1166
|
+
this.notifySubscribers();
|
1167
|
+
}
|
1168
|
+
}
|
1105
1169
|
getBranches(messageId) {
|
1106
1170
|
return this.repository.getBranches(messageId);
|
1107
1171
|
}
|
@@ -1140,18 +1204,18 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1140
1204
|
}
|
1141
1205
|
async performRoundtrip(parentId, message) {
|
1142
1206
|
const messages = this.repository.getMessages();
|
1143
|
-
_optionalChain([this, 'access',
|
1207
|
+
_optionalChain([this, 'access', _37 => _37.abortController, 'optionalAccess', _38 => _38.abort, 'call', _39 => _39()]);
|
1144
1208
|
this.abortController = new AbortController();
|
1145
1209
|
const initialContent = message.content;
|
1146
|
-
const initialRoundtrips = _optionalChain([message, 'access',
|
1147
|
-
const initalCustom = _optionalChain([message, 'access',
|
1210
|
+
const initialRoundtrips = _optionalChain([message, 'access', _40 => _40.metadata, 'optionalAccess', _41 => _41.roundtrips]);
|
1211
|
+
const initalCustom = _optionalChain([message, 'access', _42 => _42.metadata, 'optionalAccess', _43 => _43.custom]);
|
1148
1212
|
const updateMessage = (m) => {
|
1149
1213
|
message = {
|
1150
1214
|
...message,
|
1151
1215
|
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
1152
1216
|
status: _nullishCoalesce(m.status, () => ( message.status)),
|
1153
1217
|
// TODO deprecated, remove in v0.6
|
1154
|
-
..._optionalChain([m, 'access',
|
1218
|
+
..._optionalChain([m, 'access', _44 => _44.metadata, 'optionalAccess', _45 => _45.roundtrips]) ? {
|
1155
1219
|
roundtrips: [
|
1156
1220
|
..._nullishCoalesce(initialRoundtrips, () => ( [])),
|
1157
1221
|
...m.metadata.roundtrips
|
@@ -1166,7 +1230,7 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1166
1230
|
...m.metadata.roundtrips
|
1167
1231
|
]
|
1168
1232
|
} : void 0,
|
1169
|
-
..._optionalChain([m, 'access',
|
1233
|
+
..._optionalChain([m, 'access', _46 => _46.metadata, 'optionalAccess', _47 => _47.custom]) ? {
|
1170
1234
|
custom: { ..._nullishCoalesce(initalCustom, () => ( {})), ...m.metadata.custom }
|
1171
1235
|
} : void 0
|
1172
1236
|
}
|
@@ -1175,8 +1239,8 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1175
1239
|
this.repository.addOrUpdateMessage(parentId, message);
|
1176
1240
|
this.notifySubscribers();
|
1177
1241
|
};
|
1178
|
-
const maxToolRoundtrips = _nullishCoalesce(this.
|
1179
|
-
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access',
|
1242
|
+
const maxToolRoundtrips = _nullishCoalesce(this._options.maxToolRoundtrips, () => ( 1));
|
1243
|
+
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _48 => _48.metadata, 'optionalAccess', _49 => _49.roundtrips, 'optionalAccess', _50 => _50.length]), () => ( 0));
|
1180
1244
|
if (toolRoundtrips > maxToolRoundtrips) {
|
1181
1245
|
updateMessage({
|
1182
1246
|
status: {
|
@@ -1239,7 +1303,11 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1239
1303
|
this._subscriptions.add(callback);
|
1240
1304
|
return () => this._subscriptions.delete(callback);
|
1241
1305
|
}
|
1242
|
-
addToolResult({
|
1306
|
+
addToolResult({
|
1307
|
+
messageId,
|
1308
|
+
toolCallId,
|
1309
|
+
result
|
1310
|
+
}) {
|
1243
1311
|
let { parentId, message } = this.repository.getMessage(messageId);
|
1244
1312
|
if (message.role !== "assistant")
|
1245
1313
|
throw new Error("Tried to add tool result to non-assistant message");
|
@@ -1266,6 +1334,11 @@ var LocalThreadRuntime = (_class5 = class {
|
|
1266
1334
|
this.performRoundtrip(parentId, message);
|
1267
1335
|
}
|
1268
1336
|
}
|
1337
|
+
speak(messageId) {
|
1338
|
+
const { message } = this.repository.getMessage(messageId);
|
1339
|
+
const adapter = new WebSpeechSynthesisAdapter();
|
1340
|
+
return adapter.speak(message);
|
1341
|
+
}
|
1269
1342
|
export() {
|
1270
1343
|
return this.repository.export();
|
1271
1344
|
}
|
@@ -1311,7 +1384,7 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
1311
1384
|
const messages = fromCoreMessages(initialMessages);
|
1312
1385
|
this.thread.import({
|
1313
1386
|
messages: messages.map((m, idx) => ({
|
1314
|
-
parentId: _nullishCoalesce(_optionalChain([messages, 'access',
|
1387
|
+
parentId: _nullishCoalesce(_optionalChain([messages, 'access', _51 => _51[idx - 1], 'optionalAccess', _52 => _52.id]), () => ( null)),
|
1315
1388
|
message: m
|
1316
1389
|
}))
|
1317
1390
|
});
|
@@ -1424,17 +1497,9 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
1424
1497
|
}
|
1425
1498
|
};
|
1426
1499
|
|
1427
|
-
// src/utils/getThreadMessageText.tsx
|
1428
|
-
var getThreadMessageText = (message) => {
|
1429
|
-
const textParts = message.content.filter(
|
1430
|
-
(part) => part.type === "text"
|
1431
|
-
);
|
1432
|
-
return textParts.map((part) => part.text).join("\n\n");
|
1433
|
-
};
|
1434
|
-
|
1435
1500
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
1436
1501
|
var hasUpcomingMessage = (isRunning, messages) => {
|
1437
|
-
return isRunning && _optionalChain([messages, 'access',
|
1502
|
+
return isRunning && _optionalChain([messages, 'access', _53 => _53[messages.length - 1], 'optionalAccess', _54 => _54.role]) !== "assistant";
|
1438
1503
|
};
|
1439
1504
|
var ExternalStoreThreadRuntime = (_class7 = class {
|
1440
1505
|
__init18() {this._subscriptions = /* @__PURE__ */ new Set()}
|
@@ -1445,7 +1510,8 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1445
1510
|
edit: false,
|
1446
1511
|
reload: false,
|
1447
1512
|
cancel: false,
|
1448
|
-
|
1513
|
+
unstable_copy: false,
|
1514
|
+
speak: false
|
1449
1515
|
}}
|
1450
1516
|
get capabilities() {
|
1451
1517
|
return this._capabilities;
|
@@ -1475,7 +1541,8 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1475
1541
|
edit: this._store.onEdit !== void 0,
|
1476
1542
|
reload: this._store.onReload !== void 0,
|
1477
1543
|
cancel: this._store.onCancel !== void 0,
|
1478
|
-
|
1544
|
+
unstable_copy: _optionalChain([this, 'access', _58 => _58._store, 'access', _59 => _59.unstable_capabilities, 'optionalAccess', _60 => _60.copy]) !== null,
|
1545
|
+
speak: this._store.onSpeak !== void 0
|
1479
1546
|
};
|
1480
1547
|
if (oldStore) {
|
1481
1548
|
if (oldStore.convertMessage !== store.convertMessage) {
|
@@ -1502,7 +1569,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1502
1569
|
for (let i = 0; i < messages.length; i++) {
|
1503
1570
|
const message = messages[i];
|
1504
1571
|
const parent = messages[i - 1];
|
1505
|
-
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess',
|
1572
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _61 => _61.id]), () => ( null)), message);
|
1506
1573
|
}
|
1507
1574
|
if (this.assistantOptimisticId) {
|
1508
1575
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -1510,7 +1577,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1510
1577
|
}
|
1511
1578
|
if (hasUpcomingMessage(isRunning, messages)) {
|
1512
1579
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
1513
|
-
_nullishCoalesce(_optionalChain([messages, 'access',
|
1580
|
+
_nullishCoalesce(_optionalChain([messages, 'access', _62 => _62.at, 'call', _63 => _63(-1), 'optionalAccess', _64 => _64.id]), () => ( null)),
|
1514
1581
|
{
|
1515
1582
|
role: "assistant",
|
1516
1583
|
content: []
|
@@ -1518,7 +1585,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1518
1585
|
);
|
1519
1586
|
}
|
1520
1587
|
this.repository.resetHead(
|
1521
|
-
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access',
|
1588
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([messages, 'access', _65 => _65.at, 'call', _66 => _66(-1), 'optionalAccess', _67 => _67.id]))), () => ( null))
|
1522
1589
|
);
|
1523
1590
|
this.messages = this.repository.getMessages();
|
1524
1591
|
this.notifySubscribers();
|
@@ -1536,7 +1603,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1536
1603
|
this.updateMessages(this.repository.getMessages());
|
1537
1604
|
}
|
1538
1605
|
async append(message) {
|
1539
|
-
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access',
|
1606
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _68 => _68.messages, 'access', _69 => _69.at, 'call', _70 => _70(-1), 'optionalAccess', _71 => _71.id]), () => ( null)))) {
|
1540
1607
|
if (!this._store.onEdit)
|
1541
1608
|
throw new Error("Runtime does not support editing messages.");
|
1542
1609
|
await this._store.onEdit(message);
|
@@ -1559,7 +1626,7 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1559
1626
|
}
|
1560
1627
|
let messages = this.repository.getMessages();
|
1561
1628
|
const previousMessage = messages[messages.length - 1];
|
1562
|
-
if (_optionalChain([previousMessage, 'optionalAccess',
|
1629
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _72 => _72.role]) === "user" && previousMessage.id === _optionalChain([messages, 'access', _73 => _73.at, 'call', _74 => _74(-1), 'optionalAccess', _75 => _75.id])) {
|
1563
1630
|
this.repository.deleteMessage(previousMessage.id);
|
1564
1631
|
if (!this.composer.text.trim()) {
|
1565
1632
|
this.composer.setText(getThreadMessageText(previousMessage));
|
@@ -1572,20 +1639,26 @@ var ExternalStoreThreadRuntime = (_class7 = class {
|
|
1572
1639
|
this.updateMessages(messages);
|
1573
1640
|
}, 0);
|
1574
1641
|
}
|
1642
|
+
addToolResult(options) {
|
1643
|
+
if (!this._store.onAddToolResult)
|
1644
|
+
throw new Error("Runtime does not support tool results.");
|
1645
|
+
this._store.onAddToolResult(options);
|
1646
|
+
}
|
1647
|
+
speak(messageId) {
|
1648
|
+
if (!this._store.onSpeak)
|
1649
|
+
throw new Error("Runtime does not support speaking.");
|
1650
|
+
const { message } = this.repository.getMessage(messageId);
|
1651
|
+
return this._store.onSpeak(message);
|
1652
|
+
}
|
1575
1653
|
subscribe(callback) {
|
1576
1654
|
this._subscriptions.add(callback);
|
1577
1655
|
return () => this._subscriptions.delete(callback);
|
1578
1656
|
}
|
1579
1657
|
__init26() {this.updateMessages = (messages) => {
|
1580
|
-
_optionalChain([this, 'access',
|
1658
|
+
_optionalChain([this, 'access', _76 => _76._store, 'access', _77 => _77.setMessages, 'optionalCall', _78 => _78(
|
1581
1659
|
messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
1582
1660
|
)]);
|
1583
1661
|
}}
|
1584
|
-
addToolResult(options) {
|
1585
|
-
if (!this._store.onAddToolResult)
|
1586
|
-
throw new Error("Runtime does not support tool results.");
|
1587
|
-
this._store.onAddToolResult(options);
|
1588
|
-
}
|
1589
1662
|
}, _class7);
|
1590
1663
|
|
1591
1664
|
// src/runtimes/external-store/ExternalStoreRuntime.tsx
|
@@ -1793,7 +1866,7 @@ var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProvider
|
|
1793
1866
|
var MessageContext = _react.createContext.call(void 0, null);
|
1794
1867
|
function useMessageContext(options) {
|
1795
1868
|
const context = _react.useContext.call(void 0, MessageContext);
|
1796
|
-
if (!_optionalChain([options, 'optionalAccess',
|
1869
|
+
if (!_optionalChain([options, 'optionalAccess', _79 => _79.optional]) && !context)
|
1797
1870
|
throw new Error(
|
1798
1871
|
"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
|
1799
1872
|
);
|
@@ -1820,7 +1893,7 @@ var ContentPartContext = _react.createContext.call(void 0,
|
|
1820
1893
|
);
|
1821
1894
|
function useContentPartContext(options) {
|
1822
1895
|
const context = _react.useContext.call(void 0, ContentPartContext);
|
1823
|
-
if (!_optionalChain([options, 'optionalAccess',
|
1896
|
+
if (!_optionalChain([options, 'optionalAccess', _80 => _80.optional]) && !context)
|
1824
1897
|
throw new Error(
|
1825
1898
|
"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
|
1826
1899
|
);
|
@@ -1832,13 +1905,13 @@ function useContentPartContext(options) {
|
|
1832
1905
|
var toAppendMessage = (useThreadMessages, message) => {
|
1833
1906
|
if (typeof message === "string") {
|
1834
1907
|
return {
|
1835
|
-
parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access',
|
1908
|
+
parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _81 => _81.getState, 'call', _82 => _82(), 'access', _83 => _83.at, 'call', _84 => _84(-1), 'optionalAccess', _85 => _85.id]), () => ( null)),
|
1836
1909
|
role: "user",
|
1837
1910
|
content: [{ type: "text", text: message }]
|
1838
1911
|
};
|
1839
1912
|
}
|
1840
1913
|
return {
|
1841
|
-
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access',
|
1914
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _86 => _86.getState, 'call', _87 => _87(), 'access', _88 => _88.at, 'call', _89 => _89(-1), 'optionalAccess', _90 => _90.id]))), () => ( null)),
|
1842
1915
|
role: _nullishCoalesce(message.role, () => ( "user")),
|
1843
1916
|
content: message.content
|
1844
1917
|
};
|
@@ -1890,7 +1963,7 @@ var useAssistantTool = (tool) => {
|
|
1890
1963
|
const unsub2 = render ? setToolUI(toolName, render) : void 0;
|
1891
1964
|
return () => {
|
1892
1965
|
unsub1();
|
1893
|
-
_optionalChain([unsub2, 'optionalCall',
|
1966
|
+
_optionalChain([unsub2, 'optionalCall', _91 => _91()]);
|
1894
1967
|
};
|
1895
1968
|
}, [registerModelConfigProvider, setToolUI, tool]);
|
1896
1969
|
};
|
@@ -1976,8 +2049,8 @@ var useActionBarCopy = ({
|
|
1976
2049
|
const { useMessage, useMessageUtils, useEditComposer } = useMessageContext();
|
1977
2050
|
const hasCopyableContent = useCombinedStore(
|
1978
2051
|
[useMessage, useEditComposer],
|
1979
|
-
(
|
1980
|
-
return !c.isEditing &&
|
2052
|
+
({ message }, c) => {
|
2053
|
+
return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
1981
2054
|
}
|
1982
2055
|
);
|
1983
2056
|
const callback = _react.useCallback.call(void 0, () => {
|
@@ -2029,6 +2102,38 @@ var useActionBarReload = () => {
|
|
2029
2102
|
return callback;
|
2030
2103
|
};
|
2031
2104
|
|
2105
|
+
// src/primitive-hooks/actionBar/useActionBarSpeak.tsx
|
2106
|
+
|
2107
|
+
var useActionBarSpeak = () => {
|
2108
|
+
const { useThreadActions } = useThreadContext();
|
2109
|
+
const { useMessage, useEditComposer, useMessageUtils } = useMessageContext();
|
2110
|
+
const hasSpeakableContent = useCombinedStore(
|
2111
|
+
[useMessage, useEditComposer],
|
2112
|
+
({ message }, c) => {
|
2113
|
+
return !c.isEditing && (message.role !== "assistant" || message.status.type !== "running") && message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
2114
|
+
}
|
2115
|
+
);
|
2116
|
+
const callback = _react.useCallback.call(void 0, async () => {
|
2117
|
+
const { message } = useMessage.getState();
|
2118
|
+
const utt = useThreadActions.getState().speak(message.id);
|
2119
|
+
useMessageUtils.getState().addUtterance(utt);
|
2120
|
+
}, [useThreadActions, useMessage, useMessageUtils]);
|
2121
|
+
if (!hasSpeakableContent) return null;
|
2122
|
+
return callback;
|
2123
|
+
};
|
2124
|
+
|
2125
|
+
// src/primitive-hooks/actionBar/useActionBarStopSpeaking.tsx
|
2126
|
+
|
2127
|
+
var useActionBarStopSpeaking = () => {
|
2128
|
+
const { useMessageUtils } = useMessageContext();
|
2129
|
+
const isSpeaking = useMessageUtils((u) => u.isSpeaking);
|
2130
|
+
const callback = _react.useCallback.call(void 0, async () => {
|
2131
|
+
useMessageUtils.getState().stopSpeaking();
|
2132
|
+
}, [useMessageUtils]);
|
2133
|
+
if (!isSpeaking) return null;
|
2134
|
+
return callback;
|
2135
|
+
};
|
2136
|
+
|
2032
2137
|
// src/primitive-hooks/branchPicker/useBranchPickerCount.tsx
|
2033
2138
|
var useBranchPickerCount = () => {
|
2034
2139
|
const { useMessage } = useMessageContext();
|
@@ -2168,7 +2273,7 @@ var useMessageIf = (props) => {
|
|
2168
2273
|
const { useMessage, useMessageUtils } = useMessageContext();
|
2169
2274
|
return useCombinedStore(
|
2170
2275
|
[useMessage, useMessageUtils],
|
2171
|
-
({ message, branches, isLast }, { isCopied, isHovering }) => {
|
2276
|
+
({ message, branches, isLast }, { isCopied, isHovering, isSpeaking }) => {
|
2172
2277
|
if (props.hasBranches === true && branches.length < 2) return false;
|
2173
2278
|
if (props.user && message.role !== "user") return false;
|
2174
2279
|
if (props.assistant && message.role !== "assistant") return false;
|
@@ -2176,6 +2281,8 @@ var useMessageIf = (props) => {
|
|
2176
2281
|
if (props.lastOrHover === true && !isHovering && !isLast) return false;
|
2177
2282
|
if (props.copied === true && !isCopied) return false;
|
2178
2283
|
if (props.copied === false && isCopied) return false;
|
2284
|
+
if (props.speaking === true && !isSpeaking) return false;
|
2285
|
+
if (props.speaking === false && isSpeaking) return false;
|
2179
2286
|
return true;
|
2180
2287
|
}
|
2181
2288
|
);
|
@@ -2245,7 +2352,9 @@ _chunkDCHYNTHIjs.__export.call(void 0, actionBar_exports, {
|
|
2245
2352
|
Copy: () => ActionBarPrimitiveCopy,
|
2246
2353
|
Edit: () => ActionBarPrimitiveEdit,
|
2247
2354
|
Reload: () => ActionBarPrimitiveReload,
|
2248
|
-
Root: () => ActionBarPrimitiveRoot
|
2355
|
+
Root: () => ActionBarPrimitiveRoot,
|
2356
|
+
Speak: () => ActionBarPrimitiveSpeak,
|
2357
|
+
StopSpeaking: () => ActionBarPrimitiveStopSpeaking
|
2249
2358
|
});
|
2250
2359
|
|
2251
2360
|
// src/primitives/actionBar/ActionBarRoot.tsx
|
@@ -2319,7 +2428,7 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
2319
2428
|
...primitiveProps,
|
2320
2429
|
ref: forwardedRef,
|
2321
2430
|
onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
|
2322
|
-
_optionalChain([callback, 'optionalCall',
|
2431
|
+
_optionalChain([callback, 'optionalCall', _92 => _92()]);
|
2323
2432
|
})
|
2324
2433
|
}
|
2325
2434
|
);
|
@@ -2347,6 +2456,40 @@ var ActionBarPrimitiveEdit = createActionButton(
|
|
2347
2456
|
useActionBarEdit
|
2348
2457
|
);
|
2349
2458
|
|
2459
|
+
// src/primitives/actionBar/ActionBarSpeak.tsx
|
2460
|
+
var ActionBarPrimitiveSpeak = createActionButton(
|
2461
|
+
"ActionBarPrimitive.Speak",
|
2462
|
+
useActionBarSpeak
|
2463
|
+
);
|
2464
|
+
|
2465
|
+
// src/primitives/actionBar/ActionBarStopSpeaking.tsx
|
2466
|
+
|
2467
|
+
var _reactuseescapekeydown = require('@radix-ui/react-use-escape-keydown');
|
2468
|
+
|
2469
|
+
|
2470
|
+
|
2471
|
+
var ActionBarPrimitiveStopSpeaking = _react.forwardRef.call(void 0, (props, ref) => {
|
2472
|
+
const callback = useActionBarStopSpeaking();
|
2473
|
+
_reactuseescapekeydown.useEscapeKeydown.call(void 0, (e) => {
|
2474
|
+
if (callback) {
|
2475
|
+
e.preventDefault();
|
2476
|
+
callback();
|
2477
|
+
}
|
2478
|
+
});
|
2479
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
2480
|
+
_reactprimitive.Primitive.button,
|
2481
|
+
{
|
2482
|
+
type: "button",
|
2483
|
+
disabled: !callback,
|
2484
|
+
...props,
|
2485
|
+
ref,
|
2486
|
+
onClick: _primitive.composeEventHandlers.call(void 0, props.onClick, () => {
|
2487
|
+
_optionalChain([callback, 'optionalCall', _93 => _93()]);
|
2488
|
+
})
|
2489
|
+
}
|
2490
|
+
);
|
2491
|
+
});
|
2492
|
+
|
2350
2493
|
// src/primitives/assistantModal/index.ts
|
2351
2494
|
var assistantModal_exports = {};
|
2352
2495
|
_chunkDCHYNTHIjs.__export.call(void 0, assistantModal_exports, {
|
@@ -2574,9 +2717,9 @@ var useIsHoveringRef = () => {
|
|
2574
2717
|
);
|
2575
2718
|
return useManagedRef(callbackRef);
|
2576
2719
|
};
|
2577
|
-
var MessagePrimitiveRoot = _react.forwardRef.call(void 0, ({ onMouseEnter, onMouseLeave, ...rest },
|
2720
|
+
var MessagePrimitiveRoot = _react.forwardRef.call(void 0, ({ onMouseEnter, onMouseLeave, ...rest }, forwardRef30) => {
|
2578
2721
|
const isHoveringRef = useIsHoveringRef();
|
2579
|
-
const ref = _reactcomposerefs.useComposedRefs.call(void 0,
|
2722
|
+
const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardRef30, isHoveringRef);
|
2580
2723
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...rest, ref });
|
2581
2724
|
});
|
2582
2725
|
MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
|
@@ -2627,7 +2770,7 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
|
|
2627
2770
|
}
|
2628
2771
|
}
|
2629
2772
|
const status = toContentPartStatus(message, partIndex, part);
|
2630
|
-
const currentState = _optionalChain([useContentPart, 'optionalAccess',
|
2773
|
+
const currentState = _optionalChain([useContentPart, 'optionalAccess', _94 => _94.getState, 'call', _95 => _95()]);
|
2631
2774
|
if (currentState && currentState.part === part && currentState.status === status)
|
2632
2775
|
return null;
|
2633
2776
|
return Object.freeze({ part, status });
|
@@ -2775,7 +2918,7 @@ var MessageContentPartImpl = ({
|
|
2775
2918
|
};
|
2776
2919
|
var MessageContentPart = _react.memo.call(void 0,
|
2777
2920
|
MessageContentPartImpl,
|
2778
|
-
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access',
|
2921
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _96 => _96.components, 'optionalAccess', _97 => _97.Text]) === _optionalChain([next, 'access', _98 => _98.components, 'optionalAccess', _99 => _99.Text]) && _optionalChain([prev, 'access', _100 => _100.components, 'optionalAccess', _101 => _101.Image]) === _optionalChain([next, 'access', _102 => _102.components, 'optionalAccess', _103 => _103.Image]) && _optionalChain([prev, 'access', _104 => _104.components, 'optionalAccess', _105 => _105.UI]) === _optionalChain([next, 'access', _106 => _106.components, 'optionalAccess', _107 => _107.UI]) && _optionalChain([prev, 'access', _108 => _108.components, 'optionalAccess', _109 => _109.tools]) === _optionalChain([next, 'access', _110 => _110.components, 'optionalAccess', _111 => _111.tools])
|
2779
2922
|
);
|
2780
2923
|
var MessagePrimitiveContent = ({
|
2781
2924
|
components
|
@@ -2855,7 +2998,7 @@ var _reactslot = require('@radix-ui/react-slot');
|
|
2855
2998
|
|
2856
2999
|
|
2857
3000
|
var _reacttextareaautosize = require('react-textarea-autosize'); var _reacttextareaautosize2 = _interopRequireDefault(_reacttextareaautosize);
|
2858
|
-
|
3001
|
+
|
2859
3002
|
|
2860
3003
|
var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
2861
3004
|
({
|
@@ -2890,7 +3033,7 @@ var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
|
2890
3033
|
const { isRunning } = useThread.getState();
|
2891
3034
|
if (!isRunning) {
|
2892
3035
|
e.preventDefault();
|
2893
|
-
_optionalChain([textareaRef, 'access',
|
3036
|
+
_optionalChain([textareaRef, 'access', _112 => _112.current, 'optionalAccess', _113 => _113.closest, 'call', _114 => _114("form"), 'optionalAccess', _115 => _115.requestSubmit, 'call', _116 => _116()]);
|
2894
3037
|
}
|
2895
3038
|
}
|
2896
3039
|
};
|
@@ -3179,29 +3322,43 @@ var makeEditComposerStore = ({
|
|
3179
3322
|
|
3180
3323
|
// src/context/stores/MessageUtils.ts
|
3181
3324
|
|
3182
|
-
var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) =>
|
3183
|
-
|
3184
|
-
|
3185
|
-
|
3186
|
-
|
3187
|
-
|
3188
|
-
|
3189
|
-
|
3190
|
-
|
3191
|
-
})
|
3325
|
+
var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => {
|
3326
|
+
let utterance = null;
|
3327
|
+
return {
|
3328
|
+
isCopied: false,
|
3329
|
+
setIsCopied: (value) => {
|
3330
|
+
set({ isCopied: value });
|
3331
|
+
},
|
3332
|
+
isHovering: false,
|
3333
|
+
setIsHovering: (value) => {
|
3334
|
+
set({ isHovering: value });
|
3335
|
+
},
|
3336
|
+
isSpeaking: false,
|
3337
|
+
stopSpeaking: () => {
|
3338
|
+
_optionalChain([utterance, 'optionalAccess', _117 => _117.stop, 'call', _118 => _118()]);
|
3339
|
+
},
|
3340
|
+
addUtterance: (utt) => {
|
3341
|
+
utterance = utt;
|
3342
|
+
set({ isSpeaking: true });
|
3343
|
+
utt.onEnd(() => {
|
3344
|
+
set({ isSpeaking: false });
|
3345
|
+
});
|
3346
|
+
}
|
3347
|
+
};
|
3348
|
+
});
|
3192
3349
|
|
3193
3350
|
// src/context/providers/MessageProvider.tsx
|
3194
3351
|
|
3195
3352
|
var getIsLast = (messages, message) => {
|
3196
|
-
return _optionalChain([messages, 'access',
|
3353
|
+
return _optionalChain([messages, 'access', _119 => _119[messages.length - 1], 'optionalAccess', _120 => _120.id]) === message.id;
|
3197
3354
|
};
|
3198
3355
|
var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
3199
|
-
const parentId = _nullishCoalesce(_optionalChain([messages, 'access',
|
3356
|
+
const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _121 => _121[messageIndex - 1], 'optionalAccess', _122 => _122.id]), () => ( null));
|
3200
3357
|
const message = messages[messageIndex];
|
3201
3358
|
if (!message) return null;
|
3202
3359
|
const isLast = getIsLast(messages, message);
|
3203
3360
|
const branches = getBranches(message.id);
|
3204
|
-
const currentState = _optionalChain([useMessage, 'optionalAccess',
|
3361
|
+
const currentState = _optionalChain([useMessage, 'optionalAccess', _123 => _123.getState, 'call', _124 => _124()]);
|
3205
3362
|
if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
|
3206
3363
|
return null;
|
3207
3364
|
return Object.freeze({
|
@@ -3328,7 +3485,7 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
3328
3485
|
ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
|
3329
3486
|
var ThreadPrimitiveMessages = _react.memo.call(void 0,
|
3330
3487
|
ThreadPrimitiveMessagesImpl,
|
3331
|
-
(prev, next) => _optionalChain([prev, 'access',
|
3488
|
+
(prev, next) => _optionalChain([prev, 'access', _125 => _125.components, 'optionalAccess', _126 => _126.Message]) === _optionalChain([next, 'access', _127 => _127.components, 'optionalAccess', _128 => _128.Message]) && _optionalChain([prev, 'access', _129 => _129.components, 'optionalAccess', _130 => _130.UserMessage]) === _optionalChain([next, 'access', _131 => _131.components, 'optionalAccess', _132 => _132.UserMessage]) && _optionalChain([prev, 'access', _133 => _133.components, 'optionalAccess', _134 => _134.EditComposer]) === _optionalChain([next, 'access', _135 => _135.components, 'optionalAccess', _136 => _136.EditComposer]) && _optionalChain([prev, 'access', _137 => _137.components, 'optionalAccess', _138 => _138.AssistantMessage]) === _optionalChain([next, 'access', _139 => _139.components, 'optionalAccess', _140 => _140.AssistantMessage]) && _optionalChain([prev, 'access', _141 => _141.components, 'optionalAccess', _142 => _142.SystemMessage]) === _optionalChain([next, 'access', _143 => _143.components, 'optionalAccess', _144 => _144.SystemMessage])
|
3332
3489
|
);
|
3333
3490
|
|
3334
3491
|
// src/primitives/thread/ThreadScrollToBottom.tsx
|
@@ -3360,7 +3517,7 @@ var ThreadConfigProvider = ({
|
|
3360
3517
|
}) => {
|
3361
3518
|
const assistant = useAssistantContext({ optional: true });
|
3362
3519
|
const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
|
3363
|
-
if (!_optionalChain([config, 'optionalAccess',
|
3520
|
+
if (!_optionalChain([config, 'optionalAccess', _145 => _145.runtime])) return configProvider;
|
3364
3521
|
if (assistant) {
|
3365
3522
|
throw new Error(
|
3366
3523
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
@@ -3372,14 +3529,26 @@ ThreadConfigProvider.displayName = "ThreadConfigProvider";
|
|
3372
3529
|
|
3373
3530
|
// src/ui/assistant-action-bar.tsx
|
3374
3531
|
|
3532
|
+
|
3533
|
+
|
3534
|
+
|
3535
|
+
|
3536
|
+
|
3537
|
+
|
3375
3538
|
var _lucidereact = require('lucide-react');
|
3376
3539
|
|
3377
3540
|
var useAllowCopy = () => {
|
3378
3541
|
const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
|
3379
3542
|
const { useThread } = useThreadContext();
|
3380
|
-
const copySupported = useThread((t) => t.capabilities.
|
3543
|
+
const copySupported = useThread((t) => t.capabilities.unstable_copy);
|
3381
3544
|
return copySupported && allowCopy;
|
3382
3545
|
};
|
3546
|
+
var useAllowSpeak = () => {
|
3547
|
+
const { assistantMessage: { allowSpeak = true } = {} } = useThreadConfig();
|
3548
|
+
const { useThread } = useThreadContext();
|
3549
|
+
const speakSupported = useThread((t) => t.capabilities.speak);
|
3550
|
+
return speakSupported && allowSpeak;
|
3551
|
+
};
|
3383
3552
|
var useAllowReload = () => {
|
3384
3553
|
const { assistantMessage: { allowReload = true } = {} } = useThreadConfig();
|
3385
3554
|
const { useThread } = useThreadContext();
|
@@ -3397,6 +3566,7 @@ var AssistantActionBar = () => {
|
|
3397
3566
|
autohide: "not-last",
|
3398
3567
|
autohideFloat: "single-branch",
|
3399
3568
|
children: [
|
3569
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarSpeechControl, {}),
|
3400
3570
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarCopy, {}),
|
3401
3571
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarReload, {})
|
3402
3572
|
]
|
@@ -3411,7 +3581,7 @@ AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
|
|
3411
3581
|
var AssistantActionBarCopy = _react.forwardRef.call(void 0, (props, ref) => {
|
3412
3582
|
const {
|
3413
3583
|
strings: {
|
3414
|
-
assistantMessage: {
|
3584
|
+
assistantMessage: { copy: { tooltip = "Copy" } = {} } = {}
|
3415
3585
|
} = {}
|
3416
3586
|
} = useThreadConfig();
|
3417
3587
|
const allowCopy = useAllowCopy();
|
@@ -3422,6 +3592,36 @@ var AssistantActionBarCopy = _react.forwardRef.call(void 0, (props, ref) => {
|
|
3422
3592
|
] }))) }) });
|
3423
3593
|
});
|
3424
3594
|
AssistantActionBarCopy.displayName = "AssistantActionBarCopy";
|
3595
|
+
var AssistantActionBarSpeechControl = () => {
|
3596
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
3597
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { speaking: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarSpeak, {}) }),
|
3598
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { speaking: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarStopSpeaking, {}) })
|
3599
|
+
] });
|
3600
|
+
};
|
3601
|
+
var AssistantActionBarSpeak = _react.forwardRef.call(void 0, (props, ref) => {
|
3602
|
+
const {
|
3603
|
+
strings: {
|
3604
|
+
assistantMessage: { speak: { tooltip = "Read aloud" } = {} } = {}
|
3605
|
+
} = {}
|
3606
|
+
} = useThreadConfig();
|
3607
|
+
const allowSpeak = useAllowSpeak();
|
3608
|
+
if (!allowSpeak) return null;
|
3609
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Speak, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.AudioLinesIcon, {}))) }) });
|
3610
|
+
});
|
3611
|
+
AssistantActionBarSpeak.displayName = "AssistantActionBarSpeak";
|
3612
|
+
var AssistantActionBarStopSpeaking = _react.forwardRef.call(void 0, (props, ref) => {
|
3613
|
+
const {
|
3614
|
+
strings: {
|
3615
|
+
assistantMessage: {
|
3616
|
+
speak: { stop: { tooltip: stopTooltip = "Stop" } = {} } = {}
|
3617
|
+
} = {}
|
3618
|
+
} = {}
|
3619
|
+
} = useThreadConfig();
|
3620
|
+
const allowSpeak = useAllowSpeak();
|
3621
|
+
if (!allowSpeak) return null;
|
3622
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.StopSpeaking, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip: stopTooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.StopCircleIcon, {}))) }) });
|
3623
|
+
});
|
3624
|
+
AssistantActionBarStopSpeaking.displayName = "AssistantActionBarStopSpeaking";
|
3425
3625
|
var AssistantActionBarReload = _react.forwardRef.call(void 0, (props, ref) => {
|
3426
3626
|
const {
|
3427
3627
|
strings: {
|
@@ -3436,7 +3636,10 @@ AssistantActionBarReload.displayName = "AssistantActionBarReload";
|
|
3436
3636
|
var exports = {
|
3437
3637
|
Root: AssistantActionBarRoot,
|
3438
3638
|
Reload: AssistantActionBarReload,
|
3439
|
-
Copy: AssistantActionBarCopy
|
3639
|
+
Copy: AssistantActionBarCopy,
|
3640
|
+
Speak: AssistantActionBarSpeak,
|
3641
|
+
StopSpeaking: AssistantActionBarStopSpeaking,
|
3642
|
+
SpeechControl: AssistantActionBarSpeechControl
|
3440
3643
|
};
|
3441
3644
|
var assistant_action_bar_default = Object.assign(
|
3442
3645
|
AssistantActionBar,
|
@@ -3576,7 +3779,7 @@ var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: comp
|
|
3576
3779
|
{
|
3577
3780
|
components: {
|
3578
3781
|
...componentsProp,
|
3579
|
-
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess',
|
3782
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _146 => _146.Text]), () => ( components.Text)), () => ( content_part_default.Text))
|
3580
3783
|
}
|
3581
3784
|
}
|
3582
3785
|
) });
|
@@ -3753,7 +3956,7 @@ var ThreadWelcomeSuggestion = ({
|
|
3753
3956
|
};
|
3754
3957
|
var ThreadWelcomeSuggestions = () => {
|
3755
3958
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
3756
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess',
|
3959
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _147 => _147.map, 'call', _148 => _148((suggestion, idx) => {
|
3757
3960
|
const key = `${suggestion.prompt}-${idx}`;
|
3758
3961
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
3759
3962
|
})]) });
|
@@ -3831,7 +4034,7 @@ var UserMessageContent = _react.forwardRef.call(void 0,
|
|
3831
4034
|
{
|
3832
4035
|
components: {
|
3833
4036
|
...components,
|
3834
|
-
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4037
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _149 => _149.Text]), () => ( content_part_default.Text))
|
3835
4038
|
}
|
3836
4039
|
}
|
3837
4040
|
) });
|
@@ -3933,10 +4136,10 @@ var ThreadMessages = ({ components, ...rest }) => {
|
|
3933
4136
|
thread_exports.Messages,
|
3934
4137
|
{
|
3935
4138
|
components: {
|
3936
|
-
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3937
|
-
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3938
|
-
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
3939
|
-
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess',
|
4139
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _150 => _150.UserMessage]), () => ( user_message_default)),
|
4140
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _151 => _151.EditComposer]), () => ( edit_composer_default)),
|
4141
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _152 => _152.AssistantMessage]), () => ( assistant_message_default)),
|
4142
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _153 => _153.SystemMessage]), () => ( SystemMessage))
|
3940
4143
|
},
|
3941
4144
|
...rest
|
3942
4145
|
}
|
@@ -4115,5 +4318,8 @@ var assistant_modal_default = Object.assign(AssistantModal, exports11);
|
|
4115
4318
|
|
4116
4319
|
|
4117
4320
|
|
4118
|
-
|
4321
|
+
|
4322
|
+
|
4323
|
+
|
4324
|
+
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerPrimitive = composer_exports; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.WebSpeechSynthesisAdapter = WebSpeechSynthesisAdapter; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.streamUtils = streamUtils; exports.subscribeToMainThread = subscribeToMainThread; exports.toCoreMessage = _chunkBQ3MRWUVjs.toCoreMessage; exports.toCoreMessages = _chunkBQ3MRWUVjs.toCoreMessages; exports.toLanguageModelMessages = _chunkBQ3MRWUVjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkBQ3MRWUVjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useActionBarSpeak = useActionBarSpeak; exports.useActionBarStopSpeaking = useActionBarStopSpeaking; exports.useAppendMessage = useAppendMessage; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartText = useContentPartText; exports.useDangerousInBrowserRuntime = useDangerousInBrowserRuntime; exports.useEdgeRuntime = useEdgeRuntime; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadSuggestion = useThreadSuggestion;
|
4119
4325
|
//# sourceMappingURL=index.js.map
|