replicas-engine 0.1.658 → 0.1.660

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.
@@ -638,7 +638,8 @@ function isAgentChatActivityRecord(value) {
638
638
  }
639
639
  var agentCredentialSnapshotSchema = z2.object({
640
640
  method: z2.enum(CREDENTIAL_METHOD),
641
- scope: z2.enum(CREDENTIAL_SCOPE)
641
+ scope: z2.enum(CREDENTIAL_SCOPE),
642
+ revision: z2.string().optional()
642
643
  });
643
644
  function isAuthMethod(value) {
644
645
  return typeof value === "string" && Object.values(CREDENTIAL_METHOD).some((method) => method === value);
@@ -6229,7 +6230,7 @@ var DEFAULT_CODEX_ARGS = [
6229
6230
  var MIN_CODEX_CLI_VERSION = "0.144.6";
6230
6231
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
6231
6232
  var codexCliVersionEnsured = null;
6232
- var ENGINE_PACKAGE_VERSION = "0.1.658";
6233
+ var ENGINE_PACKAGE_VERSION = "0.1.660";
6233
6234
  var INITIALIZE_METHOD = "initialize";
6234
6235
  var INITIALIZED_NOTIFICATION = "initialized";
6235
6236
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -7,7 +7,7 @@ import {
7
7
  headlessAgentRequestSchema,
8
8
  putPresignedFile,
9
9
  recoverCompletedTurn
10
- } from "./chunk-OY2CUZJZ.js";
10
+ } from "./chunk-DNFS3CV6.js";
11
11
 
12
12
  // src/headless-agent.ts
13
13
  import { createHash } from "crypto";
package/dist/src/index.js CHANGED
@@ -183,7 +183,7 @@ import {
183
183
  serializeCanvasContentResponse,
184
184
  shellQuotePosix,
185
185
  stripAgentDiagnosticErrors
186
- } from "./chunk-OY2CUZJZ.js";
186
+ } from "./chunk-DNFS3CV6.js";
187
187
 
188
188
  // src/index.ts
189
189
  import { serve } from "@hono/node-server";
@@ -1459,15 +1459,27 @@ var ClaudeTokenManager = class extends BaseRefreshManager {
1459
1459
  }
1460
1460
  const data = await response.json();
1461
1461
  await this.applyCredentialsResponse(data);
1462
- if (data.scope) setAgentCredentialSnapshot("claude", { method: data.type, scope: data.scope });
1462
+ if (data.scope) {
1463
+ setAgentCredentialSnapshot("claude", {
1464
+ method: data.type,
1465
+ scope: data.scope,
1466
+ ...data.revision ? { revision: data.revision } : {}
1467
+ });
1468
+ }
1463
1469
  console.log(`[ClaudeTokenManager] Credentials refreshed (method=${data.type})`);
1464
1470
  }
1465
- async fetchFreshCredentials(failureReason, failureKind = "rejected") {
1466
- const failedMethod = ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD;
1471
+ async fetchFreshCredentials(failureReason, failureKind = "rejected", failedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude) {
1472
+ const failedMethod = failedCredential?.method === "oauth" || failedCredential?.method === "api_key" || failedCredential?.method === "bedrock" || failedCredential?.method === "foundry" ? failedCredential.method : ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD;
1467
1473
  return this.swapCredentials({
1468
1474
  provider: "claude",
1469
1475
  failureKind,
1470
- refresh: (exclusions) => this.refreshWithRequest(failedMethod && failedMethod !== "none" ? { failedMethod, failureReason, failureKind, ...exclusions } : exclusions),
1476
+ refresh: (exclusions) => this.refreshWithRequest(failedMethod && failedMethod !== "none" ? {
1477
+ failedMethod,
1478
+ ...failedCredential?.method === failedMethod ? { failedCredential } : {},
1479
+ failureReason,
1480
+ failureKind,
1481
+ ...exclusions
1482
+ } : exclusions),
1471
1483
  isOauthNow: () => ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD === "oauth"
1472
1484
  });
1473
1485
  }
@@ -1555,16 +1567,28 @@ var CodexTokenManager = class extends BaseRefreshManager {
1555
1567
  }
1556
1568
  const data = await response.json();
1557
1569
  await this.applyCredentialsResponse(data);
1558
- if (data.scope) setAgentCredentialSnapshot("codex", { method: data.type, scope: data.scope });
1570
+ if (data.scope) {
1571
+ setAgentCredentialSnapshot("codex", {
1572
+ method: data.type,
1573
+ scope: data.scope,
1574
+ ...data.revision ? { revision: data.revision } : {}
1575
+ });
1576
+ }
1559
1577
  console.log(`[CodexTokenManager] Credentials refreshed (method=${data.type})`);
1560
1578
  }
