clay-server 2.26.0-beta.5 → 2.26.0-beta.7
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/lib/browser-mcp-server.js +496 -0
- package/lib/project.js +340 -17
- package/lib/public/app.js +111 -1
- package/lib/public/css/input.css +16 -5
- package/lib/public/css/overlays.css +181 -0
- package/lib/public/css/rewind.css +79 -0
- package/lib/public/css/server-settings.css +1 -0
- package/lib/public/css/title-bar.css +3 -3
- package/lib/public/index.html +24 -1
- package/lib/public/modules/context-sources.js +116 -29
- package/lib/public/modules/notifications.js +109 -1
- package/lib/sdk-bridge.js +3 -0
- package/lib/server.js +42 -0
- package/package.json +1 -1
package/lib/server.js
CHANGED
|
@@ -38,6 +38,24 @@ function httpGet(url) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
function httpGetBinary(url) {
|
|
42
|
+
return new Promise(function (resolve, reject) {
|
|
43
|
+
var mod = url.startsWith("https") ? https : http;
|
|
44
|
+
mod.get(url, { headers: { "User-Agent": "Clay/1.0" } }, function (resp) {
|
|
45
|
+
if (resp.statusCode >= 300 && resp.statusCode < 400 && resp.headers.location) {
|
|
46
|
+
return httpGetBinary(resp.headers.location).then(resolve, reject);
|
|
47
|
+
}
|
|
48
|
+
if (resp.statusCode !== 200) {
|
|
49
|
+
return reject(new Error("HTTP " + resp.statusCode));
|
|
50
|
+
}
|
|
51
|
+
var chunks = [];
|
|
52
|
+
resp.on("data", function (c) { chunks.push(c); });
|
|
53
|
+
resp.on("end", function () { resolve(Buffer.concat(chunks)); });
|
|
54
|
+
resp.on("error", reject);
|
|
55
|
+
}).on("error", reject);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
41
59
|
function fetchSkillsPage(url) {
|
|
42
60
|
return httpGet(url).then(function (html) {
|
|
43
61
|
// Data is inside self.__next_f.push() with escaped quotes: \"initialSkills\":[{\"source\":...}]
|
|
@@ -1018,6 +1036,28 @@ function createServer(opts) {
|
|
|
1018
1036
|
return;
|
|
1019
1037
|
}
|
|
1020
1038
|
|
|
1039
|
+
// Chrome extension download (proxy from GitHub)
|
|
1040
|
+
if (fullUrl === "/api/extension/download" && req.method === "GET") {
|
|
1041
|
+
if (!isRequestAuthed(req)) {
|
|
1042
|
+
res.writeHead(401, { "Content-Type": "application/json" });
|
|
1043
|
+
res.end(JSON.stringify({ error: "Unauthorized" }));
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
var archiveUrl = "https://github.com/chadbyte/clay-chrome/archive/refs/heads/main.zip";
|
|
1047
|
+
httpGetBinary(archiveUrl).then(function (buf) {
|
|
1048
|
+
res.writeHead(200, {
|
|
1049
|
+
"Content-Type": "application/zip",
|
|
1050
|
+
"Content-Disposition": 'attachment; filename="clay-chrome-extension.zip"',
|
|
1051
|
+
"Content-Length": buf.length,
|
|
1052
|
+
});
|
|
1053
|
+
res.end(buf);
|
|
1054
|
+
}).catch(function (err) {
|
|
1055
|
+
res.writeHead(502, { "Content-Type": "application/json" });
|
|
1056
|
+
res.end(JSON.stringify({ error: "Failed to download extension: " + (err.message || "unknown error") }));
|
|
1057
|
+
});
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1021
1061
|
// CORS preflight for cross-origin requests (HTTP onboarding → HTTPS)
|
|
1022
1062
|
if (req.method === "OPTIONS") {
|
|
1023
1063
|
res.writeHead(204, {
|
|
@@ -2889,6 +2929,8 @@ function createServer(opts) {
|
|
|
2889
2929
|
osUsers: osUsers,
|
|
2890
2930
|
currentVersion: currentVersion,
|
|
2891
2931
|
lanHost: lanHost,
|
|
2932
|
+
port: portNum,
|
|
2933
|
+
tls: !!tlsOptions,
|
|
2892
2934
|
getProjectCount: function () { return projects.size; },
|
|
2893
2935
|
getProjectList: function (userId) {
|
|
2894
2936
|
var list = [];
|