replicas-engine 0.1.750 → 0.1.751

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,9 +3,9 @@ import {
3
3
  getCodexAspHost,
4
4
  restartCodexAspHost,
5
5
  restartCodexAspHostIfRunning
6
- } from "./chunk-L25NFHAA.js";
6
+ } from "./chunk-7BMG23BX.js";
7
7
  import "./chunk-GQTP5TPD.js";
8
- import "./chunk-DHJ6RX6A.js";
8
+ import "./chunk-JQ4OOC6O.js";
9
9
  import "./chunk-2RB7SIP3.js";
10
10
  import "./chunk-MNVK5OPD.js";
11
11
  import "./chunk-5KSXSK7Y.js";
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  AppServerProcess,
9
9
  buildCodexAgentEnv
10
- } from "./chunk-DHJ6RX6A.js";
10
+ } from "./chunk-JQ4OOC6O.js";
11
11
  import {
12
12
  CODEX_AUTH_ENV_KEYS,
13
13
  CODEX_AUTH_ENV_KEYS_BY_METHOD,
@@ -230,7 +230,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
230
230
  const data = await response.json();
231
231
  await this.applyCredentialsResponse(data);
232
232
  if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
233
- const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-A3HW45NL.js");
233
+ const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-GSBR46MV.js");
234
234
  await restartCodexAspHostIfRunning2();
235
235
  }
236
236
  if (data.scope) {
@@ -239,7 +239,7 @@ var DEFAULT_CODEX_ARGS = [
239
239
  var MIN_CODEX_CLI_VERSION = "0.153.3";
240
240
  var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
241
241
  var codexCliVersionEnsured = null;
242
- var ENGINE_PACKAGE_VERSION = "0.1.750";
242
+ var ENGINE_PACKAGE_VERSION = "0.1.751";
243
243
  var INITIALIZE_METHOD = "initialize";
244
244
  var INITIALIZED_NOTIFICATION = "initialized";
245
245
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  AppServerProcess,
8
8
  buildCodexAgentEnv
9
- } from "./chunk-DHJ6RX6A.js";
9
+ } from "./chunk-JQ4OOC6O.js";
10
10
  import {
11
11
  AGENT,
12
12
  getMemoryOutputSafetyViolation,
package/dist/src/index.js CHANGED
@@ -122,7 +122,7 @@ import {
122
122
  recordCredentialFallback,
123
123
  recordExhaustedCredential,
124
124
  restartCodexAspHost
125
- } from "./chunk-L25NFHAA.js";
125
+ } from "./chunk-7BMG23BX.js";
126
126
  import {
127
127
  ENGINE_ENV,
128
128
  IS_WARMING_MODE,
@@ -135,7 +135,7 @@ import {
135
135
  SUBPROCESS_MAX_BUFFER,
136
136
  execAsync,
137
137
  execFileAsync
138
- } from "./chunk-DHJ6RX6A.js";
138
+ } from "./chunk-JQ4OOC6O.js";
139
139
  import {
140
140
  isRecord as isRecord2
141
141
  } from "./chunk-2RB7SIP3.js";
@@ -16042,7 +16042,7 @@ var CodexAspManager = class extends CodingAgentManager {
16042
16042
  import { mkdir as mkdir12, readFile as readFile11, readdir as readdir5 } from "fs/promises";
16043
16043
  import { basename as basename2, dirname as dirname7, extname, join as join21 } from "path";
16044
16044
  import { parse as parseYaml } from "yaml";
16045
- import { Agent as CursorAgent } from "@cursor/sdk";
16045
+ import { Agent as CursorAgent2 } from "@cursor/sdk";
16046
16046
 
16047
16047
  // src/services/native-command-protection-hooks.ts
16048
16048
  import { existsSync as existsSync9 } from "fs";
@@ -16130,6 +16130,31 @@ ${end}`;
16130
16130
  await writeFile6(path7, config, "utf8");
16131
16131
  }
16132
16132
 
16133
+ // src/managers/cursor-run-recovery.ts
16134
+ import { Agent as CursorAgent, AgentBusyError } from "@cursor/sdk";
16135
+ async function sendCursorRun(agent, message, options, workingDirectory) {
16136
+ try {
16137
+ return await agent.send(message, options);
16138
+ } catch (error) {
16139
+ if (!(error instanceof AgentBusyError) && !/^Agent agent-[\w-]+ already has active run$/.test(error instanceof Error ? error.message : "")) {
16140
+ throw error;
16141
+ }
16142
+ const { SqliteLocalAgentStore } = await import("@cursor/sdk/sqlite");
16143
+ const store = await SqliteLocalAgentStore.open({ workspaceRef: workingDirectory });
16144
+ try {
16145
+ const storedAgent = await store.agents.get({ agentId: agent.agentId });
16146
+ if (!storedAgent?.activeRunId) throw error;
16147
+ const activeRun = await store.runs.get({ agentId: agent.agentId, runId: storedAgent.activeRunId });
16148
+ if (!activeRun || ["finished", "error", "cancelled", "expired"].includes(activeRun.status)) throw error;
16149
+ await CursorAgent.cancelRun(activeRun.runId, { runtime: "local", cwd: workingDirectory, store });
16150
+ await agent.reload();
16151
+ } finally {
16152
+ await store.dispose();
16153
+ }
16154
+ return await agent.send(message, options);
16155
+ }
16156
+ }
16157
+
16133
16158
  // src/managers/cursor-manager.ts
16134
16159
  var CURSOR_SLASH_COMMANDS_CACHE_MS = 3e4;
16135
16160
  var CURSOR_STREAM_INACTIVITY_TIMEOUT_MS = 30 * 6e4;
@@ -16305,11 +16330,11 @@ var CursorManager = class extends CodingAgentManager {
16305
16330
  const settingSources = ["project", "user"];
16306
16331
  const local = { cwd: this.workingDirectory, settingSources, enableAgentRetries: true };
16307
16332
  const resumeId = this.resumeSessionId ?? this.initialSessionId;
16308
- this.agent = resumeId ? await CursorAgent.resume(resumeId, {
16333
+ this.agent = resumeId ? await CursorAgent2.resume(resumeId, {
16309
16334
  apiKey,
16310
16335
  model,
16311
16336
  local
16312
- }) : await CursorAgent.create({
16337
+ }) : await CursorAgent2.create({
16313
16338
  apiKey,
16314
16339
  model,
16315
16340
  local
@@ -16351,14 +16376,14 @@ var CursorManager = class extends CodingAgentManager {
16351
16376
  }, CURSOR_RECONNECT_NOTICE_DELAY_MS);
16352
16377
  agent = await this.ensureAgent(request);
16353
16378
  this.recordUserMessageHistoryEvent(request, this.historyFile);
16354
- run = await agent.send(message, {
16379
+ run = await sendCursorRun(agent, message, {
16355
16380
  model: { id: model },
16356
16381
  mode: request.planMode ? "plan" : "agent",
16357
16382
  onDelta: (args) => {
16358
16383
  markCursorActivity();
16359
16384
  this.recordCursorContextUsage(args.update);
16360
16385
  }
16361
- });
16386
+ }, this.workingDirectory);
16362
16387
  this.activeRun = run;
16363
16388
  const events = run.stream()[Symbol.asyncIterator]();
16364
16389
  let interrupted = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.750",
3
+ "version": "0.1.751",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",