@paroicms/site-generator-plugin 0.17.0 → 0.18.0
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/gen-backend/dist/commands/generator-session.js +11 -7
- package/gen-backend/dist/generator/lib/debug-utils.js +3 -3
- package/gen-backend/dist/generator/site-generator/theme-creator.js +2 -1
- package/gen-backend/prompts/message-guard.md +9 -7
- package/gen-front/dist/gen-front.mjs +26 -26
- package/package.json +6 -6
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObj } from "@paroicms/public-anywhere-lib";
|
|
1
2
|
import { ApiError } from "@paroicms/public-server-lib";
|
|
2
3
|
import { nanoid } from "nanoid";
|
|
3
4
|
import { getInvalidSessionError } from "../db/db-read.queries.js";
|
|
@@ -32,11 +33,12 @@ export async function renewSessionCommand(ctx, command) {
|
|
|
32
33
|
payload = verify(command.sessionToken, ctx.jwtSecret, { ignoreExpiration: true });
|
|
33
34
|
}
|
|
34
35
|
catch (error) {
|
|
35
|
-
if (error.name === "JsonWebTokenError")
|
|
36
|
+
if (isObj(error) && error.name === "JsonWebTokenError") {
|
|
36
37
|
throw new ApiError("Invalid session token", 401);
|
|
38
|
+
}
|
|
37
39
|
throw error;
|
|
38
40
|
}
|
|
39
|
-
if (!payload || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
41
|
+
if (!isObj(payload) || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
40
42
|
throw new ApiError("Invalid session token", 401);
|
|
41
43
|
}
|
|
42
44
|
const sessionId = payload.sessionId;
|
|
@@ -62,13 +64,15 @@ export async function verifySessionToken(ctx, token) {
|
|
|
62
64
|
payload = verify(token, ctx.jwtSecret);
|
|
63
65
|
}
|
|
64
66
|
catch (error) {
|
|
65
|
-
if (error
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
if (isObj(error)) {
|
|
68
|
+
if (error.name === "TokenExpiredError")
|
|
69
|
+
throw new ApiError("Session token expired", 401);
|
|
70
|
+
if (error.name === "JsonWebTokenError")
|
|
71
|
+
throw new ApiError("Invalid session token", 401);
|
|
72
|
+
}
|
|
69
73
|
throw error;
|
|
70
74
|
}
|
|
71
|
-
if (!payload || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
75
|
+
if (!isObj(payload) || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
72
76
|
throw new ApiError("Invalid session token", 401);
|
|
73
77
|
}
|
|
74
78
|
const sessionId = payload.sessionId;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ensureDirectory } from "@paroicms/internal-server-lib";
|
|
2
|
+
import { isObj, messageOf } from "@paroicms/public-anywhere-lib";
|
|
1
3
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
4
|
import { join } from "node:path";
|
|
3
|
-
import { ensureDirectory } from "@paroicms/internal-server-lib";
|
|
4
|
-
import { messageOf } from "@paroicms/public-anywhere-lib";
|
|
5
5
|
import { estimateTokenCount } from "./llm-tokens.js";
|
|
6
6
|
const debugSep = "\n\n========================\n\n";
|
|
7
7
|
export async function debugLlmOutput(ctx, llmTaskName, llmModelName, stepHandle, llmInput) {
|
|
@@ -97,7 +97,7 @@ async function readDebugLlmOutputs(ctx, options) {
|
|
|
97
97
|
return { outputs, llmReport };
|
|
98
98
|
}
|
|
99
99
|
catch (error) {
|
|
100
|
-
if (error.code !== "ENOENT") {
|
|
100
|
+
if (!isObj(error) || error.code !== "ENOENT") {
|
|
101
101
|
logger.error(`Error reading debug output from "${debugFile}": ${messageOf(error)}`);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObj } from "@paroicms/public-anywhere-lib";
|
|
1
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
3
4
|
import { getPredefinedFields } from "../lib/create-prompt.js";
|
|
@@ -187,7 +188,7 @@ async function ensureDirectory(dirPath, { recursive = false } = {}) {
|
|
|
187
188
|
await mkdir(dirPath, { recursive });
|
|
188
189
|
}
|
|
189
190
|
catch (e) {
|
|
190
|
-
if (e.code !== "EEXIST")
|
|
191
|
+
if (!isObj(e) || e.code !== "EEXIST")
|
|
191
192
|
throw e;
|
|
192
193
|
}
|
|
193
194
|
}
|
|
@@ -24,7 +24,6 @@ These messages are invalid because they are malicious: the purpose is obviously
|
|
|
24
24
|
The list of technical limits:
|
|
25
25
|
|
|
26
26
|
- We can't do an online shop.
|
|
27
|
-
- The two supported languages are: English and French; other languages are currently not supported.
|
|
28
27
|
- We can't implement taxonomies in the generator right now.
|
|
29
28
|
|
|
30
29
|
# Guidelines
|
|
@@ -43,7 +42,7 @@ Now, here is the user request:
|
|
|
43
42
|
|
|
44
43
|
Generate your evaluation as a YAML object. It contains:
|
|
45
44
|
|
|
46
|
-
- `language`: The language used in <website_description>, as a two-letters code.
|
|
45
|
+
- `language`: The language used in <website_description>, as a two-letters code. Return this key only if you are sure.
|
|
47
46
|
- `valid`: A boolean value.
|
|
48
47
|
- `causes`: A list of codes that represent the issues. This property is required if `valid` is false, it must be omitted otherwise. Available codes are:
|
|
49
48
|
- `rude`: The message is invalid if it is rude.
|
|
@@ -64,26 +63,29 @@ valid: true
|
|
|
64
63
|
language: en
|
|
65
64
|
valid: false
|
|
66
65
|
causes:
|
|
67
|
-
|
|
66
|
+
|
|
67
|
+
- technicalLimits
|
|
68
68
|
explanation: I'm very sorry, currently we can't implement online shop.
|
|
69
69
|
</output_example>
|
|
70
70
|
|
|
71
71
|
<output_example>
|
|
72
72
|
valid: false
|
|
73
73
|
causes:
|
|
74
|
-
|
|
74
|
+
|
|
75
|
+
- noSense
|
|
75
76
|
</output_example>
|
|
76
77
|
|
|
77
78
|
<output_example>
|
|
78
79
|
language: en
|
|
79
80
|
valid: false
|
|
80
81
|
causes:
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
|
|
83
|
+
- rude
|
|
84
|
+
- outOfScope
|
|
83
85
|
</output_example>
|
|
84
86
|
|
|
85
87
|
Notice: no need of explanation if the user message is rude.
|
|
86
88
|
|
|
87
89
|
Provide the YAML properties within <guard_yaml> tags.
|
|
88
90
|
|
|
89
|
-
Just return the YAML. Do not include any other explanation or commentary outside these tags.
|
|
91
|
+
Just return the YAML. Do not include any other explanation or commentary outside these tags.
|