replicas-engine 0.1.1600 → 0.1.1603

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.
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  execFileAsync
6
- } from "./chunk-5M22SZHQ.js";
6
+ } from "./chunk-IP4QQ2LD.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-GN2YE77J.js";
9
+ } from "./chunk-2ENRWARZ.js";
10
10
 
11
11
  // src/utils/codex-agent-env.ts
12
12
  function buildCodexAgentEnv(source = process.env) {
@@ -240,7 +240,7 @@ function getCodexModelProvider(method) {
240
240
  if (method === "foundry") return "azure";
241
241
  return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
242
242
  }
243
- var ENGINE_PACKAGE_VERSION = "0.1.1600";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1603";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-GN2YE77J.js";
6
+ } from "./chunk-2ENRWARZ.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  AspClient
6
- } from "./chunk-ZDOSFRWB.js";
6
+ } from "./chunk-BO2GIGEJ.js";
7
7
  import {
8
8
  ASTER_BASE_URL,
9
9
  ASTER_PROVIDER,
@@ -15,7 +15,7 @@ import {
15
15
  isRecord,
16
16
  readOllamaAuthEnv,
17
17
  readOpenAICompatibleAuthEnv
18
- } from "./chunk-GN2YE77J.js";
18
+ } from "./chunk-2ENRWARZ.js";
19
19
 
20
20
  // src/managers/codex-asp/notification-dispatch.ts
21
21
  var TURN_STARTED_METHOD = "turn/started";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-GN2YE77J.js";
8
+ } from "./chunk-2ENRWARZ.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -3,24 +3,26 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  ENGINE_ENV,
6
- getOriginDefaultBranch,
7
6
  monolithRequest,
8
7
  runGitCommand
9
- } from "./chunk-6WSVDW2W.js";
8
+ } from "./chunk-ZLENMDGD.js";
10
9
  import {
10
+ COMMAND_PROTECTION_MAX_MESSAGE_FILE_BYTES,
11
+ COMMAND_PROTECTION_REPO_GIT_ARGS,
12
+ commandProtectionEvaluateResponseSchema,
11
13
  extractCommandProtectionCommandText,
12
14
  findCommandProtectionGitLookups,
13
15
  findGitCommitSignals,
14
16
  findPrMergeSignals,
15
17
  findScoutRepoWriteSignals,
16
18
  parseCommandProtectionRequest,
19
+ toCommandProtectionRepoState,
17
20
  withE2BRetry
18
- } from "./chunk-GN2YE77J.js";
21
+ } from "./chunk-2ENRWARZ.js";
19
22
 
20
23
  // src/services/command-protection-service.ts
21
24
  import { readFile, stat } from "fs/promises";
22
25
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
23
- var MAX_COMMIT_MESSAGE_FILE_BYTES = 64 * 1024;
24
26
  var GATEWAY_ERROR_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
25
27
  var SCOUT_REPO_WRITE_BLOCK_MESSAGE = "Scout never clones, commits, pushes, or opens pull requests. Spawn a workspace on an environment that has the repository, or relay this to the thread's workspace.";
