diff --git a/public/scripts/extensions.js b/public/scripts/extensions.js
index df4b7022f..181ec9b1c 100644
--- a/public/scripts/extensions.js
+++ b/public/scripts/extensions.js
@@ -1,4 +1,4 @@
-import { callPopup, saveSettings, saveSettingsDebounced } from "../script.js";
+import { callPopup, saveSettings, saveSettingsDebounced, token } from "../script.js";
import { isSubsetOf } from "./utils.js";
export {
getContext,
@@ -9,8 +9,8 @@ export {
extension_settings,
};
-const extensionNames = ['caption', 'dice', 'expressions', 'floating-prompt', 'memory', 'backgrounds'];
-const manifests = await getManifests(extensionNames);
+let extensionNames = [];
+let manifests = [];
const defaultUrl = "http://localhost:5100";
const extension_settings = {
@@ -34,6 +34,24 @@ const getApiUrl = () => extension_settings.apiUrl;
const defaultRequestArgs = { method: 'GET', headers: { 'Bypass-Tunnel-Reminder': 'bypass' } };
let connectedToApi = false;
+async function discoverExtensions() {
+ try {
+ const response = await fetch('/discover_extensions', { headers: { 'X-CSRF-Token': token } });
+
+ if (response.ok) {
+ const extensions = await response.json();
+ return extensions;
+ }
+ else {
+ return [];
+ }
+ }
+ catch (err) {
+ console.error(err);
+ return [];
+ }
+}
+
function onDisableExtensionClick() {
const name = $(this).data('name');
disableExtension(name);
@@ -247,7 +265,7 @@ function showExtensionsDetails() {
callPopup(`
${html}
`, 'text');
}
-function loadExtensionSettings(settings) {
+async function loadExtensionSettings(settings) {
if (settings.extension_settings) {
Object.assign(extension_settings, settings.extension_settings);
}
@@ -256,6 +274,8 @@ function loadExtensionSettings(settings) {
$("#extensions_autoconnect").prop('checked', extension_settings.autoConnect).trigger('input');
// Activate offline extensions
+ extensionNames = await discoverExtensions();
+ manifests = await getManifests(extensionNames)
activateExtensions();
}
diff --git a/public/scripts/extensions/backgrounds/manifest.json b/public/scripts/extensions/backgrounds/manifest.json
index a95e547eb..3d2e2ef68 100644
--- a/public/scripts/extensions/backgrounds/manifest.json
+++ b/public/scripts/extensions/backgrounds/manifest.json
@@ -4,5 +4,8 @@
"requires": [],
"optional": [],
"js": "index.js",
- "css": "style.css"
+ "css": "style.css",
+ "author": "Cohee#1207",
+ "version": "1.0.0",
+ "homePage": "https://github.com/Cohee1207/SillyTavern"
}
\ No newline at end of file
diff --git a/public/scripts/extensions/caption/manifest.json b/public/scripts/extensions/caption/manifest.json
index 12872d174..d693b2fff 100644
--- a/public/scripts/extensions/caption/manifest.json
+++ b/public/scripts/extensions/caption/manifest.json
@@ -6,5 +6,8 @@
],
"optional": [],
"js": "index.js",
- "css": "style.css"
+ "css": "style.css",
+ "author": "Cohee#1207",
+ "version": "1.0.0",
+ "homePage": "https://github.com/Cohee1207/SillyTavern"
}
\ No newline at end of file
diff --git a/public/scripts/extensions/dice/manifest.json b/public/scripts/extensions/dice/manifest.json
index 82b83bdff..2752ced99 100644
--- a/public/scripts/extensions/dice/manifest.json
+++ b/public/scripts/extensions/dice/manifest.json
@@ -4,5 +4,8 @@
"requires": [],
"optional": [],
"js": "index.js",
- "css": "style.css"
+ "css": "style.css",
+ "author": "Cohee#1207",
+ "version": "1.0.0",
+ "homePage": "https://github.com/Cohee1207/SillyTavern"
}
\ No newline at end of file
diff --git a/public/scripts/extensions/expressions/manifest.json b/public/scripts/extensions/expressions/manifest.json
index 836408124..d4cd793c1 100644
--- a/public/scripts/extensions/expressions/manifest.json
+++ b/public/scripts/extensions/expressions/manifest.json
@@ -6,5 +6,8 @@
"classify"
],
"js": "index.js",
- "css": "style.css"
+ "css": "style.css",
+ "author": "Cohee#1207",
+ "version": "1.0.0",
+ "homePage": "https://github.com/Cohee1207/SillyTavern"
}
\ No newline at end of file
diff --git a/public/scripts/extensions/floating-prompt/manifest.json b/public/scripts/extensions/floating-prompt/manifest.json
index 7ac886616..64fac1b56 100644
--- a/public/scripts/extensions/floating-prompt/manifest.json
+++ b/public/scripts/extensions/floating-prompt/manifest.json
@@ -4,5 +4,8 @@
"requires": [],
"optional": [],
"js": "index.js",
- "css": "style.css"
+ "css": "style.css",
+ "author": "Cohee#1207",
+ "version": "1.0.0",
+ "homePage": "https://github.com/Cohee1207/SillyTavern"
}
\ No newline at end of file
diff --git a/public/scripts/extensions/memory/manifest.json b/public/scripts/extensions/memory/manifest.json
index ddb8b01df..9cb9006c1 100644
--- a/public/scripts/extensions/memory/manifest.json
+++ b/public/scripts/extensions/memory/manifest.json
@@ -6,5 +6,8 @@
],
"optional": [],
"js": "index.js",
- "css": "style.css"
+ "css": "style.css",
+ "author": "Cohee#1207",
+ "version": "1.0.0",
+ "homePage": "https://github.com/Cohee1207/SillyTavern"
}
\ No newline at end of file
diff --git a/server.js b/server.js
index a723932cf..68931c640 100644
--- a/server.js
+++ b/server.js
@@ -118,6 +118,7 @@ const directories = {
thumbnailsBg: 'thumbnails/bg/',
thumbnailsAvatar: 'thumbnails/avatar/',
themes: 'public/themes',
+ extensions: 'public/scripts/extensions'
};
// CSRF Protection //
@@ -1920,6 +1921,14 @@ app.post('/generate_poe', jsonParser, async (request, response) => {
}
});
+app.get('/discover_extensions', jsonParser, function (_, response) {
+ const extensions = fs
+ .readdirSync(directories.extensions)
+ .filter(f => fs.statSync(path.join(directories.extensions, f)).isDirectory());
+
+ return response.send(extensions);
+});
+
function getThumbnailFolder(type) {
let thumbnailFolder;