replicas-engine 0.1.1247 → 0.1.1249

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
  listRunningCodexModels,
9
9
  restartCodexAspHost,
10
10
  restartCodexAspHostIfRunning
11
- } from "./chunk-RHMWOSGI.js";
12
- import "./chunk-BADAP2HN.js";
13
- import "./chunk-CIWBIJZN.js";
14
- import "./chunk-X3CD2PFH.js";
11
+ } from "./chunk-GH5EEUT2.js";
12
+ import "./chunk-6PVW5AKP.js";
13
+ import "./chunk-5GHRPLRX.js";
14
+ import "./chunk-3C2WTKME.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
- import "./chunk-UUGSRQQJ.js";
16
+ import "./chunk-7QJWP5ZL.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-UUGSRQQJ.js";
6
+ } from "./chunk-7QJWP5ZL.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -5,14 +5,14 @@ import {
5
5
  getOriginDefaultBranch,
6
6
  monolithRequest,
7
7
  runGitCommand
8
- } from "./chunk-BADAP2HN.js";
8
+ } from "./chunk-6PVW5AKP.js";
9
9
  import {
10
10
  extractCommandProtectionCommandText,
11
11
  findCommandProtectionGitLookups,
12
12
  findGitCommitSignals,
13
13
  findPrMergeSignals,
14
14
  parseCommandProtectionRequest
15
- } from "./chunk-UUGSRQQJ.js";
15
+ } from "./chunk-7QJWP5ZL.js";
16
16
 
17
17
  // src/services/command-protection-service.ts
18
18
  import { readFile, stat } from "fs/promises";
@@ -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-CIWBIJZN.js";
6
+ } from "./chunk-5GHRPLRX.js";
7
7
  import {
8
8
  ASTER_BASE_URL,
9
9
  ASTER_PROVIDER,
@@ -13,7 +13,7 @@ import {
13
13
  isRecord,
14
14
  readOllamaAuthEnv,
15
15
  readOpenAICompatibleAuthEnv
16
- } from "./chunk-UUGSRQQJ.js";
16
+ } from "./chunk-7QJWP5ZL.js";
17
17
 
18
18
  // src/managers/codex-asp/notification-dispatch.ts
19
19
  var TURN_STARTED_METHOD = "turn/started";
@@ -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-X3CD2PFH.js";
6
+ } from "./chunk-3C2WTKME.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-UUGSRQQJ.js";
9
+ } from "./chunk-7QJWP5ZL.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.1246";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1249";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -4,11 +4,12 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-X3CD2PFH.js";
7
+ } from "./chunk-3C2WTKME.js";
8
8
  import {
9
9
  isRecord as isRecord2
10
10
  } from "./chunk-UZSNFLDQ.js";
11
11
  import {
12
+ ENGINE_PORT,
12
13
  REPLICAS_RUNTIME_ENV_ALIASES,
13
14
  agentCredentialSnapshotSchema,
14
15
  createErrorResult,
@@ -18,7 +19,7 @@ import {
18
19
  isValidAgentProvider,
19
20
  parsePosixEnvFile,
20
21
  readReplicasRuntimeEnv
21
- } from "./chunk-UUGSRQQJ.js";
22
+ } from "./chunk-7QJWP5ZL.js";
22
23
 
23
24
  // src/runtime-env-loader.ts
24
25
  import { readFileSync } from "fs";
@@ -63,7 +64,7 @@ function readSandboxImageVersion() {
63
64
  }
