replicas-engine 0.1.1210 → 0.1.1212

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.
@@ -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-I3URDWNH.js";
6
+ } from "./chunk-ZCHENOLM.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-QNL3RGIJ.js";
16
+ } from "./chunk-FTRFBB2U.js";
17
17
 
18
18
  // src/managers/codex-asp/notification-dispatch.ts
19
19
  var TURN_STARTED_METHOD = "turn/started";
@@ -5,14 +5,14 @@ import {
5
5
  getOriginDefaultBranch,
6
6
  monolithRequest,
7
7
  runGitCommand
8
- } from "./chunk-WF66TH2R.js";
8
+ } from "./chunk-BTWJMRHR.js";
9
9
  import {
10
10
  extractCommandProtectionCommandText,
11
11
  findCommandProtectionGitLookups,
12
12
  findGitCommitSignals,
13
13
  findPrMergeSignals,
14
14
  parseCommandProtectionRequest
15
- } from "./chunk-QNL3RGIJ.js";
15
+ } from "./chunk-FTRFBB2U.js";
16
16
 
17
17
  // src/services/command-protection-service.ts
18
18
  import { readFile, stat } from "fs/promises";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-QNL3RGIJ.js";
8
+ } from "./chunk-FTRFBB2U.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -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-JVBVO5SM.js";
6
+ } from "./chunk-72NORPKS.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-QNL3RGIJ.js";
9
+ } from "./chunk-FTRFBB2U.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.1210";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1212";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -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-H46YGVWX.js";
7
- import "./chunk-WF66TH2R.js";
8
- import "./chunk-JVBVO5SM.js";
6
+ } from "./chunk-K6TRY5YR.js";
7
+ import "./chunk-BTWJMRHR.js";
8
+ import "./chunk-72NORPKS.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-QNL3RGIJ.js";
12
+ import "./chunk-FTRFBB2U.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-PS2ARUWT.js";
16
+ } from "./chunk-JSBTLSXI.js";
17
17
  import {
18
18
  AppServerProcess,
19
19
  buildCodexAgentEnv
20
- } from "./chunk-I3URDWNH.js";
21
- import "./chunk-JVBVO5SM.js";
20
+ } from "./chunk-ZCHENOLM.js";
21
+ import "./chunk-72NORPKS.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-QNL3RGIJ.js";
31
+ } from "./chunk-FTRFBB2U.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-H46YGVWX.js";
30
+ } from "./chunk-K6TRY5YR.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-PS2ARUWT.js";
67
+ } from "./chunk-JSBTLSXI.js";
68
68
  import {
69
69
  publishedPullRequestUrls
70
- } from "./chunk-BFXPBH4O.js";
70
+ } from "./chunk-N2ZH26HY.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-GWT3LWTC.js";
143
+ } from "./chunk-C5IXAOYE.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-WF66TH2R.js";
152
+ } from "./chunk-BTWJMRHR.js";
153
153
  import {
154
154
  getCodexModelProvider
155
- } from "./chunk-I3URDWNH.js";
155
+ } from "./chunk-ZCHENOLM.js";
156
156
  import {
157
157
  SUBPROCESS_MAX_BUFFER,
158
158
  execAsync,
159
159
  execFileAsync
160
- } from "./chunk-JVBVO5SM.js";
160
+ } from "./chunk-72NORPKS.js";
161
161
  import {
162
162
  isRecord as isRecord2
163
163
  } from "./chunk-UZSNFLDQ.js";
@@ -287,10 +287,12 @@ import {
287
287
  detectAgentQuotaLimit,
288
288
  detectEnvironmentAuthMethod,
289
289
  detectLanguageByPath,
290
+ engineCredentialRefreshFailureSchema,
290
291
  engineMcpOAuthTokenResponseSchema,
291
292
  excludeQueuedAcceptedEvents,
292
293
  extractErrorText,
293
294
  extractFinalResponse,
295
+ extractJsonObject,
294
296
  extractLatestContextUsage,
295
297
  extractToolResultText,
296
298
  fetchOpenCodeGoCatalog,
@@ -392,7 +394,7 @@ import {
392
394
  workspaceTokenRequestSchema,
393
395
  workspaceTokenResponseSchema,
394
396
  wrapInTag
395
- } from "./chunk-QNL3RGIJ.js";
397
+ } from "./chunk-FTRFBB2U.js";
396
398
  import {
397
399
  cloneMcpConfig,
398
400
  ensureCompatibilityImports,
@@ -11072,6 +11074,14 @@ function describeQuotaExhaustion(provider, reason, credential, fallback) {
11072
11074
  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];
11073
11075
  return `${limit} ${next}`;
11074
11076
  }