1561
- async fetchFreshCredentials(failureReason, failureKind = "rejected") {
1562
- const failedMethod = ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD;
1579
+ async fetchFreshCredentials(failureReason, failureKind = "rejected", failedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex) {
1580
+ const failedMethod = failedCredential?.method === "oauth" || failedCredential?.method === "api_key" || failedCredential?.method === "foundry" ? failedCredential.method : ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD;
1563
1581
  return this.swapCredentials({
1564
1582
  provider: "codex",
1565
1583
  failureKind,
1566
1584
  refresh: (exclusions) => this.refreshWithRequest(
1567
- failedMethod === "oauth" || failedMethod === "api_key" || failedMethod === "foundry" ? { failedMethod, failureReason, failureKind, ...exclusions } : exclusions
1585
+ failedMethod === "oauth" || failedMethod === "api_key" || failedMethod === "foundry" ? {
1586
+ failedMethod,
1587
+ ...failedCredential?.method === failedMethod ? { failedCredential } : {},
1588
+ failureReason,
1589
+ failureKind,
1590
+ ...exclusions
1591
+ } : exclusions
1568
1592
  ),
1569
1593
  isOauthNow: () => ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD === "oauth"
1570
1594
  });
@@ -4763,6 +4787,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
4763
4787
  let currentRequest = request;
4764
4788
  try {
4765
4789
  while (true) {
4790
+ const attemptedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude;
4766
4791
  try {
4767
4792
  await this.executeQuery(currentRequest, { skipUserMessageRecord: attempt > 0 });
4768
4793
  return;
@@ -4793,7 +4818,9 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
4793
4818
  );
4794
4819
  this.setAuthRetrying(true);
4795
4820
  const refreshed = await claudeTokenManager.fetchFreshCredentials(
4796
- error instanceof Error ? error.message : String(error)
4821
+ error instanceof Error ? error.message : String(error),
4822
+ "rejected",
4823
+ attemptedCredential
4797
4824
  );
4798
4825
  if (!refreshed.ok) {
4799
4826
  authRetryExhausted = true;
@@ -6739,6 +6766,7 @@ var CodexAspManager = class extends CodingAgentManager {
6739
6766
  }
6740
6767
  await this.executeAspTurn(request, recordUserMessage);
6741
6768
  };
6769
+ let attemptedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex;
6742
6770
  try {
6743
6771
  await dispatch();
6744
6772
  } catch (error) {
@@ -6750,6 +6778,7 @@ var CodexAspManager = class extends CodingAgentManager {
6750
6778
  terminalError.message
6751
6779
  );
6752
6780
  if (outcome === "switched") {
6781
+ attemptedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex;
6753
6782
  const retryFailure = await this.restartAndRetry(dispatch);
6754
6783
  if (!retryFailure) return;
6755
6784
  terminalError = retryFailure.error;
@@ -6758,7 +6787,11 @@ var CodexAspManager = class extends CodingAgentManager {
6758
6787
  }
6759
6788
  }
6760
6789
  if (isCodexAuthError(terminalError)) {
6761
- const refreshed = await codexTokenManager.fetchFreshCredentials(terminalError instanceof Error ? terminalError.message : String(terminalError));
6790
+ const refreshed = await codexTokenManager.fetchFreshCredentials(
6791
+ terminalError instanceof Error ? terminalError.message : String(terminalError),
6792
+ "rejected",
6793
+ attemptedCredential
6794
+ );
6762
6795
  if (refreshed.ok) {
6763
6796
  const retryFailure = await this.restartAndRetry(dispatch);
6764
6797
  if (!retryFailure) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.658",
3
+ "version": "0.1.660",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",