replicas-engine 0.1.1206 → 0.1.1207

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-6SGFHVNY.js";
12
- import "./chunk-7JJZWIT5.js";
13
- import "./chunk-PWUGAZDK.js";
14
- import "./chunk-SCA3IQKD.js";
11
+ } from "./chunk-EF6KRJ3M.js";
12
+ import "./chunk-KDEQVFNS.js";
13
+ import "./chunk-HHE27FT5.js";
14
+ import "./chunk-7KFWEP2H.js";
15
15
  import "./chunk-UZSNFLDQ.js";
16
- import "./chunk-C3HTI2BQ.js";
16
+ import "./chunk-T2AQMKMR.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-C3HTI2BQ.js";
6
+ } from "./chunk-T2AQMKMR.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-7JJZWIT5.js";
8
+ } from "./chunk-KDEQVFNS.js";
9
9
  import {
10
10
  extractCommandProtectionCommandText,
11
11
  findCommandProtectionGitLookups,
12
12
  findGitCommitSignals,
13
13
  findPrMergeSignals,
14
14
  parseCommandProtectionRequest
15
- } from "./chunk-C3HTI2BQ.js";
15
+ } from "./chunk-T2AQMKMR.js";
16
16
 
17
17
  // src/services/command-protection-service.ts
18
18
  import { readFile, stat } from "fs/promises";
@@ -10,15 +10,15 @@ import {
10
10
  resolveDiffBase,
11
11
  runGitCommand,
12
12
  setAgentCredentialSnapshot
13
- } from "./chunk-7JJZWIT5.js";
13
+ } from "./chunk-KDEQVFNS.js";
14
14
  import {
15
15
  AppServerProcess,
16
16
  buildCodexAgentEnv
17
- } from "./chunk-PWUGAZDK.js";
17
+ } from "./chunk-HHE27FT5.js";
18
18
  import {
19
19
  SUBPROCESS_MAX_BUFFER,
20
20
  execFileAsync
21
- } from "./chunk-SCA3IQKD.js";
21
+ } from "./chunk-7KFWEP2H.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-C3HTI2BQ.js";
58
+ } from "./chunk-T2AQMKMR.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-2BJURCM7.js");
294
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-AMENRRVC.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-2BJURCM7.js");
316
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-AMENRRVC.js");
317
317
  await restartCodexAspHostIfRunning2();
318
318
  }
319
319
  setAgentCredentialSnapshot("codex", data);
@@ -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-PWUGAZDK.js";
6
+ } from "./chunk-HHE27FT5.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-C3HTI2BQ.js";
16
+ } from "./chunk-T2AQMKMR.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-SCA3IQKD.js";
6
+ } from "./chunk-7KFWEP2H.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-C3HTI2BQ.js";
9
+ } from "./chunk-T2AQMKMR.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.1206";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1207";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  SUBPROCESS_MAX_BUFFER,
6
6
  execFileAsync
7
- } from "./chunk-SCA3IQKD.js";
7
+ } from "./chunk-7KFWEP2H.js";
8
8
  import {
9
9
  isRecord as isRecord2
10
10
  } from "./chunk-UZSNFLDQ.js";
@@ -18,7 +18,7 @@ import {
18
18
  isValidAgentProvider,
19
19
  parsePosixEnvFile,
20
20
  readReplicasRuntimeEnv
21
- } from "./chunk-C3HTI2BQ.js";
21
+ } from "./chunk-T2AQMKMR.js";
22
22
 
23
23
  // src/runtime-env-loader.ts
24
24
  import { readFileSync } from "fs";
@@ -870,7 +870,7 @@ function paginateEngineLogContent(input) {
870
870
  }
871
871
 
872
872
  // ../shared/src/agent-quota.ts
873
- var AGENT_FALLBACK_REASONS = ["rate_limit", "out_of_credits", "auth_failed"];
873
+ var AGENT_FALLBACK_REASONS = ["rate_limit", "out_of_credits", "credits_required", "auth_failed"];
874
874
  function isAgentFallbackReason(value) {
875
875
  return AGENT_FALLBACK_REASONS.some((reason) => reason === value);
876
876
  }
@@ -2173,7 +2173,7 @@ function describeAuthFallback(payload) {
2173
2173
  });
2174
2174
  const switched = payload.status === "switched";
