replicas-engine 0.1.503 → 0.1.505

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.
Files changed (2) hide show
  1. package/dist/src/index.js +74 -80
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -611,7 +611,7 @@ var WORKSPACE_SIZES = ["small", "large"];
611
611
  var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
612
612
 
613
613
  // ../shared/src/e2b.ts
614
- var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-25-v5";
614
+ var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-25-v7";
615
615
 
616
616
  // ../shared/src/runtime-env.ts
617
617
  function shellQuotePosix(value) {
@@ -3203,6 +3203,12 @@ function findPrMergeSignals(request) {
3203
3203
  ];
3204
3204
  return checks.flatMap(([name, pattern]) => pattern.test(combined) ? [name] : []);
3205
3205
  }
3206
+ function findGitCommitSignals(request) {
3207
+ const command = normalizeCommandProtectionText(
3208
+ extractCommandProtectionCommandText(request, { stringifyFallback: true }) ?? ""
3209
+ );
3210
+ return /\bgit\s+(?:-[^\s]+\s+)*commit\b/.test(command) ? ["git-commit"] : [];
3211
+ }
3206
3212
 
3207
3213
  // ../shared/src/routes/workspaces.ts
3208
3214
  var WORKSPACE_STATUSES = ["active", "sleeping", "archived", "preparing", "error"];
@@ -4875,7 +4881,6 @@ function loadEngineEnv() {
4875
4881
  ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION: readEnv("ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION"),
4876
4882
  REPLICAS_CLAUDE_AUTH_METHOD: parseClaudeAuthMethod(readEnv("REPLICAS_CLAUDE_AUTH_METHOD")),
4877
4883
  REPLICAS_CODEX_AUTH_METHOD: parseCodexAuthMethod(readEnv("REPLICAS_CODEX_AUTH_METHOD")),
4878
- REPLICAS_DISABLE_GH_PR_MERGE: readEnv("REPLICAS_DISABLE_GH_PR_MERGE")?.toLowerCase() === "true",
4879
4884
  REPLICAS_ENV_SYSTEM_PROMPT: readEnv("REPLICAS_ENV_SYSTEM_PROMPT"),
4880
4885
  REPLICAS_ENV_START_HOOK: readEnv("REPLICAS_ENV_START_HOOK"),
4881
4886
  REPLICAS_DISABLE_AUTO_START_HOOKS: readEnv("REPLICAS_DISABLE_AUTO_START_HOOKS")?.toLowerCase() === "true",
@@ -8245,7 +8250,7 @@ var LinearEventForwarder = class {
8245
8250
  };
8246
8251
 
8247
8252
  // src/services/command-protection-service.ts
8248
- var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by organization policy: agents may not merge pull requests.";
8253
+ var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
8249
8254
  function asCommandProtectionResponse(value) {
8250
8255
  if (typeof value !== "object" || value === null) return null;
8251
8256
  const candidate = value;
@@ -8260,7 +8265,7 @@ function failClosed(reason, matchedSignals) {
8260
8265
  };
8261
8266
  }
8262
8267
  async function evaluateCommandProtection(request, signal) {
8263
- const matchedSignals = findPrMergeSignals(request);
8268
+ const matchedSignals = [...findGitCommitSignals(request), ...findPrMergeSignals(request)];
8264
8269
  if (matchedSignals.length === 0) {
8265
8270
  return { allowed: true, enabled: true };
8266
8271
  }
@@ -8292,7 +8297,7 @@ function extractToolCommand(input) {
8292
8297
  }
8293
8298
  function reportCommandProtectionBlock(options) {
8294
8299
  const message = options.result.reason || DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE;
8295
- console.warn(`[${options.managerName}] blocked ${options.action} by PR merge policy: ${message}`);
8300
+ console.warn(`[${options.managerName}] blocked ${options.action} by command protection: ${message}`);
8296
8301
  options.recordHistoryEvent(options.eventType, {
8297
8302
  type: "error",
8298
8303
  message,
@@ -9031,7 +9036,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
9031
9036
  hookSpecificOutput: {
9032
9037
  hookEventName: "PreToolUse",
9033
9038
  permissionDecision: "deny",
9034
- permissionDecisionReason: result.reason || "Blocked by organization policy: agents may not merge pull requests."
9039
+ permissionDecisionReason: result.reason || "Blocked by Replicas command protection."
9035
9040
  }
9036
9041
  };
9037
9042
  };
@@ -9365,15 +9370,13 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
9365
9370
  ...supportsClaudeThinkingDisplay(resolvedModel) ? { thinking: { type: "adaptive", display: "summarized" } } : {},
9366
9371
  ...effort ? { effort } : {},
9367
9372
  canUseTool: this.buildCanUseTool(),
9368
- ...ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE ? {
9369
- hooks: {
9370
- PreToolUse: [{
9371
- matcher: "*",
9372
- hooks: [this.buildCommandProtectionHook()],
9373
- timeout: 30
9374
- }]
9375
- }
9376
- } : {}
9373
+ hooks: {
9374
+ PreToolUse: [{
9375
+ matcher: "*",
9376
+ hooks: [this.buildCommandProtectionHook()],
9377
+ timeout: 30
9378
+ }]
9379
+ }
9377
9380
  }
9378
9381
  });