64
65
  function parsePort(value) {
65
66
  if (!value) {
66
- return 3737;
67
+ return ENGINE_PORT;
67
68
  }
68
69
  const parsed = Number(value);
69
70
  if (!Number.isInteger(parsed) || parsed <= 0) {
@@ -1510,6 +1510,7 @@ var ENGINE_STREAM_LAST_EVENT_ID_HEADER = "Last-Event-ID";
1510
1510
  var ENGINE_HEALTH_WAIT_HEADER = "X-Replicas-Health-Wait";
1511
1511
  var ENGINE_HEALTH_WAIT_QUERY_PARAM = "wait_ms";
1512
1512
  var ENGINE_HEALTH_MAX_WAIT_MS = 2e3;
1513
+ var ENGINE_PROXY_SAFE_HEALTH_PATH = "/engine-health";
1513
1514
  var ENGINE_ACTIVATE_PATH = "/lifecycle/activate";
1514
1515
  var ENGINE_SLEEP_PATH = "/lifecycle/sleep";
1515
1516
  var updateChatDisplayNameRequestSchema = z4.object({
@@ -2002,6 +2003,10 @@ function parsePosixEnvFile(content) {
2002
2003
  return result;
2003
2004
  }
2004
2005
 
2006
+ // ../shared/src/engine/environment.ts
2007
+ var ENGINE_PORT = 3737;
2008
+ var DESKTOP_STREAM_PORT = 6080;
2009
+
2005
2010
  // ../shared/src/git.ts
2006
2011
  var GIT_CREDENTIAL_HELPER_FILENAME = ".git-credential-replicas";
2007
2012
  var GITHUB_CREDENTIAL_REFRESH_PATH = "/git-credentials/github/refresh";
@@ -2066,7 +2071,7 @@ refresh_credential() {
2066
2071
  esac
2067
2072
  [ -n "\${REPLICAS_ENGINE_SECRET:-}" ] || return 1
2068
2073
  command -v curl >/dev/null 2>&1 || return 1
2069
- curl --silent --fail --connect-timeout 1 --max-time 5 -X POST -H "X-Replicas-Engine-Secret: $REPLICAS_ENGINE_SECRET" "http://127.0.0.1:\${REPLICAS_ENGINE_PORT:-3737}$refresh_path" >/dev/null 2>&1
2074
+ curl --silent --fail --connect-timeout 1 --max-time 5 -X POST -H "X-Replicas-Engine-Secret: $REPLICAS_ENGINE_SECRET" "http://127.0.0.1:\${REPLICAS_ENGINE_PORT:-${ENGINE_PORT}}$refresh_path" >/dev/null 2>&1
2070
2075
  }
2071
2076
 
2072
2077
  if [ "$1" = "get" ]; then
@@ -2136,9 +2141,6 @@ var headlessAgentRequestSchema = z7.object({
2136
2141
  });
2137
2142
  var headlessAgentUsagePath = (outputPath) => `${outputPath}.usage`;
2138
2143
 
2139
- // ../shared/src/engine/environment.ts
2140
- var DESKTOP_STREAM_PORT = 6080;
2141
-
2142
2144
  // ../shared/src/sse.ts
2143
2145
  function parseSseChunk(chunk) {
2144
2146
  let data = "";
@@ -10385,6 +10387,7 @@ export {
10385
10387
  ENGINE_HEALTH_WAIT_HEADER,
10386
10388
  ENGINE_HEALTH_WAIT_QUERY_PARAM,
10387
10389
  ENGINE_HEALTH_MAX_WAIT_MS,
10390
+ ENGINE_PROXY_SAFE_HEALTH_PATH,
10388
10391
  ENGINE_ACTIVATE_PATH,
10389
10392
  ENGINE_SLEEP_PATH,
10390
10393
  updateChatDisplayNameRequestSchema,
@@ -10479,6 +10482,8 @@ export {
10479
10482
  readReplicasRuntimeEnv,
10480
10483
  shellQuotePosix,
10481
10484
  parsePosixEnvFile,
10485
+ ENGINE_PORT,
10486
+ DESKTOP_STREAM_PORT,
10482
10487
  GIT_CREDENTIAL_HELPER_FILENAME,
10483
10488
  GITHUB_CREDENTIAL_REFRESH_PATH,
10484
10489
  GITLAB_CREDENTIAL_REFRESH_PATH,
@@ -10510,7 +10515,6 @@ export {
10510
10515
  serializeMuseAuthFile,
10511
10516
  isVersionBelow,
10512
10517
  hasChatStarted,
10513
- DESKTOP_STREAM_PORT,
10514
10518
  CODEX_AUTH_ENV_KEYS,
10515
10519
  codexAuthEnvFromResponse,
10516
10520
  CODEX_AUTH_ENV_KEYS_BY_METHOD,
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-UUGSRQQJ.js";
8
+ } from "./chunk-7QJWP5ZL.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -10,15 +10,15 @@ import {
10
10
  resolveDiffBase,
11
11
  runGitCommand,
12
12
  setAgentCredentialSnapshot
13
- } from "./chunk-BADAP2HN.js";
13
+ } from "./chunk-6PVW5AKP.js";
14
14
  import {
15
15
  AppServerProcess,
16
16
  buildCodexAgentEnv
17
- } from "./chunk-CIWBIJZN.js";
17
+ } from "./chunk-5GHRPLRX.js";
18
18
  import {
19
19
  SUBPROCESS_MAX_BUFFER,
20
20
  execFileAsync
21
- } from "./chunk-X3CD2PFH.js";
21
+ } from "./chunk-3C2WTKME.js";
22
22
  import {
23
23
  isRecord
24
24
  } from "./chunk-UZSNFLDQ.js";
@@ -55,7 +55,7 @@ import {
55
55
  resolveOpenAICompatibleModelsUrl,
56
56
  splitMothershipInstructions,
57
57
  withTimeout
58
- } from "./chunk-UUGSRQQJ.js";
58
+ } from "./chunk-7QJWP5ZL.js";
59
59
 
60
60
  // src/managers/codex-token-manager.ts
61
61
  import { promises as fs } from "fs";
@@ -291,7 +291,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
291
291
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
292
292
  await this.applyCredentialsResponse(data);
293
293
  setAgentCredentialSnapshot("codex", data);
294
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-VTR4W3G7.js");
294
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-UBXPKAXA.js");
295
295
  await restartCodexAspHostIfRunning2();
296
296
  });