26
28
  async function resolveGitContext({ repoDirs, messageFiles }) {
@@ -28,29 +30,17 @@ async function resolveGitContext({ repoDirs, messageFiles }) {
28
30
  const git = (dir, args) => runGitCommand(args, dir).then((output) => output || null, () => null);
29
31
  const [repos, files] = await Promise.all([
30
32
  Promise.all(repoDirs.map(async (dir) => {
31
- const [branch, defaultBranch, pushBranch, pushConfig, headMessage, mergeHead] = await Promise.all([
32
- git(dir, ["symbolic-ref", "--quiet", "--short", "HEAD"]),
33
- getOriginDefaultBranch(dir),
34
- git(dir, ["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{push}"]),
35
- git(dir, ["config", "--get-regexp", "^(push\\.default|push\\.pushoption|remote\\..+\\.push)$"]),
36
- git(dir, ["log", "-1", "--format=%B"]),
37
- git(dir, ["rev-parse", "--quiet", "--verify", "MERGE_HEAD"])
38
- ]);
39
- return [dir, { branch, defaultBranch, pushBranch: pushBranch?.replace(/^[^/]+\//, "") ?? null, pushConfig, headMessage, mergeInProgress: mergeHead !== null }];
33
+ const outputs = await Promise.all(COMMAND_PROTECTION_REPO_GIT_ARGS.map((args) => git(dir, [...args])));
34
+ return [dir, toCommandProtectionRepoState(outputs)];
40
35
  })),
41
36
  Promise.all(messageFiles.map(async (path) => {
42
37
  const info = await stat(path).catch(() => null);
43
- const content = info?.isFile() && info.size <= MAX_COMMIT_MESSAGE_FILE_BYTES ? await readFile(path, "utf8").catch(() => null) : null;
38
+ const content = info?.isFile() && info.size <= COMMAND_PROTECTION_MAX_MESSAGE_FILE_BYTES ? await readFile(path, "utf8").catch(() => null) : null;
44
39
  return content === null ? [] : [[path, content]];
45
40
  }))
46
41
  ]);
47
42
  return { repos: Object.fromEntries(repos), messageFiles: Object.fromEntries(files.flat()) };
48
43
  }
49
- function asCommandProtectionResponse(value) {
50
- if (typeof value !== "object" || value === null) return null;
51
- const candidate = value;
52
- return typeof candidate.allowed === "boolean" && typeof candidate.enabled === "boolean" ? candidate : null;
53
- }
54
44
  function failClosed(reason, matchedSignals) {
55
45
  return {
56
46
  allowed: false,
@@ -99,7 +89,8 @@ async function evaluateCommandProtection(request, signal) {
99
89
  const detail = error instanceof Error ? error.message : String(error);
100
90
  return failClosed(`Command protection failed closed: ${detail}`, matchedSignals);
101
91
  }
102
- return asCommandProtectionResponse(payload) ?? failClosed("Command protection failed closed: invalid response from policy service", matchedSignals);
92
+ const verdict = commandProtectionEvaluateResponseSchema.safeParse(payload);
93
+ return verdict.success ? verdict.data : failClosed("Command protection failed closed: invalid response from policy service", matchedSignals);
103
94
  }
104
95
  function extractToolCommand(input) {
105
96
  return extractCommandProtectionCommandText({ toolInput: input }, { stringifyFallback: false });
@@ -12,15 +12,15 @@ import {
12
12
  resolveDiffBase,
13
13
  runGitCommand,
14
14
  setAgentCredentialSnapshot
15
- } from "./chunk-6WSVDW2W.js";
15
+ } from "./chunk-ZLENMDGD.js";
16
16
  import {
17
17
  AppServerProcess,
18
18
  buildCodexAgentEnv
19
- } from "./chunk-ZDOSFRWB.js";
19
+ } from "./chunk-BO2GIGEJ.js";
20
20
  import {
21
21
  SUBPROCESS_MAX_BUFFER,
22
22
  execFileAsync
23
- } from "./chunk-5M22SZHQ.js";
23
+ } from "./chunk-IP4QQ2LD.js";
24
24
  import {
25
25
  isRecord
26
26
  } from "./chunk-UZSNFLDQ.js";
@@ -61,7 +61,7 @@ import {
61
61
  shrunkImageSize,
62
62
  splitMothershipInstructions,
63
63
  withTimeout
64
- } from "./chunk-GN2YE77J.js";
64
+ } from "./chunk-2ENRWARZ.js";
65
65
 
66
66
  // src/managers/codex-token-manager.ts
67
67
  import { promises as fs } from "fs";
@@ -461,7 +461,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
461
461
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
462
462
  await this.applyCredentialsResponse(data);
463
463
  setAgentCredentialSnapshot("codex", data);
464
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-HR3U7S5P.js");
464
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-SS2XJOIE.js");
465
465
  await restartCodexAspHostIfRunning2();
466
466
  });
467
467
  await this.start(true);
@@ -483,7 +483,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
483
483
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
484
484
  await this.applyCredentialsResponse(data);
485
485
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
486
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-HR3U7S5P.js");
486
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-SS2XJOIE.js");
487
487
  await restartCodexAspHostIfRunning2();
488
488
  }
489
489
  setAgentCredentialSnapshot("codex", data);
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-5M22SZHQ.js";
7
+ } from "./chunk-IP4QQ2LD.js";
8
8
  import {
9
9
  isRecord as isRecord2
10
10
  } from "./chunk-UZSNFLDQ.js";
@@ -21,7 +21,7 @@ import {
21
21
  provisionedDeviceSchema,
22
22
  readReplicasRuntimeEnv,
23
23
  serializePosixEnvFile
24
- } from "./chunk-GN2YE77J.js";
24
+ } from "./chunk-2ENRWARZ.js";
25
25
 
