replicas-engine 0.1.657 → 0.1.659

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);
@@ -4443,11 +4444,14 @@ function parseDeepseekEvents(events) {
4443
4444
  continue;
4444
4445
  }
4445
4446
  if (event.type === "tool/result") {
4446
- const callId = typeof data.callId === "string" ? data.callId : String(seq);
4447
- const existing = messages.find((message) => message.id === `deepseek-tool-${callId}` && message.type === "tool_call");
4447
+ const message = isRecord(data.message) ? data.message : {};
4448
+ const messageSource = isRecord(message.source) ? message.source : {};
4449
+ const result = Array.isArray(message.content) && isRecord(message.content[0]) ? message.content[0] : {};
4450
+ const callId = typeof messageSource.callId === "string" ? messageSource.callId : typeof data.callId === "string" ? data.callId : String(seq);
4451
+ const existing = messages.find((message2) => message2.id === `deepseek-tool-${callId}` && message2.type === "tool_call");
4448
4452
  if (existing?.type === "tool_call") {
4449
- existing.output = stringifyDisplayValue(data.message ?? data.result);
4450
- existing.status = data.isError === true ? "failed" : "completed";
4453
+ existing.output = stringifyDisplayValue(result.content ?? data.result);
4454
+ existing.status = result.isError === true || data.isError === true ? "failed" : "completed";
4451
4455
  }
4452
4456
  continue;
4453
4457
  }
@@ -6226,7 +6230,7 @@ var DEFAULT_CODEX_ARGS = [
6226
6230
  var MIN_CODEX_CLI_VERSION = "0.144.6";
6227
6231
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
6228
6232
  var codexCliVersionEnsured = null;
6229
- var ENGINE_PACKAGE_VERSION = "0.1.657";
6233
+ var ENGINE_PACKAGE_VERSION = "0.1.659";
6230
6234
  var INITIALIZE_METHOD = "initialize";
6231
6235
  var INITIALIZED_NOTIFICATION = "initialized";
6232
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-HF62RZGX.js";
10
+ } from "./chunk-OFT63LK5.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-HF62RZGX.js";
186
+ } from "./chunk-OFT63LK5.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;
@@ -8331,7 +8364,7 @@ var DeepseekManager = class extends CodingAgentManager {
8331
8364
  DEEPSEEK_API_KEY: apiKey,
8332
8365
  DEEPSEEK_BASE_URL: "https://openrouter.ai/api/v1",
8333
8366
  DSH_HOME: join21(ENGINE_ENV.HOME_DIR, ".replicas", "deepseek"),
8334
- DSH_PERMISSION_MODE: "workspace-write",
8367
+ DSH_PERMISSION_MODE: "danger-full-access",
8335
8368
  DSH_TELEMETRY_DISABLED: "true"
8336
8369
  },
8337
8370
  stdio: ["ignore", "pipe", "pipe"]
@@ -8464,6 +8497,7 @@ var DeepseekManager = class extends CodingAgentManager {
8464
8497
  this.sessionId = unwrap(await client.sessions.create({ cwd: this.workingDirectory })).sessionId;
8465
8498
  await this.onSaveSessionId(this.sessionId);
8466
8499
  }
8500
+ await client.executeCommand(this.sessionId, "/permission danger-full-access");
8467
8501
  const model = request.model ?? DEFAULT_DEEPSEEK_MODEL;
8468
8502
  this.selectedModel = model;
8469
8503
  const current = unwrap(await client.sessions.models({ sessionId: this.sessionId })).current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.657",
3
+ "version": "0.1.659",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",