297
297
  await this.start(true);
@@ -313,7 +313,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
313
313
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
314
314
  await this.applyCredentialsResponse(data);
315
315
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
316
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-VTR4W3G7.js");
316
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-UBXPKAXA.js");
317
317
  await restartCodexAspHostIfRunning2();
318
318
  }
319
319
  setAgentCredentialSnapshot("codex", data);
@@ -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-EDUOGWVY.js";
7
- import "./chunk-BADAP2HN.js";
8
- import "./chunk-X3CD2PFH.js";
6
+ } from "./chunk-4AIHQBEA.js";
7
+ import "./chunk-6PVW5AKP.js";
8
+ import "./chunk-3C2WTKME.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-UUGSRQQJ.js";
12
+ import "./chunk-7QJWP5ZL.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -13,12 +13,12 @@ import {
13
13
  recoverCompletedTurn,
14
14
  spawnMuseMsp,
15
15
  startMuseSession
16
- } from "./chunk-XHPJ47AY.js";
16
+ } from "./chunk-5ANTWWVQ.js";
17
17
  import {
18
18
  AppServerProcess,
19
19
  buildCodexAgentEnv
20
- } from "./chunk-CIWBIJZN.js";
21
- import "./chunk-X3CD2PFH.js";
20
+ } from "./chunk-5GHRPLRX.js";
21
+ import "./chunk-3C2WTKME.js";
22
22
  import {
23
23
  AGENT,
24
24
  OPENCODE_GO_PROVIDER,
@@ -28,7 +28,7 @@ import {
28
28
  headlessAgentUsagePath,
29
29
  isRecord,
30
30
  withTimeout
31
- } from "./chunk-UUGSRQQJ.js";
31
+ } from "./chunk-7QJWP5ZL.js";
32
32
  import "./chunk-VEQXQN22.js";
33
33
 
34
34
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  evaluateCommandProtection,
28
28
  extractToolCommand,
29
29
  reportCommandProtectionBlock
30
- } from "./chunk-EDUOGWVY.js";
30
+ } from "./chunk-4AIHQBEA.js";
31
31
  import {
32
32
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
33
33
  AGENT_MESSAGE_DELTA_METHOD,
@@ -64,10 +64,10 @@ import {
64
64
  spawnMuseMsp,
65
65
  startMuseSession,
66
66
  uuidV7
67
- } from "./chunk-XHPJ47AY.js";
67
+ } from "./chunk-5ANTWWVQ.js";
68
68
  import {
69
69
  publishedPullRequestUrls
70
- } from "./chunk-G4UVARZK.js";
70
+ } from "./chunk-FQZ6YTN2.js";
71
71
  import {
72
72
  ACCOUNT_RATE_LIMITS_READ_METHOD,
73
73
  AsyncLock,
@@ -140,7 +140,7 @@ import {
140
140
  timestampFromSeconds,
141
141
  upsertCredentialFileLines,
142
142
  writeSecureCredentialFile
143
- } from "./chunk-RHMWOSGI.js";
143
+ } from "./chunk-GH5EEUT2.js";
144
144
  import {
145
145
  ENGINE_ENV,
146
146
  monolithRequest,
@@ -149,15 +149,15 @@ import {
149
149
  reloadEngineEnv,
150
150
  resolveDiffBase,
151
151
  setAgentCredentialSnapshot
152
- } from "./chunk-BADAP2HN.js";
152
+ } from "./chunk-6PVW5AKP.js";
153
153
  import {
154
154
  getCodexModelProvider
155
- } from "./chunk-CIWBIJZN.js";
155
+ } from "./chunk-5GHRPLRX.js";
156
156
  import {
157
157
  SUBPROCESS_MAX_BUFFER,
158
158
  execAsync,
159
159
  execFileAsync
160
- } from "./chunk-X3CD2PFH.js";
160
+ } from "./chunk-3C2WTKME.js";
161
161
  import {
162
162
  isRecord as isRecord2
163
163
  } from "./chunk-UZSNFLDQ.js";