26
26
  // src/runtime-env-loader.ts
27
27
  import { readFileSync } from "fs";
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  evaluateCommandProtection
6
- } from "./chunk-V4EFZGCN.js";
7
- import "./chunk-6WSVDW2W.js";
8
- import "./chunk-5M22SZHQ.js";
6
+ } from "./chunk-RYXGSY24.js";
7
+ import "./chunk-ZLENMDGD.js";
8
+ import "./chunk-IP4QQ2LD.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-GN2YE77J.js";
12
+ import "./chunk-2ENRWARZ.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -14,12 +14,12 @@ import {
14
14
  recoverCompletedTurn,
15
15
  spawnMuseMsp,
16
16
  startMuseSession
17
- } from "./chunk-23OSWBDM.js";
17
+ } from "./chunk-KT44NX2N.js";
18
18
  import {
19
19
  AppServerProcess,
20
20
  buildCodexAgentEnv
21
- } from "./chunk-ZDOSFRWB.js";
22
- import "./chunk-5M22SZHQ.js";
21
+ } from "./chunk-BO2GIGEJ.js";
22
+ import "./chunk-IP4QQ2LD.js";
23
23
  import {
24
24
  AGENT,
25
25
  OPENCODE_GO_PROVIDER,
@@ -29,7 +29,7 @@ import {
29
29
  headlessAgentUsagePath,
30
30
  isRecord,
31
31
  withTimeout
32
- } from "./chunk-GN2YE77J.js";
32
+ } from "./chunk-2ENRWARZ.js";
33
33
  import "./chunk-VEQXQN22.js";
34
34
 
35
35
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  evaluateCommandProtection,
28
28
  extractToolCommand,
29
29
  reportCommandProtectionBlock
30
- } from "./chunk-V4EFZGCN.js";
30
+ } from "./chunk-RYXGSY24.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -65,10 +65,10 @@ import {
65
65
  spawnMuseMsp,
66
66
  startMuseSession,
67
67
  uuidV7
68
- } from "./chunk-23OSWBDM.js";
68
+ } from "./chunk-KT44NX2N.js";
69
69
  import {
70
70
  publishedPullRequestUrls
71
- } from "./chunk-YZ465CA2.js";
71
+ } from "./chunk-PI7M37BA.js";
72
72
  import {
73
73
  ACCOUNT_RATE_LIMITS_READ_METHOD,
74
74
  AsyncLock,
@@ -147,7 +147,7 @@ import {
147
147
  transcriptSecrets,
148
148
  upsertCredentialFileLines,
149
149
  writeSecureCredentialFile
150
- } from "./chunk-2KSEOMCI.js";
150
+ } from "./chunk-TBKSOXMC.js";
151
151
  import {
152
152
  ENGINE_ENV,
153
153
  UNQUOTED_PATHS_CONFIG,
@@ -158,16 +158,16 @@ import {
158
158
  resolveDiffBase,
159
159
  setAgentCredentialSnapshot,
160
160
  setLinearSessionId
161
- } from "./chunk-6WSVDW2W.js";
161
+ } from "./chunk-ZLENMDGD.js";
162
162
  import {
163
163
  buildCodexAgentEnv,
164
164
  getCodexModelProvider
165
- } from "./chunk-ZDOSFRWB.js";
165
+ } from "./chunk-BO2GIGEJ.js";
166
166
  import {
167
167
  SUBPROCESS_MAX_BUFFER,
168
168
  execAsync,
169
169
  execFileAsync
170
- } from "./chunk-5M22SZHQ.js";
170
+ } from "./chunk-IP4QQ2LD.js";
171
171
  import {
172
172
  isRecord as isRecord2
173
173
  } from "./chunk-UZSNFLDQ.js";
