@liveblocks/core 2.16.0-toolbars5 → 2.16.1-ai
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/index.d.mts +86 -49
- package/dist/index.d.ts +86 -49
- package/dist/index.js +38 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
|
|
7
7
|
// src/version.ts
|
|
8
8
|
var PKG_NAME = "@liveblocks/core";
|
|
9
|
-
var PKG_VERSION = "2.16.
|
|
9
|
+
var PKG_VERSION = "2.16.1-ai";
|
|
10
10
|
var PKG_FORMAT = "esm";
|
|
11
11
|
|
|
12
12
|
// src/dupe-detection.ts
|
|
@@ -1536,6 +1536,25 @@ function createApiClient({
|
|
|
1536
1536
|
}
|
|
1537
1537
|
);
|
|
1538
1538
|
}
|
|
1539
|
+
async function executeContextualPrompt(options) {
|
|
1540
|
+
const result = await httpClient.post(
|
|
1541
|
+
url`/v2/c/rooms/${options.roomId}/ai/contextual-prompt`,
|
|
1542
|
+
await authManager.getAuthValue({
|
|
1543
|
+
requestedScope: "room:read",
|
|
1544
|
+
roomId: options.roomId
|
|
1545
|
+
}),
|
|
1546
|
+
{
|
|
1547
|
+
prompt: options.prompt,
|
|
1548
|
+
selectionText: options.selectionText,
|
|
1549
|
+
context: options.context
|
|
1550
|
+
},
|
|
1551
|
+
{ signal: options.signal }
|
|
1552
|
+
);
|
|
1553
|
+
if (!result || result.content.length === 0) {
|
|
1554
|
+
throw new Error("No content returned from server");
|
|
1555
|
+
}
|
|
1556
|
+
return result.content[0].text;
|
|
1557
|
+
}
|
|
1539
1558
|
async function listTextVersions(options) {
|
|
1540
1559
|
const result = await httpClient.get(
|
|
1541
1560
|
url`/v2/c/rooms/${options.roomId}/versions`,
|
|
@@ -1776,7 +1795,9 @@ function createApiClient({
|
|
|
1776
1795
|
deleteInboxNotification,
|
|
1777
1796
|
// User threads
|
|
1778
1797
|
getUserThreads_experimental,
|
|
1779
|
-
getUserThreadsSince_experimental
|
|
1798
|
+
getUserThreadsSince_experimental,
|
|
1799
|
+
// ai
|
|
1800
|
+
executeContextualPrompt
|
|
1780
1801
|
};
|
|
1781
1802
|
}
|
|
1782
1803
|
function getBearerTokenFromAuthValue(authValue) {
|
|
@@ -6504,6 +6525,12 @@ function createRoom(options, config) {
|
|
|
6504
6525
|
async function createTextVersion() {
|
|
6505
6526
|
return httpClient.createTextVersion({ roomId });
|
|
6506
6527
|
}
|
|
6528
|
+
async function executeContextualPrompt(options2) {
|
|
6529
|
+
return httpClient.executeContextualPrompt({
|
|
6530
|
+
roomId,
|
|
6531
|
+
...options2
|
|
6532
|
+
});
|
|
6533
|
+
}
|
|
6507
6534
|
function sendMessages(messages) {
|
|
6508
6535
|
const serializedPayload = JSON.stringify(messages);
|
|
6509
6536
|
const nonce = context.dynamicSessionInfoSig.get()?.nonce;
|
|
@@ -7071,11 +7098,12 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7071
7098
|
}
|
|
7072
7099
|
return messages;
|
|
7073
7100
|
}
|
|
7074
|
-
function updateYDoc(update, guid) {
|
|
7101
|
+
function updateYDoc(update, guid, isV2) {
|
|
7075
7102
|
const clientMsg = {
|
|
7076
7103
|
type: 301 /* UPDATE_YDOC */,
|
|
7077
7104
|
update,
|
|
7078
|
-
guid
|
|
7105
|
+
guid,
|
|
7106
|
+
v2: isV2
|
|
7079
7107
|
};
|
|
7080
7108
|
context.buffer.messages.push(clientMsg);
|
|
7081
7109
|
eventHub.ydoc.notify(clientMsg);
|
|
@@ -7156,14 +7184,15 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7156
7184
|
root: nn(context.root)
|
|
7157
7185
|
};
|
|
7158
7186
|
}
|
|
7159
|
-
function fetchYDoc(vector, guid) {
|
|
7187
|
+
function fetchYDoc(vector, guid, isV2) {
|
|
7160
7188
|
if (!context.buffer.messages.find((m) => {
|
|
7161
|
-
return m.type === 300 /* FETCH_YDOC */ && m.vector === vector && m.guid === guid;
|
|
7189
|
+
return m.type === 300 /* FETCH_YDOC */ && m.vector === vector && m.guid === guid && m.v2 === isV2;
|
|
7162
7190
|
})) {
|
|
7163
7191
|
context.buffer.messages.push({
|
|
7164
7192
|
type: 300 /* FETCH_YDOC */,
|
|
7165
7193
|
vector,
|
|
7166
|
-
guid
|
|
7194
|
+
guid,
|
|
7195
|
+
v2: isV2
|
|
7167
7196
|
});
|
|
7168
7197
|
}
|
|
7169
7198
|
flushNowOrSoon();
|
|
@@ -7487,6 +7516,8 @@ ${Array.from(traces).join("\n\n")}`
|
|
|
7487
7516
|
getTextVersion,
|
|
7488
7517
|
// create a version
|
|
7489
7518
|
createTextVersion,
|
|
7519
|
+
// execute contextual prompt
|
|
7520
|
+
executeContextualPrompt,
|
|
7490
7521
|
// Support for the Liveblocks browser extension
|
|
7491
7522
|
getSelf_forDevTools: () => selfAsTreeNode.get(),
|
|
7492
7523
|
getOthers_forDevTools: () => others_forDevTools.get(),
|