replicas-engine 0.1.1008 → 0.1.1010

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.
@@ -5,12 +5,12 @@ import {
5
5
  getCodexAspHost,
6
6
  restartCodexAspHost,
7
7
  restartCodexAspHostIfRunning
8
- } from "./chunk-5S6KOQGD.js";
9
- import "./chunk-XS7ZRCT2.js";
10
- import "./chunk-ZWQGNLNE.js";
11
- import "./chunk-6DNBBHFB.js";
8
+ } from "./chunk-QIACJ5UF.js";
9
+ import "./chunk-U7VFQQV4.js";
10
+ import "./chunk-3SMYITBO.js";
11
+ import "./chunk-RRKTSN4S.js";
12
12
  import "./chunk-UZSNFLDQ.js";
13
- import "./chunk-UFWZKCZ2.js";
13
+ import "./chunk-GU4OGSPA.js";
14
14
  import "./chunk-VEQXQN22.js";
15
15
  export {
16
16
  getCodexAspHost,
@@ -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-6DNBBHFB.js";
6
+ } from "./chunk-RRKTSN4S.js";
7
7
  import {
8
8
  isVersionBelow
9
- } from "./chunk-UFWZKCZ2.js";
9
+ } from "./chunk-GU4OGSPA.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.1008";
243
+ var ENGINE_PACKAGE_VERSION = "0.1.1010";
244
244
  var INITIALIZE_METHOD = "initialize";
245
245
  var INITIALIZED_NOTIFICATION = "initialized";
246
246
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -5,7 +5,7 @@ import {
5
5
  extractCommandProtectionCommandText,
6
6
  isRecord,
7
7
  parseCodeHostPrUrl
8
- } from "./chunk-UFWZKCZ2.js";
8
+ } from "./chunk-GU4OGSPA.js";
9
9
 
10
10
  // src/services/published-pull-request-urls.ts
11
11
  function publishedPullRequestUrls(result) {
@@ -9321,7 +9321,6 @@ export {
9321
9321
  SUBAGENT_MCP_TOOLS,
9322
9322
  SUBAGENT_MCP_TOOL_NAMES,
9323
9323
  headlessAgentRequestSchema,
9324
- isAuthenticationErrorText,
9325
9324
  isClaudeAuthErrorText,
9326
9325
  isCodexAuthError,
9327
9326
  serializeMuseAuthFile,
@@ -3,18 +3,18 @@ import { createRequire as __createRequire } from 'node:module';
3
3
  const require = __createRequire(import.meta.url);
4
4
  import {
5
5
  monolithRequest
6
- } from "./chunk-XS7ZRCT2.js";
6
+ } from "./chunk-U7VFQQV4.js";
7
7
  import {
8
8
  SUBPROCESS_MAX_BUFFER,
9
9
  execFileAsync
10
- } from "./chunk-6DNBBHFB.js";
10
+ } from "./chunk-RRKTSN4S.js";
11
11
  import {
12
12
  extractCommandProtectionCommandText,
13
13
  findCommandProtectionGitLookups,
14
14
  findGitCommitSignals,
15
15
  findPrMergeSignals,
16
16
  parseCommandProtectionRequest
17
- } from "./chunk-UFWZKCZ2.js";
17
+ } from "./chunk-GU4OGSPA.js";
18
18
 
19
19
  // src/services/command-protection-service.ts
20
20
  import { readFile, stat } from "fs/promises";
@@ -5,15 +5,15 @@ import {
5
5
  ENGINE_ENV,
6
6
  monolithRequest,
7
7
  setAgentCredentialSnapshot
8
- } from "./chunk-XS7ZRCT2.js";
8
+ } from "./chunk-U7VFQQV4.js";
9
9
  import {
10
10
  AppServerProcess,
11
11
  buildCodexAgentEnv
12
- } from "./chunk-ZWQGNLNE.js";
12
+ } from "./chunk-3SMYITBO.js";
13
13
  import {
14
14
  SUBPROCESS_MAX_BUFFER,
15
15
  execFileAsync
16
- } from "./chunk-6DNBBHFB.js";
16
+ } from "./chunk-RRKTSN4S.js";
17
17
  import {
18
18
  isRecord
19
19
  } from "./chunk-UZSNFLDQ.js";
@@ -28,7 +28,7 @@ import {
28
28
  listOpenAICompatibleModels,
29
29
  readOllamaAuthEnv,
30
30
  resolveOpenAICompatibleModelsUrl
31
- } from "./chunk-UFWZKCZ2.js";
31
+ } from "./chunk-GU4OGSPA.js";
32
32
 
