@openstaticfish/chattybox-config 0.1.0 → 0.2.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/README.md +2 -0
- package/dist/index.js +23 -0
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -14,3 +14,5 @@ export default defineConfig({
|
|
|
14
14
|
widget: { enabled: true },
|
|
15
15
|
});
|
|
16
16
|
```
|
|
17
|
+
|
|
18
|
+
Version 1 supports exactly one website source per project when `knowledge` is provided. Production deployments require that source so the runtime can replace and re-index the project corpus deterministically.
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var HEX_COLOR = /^#[0-9a-f]{6}$/i;
|
|
3
|
+
var PROMPT_PROFILES = new Set(["default", "support", "sales", "sarcastic", "custom"]);
|
|
4
|
+
var WIDGET_POSITIONS = new Set(["bottom-right", "bottom-left", "top-right", "top-left"]);
|
|
5
|
+
var WIDGET_LOCALES = new Set(["en", "de", "fr", "es", "it", "nl", "pl", "pt", "sv", "fi", "et", "cs", "cy", "id"]);
|
|
3
6
|
function requireNonEmptyString(value, path) {
|
|
4
7
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
5
8
|
throw new Error(`${path} must be a non-empty string`);
|
|
@@ -19,6 +22,15 @@ function validateConfig(config) {
|
|
|
19
22
|
if (config.assistant.systemPrompt !== undefined) {
|
|
20
23
|
requireNonEmptyString(config.assistant.systemPrompt, "assistant.systemPrompt");
|
|
21
24
|
}
|
|
25
|
+
if (config.assistant.promptProfile !== undefined && !PROMPT_PROFILES.has(config.assistant.promptProfile)) {
|
|
26
|
+
throw new Error("assistant.promptProfile is not supported");
|
|
27
|
+
}
|
|
28
|
+
if (config.assistant.fallbackMessage !== undefined) {
|
|
29
|
+
requireNonEmptyString(config.assistant.fallbackMessage, "assistant.fallbackMessage");
|
|
30
|
+
}
|
|
31
|
+
if (config.knowledge !== undefined && config.knowledge.sources.length !== 1) {
|
|
32
|
+
throw new Error("knowledge.sources must contain exactly one website source when provided");
|
|
33
|
+
}
|
|
22
34
|
for (const [index, source] of (config.knowledge?.sources ?? []).entries()) {
|
|
23
35
|
if (source.type !== "website") {
|
|
24
36
|
throw new Error(`knowledge.sources[${index}].type is not supported`);
|
|
@@ -35,6 +47,17 @@ function validateConfig(config) {
|
|
|
35
47
|
throw new Error(`knowledge.sources[${index}].maxPages must be a positive integer`);
|
|
36
48
|
}
|
|
37
49
|
}
|
|
50
|
+
if (config.runtime?.locale !== undefined && !WIDGET_LOCALES.has(config.runtime.locale)) {
|
|
51
|
+
throw new Error("runtime.locale is not supported");
|
|
52
|
+
}
|
|
53
|
+
if (config.widget !== undefined) {
|
|
54
|
+
if (typeof config.widget.enabled !== "boolean") {
|
|
55
|
+
throw new Error("widget.enabled must be a boolean");
|
|
56
|
+
}
|
|
57
|
+
if (config.widget.position !== undefined && !WIDGET_POSITIONS.has(config.widget.position)) {
|
|
58
|
+
throw new Error("widget.position is not supported");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
38
61
|
validateOptionalColor(config.widget?.theme?.primaryColor, "widget.theme.primaryColor");
|
|
39
62
|
validateOptionalColor(config.widget?.theme?.backgroundColor, "widget.theme.backgroundColor");
|
|
40
63
|
validateOptionalColor(config.widget?.theme?.textColor, "widget.theme.textColor");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openstaticfish/chattybox-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/OpenStaticFish/
|
|
17
|
+
"url": "git+https://github.com/OpenStaticFish/chattybots.git",
|
|
18
18
|
"directory": "packages/sdk-config"
|
|
19
19
|
},
|
|
20
20
|
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
"provenance": true
|
|
21
|
+
"access": "public"
|
|
23
22
|
},
|
|
24
23
|
"scripts": {
|
|
25
24
|
"build": "bun build src/index.ts --outdir dist --target node --format esm && tsc --declaration --emitDeclarationOnly --noEmit false --outDir dist",
|