replicas-engine 0.1.920 → 0.1.922

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.
@@ -5,11 +5,11 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-FJV46MRD.js";
9
- import "./chunk-UMXQF6DT.js";
10
- import "./chunk-6GY7ZCSO.js";
8
+ } from "./chunk-5VE2EIS6.js";
9
+ import "./chunk-LYX74DW2.js";
10
+ import "./chunk-75D2W6N3.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-MLSB5HUT.js";
12
+ import "./chunk-VT557AFP.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-MLSB5HUT.js";
8
+ } from "./chunk-VT557AFP.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -5,13 +5,13 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-UMXQF6DT.js";
8
+ } from "./chunk-LYX74DW2.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  SUBPROCESS_MAX_BUFFER,
12
12
  buildCodexAgentEnv,
13
13
  execFileAsync
14
- } from "./chunk-6GY7ZCSO.js";
14
+ } from "./chunk-75D2W6N3.js";
15
15
  import {
16
16
  isRecord
17
17
  } from "./chunk-UZSNFLDQ.js";
@@ -25,7 +25,7 @@ import {
25
25
  listOpenAICompatibleModels,
26
26
  readOllamaAuthEnv,
27
27
  resolveOpenAICompatibleModelsUrl
28
- } from "./chunk-MLSB5HUT.js";
28
+ } from "./chunk-VT557AFP.js";
29
29
 
30
30
  // src/managers/codex-token-manager.ts
31
31
  import { promises as fs } from "fs";
@@ -102,6 +102,7 @@ var BaseRefreshManager = class {
102
102
  credentialGeneration = 0;
103
103
  credentialUpdate = Promise.resolve();
104
104
  intervalHandle = null;
105
+ pendingRefresh = null;
105
106
  health;
106
107
  async start(skipInitialRefresh = false) {
107
108
  if (this.intervalHandle) {
@@ -165,13 +166,11 @@ var BaseRefreshManager = class {
165
166
  });
166
167
  }
167
168
  }
168
- stop() {
169
- if (!this.intervalHandle) {
170
- return;
171
- }
172
- clearTimeout(this.intervalHandle);
169
+ async stop() {
170
+ if (this.intervalHandle) clearTimeout(this.intervalHandle);
173
171
  this.intervalHandle = null;
174
172
  this.health.isRunning = false;
173
+ await this.pendingRefresh;
175
174
  console.log(`[${this.managerName}] Stopped`);
176
175
  }
177
176
  getHealthStatus() {
@@ -206,7 +205,8 @@ var BaseRefreshManager = class {
206
205
  const delayMs = this.getNextRefreshDelayMs();
207
206
  this.health.intervalMs = delayMs;
208
207
  this.intervalHandle = setTimeout(async () => {
209
- await this.refreshOnce();
208
+ this.pendingRefresh = this.refreshOnce();
209
+ await this.pendingRefresh;
210
210
  if (this.intervalHandle) this.scheduleNextRefresh();
211
211
  }, delayMs);
212
212
  console.log(`[${this.managerName}] Token refresh scheduled in ${Math.round(delayMs / 1e3)} seconds`);
@@ -255,7 +255,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
255
255
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
256
256
  await this.applyCredentialsResponse(data);
257
257
  setAgentCredentialSnapshot("codex", data);
258
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-7ZSVWHTS.js");
258
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-HR2E7RBS.js");
259
259
  await restartCodexAspHostIfRunning2();
260
260
  });
261
261
  await this.start(true);
@@ -275,7 +275,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
275
275
  await this.applyCredentialUpdate(generation, async () => {
276
276
  await this.applyCredentialsResponse(data);
277
277
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
278
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-7ZSVWHTS.js");
278
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-HR2E7RBS.js");
279
279
  await restartCodexAspHostIfRunning2();
280
280
  }
281
281
  setAgentCredentialSnapshot("codex", data);
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES,
6
6
  isVersionBelow
7
- } from "./chunk-MLSB5HUT.js";
7
+ } from "./chunk-VT557AFP.js";
8
8
 
9
9
  // src/utils/codex-agent-env.ts
