replicas-engine 0.1.1036 → 0.1.1039
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.
- package/dist/src/{asp-host-4JQWKA47.js → asp-host-52YDZURF.js} +11 -5
- package/dist/src/chunk-FAMMUWPY.js +2058 -0
- package/dist/src/{chunk-3OBN7KPB.js → chunk-GSLZMNCV.js} +1 -1
- package/dist/src/{chunk-OPJ5KAGY.js → chunk-N6AGUZF7.js} +80 -34
- package/dist/src/{chunk-AP442WDC.js → chunk-NB5C3CQZ.js} +4 -4
- package/dist/src/{chunk-W6NY5P76.js → chunk-UZQH4AGN.js} +5 -90
- package/dist/src/{chunk-2RHUTB67.js → chunk-WVNMT5CX.js} +86 -1
- package/dist/src/{chunk-KVJYQOUT.js → chunk-X7IXJ47H.js} +1 -1
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +3 -3
- package/dist/src/index.js +532 -1923
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/subagent-mcp.js +1 -1
- package/package.json +1 -1
- package/dist/src/chunk-EDNMHUVD.js +0 -527
|
@@ -10,6 +10,31 @@ function isNonEmptyString(value) {
|
|
|
10
10
|
return typeof value === "string" && value.trim().length > 0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
// ../shared/src/async.ts
|
|
14
|
+
var TIMEOUT = /* @__PURE__ */ Symbol("timeout");
|
|
15
|
+
async function raceWithTimeout(promise, ms) {
|
|
16
|
+
let timer;
|
|
17
|
+
try {
|
|
18
|
+
return await Promise.race([
|
|
19
|
+
promise,
|
|
20
|
+
new Promise((resolve) => {
|
|
21
|
+
timer = setTimeout(() => resolve(TIMEOUT), ms);
|
|
22
|
+
})
|
|
23
|
+
]);
|
|
24
|
+
} finally {
|
|
25
|
+
clearTimeout(timer);
|
|
26
|
+
promise.catch(() => {
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function withTimeout(promise, ms, message2) {
|
|
31
|
+
const result = await raceWithTimeout(promise, ms);
|
|
32
|
+
if (result === TIMEOUT) {
|
|
33
|
+
throw new Error(message2);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
13
38
|
// ../shared/src/result.ts
|
|
14
39
|
function createSuccessResult(data) {
|
|
15
40
|
return { ok: true, data };
|
|
@@ -78,6 +103,14 @@ function getProviderDisplayName(provider2, variant = "short") {
|
|
|
78
103
|
}
|
|
79
104
|
}
|
|
80
105
|
|
|
106
|
+
// ../shared/src/api-casing.ts
|
|
107
|
+
var toCamel = (key) => key.replace(/_([a-z0-9])/g, (_, char) => char.toUpperCase());
|
|
108
|
+
function withCamelCaseKeys(body) {
|
|
109
|
+
if (!isRecord(body)) return body;
|
|
110
|
+
const aliases = Object.entries(body).filter(([key]) => key.includes("_") && !(toCamel(key) in body));
|
|
111
|
+
return aliases.length ? { ...body, ...Object.fromEntries(aliases.map(([key, entry]) => [toCamel(key), entry])) } : body;
|
|
112
|
+
}
|
|
113
|
+
|
|
81
114
|
// ../shared/src/aster.ts
|
|
82
115
|
var ASTER_PROVIDER = "aster";
|
|
83
116
|
var ASTER_BASE_URL = "https://api.asterlab.ai/v1";
|
|
@@ -969,7 +1002,7 @@ var PLANS = {
|
|
|
969
1002
|
"Higher API rate limits",
|
|
970
1003
|
"Mobile app",
|
|
971
1004
|
"Access to a static egress IP",
|
|
972
|
-
"Auto-upgraded
|
|
1005
|
+
"Auto-upgraded to Large workspaces (4 vCPU, 16 GB memory)",
|
|
973
1006
|
"Shared Slack support channel"
|
|
974
1007
|
]
|
|
975
1008
|
},
|
|
@@ -1246,6 +1279,7 @@ var sendChatMessageRequestSchema = z3.object({
|
|
|
1246
1279
|
thinkingLevel: z3.enum(VALID_THINKING_LEVELS).optional(),
|
|
1247
1280
|
goalMode: z3.boolean().optional(),
|
|
1248
1281
|
fastMode: z3.boolean().optional(),
|
|
1282
|
+
ultrafastMode: z3.boolean().optional(),
|
|
1249
1283
|
source: z3.enum(MESSAGE_SOURCES).optional(),
|
|
1250
1284
|
enableInteractiveTools: z3.boolean().optional(),
|
|
1251
1285
|
type: z3.string().min(1).optional(),
|
|
@@ -1462,7 +1496,8 @@ function parseChatHistoryCursor(value) {
|
|
|
1462
1496
|
function createChatHistoryCursor(cursor, mode = "range") {
|
|
1463
1497
|
return cursor.events === null && cursor.turns === null ? null : JSON.stringify({ mode, ...cursor });
|
|
1464
1498
|
}
|
|
1465
|
-
function chatHistoryPageParamsFromQuery(
|
|
1499
|
+
function chatHistoryPageParamsFromQuery(rawQuery) {
|
|
1500
|
+
const query = withCamelCaseKeys(rawQuery);
|
|
1466
1501
|
const parse = (value) => {
|
|
1467
1502
|
if (value === void 0) return void 0;
|
|
1468
1503
|
const parsed = Number.parseInt(value, 10);
|
|
@@ -1472,7 +1507,8 @@ function chatHistoryPageParamsFromQuery(query) {
|
|
|
1472
1507
|
limit: parse(query.limit),
|
|
1473
1508
|
beforeEvent: parse(query.beforeEvent),
|
|
1474
1509
|
beforeTurn: parse(query.beforeTurn),
|
|
1475
|
-
beforeCursor: query.beforeCursor || void 0
|
|
1510
|
+
beforeCursor: query.beforeCursor || void 0,
|
|
1511
|
+
afterCursor: query.afterCursor || void 0
|
|
1476
1512
|
};
|
|
1477
1513
|
}
|
|
1478
1514
|
function getChatHistoryPageWindow(totalItems, limit, before) {
|
|
@@ -1832,31 +1868,6 @@ function safeJsonParse(str, fallback) {
|
|
|
1832
1868
|
}
|
|
1833
1869
|
}
|
|
1834
1870
|
|
|
1835
|
-
// ../shared/src/async.ts
|
|
1836
|
-
var TIMEOUT = /* @__PURE__ */ Symbol("timeout");
|
|
1837
|
-
async function raceWithTimeout(promise, ms) {
|
|
1838
|
-
let timer;
|
|
1839
|
-
try {
|
|
1840
|
-
return await Promise.race([
|
|
1841
|
-
promise,
|
|
1842
|
-
new Promise((resolve) => {
|
|
1843
|
-
timer = setTimeout(() => resolve(TIMEOUT), ms);
|
|
1844
|
-
})
|
|
1845
|
-
]);
|
|
1846
|
-
} finally {
|
|
1847
|
-
clearTimeout(timer);
|
|
1848
|
-
promise.catch(() => {
|
|
1849
|
-
});
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
async function withTimeout(promise, ms, message2) {
|
|
1853
|
-
const result = await raceWithTimeout(promise, ms);
|
|
1854
|
-
if (result === TIMEOUT) {
|
|
1855
|
-
throw new Error(message2);
|
|
1856
|
-
}
|
|
1857
|
-
return result;
|
|
1858
|
-
}
|
|
1859
|
-
|
|
1860
1871
|
// ../shared/src/agent-quota.ts
|
|
1861
1872
|
var OUT_OF_CREDITS_PATTERNS = [
|
|
1862
1873
|
/credit balance is too low/,
|
|
@@ -2860,7 +2871,7 @@ var SANDBOX_PATHS = {
|
|
|
2860
2871
|
REPLICAS_CANVAS_DIR: "/home/user/.replicas/canvas",
|
|
2861
2872
|
REPLICAS_RUNTIME_ENV_FILE: "/home/user/.replicas/runtime-env.sh"
|
|
2862
2873
|
};
|
|
2863
|
-
var WORKSPACE_SIZES = ["small", "large"];
|
|
2874
|
+
var WORKSPACE_SIZES = ["small", "large", "ultra"];
|
|
2864
2875
|
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
2865
2876
|
|
|
2866
2877
|
// ../shared/src/learned-skills.ts
|
|
@@ -3946,7 +3957,7 @@ Create tickets, fetch issues, update state, add comments, and search through \`r
|
|
|
3946
3957
|
|
|
3947
3958
|
Use this when:
|
|
3948
3959
|
- You need to create a Linear ticket or issue
|
|
3949
|
-
- You encounter a
|
|
3960
|
+
- You encounter a linear.app issue link and need to understand the task
|
|
3950
3961
|
- You need to update an issue's state or add a comment
|
|
3951
3962
|
- You need to search Linear issues
|
|
3952
3963
|
- A Linear request failed with an authentication error`;
|
|
@@ -4004,6 +4015,8 @@ const issue = await replicas.linear.graphql({
|
|
|
4004
4015
|
});
|
|
4005
4016
|
\`\`\`
|
|
4006
4017
|
|
|
4018
|
+
For a link such as \`https://linear.app/acme/issue/ENG-123/fix-login\`, the identifier is the path segment after \`/issue/\` (\`ENG-123\`).
|
|
4019
|
+
|
|
4007
4020
|
## Update and comment in one script
|
|
4008
4021
|
|
|
4009
4022
|
\`\`\`ts
|
|
@@ -4040,7 +4053,7 @@ For screenshots, recordings, diagrams, or other media, read \`references/MEDIA.m
|
|
|
4040
4053
|
var LINEAR_ABILITY = {
|
|
4041
4054
|
label: "Linear",
|
|
4042
4055
|
description: "Create tickets, fetch issues, comment, and update state through @replicas/sdk.",
|
|
4043
|
-
bullet: "- Interacting with Linear (creating tickets, fetching issues, updating state, commenting, or troubleshooting authentication): use replicas.linear.graphql from @replicas/sdk, which refreshes tokens automatically and needs no Linear MCP server. Read references/LINEAR.md before treating a rejected workspace token as a disconnected integration.",
|
|
4056
|
+
bullet: "- Interacting with Linear (creating tickets, fetching issues including any linear.app link the user shares, updating state, commenting, or troubleshooting authentication): use replicas.linear.graphql from @replicas/sdk, which refreshes tokens automatically and needs no Linear MCP server. Read references/LINEAR.md before treating a rejected workspace token as a disconnected integration.",
|
|
4044
4057
|
section: SECTION6,
|
|
4045
4058
|
referenceFile: { name: "LINEAR.md", content: REFERENCE6 }
|
|
4046
4059
|
};
|
|
@@ -4964,6 +4977,7 @@ Read issues and project data through the workspace-scoped TypeScript SDK.
|
|
|
4964
4977
|
**Reference:** \`references/SENTRY.md\`
|
|
4965
4978
|
|
|
4966
4979
|
Use this when:
|
|
4980
|
+
- A user shares a sentry.io link
|
|
4967
4981
|
- You need to inspect Sentry projects or issues
|
|
4968
4982
|
- A user asks for error-monitoring context outside a webhook-triggered task`;
|
|
4969
4983
|
var REFERENCE11 = `# Sentry Integration
|
|
@@ -4978,12 +4992,23 @@ import { replicas } from '@replicas/sdk';
|
|
|
4978
4992
|
const issues = await replicas.sentry.request('/organizations/acme/issues/?query=is:unresolved');
|
|
4979
4993
|
\`\`\`
|
|
4980
4994
|
|
|
4995
|
+
## Read a pasted issue link
|
|
4996
|
+
|
|
4997
|
+
Map the link to API paths instead of fetching the page. For \`https://acme.sentry.io/issues/4512345678/?project=123\` or \`https://sentry.io/organizations/acme/issues/4512345678/\`, the organization slug is \`acme\` and the issue ID is \`4512345678\`:
|
|
4998
|
+
|
|
4999
|
+
\`\`\`ts
|
|
5000
|
+
const issue = await replicas.sentry.request('/organizations/acme/issues/4512345678/');
|
|
5001
|
+
const latest = await replicas.sentry.request('/organizations/acme/issues/4512345678/events/latest/');
|
|
5002
|
+
\`\`\`
|
|
5003
|
+
|
|
5004
|
+
A link ending in \`/events/<eventId>/\` names a specific event: \`/organizations/acme/issues/4512345678/events/<eventId>/\`. Resolve a short ID such as \`BACKEND-1A2\` with \`/organizations/acme/shortids/BACKEND-1A2/\`. The event's \`entries\` hold the stack trace and breadcrumbs.
|
|
5005
|
+
|
|
4981
5006
|
Pass only a relative Sentry API path. The Replicas gateway selects the connected organization credential and rejects writes, absolute URLs, oversized responses, and long-running requests.
|
|
4982
5007
|
`;
|
|
4983
5008
|
var SENTRY_ABILITY = {
|
|
4984
5009
|
label: "Sentry",
|
|
4985
5010
|
description: "Read Sentry projects and issues through @replicas/sdk.",
|
|
4986
|
-
bullet: "- Interacting with Sentry (reading projects, issues, and error context)",
|
|
5011
|
+
bullet: "- Interacting with Sentry (reading projects, issues, and error context, including any sentry.io link the user shares): use replicas.sentry.request from @replicas/sdk. Read references/SENTRY.md to turn an issue link into API paths.",
|
|
4987
5012
|
section: SECTION11,
|
|
4988
5013
|
referenceFile: { name: "SENTRY.md", content: REFERENCE11 }
|
|
4989
5014
|
};
|
|
@@ -5234,8 +5259,8 @@ var automationUpdateToolInputSchema = automationToolInputSchema.partial().extend
|
|
|
5234
5259
|
var chatPath = { id: z15.string().describe("Workspace ID"), chat_id: z15.string().describe("Chat ID") };
|
|
5235
5260
|
var { provider, model, thinkingLevel, title, message } = forkChatRequestSchema.shape;
|
|
5236
5261
|
var createChatToolInputSchema = z15.object({ id: chatPath.id, provider, title: createChatRequestSchema.shape.title });
|
|
5237
|
-
var forkChatToolInputSchema = z15.object({ ...chatPath, provider, model, thinkingLevel, title, message });
|
|
5238
|
-
var renameChatToolInputSchema = z15.object({ ...chatPath,
|
|
5262
|
+
var forkChatToolInputSchema = z15.object({ ...chatPath, provider, model, thinking_level: thinkingLevel, title, message });
|
|
5263
|
+
var renameChatToolInputSchema = z15.object({ ...chatPath, display_name: updateChatDisplayNameRequestSchema.shape.displayName });
|
|
5239
5264
|
var runCommandToolInputSchema = z15.object({ id: chatPath.id, ...workspaceExecRequestSchema.shape });
|
|
5240
5265
|
var environmentMcpPath = { environment_id: z15.string().describe("Environment ID") };
|
|
5241
5266
|
var createEnvironmentMcpToolInputSchema = z15.object({ ...environmentMcpPath, ...createEnvironmentMcpRequestSchema.shape });
|
|
@@ -9527,6 +9552,26 @@ async function readJsonlPage(args) {
|
|
|
9527
9552
|
before: before > 0 ? String(before) : null
|
|
9528
9553
|
};
|
|
9529
9554
|
}
|
|
9555
|
+
var MAX_APPENDED_BYTES = 4 * 1024 * 1024;
|
|
9556
|
+
async function readJsonlAppended(args) {
|
|
9557
|
+
const start = /^(0|[1-9]\d*)$/.test(args.after) ? Number(args.after) : Number.NaN;
|
|
9558
|
+
if (!Number.isSafeInteger(start) || start > args.size || args.size - start > MAX_APPENDED_BYTES) return null;
|
|
9559
|
+
if (start === args.size) return { items: [], after: args.after };
|
|
9560
|
+
const from = Math.max(0, start - 1);
|
|
9561
|
+
const bytes = await readExactRange(args.readRange, from, args.size, "Incomplete JSONL append read");
|
|
9562
|
+
if (start > 0 && bytes[0] !== 10) return null;
|
|
9563
|
+
const items = [];
|
|
9564
|
+
let lineStart = start - from;
|
|
9565
|
+
for (let lineEnd = bytes.indexOf(10, lineStart); lineEnd !== -1; lineEnd = bytes.indexOf(10, lineStart)) {
|
|
9566
|
+
try {
|
|
9567
|
+
const item = args.parse(JSON.parse(decoder.decode(bytes.subarray(lineStart, lineEnd))));
|
|
9568
|
+
if (item !== void 0) items.push(item);
|
|
9569
|
+
} catch {
|
|
9570
|
+
}
|
|
9571
|
+
lineStart = lineEnd + 1;
|
|
9572
|
+
}
|
|
9573
|
+
return { items, after: String(from + lineStart) };
|
|
9574
|
+
}
|
|
9530
9575
|
function parseChatTranscriptHistoryIndex(value) {
|
|
9531
9576
|
if (!isRecord(value) || value.version !== 2 || !isNonNegativeInteger(value.sourceSize)) return void 0;
|
|
9532
9577
|
const removedMessageIds = Array.isArray(value.removedMessageIds) ? value.removedMessageIds.filter((id) => typeof id === "string") : [];
|
|
@@ -9894,6 +9939,7 @@ export {
|
|
|
9894
9939
|
searchRepoFileIndex,
|
|
9895
9940
|
isExcludedRepoFilePath,
|
|
9896
9941
|
readJsonlPage,
|
|
9942
|
+
readJsonlAppended,
|
|
9897
9943
|
normalizeChatTranscriptMetadata,
|
|
9898
9944
|
parseChatTranscriptArtifact,
|
|
9899
9945
|
readSseStream,
|
|
@@ -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-
|
|
6
|
+
} from "./chunk-X7IXJ47H.js";
|
|
7
7
|
import {
|
|
8
8
|
isVersionBelow
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-N6AGUZF7.js";
|
|
10
10
|
|
|
11
11
|
// src/utils/codex-agent-env.ts
|
|
12
12
|
function buildCodexAgentEnv(source = process.env) {
|
|
@@ -233,14 +233,14 @@ var DEFAULT_CODEX_ARGS = [
|
|
|
233
233
|
"-c",
|
|
234
234
|
"memories.generate_memories=false"
|
|
235
235
|
];
|
|
236
|
-
var MIN_CODEX_CLI_VERSION = "0.
|
|
236
|
+
var MIN_CODEX_CLI_VERSION = "0.162.1";
|
|
237
237
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
238
238
|
var codexCliVersionEnsured = null;
|
|
239
239
|
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.
|
|
243
|
+
var ENGINE_PACKAGE_VERSION = "0.1.1039";
|
|
244
244
|
var INITIALIZE_METHOD = "initialize";
|
|
245
245
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
246
246
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
execFileAsync
|
|
10
|
-
} from "./chunk-KVJYQOUT.js";
|
|
5
|
+
getOriginDefaultBranch,
|
|
6
|
+
monolithRequest,
|
|
7
|
+
runGitCommand
|
|
8
|
+
} from "./chunk-WVNMT5CX.js";
|
|
11
9
|
import {
|
|
12
10
|
extractCommandProtectionCommandText,
|
|
13
11
|
findCommandProtectionGitLookups,
|
|
14
12
|
findGitCommitSignals,
|
|
15
13
|
findPrMergeSignals,
|
|
16
14
|
parseCommandProtectionRequest
|
|
17
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-N6AGUZF7.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-X7IXJ47H.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-
|
|
21
|
+
} from "./chunk-N6AGUZF7.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,
|
|
@@ -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-
|
|
6
|
+
} from "./chunk-N6AGUZF7.js";
|
|
7
7
|
|
|
8
8
|
// src/utils/exec.ts
|
|
9
9
|
import { exec, execFile } from "child_process";
|
|
@@ -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-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-UZQH4AGN.js";
|
|
7
|
+
import "./chunk-WVNMT5CX.js";
|
|
8
|
+
import "./chunk-X7IXJ47H.js";
|
|
9
9
|
import {
|
|
10
10
|
isRecord
|
|
11
11
|
} from "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-N6AGUZF7.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/command-protection-hook.ts
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
AppServerProcess,
|
|
9
9
|
buildCodexAgentEnv
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-NB5C3CQZ.js";
|
|
11
|
+
import "./chunk-X7IXJ47H.js";
|
|
12
12
|
import {
|
|
13
13
|
AGENT,
|
|
14
14
|
headlessAgentRequestSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-N6AGUZF7.js";
|
|
16
16
|
import "./chunk-VEQXQN22.js";
|
|
17
17
|
|
|
18
18
|
// src/headless-agent.ts
|