replicas-engine 0.1.1036 → 0.1.1038

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.
@@ -2,18 +2,24 @@
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
+ CODEX_ULTRAFAST_SERVICE_TIER,
5
6
  getCodexAspHost,
7
+ listCodexModels,
8
+ listRunningCodexModels,
6
9
  restartCodexAspHost,
7
10
  restartCodexAspHostIfRunning
8
- } from "./chunk-EDNMHUVD.js";
9
- import "./chunk-2RHUTB67.js";
10
- import "./chunk-AP442WDC.js";
11
- import "./chunk-KVJYQOUT.js";
11
+ } from "./chunk-7HOZZI3W.js";
12
+ import "./chunk-5TYR5GFS.js";
13
+ import "./chunk-SHHV4JCC.js";
14
+ import "./chunk-XOSNMSSU.js";
12
15
  import "./chunk-UZSNFLDQ.js";
13
- import "./chunk-OPJ5KAGY.js";
16
+ import "./chunk-MALHGZWB.js";
14
17
  import "./chunk-VEQXQN22.js";
15
18
  export {
19
+ CODEX_ULTRAFAST_SERVICE_TIER,
16
20
  getCodexAspHost,
21
+ listCodexModels,
22
+ listRunningCodexModels,
17
23
  restartCodexAspHost,
18
24
  restartCodexAspHostIfRunning
19
25
  };
@@ -2,100 +2,20 @@
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
- monolithRequest
6
- } from "./chunk-2RHUTB67.js";
7
- import {
8
- SUBPROCESS_MAX_BUFFER,
9
- execFileAsync
10
- } from "./chunk-KVJYQOUT.js";
5
+ getOriginDefaultBranch,
6
+ monolithRequest,
7
+ runGitCommand
8
+ } from "./chunk-5TYR5GFS.js";
11
9
  import {
12
10
  extractCommandProtectionCommandText,
13
11
  findCommandProtectionGitLookups,
14
12
  findGitCommitSignals,
15
13
  findPrMergeSignals,
16
14
  parseCommandProtectionRequest
17
- } from "./chunk-OPJ5KAGY.js";
15
+ } from "./chunk-MALHGZWB.js";
18
16
 
19
17
  // src/services/command-protection-service.ts
20
18
  import { readFile, stat } from "fs/promises";