11077
+ function describeLoginFailure(provider, login, configuredMethod, revoked) {
11078
+ const agent = getProviderDisplayName(provider);
11079
+ const method = login?.method ?? configuredMethod;
11080
+ const name = login ? describeCredential(provider, login) : `the ${agent} credential this workspace uses`;
11081
+ const why = revoked ? "It was signed out, revoked, or expired." : method === "api_key" ? "The key may be invalid, revoked, out of credits, or missing access to the selected model." : method === "bedrock" ? "Check its credentials, region, IAM permissions, and Claude model access." : method === "foundry" ? `Check its API key, resource, and ${agent} deployment names.` : "It was rejected even after a refresh.";
11082
+ const reconnect = login?.scope === CREDENTIAL_SCOPE.ORG ? `An organization admin can reconnect it in Organization \u2192 Coding Agents: ${DEFAULT_WEB_APP_URL}${WEB_APP_PATHS.agents}` : `Reconnect it in Personal \u2192 Coding Agents: ${DEFAULT_WEB_APP_URL}${WEB_APP_PATHS.accountAgents}`;
11083
+ return `${agent} could not sign in with ${name}. ${why} ${reconnect}`;
11084
+ }
11075
11085
  var fallbackLocks = /* @__PURE__ */ new Map();
11076
11086
  var AuthFallbackCoordinator = class {
11077
11087
  constructor(provider, record3, context) {
@@ -13064,6 +13074,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13064
13074
  let lastError;
13065
13075
  let failedLogin;
13066
13076
  let loginRevoked = false;
13077
+ let namedLogin;
13067
13078
  let fallbacks = 0;
13068
13079
  let attempt = 0;
13069
13080
  let authRetries = 0;
@@ -13106,7 +13117,9 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13106
13117
  continue;
13107
13118
  }
13108
13119
  const method = attemptedCredential?.method ?? resolveClaudeAuthMethodForMessage();
13109
- loginRevoked = (method === "oauth" || method === "unknown") && refreshed.error.message.includes('"code":"oauth_disconnected"');
13120
+ const failure = engineCredentialRefreshFailureSchema.safeParse(extractJsonObject(refreshed.error.message)).data;
13121
+ loginRevoked = (method === "oauth" || method === "unknown") && failure?.code === "oauth_disconnected";
13122
+ namedLogin = failure?.credential;
13110
13123
  }
13111
13124
  if (quotaKind || isAuthError) {
13112
13125
  const reason = quotaKind ?? "auth_failed";
@@ -13117,6 +13130,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13117
13130
  fallbacks++;
13118
13131
  authRetries = 0;
13119
13132
  loginRevoked = false;
13133
+ namedLogin = void 0;
13120
13134
  await this.tearDownSession();
13121
13135
  attempt++;
13122
13136
  continue;
@@ -13125,7 +13139,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13125
13139
  await this.emitQuotaExhaustedEvent(quotaKind, fallback, detail, attemptedCredential);
13126
13140
  return;
13127
13141
  }
13128
- failedLogin = { credential: attemptedCredential, revoked: loginRevoked };
13142
+ failedLogin = { credential: attemptedCredential ?? namedLogin, revoked: loginRevoked };
13129
13143
  throw error;
13130
13144
  }
13131
13145
  if (error instanceof ClaudeMissingSessionError && !missingSessionReset) {
@@ -13204,14 +13218,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
13204
13218
  }
