clay-server 2.34.0-beta.8 → 2.34.0-beta.9

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.
@@ -82,16 +82,7 @@ function attachConnection(ctx) {
82
82
  setTimeout(function() { _loop.resumeLoop(); }, 500);
83
83
  }
84
84
 
85
- // Auto-assign owner if project has none and a user connects (e.g. IPC-added projects)
86
85
  var projectOwnerId = getProjectOwnerId();
87
- if (!projectOwnerId && ws._clayUser && ws._clayUser.id && !isMate) {
88
- setProjectOwnerId(ws._clayUser.id);
89
- projectOwnerId = ws._clayUser.id;
90
- if (opts.onProjectOwnerChanged) {
91
- opts.onProjectOwnerChanged(slug, projectOwnerId);
92
- }
93
- console.log("[project] Auto-assigned owner for " + slug + ": " + projectOwnerId);
94
- }
95
86
 
96
87
  // Send cached state
97
88
  var _userId = ws._clayUser ? ws._clayUser.id : null;
@@ -39,7 +39,7 @@ function formatAskUserAnswerAsMessage(input, answers) {
39
39
  * sm, sdk, tm, clients,
40
40
  * send, sendTo, sendToAdmins, sendToSession, sendToSessionOthers,
41
41
  * opts, usersModule, userPresence, matesModule, pushModule,
42
- * getSessionForWs, getLinuxUserForSession, getOsUserInfoForWs,
42
+ * getSessionForWs, getLinuxUserForSession, ensureProjectAccessForSession, getOsUserInfoForWs,
43
43
  * hydrateImageRefs, onProcessingChanged, broadcastPresence,
44
44
  * adapter, getProjectList, getProjectCount, getScheduleCount,
45
45
  * moveScheduleToProject, moveAllSchedulesToProject, getHubSchedules,
@@ -70,6 +70,7 @@ function attachSessions(ctx) {
70
70
  var pushModule = ctx.pushModule;
71
71
  var getSessionForWs = ctx.getSessionForWs;
72
72
  var getLinuxUserForSession = ctx.getLinuxUserForSession;
73
+ var ensureProjectAccessForSession = ctx.ensureProjectAccessForSession;
73
74
  var getOsUserInfoForWs = ctx.getOsUserInfoForWs;
74
75
  var hydrateImageRefs = ctx.hydrateImageRefs;
75
76
  var onProcessingChanged = ctx.onProcessingChanged;
@@ -803,7 +804,7 @@ function attachSessions(ctx) {
803
804
  session.sentToolResults = {};
804
805
  sendToSession(session.localId, { type: "status", status: "processing" });
805
806
  if (!session.queryInstance && !session.worker) {
806
- sdk.startQuery(session, answerText, undefined, getLinuxUserForSession(session));
807
+ sdk.startQuery(session, answerText, undefined, ensureProjectAccessForSession(session));
807
808
  } else {
808
809
  sdk.pushMessage(session, answerText);
809
810
  }
@@ -932,7 +933,7 @@ function attachSessions(ctx) {
932
933
  newSession.sentToolResults = {};
933
934
  sendToSession(newSession.localId, { type: "status", status: "processing" });
934
935
  newSession.acceptEditsAfterStart = true;
935
- sdk.startQuery(newSession, planPrompt, undefined, getLinuxUserForSession(newSession));
936
+ sdk.startQuery(newSession, planPrompt, undefined, ensureProjectAccessForSession(newSession));
936
937
  } catch (e) {
937
938
  console.error("[project] Error starting plan execution:", e);
938
939
  sendTo(ws, { type: "error", text: "Failed to start plan execution: " + (e.message || e) });
@@ -963,7 +964,7 @@ function attachSessions(ctx) {
963
964
  session.sentToolResults = {};
964
965
  sendToSession(session.localId, { type: "status", status: "processing" });
965
966
  if (!session.queryInstance && !session.worker) {
966
- sdk.startQuery(session, feedback, undefined, getLinuxUserForSession(session));
967
+ sdk.startQuery(session, feedback, undefined, ensureProjectAccessForSession(session));
967
968
  } else {
968
969
  sdk.pushMessage(session, feedback);
969
970
  }
@@ -13,7 +13,7 @@ var fs = require("fs");
13
13
  * send, sendTo, sendToSession, sendToSessionOthers,
14
14
  * clients, opts,
15
15
  * usersModule, matesModule,
16
- * getSessionForWs, getLinuxUserForSession, getOsUserInfoForWs,
16
+ * getSessionForWs, getLinuxUserForSession, ensureProjectAccessForSession, getOsUserInfoForWs,
17
17
  * hydrateImageRefs, saveImageFile, imagesDir,
18
18
  * onProcessingChanged, onSessionDone,
19
19
  * _loop - { handleLoopMessage: fn(ws, msg) }
@@ -49,6 +49,7 @@ function attachUserMessage(ctx) {
49
49
 
50
50
  var getSessionForWs = ctx.getSessionForWs;
51
51
  var getLinuxUserForSession = ctx.getLinuxUserForSession;
52
+ var ensureProjectAccessForSession = ctx.ensureProjectAccessForSession;
52
53
  var getOsUserInfoForWs = ctx.getOsUserInfoForWs;
53
54
 
54
55
  var hydrateImageRefs = ctx.hydrateImageRefs;
@@ -281,7 +282,7 @@ function attachUserMessage(ctx) {
281
282
  nowSession.isProcessing = true;
282
283
  onProcessingChanged();
283
284
  sendToSession(nowSession.localId, { type: "status", status: "processing" });
284
- sdk.startQuery(nowSession, schedText, null, getLinuxUserForSession(nowSession));
285
+ sdk.startQuery(nowSession, schedText, null, ensureProjectAccessForSession(nowSession));
285
286
  sm.broadcastSessionList();
286
287
  return true;
287
288
  }
@@ -484,7 +485,7 @@ function attachUserMessage(ctx) {
484
485
  // No active query (or worker idle between queries): start a new query
485
486
  session._queryStartTs = Date.now();
486
487
  console.log("[PERF] project.js: startQuery called, localId=" + session.localId + " t=0ms");
487
- sdk.startQuery(session, finalText, msg.images, getLinuxUserForSession(session));
488
+ sdk.startQuery(session, finalText, msg.images, ensureProjectAccessForSession(session));
488
489
  } else {
489
490
  sdk.pushMessage(session, finalText, msg.images);
490
491
  }
package/lib/project.js CHANGED
@@ -9,7 +9,7 @@ var { createNotesManager } = require("./notes");
9
9
  var { fetchLatestVersion, fetchVersion, isNewer } = require("./updater");
10
10
  var { execFileSync, spawn } = require("child_process");
11
11
  var usersModule = require("./users");
12
- var { resolveOsUserInfo, fsAsUser } = require("./os-users");
12
+ var { resolveOsUserInfo, fsAsUser, grantProjectAccess } = require("./os-users");
13
13
  var crisisSafety = require("./crisis-safety");
14
14
  var matesModule = require("./mates");
15
15
  var sessionSearch = require("./session-search");
@@ -188,6 +188,14 @@ function createProjectContext(opts) {
188
188
  return user.linuxUser;
189
189
  }
190
190
 
191
+ function ensureProjectAccessForSession(session) {
192
+ var linuxUser = getLinuxUserForSession(session);
193
+ if (linuxUser) {
194
+ grantProjectAccess(cwd, linuxUser);
195
+ }
196
+ return linuxUser;
197
+ }
198
+
191
199
  function getLinuxUserForWs(ws) {
192
200
  if (!osUsers) return null;
193
201
  if (!ws._clayUser || !ws._clayUser.linuxUser) return null;
@@ -800,7 +808,7 @@ function createProjectContext(opts) {
800
808
  session.isProcessing = true;
801
809
  onProcessingChanged();
802
810
  sendToSession(session.localId, { type: "status", status: "processing" });
803
- sdk.startQuery(session, text, null, getLinuxUserForSession(session));
811
+ sdk.startQuery(session, text, null, ensureProjectAccessForSession(session));
804
812
  sm.broadcastSessionList();
805
813
  }, schedDelay),
806
814
  };
@@ -1134,6 +1142,7 @@ function createProjectContext(opts) {
1134
1142
  pushModule: pushModule,
1135
1143
  getSessionForWs: getSessionForWs,
1136
1144
  getLinuxUserForSession: getLinuxUserForSession,
1145
+ ensureProjectAccessForSession: ensureProjectAccessForSession,
1137
1146
  getOsUserInfoForWs: getOsUserInfoForWs,
1138
1147
  hydrateImageRefs: hydrateImageRefs,
1139
1148
  onProcessingChanged: onProcessingChanged,
@@ -1182,6 +1191,7 @@ function createProjectContext(opts) {
1182
1191
  matesModule: matesModule,
1183
1192
  getSessionForWs: getSessionForWs,
1184
1193
  getLinuxUserForSession: getLinuxUserForSession,
1194
+ ensureProjectAccessForSession: ensureProjectAccessForSession,
1185
1195
  getOsUserInfoForWs: getOsUserInfoForWs,
1186
1196
  hydrateImageRefs: hydrateImageRefs,
1187
1197
  saveImageFile: saveImageFile,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clay-server",
3
- "version": "2.34.0-beta.8",
3
+ "version": "2.34.0-beta.9",
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",