clay-server 2.26.0-beta.4 → 2.26.0-beta.6

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/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 = [];
package/lib/sessions.js CHANGED
@@ -366,7 +366,7 @@ function createSessionManager(opts) {
366
366
  }
367
367
  }
368
368
 
369
- _send({ type: "history_done", lastUsage: lastUsage, lastModelUsage: lastModelUsage, lastCost: lastCost, lastStreamInputTokens: lastStreamInputTokens });
369
+ _send({ type: "history_done", lastUsage: lastUsage, lastModelUsage: lastModelUsage, lastCost: lastCost, lastStreamInputTokens: lastStreamInputTokens, contextUsage: session.lastContextUsage || null });
370
370
  }
371
371
 
372
372
  function switchSession(localId, targetWs, transform) {
@@ -492,6 +492,20 @@ function createSessionManager(opts) {
492
492
  sessions.delete(localId);
493
493
  }
494
494
 
495
+ function doSendToSession(session, obj) {
496
+ // Send to active clients without recording to history/disk (ephemeral data)
497
+ if (sendEach) {
498
+ var data = JSON.stringify(obj);
499
+ sendEach(function (ws) {
500
+ if (ws._clayActiveSession === session.localId && ws.readyState === 1) {
501
+ ws.send(data);
502
+ }
503
+ });
504
+ } else if (session.localId === activeSessionId) {
505
+ send(obj);
506
+ }
507
+ }
508
+
495
509
  function doSendAndRecord(session, obj) {
496
510
  session.history.push(obj);
497
511
  appendToSessionFile(session, obj);
@@ -737,6 +751,7 @@ function createSessionManager(opts) {
737
751
  saveSessionFile: saveSessionFile,
738
752
  appendToSessionFile: appendToSessionFile,
739
753
  sendAndRecord: doSendAndRecord,
754
+ sendToSession: doSendToSession,
740
755
  findTurnBoundary: findTurnBoundary,
741
756
  replayHistory: replayHistory,
742
757
  searchSessions: searchSessions,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "2.26.0-beta.4",
3
+ "version": "2.26.0-beta.6",
4
4
  "description": "Self-hosted Claude Code in your browser. Multi-session, multi-user, push notifications.",
5
5
  "bin": {
6
6
  "clay-server": "./bin/cli.js",
@@ -36,7 +36,7 @@
36
36
  "homepage": "https://github.com/chadbyte/claude-relay#readme",
37
37
  "author": "Chad",
38
38
  "dependencies": {
39
- "@anthropic-ai/claude-agent-sdk": "^0.2.76",
39
+ "@anthropic-ai/claude-agent-sdk": "^0.2.92",
40
40
  "@lydell/node-pty": "^1.2.0-beta.3",
41
41
  "nodemailer": "^6.10.1",
42
42
  "qrcode-terminal": "^0.12.0",