clay-server 2.34.0-beta.6 → 2.34.0-beta.8
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/os-users.js +13 -0
- package/lib/project.js +11 -1
- package/lib/yoke/adapters/claude-worker.js +6 -2
- package/package.json +1 -1
package/lib/os-users.js
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
var fs = require("fs");
|
|
5
5
|
var path = require("path");
|
|
6
6
|
var execFileSync = require("child_process").execFileSync;
|
|
7
|
+
var _aclGrantCache = Object.create(null);
|
|
8
|
+
|
|
9
|
+
function aclCacheKey(projectPath, linuxUser) {
|
|
10
|
+
return path.resolve(projectPath) + "::" + linuxUser;
|
|
11
|
+
}
|
|
7
12
|
|
|
8
13
|
function isSafeLinuxUsername(username) {
|
|
9
14
|
return typeof username === "string" && /^[a-z_][a-z0-9_-]*[$]?$/.test(username);
|
|
@@ -191,6 +196,10 @@ function grantProjectAccess(projectPath, linuxUser) {
|
|
|
191
196
|
console.error("[os-users] Invalid Linux username for ACL grant: " + linuxUser);
|
|
192
197
|
return;
|
|
193
198
|
}
|
|
199
|
+
var cacheKey = aclCacheKey(projectPath, linuxUser);
|
|
200
|
+
if (_aclGrantCache[cacheKey]) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
194
203
|
try {
|
|
195
204
|
// Recursive ACL for existing files
|
|
196
205
|
execFileSync("setfacl", ["-R", "-m", "u:" + linuxUser + ":rwX", projectPath], {
|
|
@@ -204,8 +213,10 @@ function grantProjectAccess(projectPath, linuxUser) {
|
|
|
204
213
|
timeout: 30000,
|
|
205
214
|
stdio: "pipe",
|
|
206
215
|
});
|
|
216
|
+
_aclGrantCache[cacheKey] = true;
|
|
207
217
|
console.log("[os-users] Granted ACL access for " + linuxUser + " on " + projectPath);
|
|
208
218
|
} catch (e) {
|
|
219
|
+
delete _aclGrantCache[cacheKey];
|
|
209
220
|
var errMsg = (e.stderr || e.message || "").toString();
|
|
210
221
|
if (errMsg.indexOf("not found") !== -1 || errMsg.indexOf("ENOENT") !== -1) {
|
|
211
222
|
var cmd = getAclInstallCommand();
|
|
@@ -229,6 +240,7 @@ function revokeProjectAccess(projectPath, linuxUser) {
|
|
|
229
240
|
console.error("[os-users] Invalid Linux username for ACL revoke: " + linuxUser);
|
|
230
241
|
return;
|
|
231
242
|
}
|
|
243
|
+
var cacheKey = aclCacheKey(projectPath, linuxUser);
|
|
232
244
|
try {
|
|
233
245
|
execFileSync("setfacl", ["-R", "-x", "u:" + linuxUser, projectPath], {
|
|
234
246
|
encoding: "utf8",
|
|
@@ -240,6 +252,7 @@ function revokeProjectAccess(projectPath, linuxUser) {
|
|
|
240
252
|
timeout: 30000,
|
|
241
253
|
stdio: "pipe",
|
|
242
254
|
});
|
|
255
|
+
delete _aclGrantCache[cacheKey];
|
|
243
256
|
console.log("[os-users] Revoked ACL access for " + linuxUser + " on " + projectPath);
|
|
244
257
|
} catch (e) {
|
|
245
258
|
var errMsg = (e.stderr || e.message || "").toString();
|
package/lib/project.js
CHANGED
|
@@ -160,6 +160,7 @@ function createProjectContext(opts) {
|
|
|
160
160
|
var serverTls = opts.tls || false;
|
|
161
161
|
var serverAuthToken = opts.authToken || null;
|
|
162
162
|
var latestVersion = null;
|
|
163
|
+
var sessionTitleMigrationScheduled = false;
|
|
163
164
|
|
|
164
165
|
// --- YOKE adapters (multi-vendor, lazy init) ---
|
|
165
166
|
var _yokeState = yoke.createAdapters({ cwd: cwd, slug: slug });
|
|
@@ -1380,7 +1381,16 @@ function createProjectContext(opts) {
|
|
|
1380
1381
|
warmup: function () {
|
|
1381
1382
|
sdk.warmup();
|
|
1382
1383
|
sdk.startIdleReaper();
|
|
1383
|
-
|
|
1384
|
+
if (!osUsers && !sessionTitleMigrationScheduled) {
|
|
1385
|
+
sessionTitleMigrationScheduled = true;
|
|
1386
|
+
setTimeout(function () {
|
|
1387
|
+
try {
|
|
1388
|
+
sm.migrateSessionTitles(adapter, cwd);
|
|
1389
|
+
} catch (e) {
|
|
1390
|
+
console.error("[project] Session title migration failed for " + slug + ":", e && e.message ? e.message : e);
|
|
1391
|
+
}
|
|
1392
|
+
}, 5000);
|
|
1393
|
+
}
|
|
1384
1394
|
},
|
|
1385
1395
|
});
|
|
1386
1396
|
|
|
@@ -16,6 +16,7 @@ try { require("fs").writeSync(2, "[sdk-worker] BOOT pid=" + process.pid + " uid=
|
|
|
16
16
|
var net = require("net");
|
|
17
17
|
var crypto = require("crypto");
|
|
18
18
|
var path = require("path");
|
|
19
|
+
var fs = require("fs");
|
|
19
20
|
|
|
20
21
|
var socketPath = process.argv[2];
|
|
21
22
|
if (!socketPath) {
|
|
@@ -355,8 +356,11 @@ async function handleQueryStart(msg) {
|
|
|
355
356
|
// This is needed because the CLI's Axios-based HTTP client ignores
|
|
356
357
|
// NODE_OPTIONS dns flags and still attempts IPv6 connections via its
|
|
357
358
|
// custom TLS agent, causing 5-10s timeouts on IPv6-less servers.
|
|
358
|
-
var preloadScript =
|
|
359
|
-
var extraOpts = "
|
|
359
|
+
var preloadScript = path.join(__dirname, "..", "..", "ipv4-only.js");
|
|
360
|
+
var extraOpts = "";
|
|
361
|
+
if (fs.existsSync(preloadScript)) {
|
|
362
|
+
extraOpts += " --require " + JSON.stringify(preloadScript);
|
|
363
|
+
}
|
|
360
364
|
extraOpts += " --dns-result-order=ipv4first --no-network-family-autoselection";
|
|
361
365
|
spawnOpts.env.NODE_OPTIONS = (spawnOpts.env.NODE_OPTIONS || "") + extraOpts;
|
|
362
366
|
console.log("[sdk-worker] spawnClaudeCodeProcess called, command=" + spawnOpts.command);
|