10
10
  function buildCodexAgentEnv(source = process.env) {
@@ -245,7 +245,7 @@ function getCodexModelProvider(method) {
245
245
  if (method === "foundry") return "azure";
246
246
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
247
247
  }
248
- var ENGINE_PACKAGE_VERSION = "0.1.920";
248
+ var ENGINE_PACKAGE_VERSION = "0.1.922";
249
249
  var INITIALIZE_METHOD = "initialize";
250
250
  var INITIALIZED_NOTIFICATION = "initialized";
251
251
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  monolithRequest
6
- } from "./chunk-UMXQF6DT.js";
6
+ } from "./chunk-LYX74DW2.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-MLSB5HUT.js";
11
+ } from "./chunk-VT557AFP.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -15,30 +15,35 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-MLSB5HUT.js";
19
-
20
- // src/engine-env.ts
21
- import { readFileSync as readFileSync2 } from "fs";
22
- import { homedir as homedir2 } from "os";
23
- import { join as join2 } from "path";
18
+ } from "./chunk-VT557AFP.js";
24
19
 
25
20
  // src/runtime-env-loader.ts
26
21
  import { readFileSync } from "fs";
27
22
  import { homedir } from "os";
28
23
  import { join } from "path";
29
- function loadRuntimeEnvFile() {
30
- let content;
24
+ var loadedKeys = [];
25
+ function readRuntimeEnvFile() {
31
26
  try {
32
- content = readFileSync(join(homedir(), ".replicas", "runtime-env.sh"), "utf-8");
27
+ return parsePosixEnvFile(readFileSync(join(homedir(), ".replicas", "runtime-env.sh"), "utf-8"));
33
28
  } catch {
34
- return;
29
+ return null;
30
+ }
31
+ }
32
+ function loadRuntimeEnvFile(values = readRuntimeEnvFile()) {
33
+ if (!values) return;
34
+ for (const key of loadedKeys) {
35
+ if (!(key in values)) delete process.env[key];
35
36
  }
36
- for (const [key, value] of Object.entries(parsePosixEnvFile(content))) {
37
+ for (const [key, value] of Object.entries(values)) {
37
38
  process.env[key] = value;
38
39
  }
40
+ loadedKeys = Object.keys(values);
39
41
  }
40
42
 
41
43
  // src/engine-env.ts
44
+ import { readFileSync as readFileSync2 } from "fs";
45
+ import { homedir as homedir2 } from "os";
46
+ import { join as join2 } from "path";
42
47
  var SANDBOX_IMAGE_VERSION_FILE = "/usr/local/lib/replicas-sandbox-image-version";
43
48
  function readEnv(name) {
44
49
  const value = process.env[name]?.trim();
@@ -108,9 +113,8 @@ function parseAgentCredentialSnapshots(value) {
108
113
  return {};
109
114
  }
110
115
  }
111
- var IS_WARMING_MODE = process.argv.includes("--warming");
112
- function loadEngineEnv() {
113
- loadRuntimeEnvFile();
116
+ function loadEngineEnv(runtimeEnvValues) {
117
+ loadRuntimeEnvFile(runtimeEnvValues);
114
118
  const HOME_DIR = homedir2();
115
119
  const backgroundTaskTimeoutMs = Number(readEnv("REPLICAS_CLAUDE_BACKGROUND_TASK_TIMEOUT_MS"));
116
120
  const env = {
@@ -151,15 +155,15 @@ function loadEngineEnv() {
151
155
  REPLICAS_AGENT_CREDENTIALS: parseAgentCredentialSnapshots(readEnv("REPLICAS_AGENT_CREDENTIALS")),
152
156
  REPLICAS_ENV_SYSTEM_PROMPT: readEnv("REPLICAS_ENV_SYSTEM_PROMPT"),
153
157
  REPLICAS_ENV_START_HOOK: readEnv("REPLICAS_ENV_START_HOOK"),
154
- REPLICAS_DISABLE_AUTO_START_HOOKS: readEnv("REPLICAS_DISABLE_AUTO_START_HOOKS")?.toLowerCase() === "true",
155
- REPLICAS_ENGINE_DEFER_INITIALIZATION: readEnv("REPLICAS_ENGINE_DEFER_INITIALIZATION")?.toLowerCase() === "true"
158
+ REPLICAS_DISABLE_AUTO_START_HOOKS: readEnv("REPLICAS_DISABLE_AUTO_START_HOOKS")?.toLowerCase() === "true"
156
159
  };
157
- if (!IS_WARMING_MODE && !env.REPLICAS_WORKSPACE_ID) {
158
- console.error("REPLICAS_WORKSPACE_ID is not set \u2014 this is required in normal (non-warming) mode");
159
- }
160
160
  return env;
161
161
  }
162
162
  var ENGINE_ENV = loadEngineEnv();
163
+ function reloadEngineEnv(runtimeEnvValues) {
164
+ ENGINE_ENV = loadEngineEnv(runtimeEnvValues);
165
+ return ENGINE_ENV;
166
+ }
163
167
  function setAgentCredentialSnapshot(provider, { type, scope, revision, account }) {
164
168
  if (!scope) return;
165
169
  ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS = {
@@ -244,8 +248,9 @@ var MonolithService = class {
244
248
  var monolithService = new MonolithService();
245
249
 
246
250
  export {
247
- IS_WARMING_MODE,
251
+ readRuntimeEnvFile,
248
252
  ENGINE_ENV,
253
+ reloadEngineEnv,
249
254
  setAgentCredentialSnapshot,
250
255
  monolithRequest,
251
256
  monolithService
@@ -2,6 +2,29 @@
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
 
5
+ // ../shared/src/type-guards.ts
6
+ function isRecord(value) {
7
+ return typeof value === "object" && value !== null && !Array.isArray(value);
8
+ }
9
+ function isNonEmptyString(value) {
10
+ return typeof value === "string" && value.trim().length > 0;
11
+ }
12
+
13
+ // ../shared/src/result.ts
14
+ function createSuccessResult(data) {
15
+ return { ok: true, data };
16
+ }
17
+ function createErrorResult(error) {
18
+ return {
19
+ ok: false,
20
+ error: {
21
+ message: error.message,
22
+ code: error.code,
23
+ details: error.details
24
+ }
25
+ };
26
+ }
27
+
5
28
  // ../shared/src/agent.ts
6
29
  var AGENT = {
7
30
  CLAUDE: "claude",
@@ -165,14 +188,6 @@ async function fetchOpenCodeGoCatalog(fallbackModelIds = [DEFAULT_OPENCODE_GO_MO
165
188
  }
166
189
  }
167
190
 
168
- // ../shared/src/type-guards.ts
169
- function isRecord(value) {
170
- return typeof value === "object" && value !== null && !Array.isArray(value);
171
- }
172
- function isNonEmptyString(value) {
173
- return typeof value === "string" && value.trim().length > 0;
174
- }
175
-
176
191
  // ../shared/src/engine/types.ts
177
192
  var DEFAULT_CHAT_TITLES = {
178
193
  claude: "Claude Code",
@@ -520,21 +535,6 @@ function paginateEngineLogContent(input) {
520
535
  // ../shared/src/analytics/types.ts
521
536
  import { z as z2 } from "zod";
522
537
 
523
- // ../shared/src/result.ts
524
- function createSuccessResult(data) {
525
- return { ok: true, data };
526
- }
527
- function createErrorResult(error) {
528
- return {
529
- ok: false,
530
- error: {
531
- message: error.message,
532
- code: error.code,
533
- details: error.details
534
- }
535
- };
536
- }
537
-
538
538
  // ../shared/src/external-api-host.ts
539
539
  function validateExternalApiHost(url, providerLabel) {
540
540
  let parsed;
@@ -1085,6 +1085,8 @@ var MERGED_MESSAGE_SEPARATOR = "\n\n<!-- replicas:merged -->\n\n";
1085
1085
  var ENGINE_HEALTH_WAIT_HEADER = "X-Replicas-Health-Wait";
1086
1086
  var ENGINE_HEALTH_WAIT_QUERY_PARAM = "wait_ms";
1087
1087
  var ENGINE_HEALTH_MAX_WAIT_MS = 2e3;
1088
+ var ENGINE_ACTIVATE_PATH = "/lifecycle/activate";
1089
+ var ENGINE_SLEEP_PATH = "/lifecycle/sleep";
1088
1090
  var updateChatDisplayNameRequestSchema = z3.object({
1089
1091
  displayName: z3.string().trim().min(1).max(100)
1090
1092
  });
@@ -1410,24 +1412,6 @@ function paginateChatHistory(full, params) {
1410
1412
  };
1411
1413
  }
1412
1414
 
1413
- // ../shared/src/sandbox.ts
1414
- var SANDBOX_LIFECYCLE = {
1415
- AUTO_STOP_MINUTES: 60,
1416
- AUTO_ARCHIVE_MINUTES: 60 * 24 * 7,
1417
- AUTO_DELETE_MINUTES: -1,
1418
- SSH_TOKEN_EXPIRATION_MINUTES: 3 * 60
1419
- };
1420
- var SANDBOX_PATHS = {
1421
- HOME_DIR: "/home/user",
1422
- WORKSPACES_DIR: "/home/user/workspaces",
1423
- REPLICAS_DIR: "/home/user/.replicas",
1424
- ENGINE_INIT_GATE: "/home/user/.replicas/engine-init-gate",
1425
- REPLICAS_CANVAS_DIR: "/home/user/.replicas/canvas",
1426
- REPLICAS_RUNTIME_ENV_FILE: "/home/user/.replicas/runtime-env.sh"
1427
- };
1428
- var WORKSPACE_SIZES = ["small", "large"];
1429
- var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
1430
-
1431
1415
  // ../shared/src/memory-safety.ts
1432
1416
  var SECRET_PATTERNS = [
1433
1417
  /sk-[A-Za-z0-9_-]{10,}/g,
@@ -1481,20 +1465,6 @@ function getMemoryOutputSafetyViolation(value, secrets, maxChars) {
1481
1465
  return null;
1482
1466
  }
1483
1467
 
1484
- // ../shared/src/github/url.ts
1485
- var GITHUB_HOST_RE = /(^|@|\/\/)github\.com[:/]/;
1486
- var GITHUB_REPO_SLUG_RE = /github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?(?:[/?#]|$)/i;
1487
- function isGitHubUrl(url) {
1488
- if (!url) return false;
1489
- return GITHUB_HOST_RE.test(url);
1490
- }
1491
- function parseRepoUrlSlug(url) {
1492
- if (!url) return null;
1493
- const match = url.match(GITHUB_REPO_SLUG_RE);
1494
- if (!match) return null;
1495
- return { owner: match[1].toLowerCase(), repo: match[2].toLowerCase() };
1496
- }
1497
-
1498
1468
  // ../shared/src/runtime-env.ts
1499
1469
  var REPLICAS_RUNTIME_ENV_ALIASES = {
1500
1470
  monolithUrl: ["REPLICAS_MONOLITH_URL", "MONOLITH_URL"],
@@ -1566,6 +1536,20 @@ function parsePosixEnvFile(content) {
1566
1536
  return result;
1567
1537
  }
1568
1538
 
1539
+ // ../shared/src/github/url.ts
1540
+ var GITHUB_HOST_RE = /(^|@|\/\/)github\.com[:/]/;
1541
+ var GITHUB_REPO_SLUG_RE = /github\.com[/:]([^/]+)\/([^/]+?)(?:\.git)?(?:[/?#]|$)/i;
1542
+ function isGitHubUrl(url) {
1543
+ if (!url) return false;
1544
+ return GITHUB_HOST_RE.test(url);
1545
+ }
1546
+ function parseRepoUrlSlug(url) {
1547
+ if (!url) return null;
1548
+ const match = url.match(GITHUB_REPO_SLUG_RE);
1549
+ if (!match) return null;
1550
+ return { owner: match[1].toLowerCase(), repo: match[2].toLowerCase() };
1551
+ }
1552
+
1569
1553
  // ../shared/src/git.ts
1570
1554
  var GIT_CREDENTIAL_HELPER_FILENAME = ".git-credential-replicas";
1571
1555
  var GITHUB_CREDENTIAL_REFRESH_PATH = "/git-credentials/github/refresh";
@@ -3291,6 +3275,25 @@ var MEDIA_ABILITY = {
3291
3275
 
3292
3276
  // ../shared/src/memory.ts
3293
3277
  import { z as z9 } from "zod";
3278
+
3279
+ // ../shared/src/sandbox.ts
3280
+ var SANDBOX_LIFECYCLE = {
3281
+ AUTO_STOP_MINUTES: 60,
3282
+ AUTO_ARCHIVE_MINUTES: 60 * 24 * 7,
3283
+ AUTO_DELETE_MINUTES: -1,
3284
+ SSH_TOKEN_EXPIRATION_MINUTES: 3 * 60
3285
+ };
3286
+ var SANDBOX_PATHS = {
3287
+ HOME_DIR: "/home/user",
3288
+ WORKSPACES_DIR: "/home/user/workspaces",
3289
+ REPLICAS_DIR: "/home/user/.replicas",
3290
+ REPLICAS_CANVAS_DIR: "/home/user/.replicas/canvas",
3291
+ REPLICAS_RUNTIME_ENV_FILE: "/home/user/.replicas/runtime-env.sh"
3292
+ };
3293
+ var WORKSPACE_SIZES = ["small", "large"];
3294
+ var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
3295
+
3296
+ // ../shared/src/memory.ts
3294
3297
  var MEMORY_ROOT = `${SANDBOX_PATHS.REPLICAS_DIR}/memories`;
3295
3298
  var MEMORY_INDEX_FILENAME = "MEMORY.md";
3296
3299
  var MEMORY_BUNDLE_FILENAME = "memory.tar.gz";
@@ -7852,7 +7855,7 @@ function isSkillRegistryManifest(value) {
7852
7855
  if (!("version" in value) || value.version !== SKILL_REGISTRY_MANIFEST_VERSION) return false;
7853
7856
  if (!("registries" in value) || !Array.isArray(value.registries)) return false;
7854
7857
  return value.registries.every(
7855
- (entry) => typeof entry === "object" && entry !== null && "index" in entry && typeof entry.index === "number" && "name" in entry && typeof entry.name === "string" && "url" in entry && typeof entry.url === "string" && "checkoutPath" in entry && typeof entry.checkoutPath === "string"
7858
+ (entry) => typeof entry === "object" && entry !== null && "index" in entry && typeof entry.index === "number" && "name" in entry && typeof entry.name === "string" && "url" in entry && typeof entry.url === "string" && "checkoutPath" in entry && typeof entry.checkoutPath === "string" && (!("head" in entry) || typeof entry.head === "string")
7856
7859
  );
7857
7860
  }
7858
7861
 
@@ -7965,6 +7968,8 @@ export {
7965
7968
  ENGINE_HEALTH_WAIT_HEADER,
7966
7969
  ENGINE_HEALTH_WAIT_QUERY_PARAM,
7967
7970
  ENGINE_HEALTH_MAX_WAIT_MS,
7971
+ ENGINE_ACTIVATE_PATH,
7972
+ ENGINE_SLEEP_PATH,
7968
7973
  updateChatDisplayNameRequestSchema,
7969
7974
  getChatExecutionProvider,
7970
7975
  createChatRequestSchema,
@@ -7992,7 +7997,6 @@ export {
7992
7997
  parseCodeHostPrUrl,
7993
7998
  decodePathSegments,
7994
7999
  buildCodeHostPrUrl,
7995
- SANDBOX_PATHS,
7996
8000
  MEMORY_ROOT,
7997
8001
  MEMORY_INDEX_FILENAME,
7998
8002
  MEMORY_MARKER_GUIDANCE,
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-AOBS7XEL.js";
7
- import "./chunk-UMXQF6DT.js";
6
+ } from "./chunk-HEYQCKMN.js";
7
+ import "./chunk-LYX74DW2.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-MLSB5HUT.js";
11
+ import "./chunk-VT557AFP.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/command-protection-hook.ts
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  AppServerProcess,
10
10
  buildCodexAgentEnv
11
- } from "./chunk-6GY7ZCSO.js";
11
+ } from "./chunk-75D2W6N3.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-MLSB5HUT.js";
16
+ } from "./chunk-VT557AFP.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
 
19
19
  // src/headless-agent.ts