replicas-engine 0.1.518 → 0.1.519
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.
- package/dist/src/index.js +34 -23
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -609,7 +609,7 @@ var WORKSPACE_SIZES = ["small", "large"];
|
|
|
609
609
|
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
610
610
|
|
|
611
611
|
// ../shared/src/e2b.ts
|
|
612
|
-
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-
|
|
612
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-29-v1";
|
|
613
613
|
|
|
614
614
|
// ../shared/src/runtime-env.ts
|
|
615
615
|
function shellQuotePosix(value) {
|
|
@@ -10069,7 +10069,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
|
10069
10069
|
var MIN_CODEX_CLI_VERSION = "0.144.6";
|
|
10070
10070
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
10071
10071
|
var codexCliVersionEnsured = null;
|
|
10072
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
10072
|
+
var ENGINE_PACKAGE_VERSION = "0.1.519";
|
|
10073
10073
|
var INITIALIZE_METHOD = "initialize";
|
|
10074
10074
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
10075
10075
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -12451,6 +12451,7 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
12451
12451
|
const message = await this.toCursorMessage(request, includeInstructions);
|
|
12452
12452
|
const agent = await this.ensureAgent(request);
|
|
12453
12453
|
const model = request.model ?? DEFAULT_CURSOR_MODEL;
|
|
12454
|
+
this.activeModel = model;
|
|
12454
12455
|
this.recordHistoryEvent("event_msg", {
|
|
12455
12456
|
type: "user_message",
|
|
12456
12457
|
message: request.message
|
|
@@ -12459,11 +12460,11 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
12459
12460
|
model: { id: model },
|
|
12460
12461
|
mode: request.planMode ? "plan" : "agent",
|
|
12461
12462
|
onDelta: async (args) => {
|
|
12463
|
+
this.recordCursorContextUsage(args.update);
|
|
12462
12464
|
await this.handleCursorToolCall(cursorToolInputFromDelta(args.update));
|
|
12463
12465
|
}
|
|
12464
12466
|
});
|
|
12465
12467
|
this.activeRun = run;
|
|
12466
|
-
this.activeModel = model;
|
|
12467
12468
|
if (this.pendingCursorBlockReason) {
|
|
12468
12469
|
await run.cancel();
|
|
12469
12470
|
throw new Error(this.pendingCursorBlockReason);
|
|
@@ -12487,7 +12488,7 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
12487
12488
|
}
|
|
12488
12489
|
if (next.done) break;
|
|
12489
12490
|
const event = next.value;
|
|
12490
|
-
this.
|
|
12491
|
+
this.recordHistoryEvent(`cursor-${event.type}`, event, this.historyFile);
|
|
12491
12492
|
if (event.type === "tool_call" && event.status === "running") {
|
|
12492
12493
|
await this.handleCursorToolCall(cursorToolInputFromMessage(event));
|
|
12493
12494
|
}
|
|
@@ -12508,9 +12509,11 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
12508
12509
|
await this.onSaveSessionId(agent.agentId);
|
|
12509
12510
|
}
|
|
12510
12511
|
if (result.status === "error") {
|
|
12512
|
+
const detail = await this.readRunErrorDetail(agent.agentId, result.id);
|
|
12513
|
+
console.error("[CursorManager] Cursor run failed:", { runId: result.id, model, detail });
|
|
12511
12514
|
this.recordHistoryEvent("cursor-error", {
|
|
12512
12515
|
type: "error",
|
|
12513
|
-
message: result.result || "Cursor run failed",
|
|
12516
|
+
message: detail || result.result || "Cursor run failed",
|
|
12514
12517
|
runId: result.id
|
|
12515
12518
|
}, this.historyFile);
|
|
12516
12519
|
} else {
|
|
@@ -12532,6 +12535,21 @@ var CursorManager = class extends CodingAgentManager {
|
|
|
12532
12535
|
await this.onTurnComplete();
|
|
12533
12536
|
}
|
|
12534
12537
|
}
|
|
12538
|
+
async readRunErrorDetail(agentId, runId) {
|
|
12539
|
+
try {
|
|
12540
|
+
const { SqliteLocalAgentStore } = await import("@cursor/sdk/sqlite");
|
|
12541
|
+
const store = await SqliteLocalAgentStore.open({ workspaceRef: this.workingDirectory });
|
|
12542
|
+
try {
|
|
12543
|
+
const record = await store.runs.get({ agentId, runId });
|
|
12544
|
+
return record?.error?.trim() || null;
|
|
12545
|
+
} finally {
|
|
12546
|
+
await store.dispose();
|
|
12547
|
+
}
|
|
12548
|
+
} catch (error) {
|
|
12549
|
+
console.error("[CursorManager] Failed to read Cursor run error detail:", error);
|
|
12550
|
+
return null;
|
|
12551
|
+
}
|
|
12552
|
+
}
|
|
12535
12553
|
async handleCursorToolCall(toolCall) {
|
|
12536
12554
|
if (!toolCall) return;
|
|
12537
12555
|
if (this.blockedToolCallIds.has(toolCall.toolUseId)) return;
|
|
@@ -12584,24 +12602,16 @@ ${request.message}` : request.message;
|
|
|
12584
12602
|
}))
|
|
12585
12603
|
};
|
|
12586
12604
|
}
|
|
12587
|
-
|
|
12588
|
-
|
|
12589
|
-
|
|
12590
|
-
if (!usage) return;
|
|
12591
|
-
|
|
12592
|
-
|
|
12593
|
-
|
|
12594
|
-
|
|
12595
|
-
return null;
|
|
12596
|
-
}
|
|
12597
|
-
const usage = "usage" in event && event.usage && typeof event.usage === "object" ? event.usage : null;
|
|
12598
|
-
if (!usage) return null;
|
|
12599
|
-
const inputTokens = finiteNumber("inputTokens" in usage ? usage.inputTokens : null);
|
|
12600
|
-
const cacheReadTokens = finiteNumber("cacheReadTokens" in usage ? usage.cacheReadTokens : null);
|
|
12601
|
-
const cacheWriteTokens = finiteNumber("cacheWriteTokens" in usage ? usage.cacheWriteTokens : null);
|
|
12602
|
-
const outputTokens = finiteNumber("outputTokens" in usage ? usage.outputTokens : null);
|
|
12605
|
+
// `turn-ended` is only ever an `onDelta` interaction update — it is not part of
|
|
12606
|
+
// the `SDKMessage` union the run stream yields, so usage has to be read here.
|
|
12607
|
+
recordCursorContextUsage(update) {
|
|
12608
|
+
if (update.type !== "turn-ended" || !update.usage) return;
|
|
12609
|
+
const inputTokens = finiteNumber(update.usage.inputTokens);
|
|
12610
|
+
const cacheReadTokens = finiteNumber(update.usage.cacheReadTokens);
|
|
12611
|
+
const cacheWriteTokens = finiteNumber(update.usage.cacheWriteTokens);
|
|
12612
|
+
const outputTokens = finiteNumber(update.usage.outputTokens);
|
|
12603
12613
|
const rawTotalTokens = inputTokens + cacheReadTokens + cacheWriteTokens + outputTokens;
|
|
12604
|
-
if (rawTotalTokens <= 0) return
|
|
12614
|
+
if (rawTotalTokens <= 0) return;
|
|
12605
12615
|
const maxTokens = CURSOR_COMPOSER_CONTEXT_WINDOW;
|
|
12606
12616
|
const { totalTokens, totalProcessedTokens } = clampTokensToWindow(rawTotalTokens, maxTokens);
|
|
12607
12617
|
const categories = [
|
|
@@ -12630,7 +12640,7 @@ ${request.message}` : request.message;
|
|
|
12630
12640
|
color: CURSOR_CATEGORY_COLORS.output
|
|
12631
12641
|
}
|
|
12632
12642
|
].filter((category) => category.tokens > 0);
|
|
12633
|
-
|
|
12643
|
+
const payload = {
|
|
12634
12644
|
provider: "cursor",
|
|
12635
12645
|
source: "provider_usage",
|
|
12636
12646
|
model: this.activeModel,
|
|
@@ -12649,6 +12659,7 @@ ${request.message}` : request.message;
|
|
|
12649
12659
|
},
|
|
12650
12660
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
12651
12661
|
};
|
|
12662
|
+
this.historyFile.append(this.emitContextUsage(payload));
|
|
12652
12663
|
}
|
|
12653
12664
|
};
|
|
12654
12665
|
|