replicas-engine 0.1.267 → 0.1.268

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/dist/src/index.js CHANGED
@@ -286,7 +286,7 @@ var WORKSPACE_SIZES = ["small", "large"];
286
286
  var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
287
287
 
288
288
  // ../shared/src/e2b.ts
289
- var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-05-v4";
289
+ var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-05-v5";
290
290
 
291
291
  // ../shared/src/runtime-env.ts
292
292
  function parsePosixEnvFile(content) {
@@ -6575,7 +6575,7 @@ var AspClient = class {
6575
6575
  // src/managers/codex-asp/app-server-process.ts
6576
6576
  var DEFAULT_CODEX_BINARY = "codex";
6577
6577
  var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
6578
- var ENGINE_PACKAGE_VERSION = "0.1.267";
6578
+ var ENGINE_PACKAGE_VERSION = "0.1.268";
6579
6579
  var INITIALIZE_METHOD = "initialize";
6580
6580
  var INITIALIZED_NOTIFICATION = "initialized";
6581
6581
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.267",
3
+ "version": "0.1.268",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -39,7 +39,12 @@ sudo prlimit --memlock=536870912:536870912 --pid $$ 2>/dev/null || true
39
39
  LOCKMEM_SO=/usr/local/lib/replicas-lockmem.so
40
40
  if [ -r "$LOCKMEM_SO" ]; then
41
41
  # Prepend (don't replace) so any inherited LD_PRELOAD still loads.
42
- if [ -n "${LD_PRELOAD:-}" ]; then
42
+ if [ "${LD_PRELOAD:-}" = "$LOCKMEM_SO" ] \
43
+ || [[ "${LD_PRELOAD:-}" == "$LOCKMEM_SO:"* ]] \
44
+ || [[ "${LD_PRELOAD:-}" == *":$LOCKMEM_SO" ]] \
45
+ || [[ "${LD_PRELOAD:-}" == *":$LOCKMEM_SO:"* ]]; then
46
+ ENGINE_LD_PRELOAD="$LD_PRELOAD"
47
+ elif [ -n "${LD_PRELOAD:-}" ]; then
43
48
  ENGINE_LD_PRELOAD="$LOCKMEM_SO:$LD_PRELOAD"
44
49
  else
45
50
  ENGINE_LD_PRELOAD="$LOCKMEM_SO"
package/scripts/lockmem.c CHANGED
@@ -5,15 +5,75 @@
5
5
  #include <sys/mman.h>
6
6
  #include <stdio.h>
7
7
  #include <errno.h>
8
+ #include <stdlib.h>
8
9
  #include <string.h>
9
10
  #include <unistd.h>
10
11
 
12
+ static int is_own_preload_token(const char *token) {
13
+ const char *basename = strrchr(token, '/');
14
+ basename = basename == NULL ? token : basename + 1;
15
+ return strcmp(basename, "replicas-lockmem.so") == 0;
16
+ }
17
+
18
+ static void scrub_own_preload(void) {
19
+ const char *current = getenv("LD_PRELOAD");
20
+ if (current == NULL) {
21
+ return;
22
+ }
23
+
24
+ char *copy = strdup(current);
25
+ if (copy == NULL) {
26
+ return;
27
+ }
28
+
29
+ char *next = copy;
30
+ char *token;
31
+ size_t output_len = 0;
32
+ int removed = 0;
33
+ char *output = malloc(strlen(current) + 1);
34
+ if (output == NULL) {
35
+ free(copy);
36
+ return;
37
+ }
38
+ output[0] = '\0';
39
+
40
+ while ((token = strsep(&next, ":")) != NULL) {
41
+ if (is_own_preload_token(token)) {
42
+ removed = 1;
43
+ continue;
44
+ }
45
+
46
+ if (output_len > 0) {
47
+ output[output_len++] = ':';
48
+ output[output_len] = '\0';
49
+ }
50
+ strcpy(output + output_len, token);
51
+ output_len += strlen(token);
52
+ }
53
+
54
+ if (removed) {
55
+ if (output_len == 0) {
56
+ unsetenv("LD_PRELOAD");
57
+ } else {
58
+ setenv("LD_PRELOAD", output, 1);
59
+ }
60
+ }
61
+
62
+ free(output);
63
+ free(copy);
64
+ }
65
+
11
66
  __attribute__((constructor))
12
67
  static void replicas_lockmem_init(void) {
68
+ scrub_own_preload();
69
+
13
70
  if (mlockall(MCL_CURRENT) != 0) {
14
71
  fprintf(stderr, "[lockmem] mlockall(MCL_CURRENT) failed: %s (errno=%d); engine running unprotected\n",
15
72
  strerror(errno), errno);
16
73
  return;
17
74
  }
18
- fprintf(stderr, "[lockmem] engine pages locked (pid=%d)\n", getpid());
75
+
76
+ if (getenv("REPLICAS_LOCKMEM_VERBOSE") != NULL) {
77
+ fprintf(stderr, "[lockmem] engine pages locked (pid=%d)\n", getpid());
78
+ }
19
79
  }