@@ -463,7 +463,7 @@ import {
463
463
  workspaceTokenRequestSchema,
464
464
  workspaceTokenResponseSchema,
465
465
  wrapInTag
466
- } from "./chunk-GN2YE77J.js";
466
+ } from "./chunk-2ENRWARZ.js";
467
467
  import {
468
468
  cloneMcpConfig,
469
469
  ensureCompatibilityImports,
@@ -10318,7 +10318,7 @@ These hooks are currently executing in the background. You can:
10318
10318
  - View hook commands in each repository's replicas.json (under the "startHook" field)
10319
10319
 
10320
10320
  The start hooks may install dependencies, build projects, or perform other setup tasks.
10321
- If your task depends on setup being complete, check the log file before proceeding.`;
10321
+ Don't run those steps yourself while the hooks are running: a second install or build alongside theirs can break both. Before anything that needs the setup, wait until the log shows "=== All start hooks completed".`;
10322
10322
  async function readReplicasConfigFromDir(dirPath) {
10323
10323
  for (const filename of REPLICAS_CONFIG_FILENAMES) {
10324
10324
  const configPath = join5(dirPath, filename);
@@ -10357,6 +10357,7 @@ var ReplicasConfigService = class {
10357
10357
  }
10358
10358
  };
10359
10359
  this.hooksRunning = true;
10360
+ if (this.getStartHookConfig()) await writeFile3(START_HOOKS_LOG, "Start hooks are waiting to run.\n", "utf-8").catch((error) => console.error("Failed to reset start hooks log:", error));
10360
10361
  void beforeHooks.then(() => this.executeStartHooks({ onStart: () => void report({ status: "running" }) })).then(async (result) => report({
10361
10362
  status: result.exitCode === 0 && !result.timedOut ? "succeeded" : "failed",
10362
10363
  exitCode: result.exitCode,
@@ -10684,7 +10685,6 @@ ${startHookConfig.commands.join("\n")}`;
10684
10685
  }
10685
10686
  this.hooksCompleted = true;
10686
10687
  this.hooksFailed = overallExitCode !== 0;
10687
- await this.logToFile(`=== All start hooks completed at ${(/* @__PURE__ */ new Date()).toISOString()} ===`);
10688
10688
  const result = {
10689
10689
  exitCode: overallExitCode,
10690
10690
  output: outputBlocks.join("\n\n"),
@@ -10700,6 +10700,7 @@ ${startHookConfig.commands.join("\n")}`;
10700
10700
  await this.logToFile(`[SYSTEM] [ERROR] Start hooks execution failed: ${errorMessage}`);
10701
10701
  throw error;
10702
10702
  } finally {
10703
+ await this.logToFile(`=== All start hooks completed at ${(/* @__PURE__ */ new Date()).toISOString()} ===`);
10703
10704
  this.hooksRunning = false;
10704
10705
  }
10705
10706
  }
@@ -11160,7 +11161,7 @@ import { z as z4 } from "zod";
11160
11161
 
11161
11162
  // ../shared/src/persisted-query-hashes.ts
11162
11163
  var PERSISTED_QUERY_HASHES = {
11163
- workspaceChats: "79951346"
11164
+ workspaceChats: "e406bd60"
11164
11165
  };
11165
11166
 
11166
11167
  // ../shared/src/workspace-chat.ts
@@ -14441,7 +14442,10 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
14441
14442
  env: {
14442
14443
  ...shared.env,
14443
14444
  // A resumed session reports tools from a still-connecting MCP server as removed, so the agent stops using them.
14444
- ...this.sessionId ? { MCP_CONNECTION_NONBLOCKING: "false" } : {},
14445
+ // A new session waits too: tools that connect after its first request stay out of its tool list, so the next process would send a different list and rewrite the whole prompt cache.
14446
+ MCP_CONNECTION_NONBLOCKING: "false",
14447
+ // That wait ends after 5 seconds. Without this, a chat that passes a server of its own would go on waiting for every server still connecting, up to 30 seconds.
14448
+ CLAUDE_CODE_MCP_STARTUP_WAIT_MS: "0",
14445
14449
  ...resolveClaudeAuthMethodForMessage() === "ollama" ? {
14446
14450
  ANTHROPIC_DEFAULT_SONNET_MODEL: resolvedModel,
14447
14451
  ANTHROPIC_DEFAULT_OPUS_MODEL: resolvedModel,
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-YZ465CA2.js";
6
+ } from "./chunk-PI7M37BA.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-GN2YE77J.js";
12
+ } from "./chunk-2ENRWARZ.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -11,7 +11,7 @@ import {
11
11
  spawnSubagentRequestSchema,
12
12
  subagentResponseSchema,
13
13
  waitSubagentRequestSchema
14
- } from "./chunk-GN2YE77J.js";
14
+ } from "./chunk-2ENRWARZ.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1600",
3
+ "version": "0.1.1603",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",