@blinkk/root-cms 3.0.1-beta.3 → 3.0.1-beta.4
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/app.js +3 -2
- package/dist/{chunk-F4SODS5S.js → chunk-2BSW7SIH.js} +295 -4
- package/dist/chunk-BGTUWIV6.js +187 -0
- package/dist/{chunk-TRM4MQHU.js → chunk-C245C557.js} +14 -192
- package/dist/{chunk-NXEXOHBD.js → chunk-MVS2NLZM.js} +243 -16
- package/dist/cli.js +1 -2
- package/dist/client.js +1 -2
- package/dist/core.js +1 -2
- package/dist/functions.js +3 -3
- package/dist/plugin.js +29 -12
- package/dist/ui/ui.js +161 -161
- package/package.json +3 -3
- package/dist/chunk-CRK7N6RR.js +0 -298
package/dist/plugin.js
CHANGED
|
@@ -12,17 +12,18 @@ import {
|
|
|
12
12
|
serializeAiConfig,
|
|
13
13
|
summarizeDiff,
|
|
14
14
|
translateString
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-MVS2NLZM.js";
|
|
16
16
|
import {
|
|
17
|
-
SearchIndexService,
|
|
18
17
|
runCronJobs
|
|
19
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-BGTUWIV6.js";
|
|
19
|
+
import {
|
|
20
|
+
SearchIndexService
|
|
21
|
+
} from "./chunk-C245C557.js";
|
|
20
22
|
import {
|
|
21
23
|
RootCMSClient,
|
|
22
24
|
parseDocId,
|
|
23
25
|
unmarshalData
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-CRK7N6RR.js";
|
|
26
|
+
} from "./chunk-2BSW7SIH.js";
|
|
26
27
|
import "./chunk-MLKGABMK.js";
|
|
27
28
|
|
|
28
29
|
// core/plugin.ts
|
|
@@ -546,11 +547,6 @@ function api(server, options) {
|
|
|
546
547
|
return;
|
|
547
548
|
}
|
|
548
549
|
const body = req.body || {};
|
|
549
|
-
const messages = body.messages || [];
|
|
550
|
-
if (!Array.isArray(messages) || messages.length === 0) {
|
|
551
|
-
res.status(400).json({ success: false, error: "MISSING_MESSAGES" });
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
550
|
const model = findModel(aiConfig, body.modelId);
|
|
555
551
|
if (!model) {
|
|
556
552
|
res.status(400).json({ success: false, error: "UNKNOWN_MODEL" });
|
|
@@ -561,10 +557,12 @@ function api(server, options) {
|
|
|
561
557
|
const store = new ChatStore(cmsClient, req.user.email);
|
|
562
558
|
const requestedChatId = typeof body.chatId === "string" ? body.chatId.trim() : "";
|
|
563
559
|
let chatId = "";
|
|
560
|
+
let storedMessages = [];
|
|
564
561
|
if (requestedChatId) {
|
|
565
562
|
const existing = await store.getChat(requestedChatId);
|
|
566
563
|
if (existing) {
|
|
567
564
|
chatId = existing.id;
|
|
565
|
+
storedMessages = existing.messages || [];
|
|
568
566
|
} else {
|
|
569
567
|
const created = await store.createChat({
|
|
570
568
|
id: requestedChatId,
|
|
@@ -576,6 +574,15 @@ function api(server, options) {
|
|
|
576
574
|
const created = await store.createChat({ modelId: model.id });
|
|
577
575
|
chatId = created.id;
|
|
578
576
|
}
|
|
577
|
+
let messages;
|
|
578
|
+
if (body.message && typeof body.message === "object") {
|
|
579
|
+
messages = [...storedMessages, body.message];
|
|
580
|
+
} else if (Array.isArray(body.messages) && body.messages.length > 0) {
|
|
581
|
+
messages = body.messages;
|
|
582
|
+
} else {
|
|
583
|
+
res.status(400).json({ success: false, error: "MISSING_MESSAGES" });
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
579
586
|
try {
|
|
580
587
|
const streamResponse = await runChatStream({
|
|
581
588
|
rootConfig: req.rootConfig,
|
|
@@ -585,7 +592,9 @@ function api(server, options) {
|
|
|
585
592
|
messages,
|
|
586
593
|
chatId,
|
|
587
594
|
user: req.user.email,
|
|
588
|
-
executionMode
|
|
595
|
+
executionMode,
|
|
596
|
+
loadCollection: (collectionId) => getCollectionSchema(req, collectionId),
|
|
597
|
+
loadAllCollections: async () => (await options.getRenderer(req)).getCollections()
|
|
589
598
|
});
|
|
590
599
|
streamResponse.headers.set("x-root-cms-chat-id", chatId);
|
|
591
600
|
await pipeWebResponse(streamResponse, res);
|
|
@@ -628,10 +637,14 @@ function api(server, options) {
|
|
|
628
637
|
try {
|
|
629
638
|
const streamResponse = await runEditObjectStream({
|
|
630
639
|
rootConfig: req.rootConfig,
|
|
640
|
+
cmsClient: new RootCMSClient(req.rootConfig),
|
|
641
|
+
user: req.user.email,
|
|
631
642
|
config: aiConfig,
|
|
632
643
|
model,
|
|
633
644
|
messages,
|
|
634
|
-
editData: body.editData
|
|
645
|
+
editData: body.editData,
|
|
646
|
+
loadCollection: (collectionId) => getCollectionSchema(req, collectionId),
|
|
647
|
+
loadAllCollections: async () => (await options.getRenderer(req)).getCollections()
|
|
635
648
|
});
|
|
636
649
|
await pipeWebResponse(streamResponse, res);
|
|
637
650
|
} catch (err) {
|
|
@@ -1442,6 +1455,10 @@ function cmsPlugin(options) {
|
|
|
1442
1455
|
* Attaches CMS-specific middleware to the Root.js server.
|
|
1443
1456
|
*/
|
|
1444
1457
|
configureServer: async (server, serverOptions) => {
|
|
1458
|
+
server.use(
|
|
1459
|
+
["/cms/api/ai.chat", "/cms/api/ai.edit_object"],
|
|
1460
|
+
bodyParser.json({ limit: "4mb" })
|
|
1461
|
+
);
|
|
1445
1462
|
server.use(bodyParser.json());
|
|
1446
1463
|
server.use(
|
|
1447
1464
|
(err, req, res, next) => {
|