9379
9382
  this.activeQuery = response;
@@ -9955,7 +9958,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
9955
9958
  var MIN_CODEX_CLI_VERSION = "0.144.6";
9956
9959
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
9957
9960
  var codexCliVersionEnsured = null;
9958
- var ENGINE_PACKAGE_VERSION = "0.1.503";
9961
+ var ENGINE_PACKAGE_VERSION = "0.1.505";
9959
9962
  var INITIALIZE_METHOD = "initialize";
9960
9963
  var INITIALIZED_NOTIFICATION = "initialized";
9961
9964
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -10259,9 +10262,6 @@ var MODEL_LIST_METHOD = "model/list";
10259
10262
  var SKILLS_LIST_METHOD = "skills/list";
10260
10263
  var MAX_CODEX_ASP_TRANSCRIPT_OUTPUT_CHARS = DEFAULT_HOOK_OUTPUT_PREVIEW_CHARS;
10261
10264
  function codexApprovalPolicyOverrides() {
10262
- if (!ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE) {
10263
- return { approvalPolicy: "never" };
10264
- }
10265
10265
  return {
10266
10266
  approvalPolicy: "untrusted",
10267
10267
  approvalsReviewer: "user"
@@ -11654,36 +11654,33 @@ var CodexAspManager = class extends CodingAgentManager {
11654
11654
  const method = serverRequest.method;
11655
11655
  switch (serverRequest.method) {
11656
11656
  case "item/commandExecution/requestApproval": {
11657
- if (ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE) {
11658
- const result = await evaluateCommandProtection({
11659
- provider: "codex",
11660
- source: "codex_approval_request",
11661
- toolName: "commandExecution",
11662
- toolInput: {
11663
- command: serverRequest.params.command,
11664
- commandActions: serverRequest.params.commandActions ?? null
11665
- },
11657
+ const result = await evaluateCommandProtection({
11658
+ provider: "codex",
11659
+ source: "codex_approval_request",
11660
+ toolName: "commandExecution",
11661
+ toolInput: {
11666
11662
  command: serverRequest.params.command,
11667
- cwd: serverRequest.params.cwd ?? null,
11668
- toolUseId: serverRequest.params.itemId ?? null
11669
- });
11670
- if (!result.allowed) {
11671
- console.warn(`[CodexAspManager] blocked command approval by PR merge policy: ${result.reason ?? "unknown reason"}`);
11672
- this.recordBlockedCommand(
11673
- serverRequest.params.threadId,
11674
- serverRequest.params.turnId,
11675
- serverRequest.params.itemId,
11676
- serverRequest.params.command ?? "",
11677
- result.reason,
11678
- serverRequest.params.startedAtMs,
11679
- serverRequest.params.cwd,
11680
- serverRequest.params.commandActions
11681
- );
11682
- host.client.respond(requestId, { decision: "decline" });
11683
- return;
11684
- }
11663
+ commandActions: serverRequest.params.commandActions ?? null
11664
+ },
11665
+ command: serverRequest.params.command,
11666
+ cwd: serverRequest.params.cwd ?? null,
11667
+ toolUseId: serverRequest.params.itemId ?? null
11668
+ });
11669
+ if (!result.allowed) {
11670
+ console.warn(`[CodexAspManager] blocked command approval: ${result.reason ?? "unknown reason"}`);
11671
+ this.recordBlockedCommand(
11672
+ serverRequest.params.threadId,
11673
+ serverRequest.params.turnId,
11674
+ serverRequest.params.itemId,
11675
+ serverRequest.params.command ?? "",
11676
+ result.reason,
11677
+ serverRequest.params.startedAtMs,
11678
+ serverRequest.params.cwd,
11679
+ serverRequest.params.commandActions
11680
+ );
11681
+ host.client.respond(requestId, { decision: "decline" });
11682
+ return;
11685
11683
  }
11686
- console.warn("[CodexAspManager] approval requested while sandbox is danger-full-access");
11687
11684
  host.client.respond(requestId, { decision: "accept" });
11688
11685
  return;
11689
11686
  }
@@ -11692,37 +11689,34 @@ var CodexAspManager = class extends CodingAgentManager {
11692
11689
  host.client.respond(requestId, { decision: "accept" });
11693
11690
  return;
11694
11691
  case "execCommandApproval": {
11695
- if (ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE) {
11696
- const command = serverRequest.params.command.join(" ");
11697
- const result = await evaluateCommandProtection({
11698
- provider: "codex",
11699
- source: "codex_approval_request",
11700
- toolName: "execCommand",
11701
- toolInput: {
11702
- command: serverRequest.params.command,
11703
- parsedCmd: serverRequest.params.parsedCmd ?? null
11704
- },
11692
+ const command = serverRequest.params.command.join(" ");
11693
+ const result = await evaluateCommandProtection({
11694
+ provider: "codex",
11695
+ source: "codex_approval_request",
11696
+ toolName: "execCommand",
11697
+ toolInput: {
11698
+ command: serverRequest.params.command,
11699
+ parsedCmd: serverRequest.params.parsedCmd ?? null
11700
+ },
11701
+ command,
11702
+ cwd: serverRequest.params.cwd ?? null,
11703
+ toolUseId: serverRequest.params.callId ?? null
11704
+ });
11705
+ if (!result.allowed) {
11706
+ console.warn(`[CodexAspManager] blocked legacy command approval: ${result.reason ?? "unknown reason"}`);
11707
+ this.recordBlockedCommand(
11708
+ this.currentThreadId ?? serverRequest.params.conversationId,
11709
+ this.activeTurnId ?? `legacy-${requestId}`,
11710
+ serverRequest.params.callId,
11705
11711
  command,
11706
- cwd: serverRequest.params.cwd ?? null,
11707
- toolUseId: serverRequest.params.callId ?? null
11708
- });
11709
- if (!result.allowed) {
11710
- console.warn(`[CodexAspManager] blocked legacy command approval by PR merge policy: ${result.reason ?? "unknown reason"}`);
11711
- this.recordBlockedCommand(
11712
- this.currentThreadId ?? serverRequest.params.conversationId,
11713
- this.activeTurnId ?? `legacy-${requestId}`,
11714
- serverRequest.params.callId,
11715
- command,
11716
- result.reason,
11717
- Date.now(),
11718
- serverRequest.params.cwd,
11719
- [{ type: "unknown", command }]
11720
- );
11721
- host.client.respond(requestId, { decision: "denied" });
11722
- return;
11723
- }
11712
+ result.reason,
11713
+ Date.now(),
11714
+ serverRequest.params.cwd,
11715
+ [{ type: "unknown", command }]
11716
+ );
11717
+ host.client.respond(requestId, { decision: "denied" });
11718
+ return;
11724
11719
  }
11725
- console.warn("[CodexAspManager] legacy approval requested while sandbox is danger-full-access");
11726
11720
  host.client.respond(requestId, { decision: "approved" });
11727
11721
  return;
11728
11722
  }
@@ -12428,7 +12422,7 @@ var CursorManager = class extends CodingAgentManager {
12428
12422
  }
12429
12423
  }
12430
12424
  async handleCursorToolCall(toolCall) {
12431
- if (!ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE || !toolCall) return;
12425
+ if (!toolCall) return;
12432
12426
  if (this.blockedToolCallIds.has(toolCall.toolUseId)) return;
12433
12427
  const result = await evaluateCommandProtection({
12434
12428
  provider: "cursor",
@@ -13079,7 +13073,7 @@ var OpencodeManager = class extends CodingAgentManager {
13079
13073
  const callId = typeof source?.callID === "string" ? source.callID : isRecord4(payload.tool) && typeof payload.tool.callID === "string" ? payload.tool.callID : void 0;
13080
13074
  const toolInput = callId ? this.opencodeToolInputs.get(callId) ?? payload : payload;
13081
13075
  const command = opencodePermissionCommand(payload, toolInput);
13082
- const result = ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE ? await evaluateCommandProtection({
13076
+ const result = await evaluateCommandProtection({
13083
13077
  provider: "opencode",
13084
13078
  source: "opencode_permission_request",
13085
13079
  toolName: typeof payload.action === "string" ? payload.action : typeof payload.permission === "string" ? payload.permission : "permission",
@@ -13087,7 +13081,7 @@ var OpencodeManager = class extends CodingAgentManager {
13087
13081
  command,
13088
13082
  cwd: this.workingDirectory,
13089
13083
  toolUseId: requestId
13090
- }) : { allowed: true, enabled: false };
13084
+ });
13091
13085
  const reply = result.allowed ? "once" : "reject";
13092
13086
  const message = result.allowed ? void 0 : reportCommandProtectionBlock({
13093
13087
  managerName: "OpencodeManager",
@@ -13137,7 +13131,7 @@ var OpencodeManager = class extends CodingAgentManager {
13137
13131
  await this.evaluateOpencodeToolProtection(part.tool, state.input, extractToolCommand(state.input), part.id);
13138
13132
  }
13139
13133
  async evaluateOpencodeToolProtection(toolName, toolInput, command, toolUseId) {
13140
- if (!ENGINE_ENV.REPLICAS_DISABLE_GH_PR_MERGE || this.handledToolCallIds.has(toolUseId) || this.pendingToolCallIds.has(toolUseId)) return;
13134
+ if (this.handledToolCallIds.has(toolUseId) || this.pendingToolCallIds.has(toolUseId)) return;
13141
13135
  this.pendingToolCallIds.add(toolUseId);
13142
13136
  try {
13143
13137
  const result = await evaluateCommandProtection({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.503",
3
+ "version": "0.1.505",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",