replicas-engine 0.1.756 → 0.1.758

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.
@@ -5,11 +5,11 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-QJJE6MBM.js";
9
- import "./chunk-D7K5M3NA.js";
10
- import "./chunk-KO62WDEE.js";
8
+ } from "./chunk-EQEWL6FF.js";
9
+ import "./chunk-WTNFZX53.js";
10
+ import "./chunk-IHGPS5IS.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-CRFPCWWZ.js";
12
+ import "./chunk-24FE3TDH.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
  export {
15
15
  getCodexAspHost,
@@ -465,6 +465,7 @@ var CREDENTIAL_SCOPE_PRIORITY = [CREDENTIAL_SCOPE.USER, CREDENTIAL_SCOPE.ORG];
465
465
  var CREDENTIAL_METHOD = {
466
466
  OAUTH: "oauth",
467
467
  API_KEY: "api_key",
468
+ OPENAI_COMPATIBLE: "openai-compatible",
468
469
  FOUNDRY: "foundry",
469
470
  BEDROCK: "bedrock",
470
471
  OPENCODE_GO: "opencode-go",
@@ -480,6 +481,7 @@ var CREDENTIAL_TYPE = {
480
481
  CLAUDE_BEDROCK: "claude_bedrock",
481
482
  CODEX_OAUTH: "codex",
482
483
  OPENAI_API_KEY: "openai_api_key",
484
+ OPENAI_COMPATIBLE: "openai_compatible",
483
485
  CODEX_FOUNDRY: "codex_foundry",
484
486
  CURSOR_API_KEY: "cursor_api_key",
485
487
  OPENCODE_GO_API_KEY: "opencode_go_api_key",
@@ -503,6 +505,7 @@ var AGENT_CREDENTIAL_METHODS_IN_ORDER = {
503
505
  [AGENT.CODEX]: [
504
506
  { method: CREDENTIAL_METHOD.OAUTH, credentialType: CREDENTIAL_TYPE.CODEX_OAUTH },
505
507
  { method: CREDENTIAL_METHOD.API_KEY, credentialType: CREDENTIAL_TYPE.OPENAI_API_KEY },
508
+ { method: CREDENTIAL_METHOD.OPENAI_COMPATIBLE, credentialType: CREDENTIAL_TYPE.OPENAI_COMPATIBLE },
506
509
  { method: CREDENTIAL_METHOD.FOUNDRY, credentialType: CREDENTIAL_TYPE.CODEX_FOUNDRY }
507
510
  ],
508
511
  [AGENT.CURSOR]: [
@@ -539,6 +542,8 @@ function getCredentialMethodLabel(agent, method) {
539
542
  if (agent === AGENT.CODEX) return "OpenAI API key";
540
543
  if (agent === AGENT.CURSOR) return "Cursor API key";
541
544
  return "Anthropic API key";
545
+ case CREDENTIAL_METHOD.OPENAI_COMPATIBLE:
546
+ return "OpenAI-compatible endpoint";
542
547
  case CREDENTIAL_METHOD.FOUNDRY:
543
548
  return "Microsoft Foundry";
544
549
  case CREDENTIAL_METHOD.BEDROCK:
@@ -1692,6 +1697,53 @@ var LEGACY_WEB_APP_PATHS = {
1692
1697
  app: "/app",
1693
1698
  dashboardWorkspaces: `${DASHBOARD_PATH}/workspaces`
1694
1699
  };
1700
+ var PR_URL_REGEX = /github\.com\/([^/]+)\/([^/]+)\/pull\/(\d+)/;
1701
+ function parsePrUrl(url) {
1702
+ const match = url.match(PR_URL_REGEX);
1703
+ if (!match) return null;
1704
+ const [, owner, repo, numberStr] = match;
1705
+ const number = Number.parseInt(numberStr, 10);
1706
+ if (!Number.isFinite(number)) return null;
1707
+ return { owner, repo, number };
1708
+ }
1709
+ function parseCodeHostPrUrl(url) {
1710
+ const github = parsePrUrl(url);
1711
+ if (github) {
1712
+ return {
1713
+ ...github,
1714
+ provider: "github",
1715
+ host: "github.com",
1716
+ repositoryPath: `${github.owner}/${github.repo}`,
1717
+ repoUrl: `https://github.com/${github.owner}/${github.repo}`
1718
+ };
1719
+ }
1720
+ let parsed;
1721
+ try {
1722
+ parsed = new URL(url);
1723
+ } catch {
1724
+ return null;
1725
+ }
1726
+ if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
1727
+ const segments = parsed.pathname.split("/").filter(Boolean);
1728
+ const separatorIndex = segments.indexOf("-");
1729
+ if (separatorIndex <= 0 || segments[separatorIndex + 1] !== "merge_requests") return null;
1730
+ const number = Number.parseInt(segments[separatorIndex + 2] ?? "", 10);
1731
+ if (!Number.isFinite(number)) return null;
1732
+ const repositorySegments = decodePathSegments(segments.slice(0, separatorIndex));
1733
+ const repo = repositorySegments[repositorySegments.length - 1];
1734
+ const owner = repositorySegments[0];
1735
+ if (!owner || !repo) return null;
1736
+ const repositoryPath = repositorySegments.join("/");
1737
+ return {
1738
+ provider: "gitlab",
1739
+ host: parsed.host.toLowerCase(),
1740
+ owner,
1741
+ repo,
1742
+ number,
1743
+ repositoryPath,
1744
+ repoUrl: `${parsed.origin}/${repositoryPath}`
1745
+ };
1746
+ }
1695
1747
  function decodePathSegments(segments) {
1696
1748
  return segments.map((segment) => {
1697
1749
  try {
@@ -6421,17 +6473,28 @@ var CODEX_AUTH_ENV_KEYS = [
6421
6473
  "CODEX_FOUNDRY_MODEL",
6422
6474
  "REPLICAS_CODEX_AUTH_METHOD"
6423
6475
  ];
6476
+ function codexOpenAICompatibleAuthEnv(response) {
6477
+ return {
6478
+ ...response.apiKey && !response.authorizationHeader ? { OPENAI_API_KEY: response.apiKey } : {},
6479
+ ...response.baseUrl ? { CODEX_OPENAI_BASE_URL: response.baseUrl } : {},
6480
+ ...response.authorizationHeader ? { CODEX_OPENAI_AUTHORIZATION_HEADER: response.authorizationHeader } : {},
6481
+ REPLICAS_CODEX_AUTH_METHOD: "openai-compatible"
6482
+ };
6483
+ }
6424
6484
  function codexAuthEnvFromResponse(response) {
6425
6485
  switch (response.type) {
6426
6486
  case "oauth":
6427
6487
  return { REPLICAS_CODEX_AUTH_METHOD: "oauth" };
6428
6488
  case "api_key":
6489
+ if (response.baseUrl) {
6490
+ return codexOpenAICompatibleAuthEnv(response);
6491
+ }
6429
6492
  return {
6430
- ...response.apiKey && !response.authorizationHeader ? { OPENAI_API_KEY: response.apiKey } : {},
6431
- ...response.baseUrl ? { CODEX_OPENAI_BASE_URL: response.baseUrl } : {},
6432
- ...response.authorizationHeader ? { CODEX_OPENAI_AUTHORIZATION_HEADER: response.authorizationHeader } : {},
6493
+ ...response.apiKey ? { OPENAI_API_KEY: response.apiKey } : {},
6433
6494
  REPLICAS_CODEX_AUTH_METHOD: "api_key"
6434
6495
  };
6496
+ case "openai-compatible":
6497
+ return codexOpenAICompatibleAuthEnv(response);
6435
6498
  case "foundry":
6436
6499
  return {
6437
6500
  AZURE_OPENAI_API_KEY: response.apiKey,
@@ -6445,6 +6508,10 @@ var CODEX_AUTH_ENV_KEYS_BY_METHOD = {
6445
6508
  none: [],
6446
6509
  oauth: ["REPLICAS_CODEX_AUTH_METHOD"],
6447
6510
  api_key: [
6511
+ "OPENAI_API_KEY",
6512
+ "REPLICAS_CODEX_AUTH_METHOD"
6513
+ ],
6514
+ "openai-compatible": [
6448
6515
  "OPENAI_API_KEY",
6449
6516
  "CODEX_OPENAI_BASE_URL",
6450
6517
  "CODEX_OPENAI_AUTHORIZATION_HEADER",
@@ -6501,6 +6568,7 @@ var CLAUDE_AUTH_ENV_KEYS_BY_METHOD = {
6501
6568
  none: [],
6502
6569
  oauth: ["REPLICAS_CLAUDE_AUTH_METHOD"],
6503
6570
  api_key: ["ANTHROPIC_API_KEY", "REPLICAS_CLAUDE_AUTH_METHOD"],
6571
+ "openai-compatible": [],
6504
6572
  bedrock: [
6505
6573
  "CLAUDE_CODE_USE_BEDROCK",
6506
6574
  "AWS_ACCESS_KEY_ID",
@@ -6549,6 +6617,10 @@ function stringifyCommandProtectionInput(value) {
6549
6617
  return String(value);
6550
6618
  }
6551
6619
  }
6620
+ function findCodeHostPullRequestUrls(value) {
6621
+ const candidates = stringifyCommandProtectionInput(value).match(/https?:\/\/[^\s<>"'\\]+/g) ?? [];
6622
+ return [...new Set(candidates.map((url) => url.replace(/[),.;\]}]+$/, "")).filter((url) => parseCodeHostPrUrl(url) !== null))];
6623
+ }
6552
6624
  function normalizeCommandProtectionText(text) {
6553
6625
  return text.replace(/\\\n/g, " ").replace(/\s+/g, " ").trim().toLowerCase();
6554
6626
  }
@@ -7494,6 +7566,7 @@ export {
7494
7566
  CLAUDE_AUTH_ENV_KEYS_BY_METHOD,
7495
7567
  AI_GATEWAY_BASE_URL,
7496
7568
  fetchAiGatewayModels,
7569
+ findCodeHostPullRequestUrls,
7497
7570
  extractCommandProtectionCommandText,
7498
7571
  findPrMergeSignals,
7499
7572
  findGitCommitSignals,
@@ -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-D7K5M3NA.js";
6
+ } from "./chunk-WTNFZX53.js";
7
7
  import {
8
8
  extractCommandProtectionCommandText,
9
9
  findGitCommitSignals,
10
10
  findPrMergeSignals
11
- } from "./chunk-CRFPCWWZ.js";
11
+ } from "./chunk-24FE3TDH.js";
12
12
 
13
13
  // src/services/command-protection-service.ts
14
14
  var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
@@ -5,18 +5,18 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-D7K5M3NA.js";
8
+ } from "./chunk-WTNFZX53.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  buildCodexAgentEnv
12
- } from "./chunk-KO62WDEE.js";
12
+ } from "./chunk-IHGPS5IS.js";
13
13
  import {
14
14
  CODEX_AUTH_ENV_KEYS,
15
15
  CODEX_AUTH_ENV_KEYS_BY_METHOD,
16
16
  codexAuthEnvFromResponse,
17
17
  createErrorResult,
18
18
  createSuccessResult
19
- } from "./chunk-CRFPCWWZ.js";
19
+ } from "./chunk-24FE3TDH.js";
20
20
 
21
21
  // src/managers/codex-token-manager.ts
22
22
  import { promises as fs } from "fs";
@@ -223,7 +223,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
223
223
  const previousEnv = CODEX_AUTH_ENV_KEYS.map((key) => process.env[key]);
224
224
  console.log("[CodexTokenManager] Refreshing Codex credentials...");
225
225
  const response = await monolithRequest("/v1/engine/codex/refresh-credentials", {
226
- body: request
226
+ body: { supportsOpenAICompatibleAuth: true, ...request }
227
227
  });
228
228
  if (!response.ok) {
229
229
  const errorText = await response.text();
@@ -232,7 +232,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
232
232
  const data = await response.json();
233
233
  await this.applyCredentialsResponse(data);
234
234
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
235
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-RF22WMSU.js");
235
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-WE57RJ6E.js");
236
236
  await restartCodexAspHostIfRunning2();
237
237
  }
238
238
  if (data.scope) {
@@ -293,14 +293,14 @@ var CodexTokenManager = class extends BaseRefreshManager {
293
293
  }
294
294
  }
295
295
  async fetchFreshCredentials(failureReason, failureKind = "rejected", failedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex, allowedMethods) {
296
- const failedMethod = failedCredential?.method === "oauth" || failedCredential?.method === "api_key" || failedCredential?.method === "foundry" ? failedCredential.method : ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD;
296
+ const failedMethod = failedCredential?.method === "oauth" || failedCredential?.method === "api_key" || failedCredential?.method === "openai-compatible" || failedCredential?.method === "foundry" ? failedCredential.method : ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD;
297
297
  return this.swapCredentials({
298
298
  provider: "codex",
299
299
  failureKind,
300
300
  allowedMethods,
301
301
  refresh: async (exclusions) => {
302
302
  await this.refreshWithRequest(
303
- failedMethod === "oauth" || failedMethod === "api_key" || failedMethod === "foundry" ? {
303
+ failedMethod === "oauth" || failedMethod === "api_key" || failedMethod === "openai-compatible" || failedMethod === "foundry" ? {
304
304
  failedMethod,
305
305
  ...failedCredential?.method === failedMethod ? { failedCredential } : {},
306
306
  failureReason,
@@ -2,18 +2,20 @@
2
2
  import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
+ findCodeHostPullRequestUrls,
5
6
  mayCreatePullRequest
6
- } from "./chunk-CRFPCWWZ.js";
7
+ } from "./chunk-24FE3TDH.js";
7
8
 
8
9
  // src/services/post-tool-pr-notifier.ts
9
- async function notifyPostToolUse(toolName, toolInput) {
10
+ async function notifyPostToolUse(toolName, toolInput, toolResult) {
10
11
  if (!mayCreatePullRequest(toolName, toolInput)) return false;
11
12
  const port = process.env.REPLICAS_ENGINE_PORT;
12
13
  const secret = process.env.REPLICAS_ENGINE_SECRET;
13
14
  if (!port || !secret) throw new Error("Replicas engine connection is unavailable.");
14
15
  const response = await fetch(`http://127.0.0.1:${port}/pull-requests/check`, {
15
16
  method: "POST",
16
- headers: { "X-Replicas-Engine-Secret": secret },
17
+ headers: { "X-Replicas-Engine-Secret": secret, "Content-Type": "application/json" },
18
+ body: JSON.stringify({ prUrls: findCodeHostPullRequestUrls(toolResult) }),
17
19
  signal: AbortSignal.timeout(3e4)
18
20
  });
19
21
  if (!response.ok) throw new Error(`Replicas pull request check failed (${response.status}).`);
@@ -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-CRFPCWWZ.js";
7
+ } from "./chunk-24FE3TDH.js";
8
8
 
9
9
  // src/utils/codex-agent-env.ts
10
10
  function buildCodexAgentEnv(source = process.env) {
@@ -241,7 +241,7 @@ var DEFAULT_CODEX_ARGS = [
241
241
  var MIN_CODEX_CLI_VERSION = "0.153.3";
242
242
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
243
243
  var codexCliVersionEnsured = null;
244
- var ENGINE_PACKAGE_VERSION = "0.1.756";
244
+ var ENGINE_PACKAGE_VERSION = "0.1.758";
245
245
  var INITIALIZE_METHOD = "initialize";
246
246
  var INITIALIZED_NOTIFICATION = "initialized";
247
247
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -276,7 +276,7 @@ var AppServerProcess = class {
276
276
  "-c",
277
277
  'model_providers.azure.wire_api="responses"'
278
278
  ];
279
- } else if (!options.args && options.env.REPLICAS_CODEX_AUTH_METHOD === "api_key" && options.env.CODEX_OPENAI_BASE_URL) {
279
+ } else if (!options.args && options.env.REPLICAS_CODEX_AUTH_METHOD === "openai-compatible") {
280
280
  baseArgs = [
281
281
  ...DEFAULT_CODEX_ARGS,
282
282
  "-c",
@@ -15,7 +15,7 @@ import {
15
15
  isValidRelayBaseProvider,
16
16
  parsePosixEnvFile,
17
17
  readReplicasRuntimeEnv
18
- } from "./chunk-CRFPCWWZ.js";
18
+ } from "./chunk-24FE3TDH.js";
19
19
 
20
20
  // src/engine-env.ts
21
21
  import { readFileSync as readFileSync2 } from "fs";
@@ -84,7 +84,7 @@ function parseClaudeAuthMethod(value) {
84
84
  return void 0;
85
85
  }
86
86
  function parseCodexAuthMethod(value) {
87
- if (value === "oauth" || value === "api_key" || value === "foundry") {
87
+ if (value === "oauth" || value === "api_key" || value === "openai-compatible" || value === "foundry") {
88
88
  return value;
89
89
  }
90
90
  return void 0;
@@ -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-AGAAN5SZ.js";
7
- import "./chunk-D7K5M3NA.js";
6
+ } from "./chunk-2N4HGHFZ.js";
7
+ import "./chunk-WTNFZX53.js";
8
8
  import {
9
9
  isRecord
10
10
  } from "./chunk-UZSNFLDQ.js";
11
- import "./chunk-CRFPCWWZ.js";
11
+ import "./chunk-24FE3TDH.js";
12
12
  import "./chunk-VEQXQN22.js";
13
13
 
14
14
  // src/command-protection-hook.ts
@@ -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-AGAAN5SZ.js";
6
+ } from "./chunk-2N4HGHFZ.js";
7
7
  import {
8
8
  notifyPostToolUse
9
- } from "./chunk-KERIK6MD.js";
10
- import "./chunk-D7K5M3NA.js";
9
+ } from "./chunk-FTXE5FES.js";
10
+ import "./chunk-WTNFZX53.js";
11
11
  import "./chunk-UZSNFLDQ.js";
12
- import "./chunk-CRFPCWWZ.js";
12
+ import "./chunk-24FE3TDH.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/deepseek-command-protection-plugin.ts
@@ -25,8 +25,8 @@ function replicasCommandProtection(context) {
25
25
  });
26
26
  return result.allowed ? next() : { kind: "deny", reason: result.reason ?? "Blocked by Replicas command protection." };
27
27
  });
28
- context.on("tools/post-execute", async (execution, _result, next) => {
29
- await notifyPostToolUse(execution.name, execution.arguments).catch(() => {
28
+ context.on("tools/post-execute", async (execution, result, next) => {
29
+ await notifyPostToolUse(execution.name, execution.arguments, result).catch(() => {
30
30
  });
31
31
  return next();
32
32
  });
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  AppServerProcess,
10
10
  buildCodexAgentEnv
11
- } from "./chunk-KO62WDEE.js";
11
+ } from "./chunk-IHGPS5IS.js";
12
12
  import {
13
13
  AGENT,
14
14
  getMemoryOutputSafetyViolation,
15
15
  headlessAgentRequestSchema
16
- } from "./chunk-CRFPCWWZ.js";
16
+ } from "./chunk-24FE3TDH.js";
17
17
  import "./chunk-VEQXQN22.js";
18
18
 
19
19
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -91,7 +91,7 @@ import {
91
91
  evaluateCommandProtection,
92
92
  extractToolCommand,
93
93
  reportCommandProtectionBlock
94
- } from "./chunk-AGAAN5SZ.js";
94
+ } from "./chunk-2N4HGHFZ.js";
95
95
  import {
96
96
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
97
97
  AGENT_MESSAGE_DELTA_METHOD,
@@ -124,20 +124,20 @@ import {
124
124
  recordCredentialFallback,
125
125
  recordExhaustedCredential,
126
126
  restartCodexAspHost
127
- } from "./chunk-QJJE6MBM.js";
127
+ } from "./chunk-EQEWL6FF.js";
128
128
  import {
129
129
  ENGINE_ENV,
130
130
  IS_WARMING_MODE,
131
131
  monolithRequest,
132
132
  monolithService,
133
133
  setAgentCredentialSnapshot
134
- } from "./chunk-D7K5M3NA.js";
134
+ } from "./chunk-WTNFZX53.js";
135
135
  import {
136
136
  AspClient,
137
137
  SUBPROCESS_MAX_BUFFER,
138
138
  execAsync,
139
139
  execFileAsync
140
- } from "./chunk-KO62WDEE.js";
140
+ } from "./chunk-IHGPS5IS.js";
141
141
  import {
142
142
  isRecord as isRecord2
143
143
  } from "./chunk-UZSNFLDQ.js";
@@ -252,6 +252,7 @@ import {
252
252
  extractToolResultText,
253
253
  fetchAiGatewayModels,
254
254
  fetchModelsDevCatalog,
255
+ findCodeHostPullRequestUrls,
255
256
  forkChatRequestSchema,
256
257
  formatChatForkHandoffMessage,
257
258
  getChatExecutionProvider,
@@ -330,7 +331,7 @@ import {
330
331
  spawnRelaySubagentRequestSchema,
331
332
  stripAgentDiagnosticErrors,
332
333
  withTimeout
333
- } from "./chunk-CRFPCWWZ.js";
334
+ } from "./chunk-24FE3TDH.js";
334
335
  import {
335
336
  __commonJS,
336
337
  __export,
@@ -9421,12 +9422,13 @@ var ClaudeTokenManager = class extends BaseRefreshManager {
9421
9422
  console.log(`[ClaudeTokenManager] Credentials refreshed (method=${data.type})`);
9422
9423
  }
9423
9424
  async fetchFreshCredentials(failureReason, failureKind = "rejected", failedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude, allowedMethods) {
9424
- const failedMethod = failedCredential?.method === "oauth" || failedCredential?.method === "api_key" || failedCredential?.method === "bedrock" || failedCredential?.method === "foundry" ? failedCredential.method : ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD;
9425
+ const configuredMethod = ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD;
9426
+ const failedMethod = failedCredential?.method === "oauth" || failedCredential?.method === "api_key" || failedCredential?.method === "bedrock" || failedCredential?.method === "foundry" ? failedCredential.method : configuredMethod === "oauth" || configuredMethod === "api_key" || configuredMethod === "bedrock" || configuredMethod === "foundry" ? configuredMethod : void 0;
9425
9427
  return this.swapCredentials({
9426
9428
  provider: "claude",
9427
9429
  failureKind,
9428
9430
  allowedMethods,
9429
- refresh: (exclusions) => this.refreshWithRequest(failedMethod && failedMethod !== "none" ? {
9431
+ refresh: (exclusions) => this.refreshWithRequest(failedMethod ? {
9430
9432
  failedMethod,
9431
9433
  ...failedCredential?.method === failedMethod ? { failedCredential } : {},
9432
9434
  failureReason,
@@ -12094,15 +12096,15 @@ var PullRequestCheckService = class {
12094
12096
  // Plain single-flight would hand a caller a result gathered before its PR
12095
12097
  // existed, so callers arriving mid-run instead share one trailing run that
12096
12098
  // starts after the current one settles.
12097
- check() {
12099
+ check(prUrls = []) {
12100
+ const registration = prUrls.length > 0 ? monolithService.sendEvent({ type: "pull_request_check", payload: { repoStatuses: [], prUrls } }) : Promise.resolve();
12098
12101
  const running = this.running;
12099
- if (!running) return this.start();
12100
- this.trailing ??= running.catch(() => {
12102
+ const refresh = !running ? this.start() : this.trailing ??= running.catch(() => {
12101
12103
  }).then(() => {
12102
12104
  this.trailing = null;
12103
12105
  return this.start();
12104
12106
  });
12105
- return this.trailing;
12107
+ return registration.then(() => refresh);
12106
12108
  }
12107
12109
  start() {
12108
12110
  const run = withTimeout(this.refresh(), CHECK_TIMEOUT_MS, "Pull request check timed out").finally(() => {
@@ -13352,7 +13354,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13352
13354
  matcher: "*",
13353
13355
  hooks: [async (input) => {
13354
13356
  if (input.hook_event_name === "PostToolUse" && mayCreatePullRequest(input.tool_name, input.tool_input)) {
13355
- pullRequestCheckService.check().catch(() => {
13357
+ pullRequestCheckService.check(findCodeHostPullRequestUrls(input)).catch(() => {
13356
13358
  });
13357
13359
  }
13358
13360
  return {};
@@ -15298,7 +15300,7 @@ var CodexAspManager = class extends CodingAgentManager {
15298
15300
  linearForwarder.sendEvent(convertCodexAspNotification(notification, linearSessionId ?? ""));
15299
15301
  const completedItem = notification.params.item;
15300
15302
  if (completedItem.type === "commandExecution" && completedItem.exitCode === 0 && mayCreatePullRequest("commandExecution", { command: completedItem.command }) || completedItem.type === "mcpToolCall" && completedItem.status === "completed" && mayCreatePullRequest(completedItem.tool, completedItem.arguments) || completedItem.type === "dynamicToolCall" && completedItem.success !== false && mayCreatePullRequest(completedItem.tool, completedItem.arguments)) {
15301
- pullRequestCheckService.check().catch(() => {
15303
+ pullRequestCheckService.check(findCodeHostPullRequestUrls(completedItem)).catch(() => {
15302
15304
  });
15303
15305
  }
15304
15306
  },
@@ -59256,7 +59258,7 @@ function registerCommandProtection(cwd, historyFile, recordHistoryEvent) {
59256
59258
  });
59257
59259
  pi.on("tool_result", (event) => {
59258
59260
  if (!event.isError && mayCreatePullRequest(event.toolName, event.input)) {
59259
- pullRequestCheckService.check().catch(() => {
59261
+ pullRequestCheckService.check(findCodeHostPullRequestUrls(event)).catch(() => {
59260
59262
  });
59261
59263
  }
59262
59264
  });
@@ -63443,8 +63445,10 @@ function jsonError(message, details) {
63443
63445
  }
63444
63446
  function createV1Routes(deps) {
63445
63447
  const app2 = new Hono();
63446
- app2.post("/pull-requests/check", (c) => {
63447
- pullRequestCheckService.check().catch(() => {
63448
+ app2.post("/pull-requests/check", async (c) => {
63449
+ const body = await c.req.json().catch(() => null);
63450
+ const prUrls = isRecord2(body) && Array.isArray(body.prUrls) ? body.prUrls.filter((url3) => typeof url3 === "string") : [];
63451
+ pullRequestCheckService.check(prUrls).catch(() => {
63448
63452
  });
63449
63453
  return c.json({ accepted: true }, 202);
63450
63454
  });
@@ -3,11 +3,11 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  notifyPostToolUse
6
- } from "./chunk-KERIK6MD.js";
6
+ } from "./chunk-FTXE5FES.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
- import "./chunk-CRFPCWWZ.js";
10
+ import "./chunk-24FE3TDH.js";
11
11
  import "./chunk-VEQXQN22.js";
12
12
 
13
13
  // src/post-tool-pr-hook.ts
@@ -19,7 +19,8 @@ async function main() {
19
19
  const record = isRecord(input) ? input : {};
20
20
  const toolName = [record.tool_name, record.tool, record.name].find((value) => typeof value === "string") ?? "";
21
21
  const toolInput = record.tool_input ?? record.arguments ?? record.args ?? ("command" in record ? { command: record.command } : record);
22
- await notifyPostToolUse(toolName, toolInput);
22
+ const toolResult = record.tool_response ?? record.tool_result ?? record.tool_output ?? record.toolOutput ?? record.output ?? record.result;
23
+ await notifyPostToolUse(toolName, toolInput, toolResult);
23
24
  } catch (error) {
24
25
  process.stderr.write(`${error instanceof Error ? error.message : String(error)}
25
26
  `);
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  messageRelaySubagentRequestSchema,
6
6
  spawnRelaySubagentRequestSchema
7
- } from "./chunk-CRFPCWWZ.js";
7
+ } from "./chunk-24FE3TDH.js";
8
8
  import "./chunk-VEQXQN22.js";
9
9
 
10
10
  // src/relay-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.756",
3
+ "version": "0.1.758",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -14,6 +14,10 @@ interface ToolExecuteBeforeOutput {
14
14
  args: unknown;
15
15
  }
16
16
 
17
+ interface ToolExecuteAfterOutput {
18
+ output: string;
19
+ }
20
+
17
21
  const toolInputs = new Map<string, unknown>();
18
22
 
19
23
  function evaluate(tool: string, args: unknown, callId: string, cwd: string): Promise<PolicyResult> {
@@ -69,7 +73,7 @@ export const ReplicasCommandProtection = async ({ directory }: { directory: stri
69
73
  if (!result.allowed) throw new Error(result.reason ?? 'Blocked by Replicas command protection.');
70
74
  toolInputs.set(input.callID, output.args);
71
75
  },
72
- 'tool.execute.after': async (input: ToolExecuteBeforeInput) => {
76
+ 'tool.execute.after': async (input: ToolExecuteBeforeInput, output: ToolExecuteAfterOutput) => {
73
77
  const args = toolInputs.get(input.callID);
74
78
  toolInputs.delete(input.callID);
75
79
  const hookPath = process.env.REPLICAS_POST_TOOL_PR_HOOK_PATH;
@@ -82,7 +86,7 @@ export const ReplicasCommandProtection = async ({ directory }: { directory: stri
82
86
  const child = spawn(runtimePath, hookArgs, { cwd: directory, stdio: ['pipe', 'ignore', 'ignore'] });
83
87
  child.on('error', () => resolve());
84
88
  child.on('exit', () => resolve());
85
- child.stdin.end(JSON.stringify({ tool: input.tool, args }));
89
+ child.stdin.end(JSON.stringify({ tool: input.tool, args, output: output.output }));
86
90
  });
87
91
  },
88
92
  });