33
33
  // src/managers/codex-token-manager.ts
34
34
  import { promises as fs } from "fs";
@@ -264,7 +264,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
264
264
  await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
265
265
  await this.applyCredentialsResponse(data);
266
266
  setAgentCredentialSnapshot("codex", data);
267
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-JPVVE5ZK.js");
267
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-LQV2Q6HJ.js");
268
268
  await restartCodexAspHostIfRunning2();
269
269
  });
270
270
  await this.start(true);
@@ -285,7 +285,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
285
285
  const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
286
286
  await this.applyCredentialsResponse(data);
287
287
  if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
288
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-JPVVE5ZK.js");
288
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-LQV2Q6HJ.js");
289
289
  await restartCodexAspHostIfRunning2();
290
290
  }
291
291
  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
  HOOK_EXEC_MAX_BUFFER_BYTES
6
- } from "./chunk-UFWZKCZ2.js";
6
+ } from "./chunk-GU4OGSPA.js";
7
7
 
8
8
  // src/utils/exec.ts
9
9
  import { exec, execFile } from "child_process";
@@ -14,7 +14,7 @@ import {
14
14
  isValidAgentProvider,
15
15
  parsePosixEnvFile,
16
16
  readReplicasRuntimeEnv
17
- } from "./chunk-UFWZKCZ2.js";
17
+ } from "./chunk-GU4OGSPA.js";
18
18
 
19
19
  // src/runtime-env-loader.ts
20
20
  import { readFileSync } from "fs";
@@ -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-XTDADQOV.js";
7
- import "./chunk-XS7ZRCT2.js";
8
- import "./chunk-6DNBBHFB.js";
6
+ } from "./chunk-H4XZMWVS.js";
7
+ import "./chunk-U7VFQQV4.js";
8
+ import "./chunk-RRKTSN4S.js";
9
9
  import {
10
10
  isRecord
11
11
  } from "./chunk-UZSNFLDQ.js";
12
- import "./chunk-UFWZKCZ2.js";
12
+ import "./chunk-GU4OGSPA.js";
13
13
  import "./chunk-VEQXQN22.js";
14
14
 
15
15
  // src/command-protection-hook.ts
@@ -7,12 +7,12 @@ import {
7
7
  import {
8
8
  AppServerProcess,
9
9
  buildCodexAgentEnv
10
- } from "./chunk-ZWQGNLNE.js";
11
- import "./chunk-6DNBBHFB.js";
10
+ } from "./chunk-3SMYITBO.js";
11
+ import "./chunk-RRKTSN4S.js";
12
12
  import {
13
13
  AGENT,
14
14
  headlessAgentRequestSchema
15
- } from "./chunk-UFWZKCZ2.js";
15
+ } from "./chunk-GU4OGSPA.js";
16
16
  import "./chunk-VEQXQN22.js";
17
17
 
18
18
  // src/headless-agent.ts
package/dist/src/index.js CHANGED
@@ -32,7 +32,7 @@ import {
32
32
  reportCommandProtectionBlock,
33
33
  resolveDiffBase,
34
34
  runGitCommand
35
- } from "./chunk-XTDADQOV.js";
35
+ } from "./chunk-H4XZMWVS.js";
36
36
  import {
37
37
  ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
38
38
  AGENT_MESSAGE_DELTA_METHOD,
@@ -57,7 +57,7 @@ import {
57
57
  } from "./chunk-P73LGPQO.js";
58
58
  import {
59
59
  publishedPullRequestUrls
60
- } from "./chunk-2QON5DPE.js";
60
+ } from "./chunk-DKM5SKZL.js";
61
61
  import {
62
62
  BaseRefreshManager,
63
63
  CodexAspAuthMethodChangedError,
@@ -71,7 +71,7 @@ import {
71
71
  refreshDelayMs,
72
72
  restartCodexAspHost,
73
73
  routineRefreshRequest
74
- } from "./chunk-5S6KOQGD.js";
74
+ } from "./chunk-QIACJ5UF.js";
75
75
  import {
76
76
  ENGINE_ENV,
77
77
  monolithRequest,
@@ -79,16 +79,16 @@ import {
79
79
  readRuntimeEnvFile,
80
80
  reloadEngineEnv,
81
81
  setAgentCredentialSnapshot
82
- } from "./chunk-XS7ZRCT2.js";
82
+ } from "./chunk-U7VFQQV4.js";
83
83
  import {
84
84
  AspClient,
85
85
  getCodexModelProvider
86
- } from "./chunk-ZWQGNLNE.js";
86
+ } from "./chunk-3SMYITBO.js";
87
87
  import {
88
88
  SUBPROCESS_MAX_BUFFER,
89
89
  execAsync,
90
90
  execFileAsync
91
- } from "./chunk-6DNBBHFB.js";
91
+ } from "./chunk-RRKTSN4S.js";
92
92
  import {
93
93
  isRecord as isRecord2
94
94
  } from "./chunk-UZSNFLDQ.js";
