replicas-engine 0.1.1601 → 0.1.1604

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.
@@ -8,12 +8,12 @@ import {
8
8
  listCodexModelsForDetails,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-LM3GPSH5.js";
12
- import "./chunk-LAVIBP35.js";
13
- import "./chunk-E5U45B5E.js";
14
- import "./chunk-6DGCGNRD.js";
11
+ } from "./chunk-YSWTDVQS.js";
12
+ import "./chunk-YMTLOKKY.js";
13
+ import "./chunk-CLNFEQTV.js";
14
+ import "./chunk-6D5SMRMT.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
- import "./chunk-Z744SRUU.js";
16
+ import "./chunk-ZKSPRQIP.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
  export {
19
19
  CODEX_ULTRAFAST_SERVICE_TIER,
@@ -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-Z744SRUU.js";
6
+ } from "./chunk-ZKSPRQIP.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -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-6DGCGNRD.js";
6
+ } from "./chunk-6D5SMRMT.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-Z744SRUU.js";
9
+ } from "./chunk-ZKSPRQIP.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.1601";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1604";
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
  AspClient
6
- } from "./chunk-E5U45B5E.js";
6
+ } from "./chunk-CLNFEQTV.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-Z744SRUU.js";
18
+ } from "./chunk-ZKSPRQIP.js";
19
19
 
20
20
  // src/managers/codex-asp/notification-dispatch.ts
21
21
  var TURN_STARTED_METHOD = "turn/started";
@@ -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-LAVIBP35.js";
8
+ } from "./chunk-YMTLOKKY.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-Z744SRUU.js";
21
+ } from "./chunk-ZKSPRQIP.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 });
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-Z744SRUU.js";
8
+ } from "./chunk-ZKSPRQIP.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-6DGCGNRD.js";
7
+ } from "./chunk-6D5SMRMT.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-Z744SRUU.js";
24
+ } from "./chunk-ZKSPRQIP.js";
25
25
 
26
26
  // src/runtime-env-loader.ts
27
27
  import { readFileSync } from "fs";
@@ -12,15 +12,15 @@ import {
12
12
  resolveDiffBase,
13
13
  runGitCommand,
14
14
  setAgentCredentialSnapshot
15
- } from "./chunk-LAVIBP35.js";
15
+ } from "./chunk-YMTLOKKY.js";
16
16
  import {
17
17
  AppServerProcess,
18
18
  buildCodexAgentEnv
19
- } from "./chunk-E5U45B5E.js";
19
+ } from "./chunk-CLNFEQTV.js";
20
20
  import {
21
21
  SUBPROCESS_MAX_BUFFER,
22
22
  execFileAsync
23
- } from "./chunk-6DGCGNRD.js";
23
+ } from "./chunk-6D5SMRMT.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-Z744SRUU.js";
64
+ } from "./chunk-ZKSPRQIP.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-OTRP5WWS.js");
464
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-SREXP5OS.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-OTRP5WWS.js");
486
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-SREXP5OS.js");
487
487
  await restartCodexAspHostIfRunning2();
488
488
  }
489
489
  setAgentCredentialSnapshot("codex", data);