replicas-engine 0.1.519 → 0.1.520
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 +71 -43
- 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-29-
|
|
612
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-29-v2";
|
|
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.520";
|
|
10073
10073
|
var INITIALIZE_METHOD = "initialize";
|
|
10074
10074
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
10075
10075
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -14407,7 +14407,10 @@ async function reconcileCanvasItems(filenames) {
|
|
|
14407
14407
|
}
|
|
14408
14408
|
|
|
14409
14409
|
// src/services/upload-chat-transcripts.ts
|
|
14410
|
-
import {
|
|
14410
|
+
import { createReadStream } from "fs";
|
|
14411
|
+
import { readdir as readdir7, readFile as readFile13, stat as stat4 } from "fs/promises";
|
|
14412
|
+
import { request as httpRequest } from "http";
|
|
14413
|
+
import { request as httpsRequest } from "https";
|
|
14411
14414
|
import { basename as basename2, join as join23 } from "path";
|
|
14412
14415
|
|
|
14413
14416
|
// src/services/chat/chat-senders.ts
|
|
@@ -14434,6 +14437,34 @@ var HISTORY_DIRS = [
|
|
|
14434
14437
|
join23(ENGINE_DIR2, "relay-histories"),
|
|
14435
14438
|
join23(ENGINE_DIR2, "codex-histories")
|
|
14436
14439
|
];
|
|
14440
|
+
async function putTranscript(uploadUrl, filePath, size) {
|
|
14441
|
+
await new Promise((resolve4, reject) => {
|
|
14442
|
+
const url = new URL(uploadUrl);
|
|
14443
|
+
const request = (url.protocol === "https:" ? httpsRequest : httpRequest)(url, {
|
|
14444
|
+
method: "PUT",
|
|
14445
|
+
headers: {
|
|
14446
|
+
"content-length": String(size),
|
|
14447
|
+
"content-type": "application/x-ndjson"
|
|
14448
|
+
}
|
|
14449
|
+
}, (response) => {
|
|
14450
|
+
response.setEncoding("utf8");
|
|
14451
|
+
let body = "";
|
|
14452
|
+
response.on("data", (chunk) => {
|
|
14453
|
+
body += chunk;
|
|
14454
|
+
});
|
|
14455
|
+
response.on("end", () => {
|
|
14456
|
+
const status = response.statusCode ?? 0;
|
|
14457
|
+
if (status >= 200 && status < 300) resolve4();
|
|
14458
|
+
else reject(new Error(`upload failed: ${status} ${body}`));
|
|
14459
|
+
});
|
|
14460
|
+
response.on("error", reject);
|
|
14461
|
+
});
|
|
14462
|
+
request.on("error", reject);
|
|
14463
|
+
const file = createReadStream(filePath, { start: 0, end: size - 1 });
|
|
14464
|
+
file.on("error", (error) => request.destroy(error));
|
|
14465
|
+
file.pipe(request);
|
|
14466
|
+
});
|
|
14467
|
+
}
|
|
14437
14468
|
async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map()) {
|
|
14438
14469
|
let flushed = 0;
|
|
14439
14470
|
let failed = 0;
|
|
@@ -14462,44 +14493,41 @@ async function flushAllChatTranscripts(chatsById = /* @__PURE__ */ new Map()) {
|
|
|
14462
14493
|
return { flushed, failed };
|
|
14463
14494
|
}
|
|
14464
14495
|
async function uploadChatTranscript(chatId, filePath, chat) {
|
|
14465
|
-
const
|
|
14466
|
-
if (
|
|
14467
|
-
|
|
14496
|
+
const { size } = await stat4(filePath);
|
|
14497
|
+
if (size === 0) return;
|
|
14498
|
+
const metadata = chat ? {
|
|
14499
|
+
provider: chat.provider,
|
|
14500
|
+
title: chat.title,
|
|
14501
|
+
createdAt: chat.createdAt,
|
|
14502
|
+
updatedAt: chat.updatedAt,
|
|
14503
|
+
parentChatId: chat.parentChatId,
|
|
14504
|
+
deletedAt: chat.deletedAt ?? null
|
|
14505
|
+
} : {};
|
|
14468
14506
|
try {
|
|
14469
|
-
senders = parseChatMessageSendersJsonl(
|
|
14507
|
+
metadata.senders = parseChatMessageSendersJsonl(
|
|
14508
|
+
await readFile13(chatMessageSendersFilePath(chatId), "utf-8")
|
|
14509
|
+
);
|
|
14470
14510
|
} catch (error) {
|
|
14471
14511
|
if (!(error && typeof error === "object" && "code" in error && error.code === "ENOENT")) throw error;
|
|
14472
14512
|
}
|
|
14473
|
-
const
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
createdAt: chat.createdAt,
|
|
14480
|
-
updatedAt: chat.updatedAt,
|
|
14481
|
-
parentChatId: chat.parentChatId,
|
|
14482
|
-
deletedAt: chat.deletedAt ?? null
|
|
14483
|
-
};
|
|
14484
|
-
form.append("provider", metadata.provider);
|
|
14485
|
-
form.append("title", metadata.title);
|
|
14486
|
-
form.append("created_at", metadata.createdAt);
|
|
14487
|
-
form.append("updated_at", metadata.updatedAt);
|
|
14488
|
-
if (metadata.parentChatId) form.append("parent_chat_id", metadata.parentChatId);
|
|
14489
|
-
form.append("deleted_at", metadata.deletedAt ?? "");
|
|
14513
|
+
const uploadRequest = { chatId, size, metadata };
|
|
14514
|
+
const prepareResponse = await monolithRequest("/v1/engine/chat-transcripts/upload-url", {
|
|
14515
|
+
body: uploadRequest
|
|
14516
|
+
});
|
|
14517
|
+
if (!prepareResponse.ok) {
|
|
14518
|
+
throw new Error(`prepare failed: ${prepareResponse.status} ${await prepareResponse.text()}`);
|
|
14490
14519
|
}
|
|
14491
|
-
|
|
14492
|
-
|
|
14520
|
+
const prepareBody = await prepareResponse.json();
|
|
14521
|
+
if (!isRecord(prepareBody) || typeof prepareBody.uploadUrl !== "string" && prepareBody.uploadUrl !== null) {
|
|
14522
|
+
throw new Error("prepare failed: invalid response");
|
|
14493
14523
|
}
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
);
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
const errorText = await response.text();
|
|
14502
|
-
throw new Error(`upload failed: ${response.status} ${errorText}`);
|
|
14524
|
+
if (prepareBody.uploadUrl === null) return;
|
|
14525
|
+
await putTranscript(prepareBody.uploadUrl, filePath, size);
|
|
14526
|
+
const finalizeResponse = await monolithRequest("/v1/engine/chat-transcripts/finalize", {
|
|
14527
|
+
body: uploadRequest
|
|
14528
|
+
});
|
|
14529
|
+
if (!finalizeResponse.ok) {
|
|
14530
|
+
throw new Error(`finalize failed: ${finalizeResponse.status} ${await finalizeResponse.text()}`);
|
|
14503
14531
|
}
|
|
14504
14532
|
}
|
|
14505
14533
|
|
|
@@ -14537,8 +14565,8 @@ async function flushRepoState() {
|
|
|
14537
14565
|
}
|
|
14538
14566
|
|
|
14539
14567
|
// src/services/upload-engine-logs.ts
|
|
14540
|
-
import { createReadStream } from "fs";
|
|
14541
|
-
import { readdir as readdir8, stat as
|
|
14568
|
+
import { createReadStream as createReadStream2 } from "fs";
|
|
14569
|
+
import { readdir as readdir8, stat as stat5 } from "fs/promises";
|
|
14542
14570
|
import { join as join24 } from "path";
|
|
14543
14571
|
var MAX_ENGINE_LOG_FLUSH_SESSIONS = 10;
|
|
14544
14572
|
var MAX_ENGINE_LOG_FLUSH_BYTES = 5 * 1024 * 1024;
|
|
@@ -14569,7 +14597,7 @@ async function flushAllEngineLogs() {
|
|
|
14569
14597
|
try {
|
|
14570
14598
|
const sessionId = filename.slice(0, -".log".length);
|
|
14571
14599
|
const filePath = join24(LOG_DIR, filename);
|
|
14572
|
-
const fileStat = await runBeforeDeadline(() =>
|
|
14600
|
+
const fileStat = await runBeforeDeadline(() => stat5(filePath), deadline);
|
|
14573
14601
|
if (!fileStat.isFile()) {
|
|
14574
14602
|
skipped++;
|
|
14575
14603
|
return null;
|
|
@@ -14601,7 +14629,7 @@ async function flushAllEngineLogs() {
|
|
|
14601
14629
|
const content = await runBeforeDeadline(async (signal) => {
|
|
14602
14630
|
if (candidate.length === 0) return Buffer.alloc(0);
|
|
14603
14631
|
const chunks = [];
|
|
14604
|
-
for await (const chunk of
|
|
14632
|
+
for await (const chunk of createReadStream2(candidate.filePath, {
|
|
14605
14633
|
start: candidate.offset,
|
|
14606
14634
|
end: candidate.offset + candidate.length - 1,
|
|
14607
14635
|
signal
|
|
@@ -15542,7 +15570,7 @@ var ChatService = class {
|
|
|
15542
15570
|
|
|
15543
15571
|
// src/services/repo-file-service.ts
|
|
15544
15572
|
import { execFile as execFile2 } from "child_process";
|
|
15545
|
-
import { readFile as readFile15, realpath, stat as
|
|
15573
|
+
import { readFile as readFile15, realpath, stat as stat6 } from "fs/promises";
|
|
15546
15574
|
import { join as join26, resolve as resolve2, extname as extname2 } from "path";
|
|
15547
15575
|
var CACHE_TTL_MS = 3e4;
|
|
15548
15576
|
var SEARCH_TIMEOUT_MS = 15e3;
|
|
@@ -15707,7 +15735,7 @@ var RepoFileService = class {
|
|
|
15707
15735
|
const repoRoot = await realpath(repo.path);
|
|
15708
15736
|
const repoPrefix = repoRoot.endsWith("/") ? repoRoot : repoRoot + "/";
|
|
15709
15737
|
if (!fullPath.startsWith(repoPrefix) && fullPath !== repoRoot) return null;
|
|
15710
|
-
const fileStat = await
|
|
15738
|
+
const fileStat = await stat6(fullPath);
|
|
15711
15739
|
if (!fileStat.isFile()) return null;
|
|
15712
15740
|
const sizeBytes = fileStat.size;
|
|
15713
15741
|
if (isBinaryExtension(filePath)) {
|
|
@@ -15810,7 +15838,7 @@ var RepoFileService = class {
|
|
|
15810
15838
|
// src/v1-routes.ts
|
|
15811
15839
|
import { Hono } from "hono";
|
|
15812
15840
|
import { z as z7 } from "zod";
|
|
15813
|
-
import { readdir as readdir10, stat as
|
|
15841
|
+
import { readdir as readdir10, stat as stat7, readFile as readFile18 } from "fs/promises";
|
|
15814
15842
|
import { join as join29, resolve as resolve3 } from "path";
|
|
15815
15843
|
|
|
15816
15844
|
// src/services/warm-hooks-service.ts
|
|
@@ -17200,7 +17228,7 @@ data: ${JSON.stringify("Terminal session not found")}
|
|
|
17200
17228
|
const sessions = await Promise.all(
|
|
17201
17229
|
logFiles.map(async (filename) => {
|
|
17202
17230
|
const filePath = join29(LOG_DIR, filename);
|
|
17203
|
-
const fileStat = await
|
|
17231
|
+
const fileStat = await stat7(filePath);
|
|
17204
17232
|
const sessionId = filename.replace(/\.log$/, "");
|
|
17205
17233
|
return {
|
|
17206
17234
|
sessionId,
|