replicas-engine 0.1.889 → 0.1.891
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-7TTLBO5M.js → asp-host-RKLHLTPR.js} +4 -4
- package/dist/src/{chunk-WMRZEQIH.js → chunk-4NFLZXZX.js} +2 -2
- package/dist/src/{chunk-RG6ZP2EU.js → chunk-DG4VIQXA.js} +1 -1
- package/dist/src/{chunk-F33TXACU.js → chunk-EDLDRUYW.js} +2 -2
- package/dist/src/{chunk-ISNWC7OA.js → chunk-IB2SHITZ.js} +9 -4
- package/dist/src/{chunk-45I2CJU6.js → chunk-OBAGPETY.js} +56 -0
- package/dist/src/{chunk-N7JSMN3R.js → chunk-TDLEF5FU.js} +5 -5
- package/dist/src/chunk-U2T2QCYP.js +54 -0
- package/dist/src/command-protection-hook.js +3 -3
- package/dist/src/deepseek-command-protection-plugin.js +5 -4
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +283 -201
- package/dist/src/post-tool-pr-hook.js +4 -3
- package/dist/src/relay-mcp.js +1 -1
- package/package.json +1 -1
- package/scripts/opencode-command-protection-plugin.ts +10 -9
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
getCodexAspHost,
|
|
6
6
|
restartCodexAspHost,
|
|
7
7
|
restartCodexAspHostIfRunning
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-TDLEF5FU.js";
|
|
9
|
+
import "./chunk-DG4VIQXA.js";
|
|
10
|
+
import "./chunk-EDLDRUYW.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-OBAGPETY.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
export {
|
|
15
15
|
getCodexAspHost,
|
|
@@ -3,12 +3,12 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
monolithRequest
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DG4VIQXA.js";
|
|
7
7
|
import {
|
|
8
8
|
extractCommandProtectionCommandText,
|
|
9
9
|
findGitCommitSignals,
|
|
10
10
|
findPrMergeSignals
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-OBAGPETY.js";
|
|
12
12
|
|
|
13
13
|
// src/services/command-protection-service.ts
|
|
14
14
|
var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
|
|
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
HOOK_EXEC_MAX_BUFFER_BYTES,
|
|
6
6
|
isVersionBelow
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-OBAGPETY.js";
|
|
8
8
|
|
|
9
9
|
// src/utils/codex-agent-env.ts
|
|
10
10
|
function buildCodexAgentEnv(source = process.env) {
|
|
@@ -245,7 +245,7 @@ function getCodexModelProvider(method) {
|
|
|
245
245
|
if (method === "foundry") return "azure";
|
|
246
246
|
return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
|
|
247
247
|
}
|
|
248
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
248
|
+
var ENGINE_PACKAGE_VERSION = "0.1.891";
|
|
249
249
|
var INITIALIZE_METHOD = "initialize";
|
|
250
250
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
251
251
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -1,19 +1,24 @@
|
|
|
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
|
+
publishedPullRequestUrls
|
|
6
|
+
} from "./chunk-U2T2QCYP.js";
|
|
4
7
|
import {
|
|
5
8
|
shouldRefreshPullRequests
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OBAGPETY.js";
|
|
7
10
|
|
|
8
11
|
// src/services/post-tool-pr-notifier.ts
|
|
9
|
-
async function notifyPostToolUse(toolName, toolInput) {
|
|
10
|
-
|
|
12
|
+
async function notifyPostToolUse(toolName, toolInput, result) {
|
|
13
|
+
const publication = result ? { toolName, toolInput, ...result } : void 0;
|
|
14
|
+
if (!shouldRefreshPullRequests(toolName, toolInput) && (!publication || publishedPullRequestUrls(publication).length === 0)) return false;
|
|
11
15
|
const port = process.env.REPLICAS_ENGINE_PORT;
|
|
12
16
|
const secret = process.env.REPLICAS_ENGINE_SECRET;
|
|
13
17
|
if (!port || !secret) throw new Error("Replicas engine connection is unavailable.");
|
|
14
18
|
const response = await fetch(`http://127.0.0.1:${port}/pull-requests/check`, {
|
|
15
19
|
method: "POST",
|
|
16
|
-
headers: { "X-Replicas-Engine-Secret": secret },
|
|
20
|
+
headers: { "X-Replicas-Engine-Secret": secret, ...publication ? { "Content-Type": "application/json" } : {} },
|
|
21
|
+
...publication ? { body: JSON.stringify(publication) } : {},
|
|
17
22
|
signal: AbortSignal.timeout(3e4)
|
|
18
23
|
});
|
|
19
24
|
if (!response.ok) throw new Error(`Replicas pull request check failed (${response.status}).`);
|
|
@@ -2341,6 +2341,53 @@ var LEGACY_WEB_APP_PATHS = {
|
|
|
2341
2341
|
home: "/home",
|
|
2342
2342
|
dashboardWorkspaces: `${DASHBOARD_PATH}/workspaces`
|
|
2343
2343
|
};
|
|
2344
|
+
var PR_URL_REGEX = /github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/;
|
|
2345
|
+
function parsePrUrl(url) {
|
|
2346
|
+
const match = url.match(PR_URL_REGEX);
|
|
2347
|
+
if (!match) return null;
|
|
2348
|
+
const [, owner, repo, numberStr] = match;
|
|
2349
|
+
const number = Number.parseInt(numberStr, 10);
|
|
2350
|
+
if (!Number.isFinite(number)) return null;
|
|
2351
|
+
return { owner, repo, number };
|
|
2352
|
+
}
|
|
2353
|
+
function parseCodeHostPrUrl(url) {
|
|
2354
|
+
const github = parsePrUrl(url);
|
|
2355
|
+
if (github) {
|
|
2356
|
+
return {
|
|
2357
|
+
...github,
|
|
2358
|
+
provider: "github",
|
|
2359
|
+
host: "github.com",
|
|
2360
|
+
repositoryPath: `${github.owner}/${github.repo}`,
|
|
2361
|
+
repoUrl: `https://github.com/${github.owner}/${github.repo}`
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2364
|
+
let parsed;
|
|
2365
|
+
try {
|
|
2366
|
+
parsed = new URL(url);
|
|
2367
|
+
} catch {
|
|
2368
|
+
return null;
|
|
2369
|
+
}
|
|
2370
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
|
|
2371
|
+
const segments = parsed.pathname.split("/").filter(Boolean);
|
|
2372
|
+
const separatorIndex = segments.indexOf("-");
|
|
2373
|
+
if (separatorIndex <= 0 || segments[separatorIndex + 1] !== "merge_requests") return null;
|
|
2374
|
+
const number = Number.parseInt(segments[separatorIndex + 2] ?? "", 10);
|
|
2375
|
+
if (!Number.isFinite(number)) return null;
|
|
2376
|
+
const repositorySegments = decodePathSegments(segments.slice(0, separatorIndex));
|
|
2377
|
+
const repo = repositorySegments[repositorySegments.length - 1];
|
|
2378
|
+
const owner = repositorySegments[0];
|
|
2379
|
+
if (!owner || !repo) return null;
|
|
2380
|
+
const repositoryPath = repositorySegments.join("/");
|
|
2381
|
+
return {
|
|
2382
|
+
provider: "gitlab",
|
|
2383
|
+
host: parsed.host.toLowerCase(),
|
|
2384
|
+
owner,
|
|
2385
|
+
repo,
|
|
2386
|
+
number,
|
|
2387
|
+
repositoryPath,
|
|
2388
|
+
repoUrl: `${parsed.origin}/${repositoryPath}`
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2344
2391
|
function decodePathSegments(segments) {
|
|
2345
2392
|
return segments.map((segment) => {
|
|
2346
2393
|
try {
|
|
@@ -2350,6 +2397,13 @@ function decodePathSegments(segments) {
|
|
|
2350
2397
|
}
|
|
2351
2398
|
});
|
|
2352
2399
|
}
|
|
2400
|
+
function buildCodeHostPrUrl(repoUrl, provider, prNumber) {
|
|
2401
|
+
const normalizedRepoUrl = repoUrl.replace(/\.git$/, "");
|
|
2402
|
+
if (provider === "gitlab") {
|
|
2403
|
+
return `${normalizedRepoUrl}/-/merge_requests/${prNumber}`;
|
|
2404
|
+
}
|
|
2405
|
+
return `${normalizedRepoUrl}/pull/${prNumber}`;
|
|
2406
|
+
}
|
|
2353
2407
|
|
|
2354
2408
|
// ../shared/src/default-skills/replicas-agent/abilities/computer.ts
|
|
2355
2409
|
var SECTION = `### Computer use (Linux desktop control)
|
|
@@ -8263,7 +8317,9 @@ export {
|
|
|
8263
8317
|
paginateChatHistory,
|
|
8264
8318
|
coerceBackgroundTaskPayload,
|
|
8265
8319
|
isGitHubUrl,
|
|
8320
|
+
parseCodeHostPrUrl,
|
|
8266
8321
|
decodePathSegments,
|
|
8322
|
+
buildCodeHostPrUrl,
|
|
8267
8323
|
SANDBOX_PATHS,
|
|
8268
8324
|
MEMORY_ROOT,
|
|
8269
8325
|
MEMORY_INDEX_FILENAME,
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
ENGINE_ENV,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
setAgentCredentialSnapshot
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-DG4VIQXA.js";
|
|
9
9
|
import {
|
|
10
10
|
AppServerProcess,
|
|
11
11
|
SUBPROCESS_MAX_BUFFER,
|
|
12
12
|
buildCodexAgentEnv,
|
|
13
13
|
execFileAsync
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-EDLDRUYW.js";
|
|
15
15
|
import {
|
|
16
16
|
isRecord
|
|
17
17
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
listOpenAICompatibleModels,
|
|
26
26
|
readOllamaAuthEnv,
|
|
27
27
|
resolveOpenAICompatibleModelsUrl
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-OBAGPETY.js";
|
|
29
29
|
|
|
30
30
|
// src/managers/codex-token-manager.ts
|
|
31
31
|
import { promises as fs } from "fs";
|
|
@@ -255,7 +255,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
255
255
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
256
256
|
await this.applyCredentialsResponse(data);
|
|
257
257
|
if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope, revision: data.revision });
|
|
258
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
258
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-RKLHLTPR.js");
|
|
259
259
|
await restartCodexAspHostIfRunning2();
|
|
260
260
|
});
|
|
261
261
|
await this.start(true);
|
|
@@ -275,7 +275,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
275
275
|
await this.applyCredentialUpdate(generation, async () => {
|
|
276
276
|
await this.applyCredentialsResponse(data);
|
|
277
277
|
if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
|
|
278
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
278
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-RKLHLTPR.js");
|
|
279
279
|
await restartCodexAspHostIfRunning2();
|
|
280
280
|
}
|
|
281
281
|
if (data.scope) {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
3
|
+
const require = __createRequire(import.meta.url);
|
|
4
|
+
import {
|
|
5
|
+
extractCommandProtectionCommandText,
|
|
6
|
+
isRecord,
|
|
7
|
+
parseCodeHostPrUrl
|
|
8
|
+
} from "./chunk-OBAGPETY.js";
|
|
9
|
+
|
|
10
|
+
// src/services/published-pull-request-urls.ts
|
|
11
|
+
function publishedPullRequestUrls(result) {
|
|
12
|
+
if (!result.success) return [];
|
|
13
|
+
const name = result.toolName.toLowerCase();
|
|
14
|
+
const publicationTool = /(?:^|[_-])(?:create[_-]?(?:pr|pull[_-]?request|mr|merge[_-]?request)|(?:pr|pull[_-]?request|mr|merge[_-]?request)[_-]?create)$/.test(name);
|
|
15
|
+
const command = extractCommandProtectionCommandText({ toolInput: result.toolInput }) ?? "";
|
|
16
|
+
const shell = command.replace(/\\\r?\n/g, " ").replace(/'[^']*'|"(?:\\.|[^"\\])*"|`[^`]*`|#[^\n]*/g, "ARG");
|
|
17
|
+
const commands = shell.split(/&&|[;\n]/).map((part) => part.trim()).filter(Boolean);
|
|
18
|
+
const isPublicationCommand = (part) => {
|
|
19
|
+
if (/^(?:[\w]+=[^\s;&|]+\s+)*(?:\S*\/)?(?:gh(?:\s+(?:-R|--repo)\s+\S+)?\s+pr\s+create|glab(?:\s+(?:-R|--repo)\s+\S+)?\s+mr\s+create|git(?:\s+-C\s+\S+)?\s+push)\b/.test(part)) return true;
|
|
20
|
+
return /^(?:gh\s+api|glab\s+api|curl)\s/.test(part) && /(?:^|\s)(?:-X\s*|--(?:method|request)[=\s]+)POST\b/i.test(part) && /\/(?:pulls|merge_requests)(?:\s|$)/.test(part);
|
|
21
|
+
};
|
|
22
|
+
const publicationCommand = !shell.includes("<<") && !/[|&(){}\\]/.test(commands.join(" ")) && commands.some(isPublicationCommand) && commands.every((part) => isPublicationCommand(part) || /^(?:cd|rm)\s/.test(part) || /^git(?:\s+-C\s+\S+)?\s+worktree\s+(?:add|remove)\b/.test(part));
|
|
23
|
+
if (!publicationTool && !publicationCommand) return [];
|
|
24
|
+
const urls = /* @__PURE__ */ new Set();
|
|
25
|
+
const visit = (value, depth = 0) => {
|
|
26
|
+
if (depth > 8) return;
|
|
27
|
+
if (typeof value === "string") {
|
|
28
|
+
const text = value.trim();
|
|
29
|
+
try {
|
|
30
|
+
const parsed = JSON.parse(text);
|
|
31
|
+
if (parsed !== value) visit(parsed, depth + 1);
|
|
32
|
+
return;
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
for (const line of text.split("\n")) {
|
|
36
|
+
const candidate = line.trim().replace(/^remote:\s*/, "");
|
|
37
|
+
if (!/^https?:\/\/[^\s<>"']+\/(?:pull|merge_requests)\/\d+\/?(?:[?#][^\s<>"']*)?$/.test(candidate)) continue;
|
|
38
|
+
if (parseCodeHostPrUrl(candidate)) urls.add(candidate);
|
|
39
|
+
}
|
|
40
|
+
} else if (Array.isArray(value)) {
|
|
41
|
+
for (const item of value) visit(item, depth + 1);
|
|
42
|
+
} else if (isRecord(value) && value.isError !== true) {
|
|
43
|
+
for (const key of ["url", "html_url", "web_url", "content", "structuredContent", "text", "output", "result", "stdout", "stderr"]) {
|
|
44
|
+
if (key in value) visit(value[key], depth + 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
visit(result.output);
|
|
49
|
+
return [...urls];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
publishedPullRequestUrls
|
|
54
|
+
};
|
|
@@ -3,12 +3,12 @@ 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-
|
|
6
|
+
} from "./chunk-4NFLZXZX.js";
|
|
7
|
+
import "./chunk-DG4VIQXA.js";
|
|
8
8
|
import {
|
|
9
9
|
isRecord
|
|
10
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-OBAGPETY.js";
|
|
12
12
|
import "./chunk-VEQXQN22.js";
|
|
13
13
|
|
|
14
14
|
// src/command-protection-hook.ts
|
|
@@ -3,13 +3,14 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
evaluateCommandProtection
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4NFLZXZX.js";
|
|
7
7
|
import {
|
|
8
8
|
notifyPostToolUse
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-IB2SHITZ.js";
|
|
10
|
+
import "./chunk-U2T2QCYP.js";
|
|
11
|
+
import "./chunk-DG4VIQXA.js";
|
|
11
12
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-OBAGPETY.js";
|
|
13
14
|
import "./chunk-VEQXQN22.js";
|
|
14
15
|
|
|
15
16
|
// src/deepseek-command-protection-plugin.ts
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
AppServerProcess,
|
|
10
10
|
buildCodexAgentEnv
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-EDLDRUYW.js";
|
|
12
12
|
import {
|
|
13
13
|
AGENT,
|
|
14
14
|
getMemoryOutputSafetyViolation,
|
|
15
15
|
headlessAgentRequestSchema
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-OBAGPETY.js";
|
|
17
17
|
import "./chunk-VEQXQN22.js";
|
|
18
18
|
|
|
19
19
|
// src/headless-agent.ts
|