@@ -249,7 +249,6 @@ import {
249
249
  isAgentChatMcpActivityRecord,
250
250
  isAgentChatSkillActivityRecord,
251
251
  isAgentChatTurnActivityRecord,
252
- isAuthenticationErrorText,
253
252
  isCanvasTextKind,
254
253
  isChatHistoryEvent,
255
254
  isChatMessageSender,
@@ -316,7 +315,7 @@ import {
316
315
  workspaceCredentialProviderSchema,
317
316
  workspaceTokenRequestSchema,
318
317
  workspaceTokenResponseSchema
319
- } from "./chunk-UFWZKCZ2.js";
318
+ } from "./chunk-GU4OGSPA.js";
320
319
  import {
321
320
  cloneMcpConfig,
322
321
  ensureCompatibilityImports,
@@ -16307,7 +16306,7 @@ ${text.slice(-24e3)}`
16307
16306
  // src/managers/cursor-manager.ts
16308
16307
  import { mkdir as mkdir13, readFile as readFile12, readdir as readdir5 } from "fs/promises";
16309
16308
  import { basename as basename2, dirname as dirname7, extname, join as join19 } from "path";
16310
- import { Agent as CursorAgent2 } from "@cursor/sdk";
16309
+ import { Agent as CursorAgent2, AuthenticationError, CursorSdkError } from "@cursor/sdk";
16311
16310
 
16312
16311
  // src/services/native-command-protection-hooks.ts
16313
16312
  import { existsSync as existsSync10 } from "fs";
@@ -16413,8 +16412,20 @@ var CURSOR_TRANSPORT_ERROR_PATTERNS = [
16413
16412
  function isCursorTransportError(text) {
16414
16413
  return isTransientErrorText(text, { extraPatterns: CURSOR_TRANSPORT_ERROR_PATTERNS });
16415
16414
  }
16416
- function isCursorAuthenticationError(text) {
16417
- return isAuthenticationErrorText(text, [/error_not_logged_in/]);
16415
+ var CURSOR_AUTH_ERROR_CODES = [
16416
+ "unauthenticated",
16417
+ "not_logged_in",
16418
+ "agent_requires_login",
16419
+ "auth_token_not_found",
16420
+ "auth_token_expired",
16421
+ "invalid_auth_id",
16422
+ "unauthorized",
16423
+ "bad_api_key",
16424
+ "bad_user_api_key"
16425
+ ];
16426
+ var CURSOR_AUTH_ERROR_TEXT_PATTERN = new RegExp(`\\berror_(${CURSOR_AUTH_ERROR_CODES.join("|")})\\b`);
16427
+ function isCursorAuthenticationError(code, text) {
16428
+ return CURSOR_AUTH_ERROR_CODES.includes(code?.toLowerCase().replace(/^error_/, "") ?? "") || CURSOR_AUTH_ERROR_TEXT_PATTERN.test(text.toLowerCase());
16418
16429
  }
16419
16430
  function finiteNumber(value) {
16420
16431
  return typeof value === "number" && Number.isFinite(value) ? value : 0;
@@ -16667,12 +16678,14 @@ var CursorManager = class extends CodingAgentManager {
16667
16678
  }
16668
16679
  if (result.status === "error") {
16669
16680
  const detail = await this.readRunErrorDetail(agent.agentId, result.id);
16670
- const text = detail || result.result || "Cursor run failed";
16681
+ const text = detail || result.error?.message || result.result || "Cursor run failed";
16671
16682
  failure = {
16672
16683
  text,
16684
+ ...result.error?.code ? { code: result.error.code } : {},
16673
16685
  runId: result.id,
16674
16686
  ...result.requestId ? { requestId: result.requestId } : {},
16675
- transport: isCursorTransportError(text)
16687
+ transport: isCursorTransportError(text),
16688
+ authentication: isCursorAuthenticationError(result.error?.code, text)
16676
16689
  };
16677
16690
  } else {
16678
16691
  await this.retainThread(agent.agentId);
@@ -16682,11 +16695,14 @@ var CursorManager = class extends CodingAgentManager {
16682
16695
  } catch (error) {
16683
16696
  await this.cancelRun(run);
16684
16697
  const text = extractErrorText(error) || "Cursor run failed";
16698
+ const code = error instanceof CursorSdkError ? error.code : void 0;
16685
16699
  failure = {
16686
16700
  text,
16701
+ ...code ? { code } : {},
16687
16702
  ...run ? { runId: run.id } : {},
16688
16703
  ...run?.requestId ? { requestId: run.requestId } : {},
16689
- transport: isCursorTransportError(text)
16704
+ transport: isCursorTransportError(text),
16705
+ authentication: error instanceof AuthenticationError || isCursorAuthenticationError(code, text)
16690
16706
  };
16691
16707
  }
16692
16708
  if (agent && sawCursorActivity) await this.retainThread(agent.agentId);
@@ -16694,27 +16710,31 @@ var CursorManager = class extends CodingAgentManager {
16694
16710
  console.error("[CursorManager] Cursor run failed:", {
16695
16711
  runId: failure.runId,
16696
16712
  requestId: failure.requestId,
16713
+ code: failure.code,
16697
16714
  model,
16698
16715
  detail: failure.text,
16699
- transport: failure.transport
16716
+ transport: failure.transport,
16717
+ authentication: failure.authentication
16700
16718
  });
16701
16719
  const credentialScope = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.cursor?.scope;
16702
16720
  const credentialLabel = credentialScope === "user" ? "personal API key or account" : credentialScope === "org" ? "organization API key or account" : "configured API key or account";
16703
- const authenticationMessage = isCursorAuthenticationError(failure.text) ? [
16721
+ const authentication = failure.authentication && !failure.transport;
16722
+ const authenticationMessage = authentication ? [
16704
16723
  `Cursor rejected the ${credentialLabel} for this request.`,
16705
- "Logging out and back in does not replace the Cursor API key stored in Replicas.",
16706
- "Update it in Settings \u2192 Coding Agents before starting a new workspace.",
16724
+ "Retry the message to reconnect with the stored key.",
16725
+ "If it keeps failing, update the Cursor API key in Settings \u2192 Coding Agents (logging out and back in does not replace it), then start a new workspace.",
16707
16726
  failure.requestId ? `If a fresh key still fails, contact Cursor support with request ID ${failure.requestId}.` : ""
16708
16727
  ].filter(Boolean).join(" ") : null;
16709
16728
  const displayMessage = failure.transport ? sawCursorActivity ? "Cursor couldn't reconnect after its automatic retries. Retry the message to continue from the same chat." : run ? "Cursor couldn't connect after its automatic retries. Retry the message or start a new Cursor chat if the problem continues." : "The connection to Cursor failed. Retry the message or start a new Cursor chat if the problem continues." : authenticationMessage ?? failure.text;
16710
- if (failure.transport) {
16729
+ if (failure.transport || authentication) {
16711
16730
  this.activeRun = null;
16712
16731
  this.closeAgent();
16713
16732
  }
16714
16733
  this.recordHistoryEvent("cursor-error", {
16715
16734
  type: "error",
16716
16735
  message: displayMessage,
16717
- ...failure.transport ? { detail: failure.text } : {},
16736
+ ...displayMessage !== failure.text ? { detail: failure.text } : {},
16737
+ ...failure.code ? { code: failure.code } : {},
16718
16738
  ...failure.runId ? { runId: failure.runId } : {},
16719
16739
  ...failure.requestId ? { requestId: failure.requestId } : {}
16720
16740
  }, this.historyFile);
@@ -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-2QON5DPE.js";
6
+ } from "./chunk-DKM5SKZL.js";
7
7
  import {
8
8
  isRecord
9
9
  } from "./chunk-UZSNFLDQ.js";
10
10
  import {
11
11
  shouldRefreshPullRequests
12
- } from "./chunk-UFWZKCZ2.js";
12
+ } from "./chunk-GU4OGSPA.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-UFWZKCZ2.js";
12
+ } from "./chunk-GU4OGSPA.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.1008",
3
+ "version": "0.1.1010",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",