@@ -211,6 +211,7 @@ import {
211
211
  ENGINE_HEALTH_MAX_WAIT_MS,
212
212
  ENGINE_HEALTH_WAIT_HEADER,
213
213
  ENGINE_HEALTH_WAIT_QUERY_PARAM,
214
+ ENGINE_PROXY_SAFE_HEALTH_PATH,
214
215
  ENGINE_SEND_MESSAGE_FAILED_ERROR,
215
216
  ENGINE_SLEEP_PATH,
216
217
  ENGINE_STREAM_LAST_EVENT_ID_HEADER,
@@ -395,7 +396,7 @@ import {
395
396
  workspaceTokenRequestSchema,
396
397
  workspaceTokenResponseSchema,
397
398
  wrapInTag
398
- } from "./chunk-UUGSRQQJ.js";
399
+ } from "./chunk-7QJWP5ZL.js";
399
400
  import {
400
401
  cloneMcpConfig,
401
402
  ensureCompatibilityImports,
@@ -8843,7 +8844,7 @@ var ClaudeTokenManager = class extends BaseRefreshManager {
8843
8844
  await this.applyCredentialUpdate(generation, () => this.applyCredentialsResponse(data));
8844
8845
  console.log(`[ClaudeTokenManager] Credentials refreshed (method=${data.type})`);
8845
8846
  }
8846
- async fetchFreshCredentials(failureReason, failureKind = "rejected", failedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude, allowedMethods) {
8847
+ async fetchFreshCredentials(failureReason, failureKind = "rejected", failedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude, allowedMethods, resetsAt) {
8847
8848
  const configuredMethod = ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD;
8848
8849
  const failedMethod = failedCredential?.method === "ollama" || failedCredential?.method === "oauth" || failedCredential?.method === "api_key" || failedCredential?.method === "bedrock" || failedCredential?.method === "foundry" ? failedCredential.method : configuredMethod === "ollama" || configuredMethod === "oauth" || configuredMethod === "api_key" || configuredMethod === "bedrock" || configuredMethod === "foundry" ? configuredMethod : void 0;
8849
8850
  return this.swapCredentials({
@@ -8855,6 +8856,7 @@ var ClaudeTokenManager = class extends BaseRefreshManager {
8855
8856
  ...failedCredential?.method === failedMethod ? { failedCredential } : {},
8856
8857
  failureReason,
8857
8858
  failureKind,
8859
+ ...resetsAt ? { resetsAt } : {},
8858
8860
  ...exclusions
8859
8861
  } : exclusions),
8860
8862
  isOauthNow: () => ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD === "oauth"
@@ -11176,12 +11178,12 @@ var AuthFallbackCoordinator = class {
11176
11178
  record;
11177
11179
  context;
11178
11180
  /** `attempted` is the credential the failed turn ran on, which another chat may already have replaced. */
11179
- fallBack(reason, detail, attempted) {
11181
+ fallBack(reason, detail, attempted, resetsAt) {
11180
11182
  let lock = fallbackLocks.get(this.provider);
11181
11183
  if (!lock) fallbackLocks.set(this.provider, lock = new AsyncLock());
11182
- return lock.run(() => this.fallBackNow(reason, detail, attempted));
11184
+ return lock.run(() => this.fallBackNow(reason, detail, attempted, resetsAt));
11183
11185
  }
11184
- async fallBackNow(reason, detail, attempted) {
11186
+ async fallBackNow(reason, detail, attempted, resetsAt) {
11185
11187
  const tokenManager = SWAPPABLE_AGENTS[this.provider];
11186
11188
  const live = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS[this.provider];
11187
11189
  const exhausted = attempted ?? live;
@@ -11218,7 +11220,8 @@ var AuthFallbackCoordinator = class {
11218
11220
  // Skipped via the exclusion above, not rested, so Settings doesn't show a usage limit.
11219
11221
  reason === "auth_failed" || reason === "credits_required" ? "rejected" : "exhausted",
11220
11222
  exhausted,
11221
- step.methods.length > 0 ? step.methods : void 0
11223
+ step.methods.length > 0 ? step.methods : void 0,
11224
+ resetsAt
11222
11225
  );
11223
11226
  if (!swap.ok) {
11224
11227
  failed ||= swap.error.code !== "no_credentials";
@@ -11573,9 +11576,9 @@ var CodingAgentManager = class {
11573
11576
  this.getHistorySink()?.append(event);
11574
11577
  }, options.fallbackContext ?? (() => ({ excludeProviders: [], forkable: false }))) : null;
11575
11578
  }
11576
- async fallBackCredential(reason, detail, attempted) {
11579
+ async fallBackCredential(reason, detail, attempted, resetsAt) {
11577
11580
  if (!this.authFallback) return { outcome: "unavailable" };
11578
- const result = await this.authFallback.fallBack(reason, detail, attempted);
11581
+ const result = await this.authFallback.fallBack(reason, detail, attempted, resetsAt);
11579
11582
  if (result.outcome === "switched" && result.model) await this.onModelSwitched(result.model);
11580
11583
  return result;
11581
11584
  }
@@ -12805,12 +12808,14 @@ var ClaudeMissingSessionError = class extends Error {
12805
12808
  }
12806
12809
  };
12807
12810
  var ClaudeQuotaError = class extends Error {
12808
- constructor(message, kind) {
12811
+ constructor(message, kind, resetsAt) {
12809
12812
  super(message);
12810
12813
  this.kind = kind;
12814
+ this.resetsAt = resetsAt;
12811
12815
  this.name = "ClaudeQuotaError";
12812
12816
  }
12813
12817
  kind;
12818
+ resetsAt;
12814
12819
  };
12815
12820
  var MAX_AUTH_RETRIES = 2;
12816
12821
  var MAX_TRANSIENT_RETRIES = 2;
@@ -13259,7 +13264,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13259
13264
  const detail = error instanceof ClaudeQuotaError ? error.message : extractErrorText(error);
13260
13265
  const repeated = !!attemptedCredential && failedCredentials.some((failed) => isSameCredential(failed, attemptedCredential));
13261
13266
  if (attemptedCredential) failedCredentials.push(attemptedCredential);
13262
- const fallback = repeated ? { outcome: "unavailable" } : await this.fallBackCredential(reason, detail, attemptedCredential);
13267
+ const fallback = repeated ? { outcome: "unavailable" } : await this.fallBackCredential(reason, detail, attemptedCredential, error instanceof ClaudeQuotaError ? error.resetsAt : void 0);
13263
13268
  if (fallback.outcome === "switched") {
13264
13269
  if (fallback.model) currentRequest = { ...currentRequest, model: fallback.model };
13265
13270
  authRetries = 0;
@@ -13672,6 +13677,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13672
13677
  let loopError = null;
13673
13678
  let suppressLinearResponseFlush = false;
13674
13679
  let creditsRequired = false;
13680
+ let resetsAt;
13675
13681
  let turnFailed = false;
13676
13682
  try {
13677
13683
  while (true) {
@@ -13679,10 +13685,15 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13679
13685
  if (next.done || this.activeQuery !== response) break;
13680
13686
  const msg = next.value;
13681
13687
  if (!msg) break;
13682
- if (msg.type === "rate_limit_event") creditsRequired = msg.rate_limit_info.errorCode === "credits_required";
13688
+ if (msg.type === "rate_limit_event") {
13689
+ creditsRequired = msg.rate_limit_info.errorCode === "credits_required";
13690
+ if (msg.rate_limit_info.status === "rejected" && msg.rate_limit_info.resetsAt) {
13691
+ resetsAt = new Date(msg.rate_limit_info.resetsAt * 1e3).toISOString();
13692
+ }
13693
+ }
13683
13694
  const authErrorMessage = _ClaudeManager.detectAuthErrorInMessage(msg);
13684
13695
  const transientErrorMessage = _ClaudeManager.detectTransientTurnErrorInMessage(msg);
13685
- const turnError = authErrorMessage ? new ClaudeAuthError(authErrorMessage) : msg.type === "result" && msg.subtype !== "success" && msg.num_turns === 0 && msg.errors.some((err) => err.startsWith("No conversation found with session ID")) ? new ClaudeMissingSessionError(msg.errors.join("\n")) : _ClaudeManager.detectQuotaErrorInMessage(msg, creditsRequired) ?? (transientErrorMessage ? new ClaudeTransientTurnError(transientErrorMessage, this.pendingTurn?.sawActivity ?? false) : null);
13696
+ const turnError = authErrorMessage ? new ClaudeAuthError(authErrorMessage) : msg.type === "result" && msg.subtype !== "success" && msg.num_turns === 0 && msg.errors.some((err) => err.startsWith("No conversation found with session ID")) ? new ClaudeMissingSessionError(msg.errors.join("\n")) : _ClaudeManager.detectQuotaErrorInMessage(msg, creditsRequired, resetsAt) ?? (transientErrorMessage ? new ClaudeTransientTurnError(transientErrorMessage, this.pendingTurn?.sawActivity ?? false) : null);
13686
13697
  if (turnError) {
13687
13698
  suppressLinearResponseFlush = true;
13688
13699
  turnFailed = true;
@@ -13976,17 +13987,18 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13976
13987
  if (error instanceof ClaudeQuotaError) return error.kind;
13977
13988
  return detectAgentQuotaLimit(extractErrorText(error));
13978
13989
  }
13979
- static detectQuotaErrorInMessage(message, creditsRequired) {
13990
+ static detectQuotaErrorInMessage(message, creditsRequired, resetsAt) {
13991
+ const quotaError = (text2, kind2) => new ClaudeQuotaError(text2, creditsRequired ? "credits_required" : kind2, resetsAt);
13980
13992
  if (message.type === "assistant" && "error" in message) {
13981
13993
  const content = Array.isArray(message.message?.content) ? message.message.content.map((block) => "text" in block ? block.text : "").join("\n") : "";
13982
13994
  const text2 = [typeof message.error === "string" ? message.error : "", content].filter(Boolean).join("\n");
13983
13995
  const kind2 = detectAgentQuotaLimit(text2);
13984
- if (kind2) return new ClaudeQuotaError(text2, creditsRequired ? "credits_required" : kind2);
13996
+ if (kind2) return quotaError(text2, kind2);
13985
13997
  }
13986
13998
  if (message.type !== "result" || !message.is_error) return null;
13987
13999
  const text = message.subtype === "success" ? message.result : message.errors.join("\n");
13988
14000
  const kind = detectAgentQuotaLimit(text);
13989
- return kind ? new ClaudeQuotaError(text, creditsRequired ? "credits_required" : kind) : null;
14001
+ return kind ? quotaError(text, kind) : null;
13990
14002
  }
13991
14003
  static isTransientTurnError(error) {
13992
14004
  if (error instanceof ClaudeTransientTurnError) return true;
@@ -63789,7 +63801,7 @@ var chatService = new ChatService(
63789
63801
  agentChatActivityTrackerService,
63790
63802
  agentTokenUsageTracker
63791
63803
  );
63792
- app.get("/health", async (c) => {
63804
+ app.on("GET", ["/health", ENGINE_PROXY_SAFE_HEALTH_PATH], async (c) => {
63793
63805
  const requestedWaitMs = Number(c.req.query(ENGINE_HEALTH_WAIT_QUERY_PARAM));
63794
63806
  const waitMs = Number.isFinite(requestedWaitMs) ? Math.min(Math.max(requestedWaitMs, 0), ENGINE_HEALTH_MAX_WAIT_MS) : 0;
63795
63807
  if (!lifecycle.active && waitMs > 0) {
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  publishedPullRequestUrls
6
- } from "./chunk-G4UVARZK.js";
6
+ } from "./chunk-FQZ6YTN2.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-UUGSRQQJ.js";
12
+ } from "./chunk-7QJWP5ZL.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -11,7 +11,7 @@ import {
11
11
  spawnSubagentRequestSchema,
12
12
  subagentResponseSchema,
13
13
  waitSubagentRequestSchema
14
- } from "./chunk-UUGSRQQJ.js";
14
+ } from "./chunk-7QJWP5ZL.js";
15
15
  import "./chunk-VEQXQN22.js";
16
16
 
17
17
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1247",
3
+ "version": "0.1.1249",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",