2175
2175
  return {
2176
- headline: payload.reason === "out_of_credits" ? `${agent} is out of credits on ${exhausted}` : payload.reason === "auth_failed" ? `${agent} could not authenticate with ${exhausted}` : `${agent} hit its usage limit on ${exhausted}`,
2176
+ headline: payload.reason === "out_of_credits" ? `${agent} is out of credits on ${exhausted}` : payload.reason === "auth_failed" ? `${agent} could not authenticate with ${exhausted}` : payload.reason === "credits_required" ? `The selected model needs usage credits on ${exhausted}` : `${agent} hit its usage limit on ${exhausted}`,
2177
2177
  outcomeClause: switched ? `switched to ${describeCredential(payload.provider, {
2178
2178
  method: payload.candidateMethod,
2179
2179
  scope: payload.candidateScope,
@@ -2255,6 +2255,7 @@ var forkChatRequestSchema = z9.object({
2255
2255
  });
2256
2256
  function describeQuotaLimit(reason) {
2257
2257
  if (reason === "auth_failed") return "could not authenticate";
2258
+ if (reason === "credits_required") return "needed usage credits for the selected model";
2258
2259
  return reason === "out_of_credits" ? "ran out of credits" : "hit its usage limit";
2259
2260
  }
2260
2261
  function describeChatForkReason(reason, provider2) {
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-C3HTI2BQ.js";
8
+ } from "./chunk-T2AQMKMR.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -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-KN22LR36.js";
7
- import "./chunk-7JJZWIT5.js";
8
- import "./chunk-SCA3IQKD.js";
6
+ } from "./chunk-BDG3ZBSX.js";
7
+ import "./chunk-KDEQVFNS.js";
8
+ import "./chunk-7KFWEP2H.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-C3HTI2BQ.js";
12
+ import "./chunk-T2AQMKMR.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-QN2KQMX3.js";
16
+ } from "./chunk-HFDKOF2D.js";
17
17
  import {
18
18
  AppServerProcess,
19
19
  buildCodexAgentEnv
20
- } from "./chunk-PWUGAZDK.js";
21
- import "./chunk-SCA3IQKD.js";
20
+ } from "./chunk-HHE27FT5.js";
21
+ import "./chunk-7KFWEP2H.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-C3HTI2BQ.js";
31
+ } from "./chunk-T2AQMKMR.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-KN22LR36.js";
30
+ } from "./chunk-BDG3ZBSX.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-QN2KQMX3.js";
67
+ } from "./chunk-HFDKOF2D.js";
68
68
  import {
69
69
  publishedPullRequestUrls
70
- } from "./chunk-YT7BF2FG.js";
70
+ } from "./chunk-V6WTK62K.js";
71
71
  import {
72
72
  ACCOUNT_RATE_LIMITS_READ_METHOD,
73
73
  AsyncLock,
@@ -139,7 +139,7 @@ import {
139
139
  timestampFromSeconds,
140
140
  upsertCredentialFileLines,
141
141
  writeSecureCredentialFile
142
- } from "./chunk-6SGFHVNY.js";
142
+ } from "./chunk-EF6KRJ3M.js";
143
143
  import {
144
144
  ENGINE_ENV,
145
145
  monolithRequest,
@@ -148,15 +148,15 @@ import {
148
148
  reloadEngineEnv,
149
149
  resolveDiffBase,
150
150
  setAgentCredentialSnapshot
151
- } from "./chunk-7JJZWIT5.js";
151
+ } from "./chunk-KDEQVFNS.js";
152
152
  import {
153
153
  getCodexModelProvider
154
- } from "./chunk-PWUGAZDK.js";
154
+ } from "./chunk-HHE27FT5.js";
155
155
  import {
156
156
  SUBPROCESS_MAX_BUFFER,
157
157
  execAsync,
158
158
  execFileAsync
159
- } from "./chunk-SCA3IQKD.js";
159
+ } from "./chunk-7KFWEP2H.js";
160
160
  import {
161
161
  isRecord as isRecord2
162
162
  } from "./chunk-UZSNFLDQ.js";
@@ -391,7 +391,7 @@ import {
391
391
  workspaceTokenRequestSchema,
392
392
  workspaceTokenResponseSchema,
393
393
  wrapInTag
394
- } from "./chunk-C3HTI2BQ.js";
394
+ } from "./chunk-T2AQMKMR.js";
395
395
  import {
396
396
  cloneMcpConfig,
397
397
  ensureCompatibilityImports,
@@ -11066,8 +11066,8 @@ var QUOTA_STOP_NEXT_STEP = {
11066
11066
  function describeQuotaExhaustion(provider, reason, credential, fallback) {
11067
11067
  const agent = getProviderDisplayName(provider);
11068
11068
  const account = credential ? describeCredential(provider, credential) : "the credential this workspace is using";
11069
- const limit = reason === "out_of_credits" ? `${agent} ran out of credits on ${account}.` : `${agent} hit the usage limit on ${account}.`;
11070
- const next = fallback.outcome === "fork" ? `Continuing in ${getProviderDisplayName(fallback.target.provider, "long")}.` : QUOTA_STOP_NEXT_STEP[fallback.outcome];
11069
+ const limit = reason === "credits_required" ? `The selected model needs usage credits on ${account}.` : reason === "out_of_credits" ? `${agent} ran out of credits on ${account}.` : `${agent} hit the usage limit on ${account}.`;
11070
+ const next = fallback.outcome === "fork" ? `Continuing in ${getProviderDisplayName(fallback.target.provider, "long")}.` : reason === "credits_required" ? "Pick a different model, or turn on usage credits for this account." : QUOTA_STOP_NEXT_STEP[fallback.outcome];
11071
11071
  return `${limit} ${next}`;
11072
11072
  }
11073
11073
  var fallbackLocks = /* @__PURE__ */ new Map();
@@ -11120,9 +11120,8 @@ var AuthFallbackCoordinator = class {
11120
11120
  if (!tokenManager || !exhausted) continue;
11121
11121
  const swap = await tokenManager.fetchFreshCredentials(
11122
11122
  `${this.provider} ${describeQuotaLimit(reason)}: ${detail}`,
11123
- // A rejected login is skipped through the exclusion above rather than rested
11124
- // like a spent quota, which Settings would show as a usage limit.
11125
- reason === "auth_failed" ? "rejected" : "exhausted",
11123
+ // Skipped via the exclusion above, not rested, so Settings doesn't show a usage limit.
11124
+ reason === "auth_failed" || reason === "credits_required" ? "rejected" : "exhausted",
11126
11125
  exhausted,
11127
11126
  step.methods.length > 0 ? step.methods : void 0
11128
11127
  );
@@ -13525,15 +13524,17 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13525
13524
  const iterator = response[Symbol.asyncIterator]();
13526
13525
  let loopError = null;
13527
13526
  let suppressLinearResponseFlush = false;
13527
+ let creditsRequired = false;
13528
13528
  try {
13529
13529
  while (true) {
13530
13530
  const next = await iterator.next();
13531
13531
  if (next.done || this.activeQuery !== response) break;
13532
13532
  const msg = next.value;
13533
13533
  if (!msg) break;
13534
+ if (msg.type === "rate_limit_event") creditsRequired = msg.rate_limit_info.errorCode === "credits_required";
13534
13535
  const authErrorMessage = _ClaudeManager.detectAuthErrorInMessage(msg);
13535
13536
  const transientErrorMessage = _ClaudeManager.detectTransientTurnErrorInMessage(msg);
13536
- 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) ?? (transientErrorMessage ? new ClaudeTransientTurnError(transientErrorMessage, this.pendingTurn?.sawActivity ?? false) : null);
13537
+ 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);
13537
13538
  if (turnError) {
13538
13539
  suppressLinearResponseFlush = true;
13539
13540
  this.failPendingTurn(turnError);
@@ -13797,17 +13798,17 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13797
13798
  if (error instanceof ClaudeQuotaError) return error.kind;
13798
13799
  return detectAgentQuotaLimit(extractErrorText(error));
13799
13800
  }
13800
- static detectQuotaErrorInMessage(message) {
13801
+ static detectQuotaErrorInMessage(message, creditsRequired) {
13801
13802
  if (message.type === "assistant" && "error" in message) {
13802
13803
  const content = Array.isArray(message.message?.content) ? message.message.content.map((block) => "text" in block ? block.text : "").join("\n") : "";
13803
13804
  const text2 = [typeof message.error === "string" ? message.error : "", content].filter(Boolean).join("\n");
13804
13805
  const kind2 = detectAgentQuotaLimit(text2);
13805
- if (kind2) return new ClaudeQuotaError(text2, kind2);
13806
+ if (kind2) return new ClaudeQuotaError(text2, creditsRequired ? "credits_required" : kind2);
13806
13807
  }
13807
13808
  if (message.type !== "result" || !message.is_error) return null;
13808
13809
  const text = message.subtype === "success" ? message.result : message.errors.join("\n");
13809
13810
  const kind = detectAgentQuotaLimit(text);
13810
- return kind ? new ClaudeQuotaError(text, kind) : null;
13811
+ return kind ? new ClaudeQuotaError(text, creditsRequired ? "credits_required" : kind) : null;
13811
13812
  }
13812
13813
  static isTransientTurnError(error) {
13813
13814
  if (error instanceof ClaudeTransientTurnError) return true;
@@ -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-YT7BF2FG.js";
6
+ } from "./chunk-V6WTK62K.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-C3HTI2BQ.js";
12
+ } from "./chunk-T2AQMKMR.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/services/post-tool-pr-notifier.ts
@@ -9,7 +9,7 @@ import {
9
9
  spawnSubagentRequestSchema,
10
10
  subagentResponseSchema,
11
11
  waitSubagentRequestSchema
12
- } from "./chunk-C3HTI2BQ.js";
12
+ } from "./chunk-T2AQMKMR.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/subagent-mcp.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.1206",
3
+ "version": "0.1.1207",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",