21
-
22
- // src/git/commands.ts
23
- import { readdirSync, readFileSync, statSync } from "fs";
24
- import { join, resolve } from "path";
25
- async function runGitCommand(args, cwd, options = {}) {
26
- const { stdout } = await execFileAsync("git", args, {
27
- cwd,
28
- encoding: "utf-8",
29
- maxBuffer: options.maxBuffer ?? SUBPROCESS_MAX_BUFFER
30
- });
31
- return stdout.trim();
32
- }
33
- function readRepoHeadBranches(repoPath) {
34
- const branches = /* @__PURE__ */ new Set();
35
- try {
36
- let gitDir = join(repoPath, ".git");
37
- if (statSync(gitDir).isFile()) {
38
- const target = readFileSync(gitDir, "utf8").trim().match(/^gitdir: (.+)$/)?.[1];
39
- if (!target) return branches;
40
- gitDir = resolve(repoPath, target);
41
- }
42
- let commonDir = gitDir;
43
- try {
44
- commonDir = resolve(gitDir, readFileSync(join(gitDir, "commondir"), "utf8").trim());
45
- } catch {
46
- }
47
- const headDirs = /* @__PURE__ */ new Set([gitDir, commonDir]);
48
- try {
49
- for (const entry of readdirSync(join(commonDir, "worktrees"))) {
50
- headDirs.add(join(commonDir, "worktrees", entry));
51
- }
52
- } catch {
53
- }
54
- for (const dir of headDirs) {
55
- try {
56
- const branch = readFileSync(join(dir, "HEAD"), "utf8").trim().match(/^ref:\s+refs\/heads\/(.+)$/)?.[1];
57
- if (branch) branches.add(branch);
58
- } catch {
59
- }
60
- }
61
- } catch {
62
- }
63
- return branches;
64
- }
65
- async function branchExists(branchName, cwd) {
66
- try {
67
- await runGitCommand(["rev-parse", "--verify", branchName], cwd);
68
- return true;
69
- } catch {
70
- return false;
71
- }
72
- }
73
- async function getOriginDefaultBranch(repoPath) {
74
- try {
75
- const output = await runGitCommand(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], repoPath);
76
- return output.match(/^origin\/(.+)$/)?.[1] ?? null;
77
- } catch {
78
- return null;
79
- }
80
- }
81
- async function getCurrentBranch(cwd) {
82
- try {
83
- return await runGitCommand(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
84
- } catch (error) {
85
- console.error("Error getting current branch:", error);
86
- return null;
87
- }
88
- }
89
- async function resolveDiffBase(repoPath, defaultBranch) {
90
- const baseBranch = `origin/${defaultBranch}`;
91
- try {
92
- return await runGitCommand(["merge-base", baseBranch, "HEAD"], repoPath);
93
- } catch {
94
- }
95
- return await branchExists(baseBranch, repoPath) ? baseBranch : "HEAD";
96
- }
97
-
98
- // src/services/command-protection-service.ts
99
19
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
100
20
  var MAX_COMMIT_MESSAGE_FILE_BYTES = 64 * 1024;
101
21
  async function resolveGitContext({ repoDirs, messageFiles }) {
@@ -180,11 +100,6 @@ function reportCommandProtectionBlock(options) {
180
100
  }
181
101
 
182
102
  export {
183
- runGitCommand,
184
- readRepoHeadBranches,
185
- getOriginDefaultBranch,
186
- getCurrentBranch,
187
- resolveDiffBase,
188
103
  evaluateCommandProtection,
189
104
  extractToolCommand,
190
105
  reportCommandProtectionBlock
@@ -1,6 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
+ import {
5
+ SUBPROCESS_MAX_BUFFER,
6
+ execFileAsync
7
+ } from "./chunk-XOSNMSSU.js";
4
8
  import {
5
9
  isRecord as isRecord2
6
10
  } from "./chunk-UZSNFLDQ.js";
@@ -14,7 +18,7 @@ import {
14
18
  isValidAgentProvider,
15
19
  parsePosixEnvFile,
16
20
  readReplicasRuntimeEnv
17
- } from "./chunk-OPJ5KAGY.js";
21
+ } from "./chunk-MALHGZWB.js";
18
22
 
19
23
  // src/runtime-env-loader.ts
20
24
  import { readFileSync } from "fs";
@@ -176,6 +180,82 @@ function setAgentCredentialSnapshot(provider, { type, scope, revision, account,
176
180
  process.env.REPLICAS_AGENT_CREDENTIALS = JSON.stringify(ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS);
177
181
  }
178
182
 
183
+ // src/git/commands.ts
184
+ import { readdirSync, readFileSync as readFileSync3, statSync } from "fs";
185
+ import { join as join3, resolve } from "path";
186
+ async function runGitCommand(args, cwd, options = {}) {
187
+ const { stdout } = await execFileAsync("git", args, {
188
+ cwd,
189
+ encoding: "utf-8",
190
+ maxBuffer: options.maxBuffer ?? SUBPROCESS_MAX_BUFFER
191
+ });
192
+ return stdout.trim();
193
+ }
194
+ function readRepoHeadBranches(repoPath) {
195
+ const branches = /* @__PURE__ */ new Set();
196
+ try {
197
+ let gitDir = join3(repoPath, ".git");
198
+ if (statSync(gitDir).isFile()) {
199
+ const target = readFileSync3(gitDir, "utf8").trim().match(/^gitdir: (.+)$/)?.[1];
200
+ if (!target) return branches;
201
+ gitDir = resolve(repoPath, target);
202
+ }
203
+ let commonDir = gitDir;
204
+ try {
205
+ commonDir = resolve(gitDir, readFileSync3(join3(gitDir, "commondir"), "utf8").trim());
206
+ } catch {
207
+ }
208
+ const headDirs = /* @__PURE__ */ new Set([gitDir, commonDir]);
209
+ try {
210
+ for (const entry of readdirSync(join3(commonDir, "worktrees"))) {
211
+ headDirs.add(join3(commonDir, "worktrees", entry));
212
+ }
213
+ } catch {
214
+ }
215
+ for (const dir of headDirs) {
216
+ try {
217
+ const branch = readFileSync3(join3(dir, "HEAD"), "utf8").trim().match(/^ref:\s+refs\/heads\/(.+)$/)?.[1];
218
+ if (branch) branches.add(branch);
219
+ } catch {
220
+ }
221
+ }
222
+ } catch {
223
+ }
224
+ return branches;
225
+ }
226
+ async function branchExists(branchName, cwd) {
227
+ try {
228
+ await runGitCommand(["rev-parse", "--verify", branchName], cwd);
229
+ return true;
230
+ } catch {
231
+ return false;
232
+ }
233
+ }
234
+ async function getOriginDefaultBranch(repoPath) {
235
+ try {
236
+ const output = await runGitCommand(["symbolic-ref", "--short", "refs/remotes/origin/HEAD"], repoPath);
237
+ return output.match(/^origin\/(.+)$/)?.[1] ?? null;
238
+ } catch {
239
+ return null;
240
+ }
241
+ }
242
+ async function getCurrentBranch(cwd) {
243
+ try {
244
+ return await runGitCommand(["rev-parse", "--abbrev-ref", "HEAD"], cwd);
245
+ } catch (error) {
246
+ console.error("Error getting current branch:", error);
247
+ return null;
248
+ }
249
+ }
250
+ async function resolveDiffBase(repoPath, defaultBranch) {
251
+ const baseBranch = `origin/${defaultBranch}`;
252
+ try {
253
+ return await runGitCommand(["merge-base", baseBranch, "HEAD"], repoPath);
254
+ } catch {
255
+ }
256
+ return await branchExists(baseBranch, repoPath) ? baseBranch : "HEAD";
257
+ }
258
+
179
259
  // src/services/monolith-service.ts
180
260
  async function monolithRequest(path, init = {}) {
181
261
  if (!ENGINE_ENV.REPLICAS_WORKSPACE_ID) {
@@ -251,6 +331,11 @@ var MonolithService = class {
251
331
  var monolithService = new MonolithService();
252
332
 
253
333
  export {
334
+ runGitCommand,
335
+ readRepoHeadBranches,
336
+ getOriginDefaultBranch,
337
+ getCurrentBranch,
338
+ resolveDiffBase,
254
339
  readRuntimeEnvFile,
255
340
  ENGINE_ENV,
256
341
  reloadEngineEnv,