13205
13219
  async emitAuthRetryExhaustedEvent(error, login, revoked) {
13206
13220
  const detail = error instanceof Error ? error.message : String(error);
13207
- await this.emitTerminalErrorResult(detail, [_ClaudeManager.authFailureMessage(login, revoked)]);
13208
- }
13209
- static authFailureMessage(login, revoked) {
13210
- const method = login?.method ?? resolveClaudeAuthMethodForMessage();
13211
- const name = login ? describeCredential("claude", login) : "the Claude credential this workspace uses";
13212
- const why = revoked ? "It was signed out, revoked, or expired." : method === "api_key" ? "The key may be invalid, revoked, out of credits, or missing access to the selected model." : method === "bedrock" ? "Check its credentials, region, IAM permissions, and Claude model access." : method === "foundry" ? "Check its API key, resource, and Claude deployment names." : "It was rejected even after a refresh.";
13213
- const reconnect = login?.scope === CREDENTIAL_SCOPE.ORG ? `An organization admin can reconnect it in Organization \u2192 Coding Agents: ${DEFAULT_WEB_APP_URL}${WEB_APP_PATHS.agents}` : `Reconnect it in Personal \u2192 Coding Agents: ${DEFAULT_WEB_APP_URL}${WEB_APP_PATHS.accountAgents}`;
13214
- return `Claude could not sign in with ${name}. ${why} ${reconnect}`;
13221
+ await this.emitTerminalErrorResult(detail, [describeLoginFailure("claude", login, resolveClaudeAuthMethodForMessage(), revoked)]);
13215
13222
  }
13216
13223
  async emitQuotaExhaustedEvent(kind, fallback, detail, credential) {
13217
13224
  await this.emitTerminalErrorResult(detail, [describeQuotaExhaustion("claude", kind, credential, fallback)]);
@@ -14529,6 +14536,7 @@ var CodexAspManager = class extends CodingAgentManager {
14529
14536
  if (!retryFailure) return;
14530
14537
  terminalError = retryFailure.error;
14531
14538
  }
14539
+ let loginFailure = null;
14532
14540
  if (isCodexAuthError(terminalError)) {
14533
14541
  const refreshed = await codexTokenManager.fetchFreshCredentials(
14534
14542
  terminalError instanceof Error ? terminalError.message : String(terminalError),
@@ -14540,6 +14548,17 @@ var CodexAspManager = class extends CodingAgentManager {
14540
14548
  if (!retryFailure) return;
14541
14549
  terminalError = retryFailure.error;
14542
14550
  }
14551
+ if (isCodexAuthError(terminalError)) {
14552
+ const failure = refreshed.ok ? null : engineCredentialRefreshFailureSchema.safeParse(extractJsonObject(refreshed.error.message)).data;
14553
+ const login = refreshed.ok ? ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex : attemptedCredential ?? failure?.credential;
14554
+ const method = login?.method ?? ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD;
14555
+ loginFailure = describeLoginFailure(
14556
+ "codex",
14557
+ login,
14558
+ ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD,
14559
+ (!method || method === "oauth") && failure?.code === "oauth_disconnected"
14560
+ );
14561
+ }
14543
14562
  }
14544
14563
  const message = terminalError instanceof Error ? terminalError.message : String(terminalError);
14545
14564
  const failedTurnId = this.lastTurnFailure?.message === message ? this.lastTurnFailure.turnId : null;
@@ -14548,6 +14567,7 @@ var CodexAspManager = class extends CodingAgentManager {
14548
14567
  ...failedTurnId ? { [CODEX_ASP_ITEM_ID_PAYLOAD_KEY]: failedTurnId } : {}
14549
14568
  });
14550
14569
  this.onEvent(event);
14570
+ if (loginFailure) this.onEvent(this.recordCodexHistoryEvent("codex-asp-error", { message: loginFailure }));
14551
14571
  throw terminalError;
14552
14572
  } finally {
14553
14573
  this.itemUpdateCoalescer.flushPending();
@@ -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-BFXPBH4O.js";
6
+ } from "./chunk-N2ZH26HY.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-QNL3RGIJ.js";
12
+ } from "./chunk-FTRFBB2U.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-QNL3RGIJ.js";
12
+ } from "./chunk-FTRFBB2U.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.1210",
3
+ "version": "0.1.1212",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",