replicas-engine 0.1.243 → 0.1.245
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 +65 -12
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -289,7 +289,7 @@ var WORKSPACE_SIZES = ["small", "large"];
|
|
|
289
289
|
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
290
290
|
|
|
291
291
|
// ../shared/src/e2b.ts
|
|
292
|
-
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-05-30-
|
|
292
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-05-30-v6";
|
|
293
293
|
|
|
294
294
|
// ../shared/src/runtime-env.ts
|
|
295
295
|
function parsePosixEnvFile(content) {
|
|
@@ -1823,6 +1823,18 @@ function normalizeCodexAspTranscriptStatus(status, failed = false) {
|
|
|
1823
1823
|
if (status === "completed") return "completed";
|
|
1824
1824
|
return "in_progress";
|
|
1825
1825
|
}
|
|
1826
|
+
function imageContentToUserMessageImages(images) {
|
|
1827
|
+
const userImages = [];
|
|
1828
|
+
for (const image of images ?? []) {
|
|
1829
|
+
if (image.source.type !== "base64" || image.source.data.length === 0) continue;
|
|
1830
|
+
userImages.push({
|
|
1831
|
+
type: "image",
|
|
1832
|
+
mediaType: image.source.media_type,
|
|
1833
|
+
data: image.source.data
|
|
1834
|
+
});
|
|
1835
|
+
}
|
|
1836
|
+
return userImages.length > 0 ? userImages : void 0;
|
|
1837
|
+
}
|
|
1826
1838
|
function isCodexAspTranscript(value) {
|
|
1827
1839
|
if (!isRecord(value)) return false;
|
|
1828
1840
|
return typeof value.threadId === "string" && typeof value.updatedAt === "string" && Array.isArray(value.turns);
|
|
@@ -1922,7 +1934,13 @@ function coerceBackgroundTaskPayload(payload) {
|
|
|
1922
1934
|
const patch = isRecord(payload.patch) ? {
|
|
1923
1935
|
status: optionalString(payload.patch.status),
|
|
1924
1936
|
description: optionalString(payload.patch.description),
|
|
1925
|
-
error: optionalString(payload.patch.error)
|
|
1937
|
+
error: optionalString(payload.patch.error),
|
|
1938
|
+
isBackgrounded: optionalBoolean(payload.patch.is_backgrounded)
|
|
1939
|
+
} : void 0;
|
|
1940
|
+
const usage = isRecord(payload.usage) ? {
|
|
1941
|
+
totalTokens: optionalNumber(payload.usage.total_tokens),
|
|
1942
|
+
toolUses: optionalNumber(payload.usage.tool_uses),
|
|
1943
|
+
durationMs: optionalNumber(payload.usage.duration_ms)
|
|
1926
1944
|
} : void 0;
|
|
1927
1945
|
return {
|
|
1928
1946
|
subtype,
|
|
@@ -1931,9 +1949,20 @@ function coerceBackgroundTaskPayload(payload) {
|
|
|
1931
1949
|
summary: optionalString(payload.summary),
|
|
1932
1950
|
outputFile: optionalString(payload.output_file),
|
|
1933
1951
|
status: optionalString(payload.status),
|
|
1952
|
+
taskType: optionalString(payload.task_type),
|
|
1953
|
+
workflowName: optionalString(payload.workflow_name),
|
|
1954
|
+
prompt: optionalString(payload.prompt),
|
|
1955
|
+
lastToolName: optionalString(payload.last_tool_name),
|
|
1956
|
+
usage,
|
|
1934
1957
|
patch
|
|
1935
1958
|
};
|
|
1936
1959
|
}
|
|
1960
|
+
function optionalNumber(value) {
|
|
1961
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1962
|
+
}
|
|
1963
|
+
function optionalBoolean(value) {
|
|
1964
|
+
return typeof value === "boolean" ? value : void 0;
|
|
1965
|
+
}
|
|
1937
1966
|
function normalizeBackgroundTaskStatus(status) {
|
|
1938
1967
|
if (status === "completed" || status === "failed" || status === "stopped") {
|
|
1939
1968
|
return status;
|
|
@@ -4101,7 +4130,7 @@ async function registerDesktopPreview() {
|
|
|
4101
4130
|
}
|
|
4102
4131
|
|
|
4103
4132
|
// src/services/chat/chat-service.ts
|
|
4104
|
-
import { existsSync as
|
|
4133
|
+
import { existsSync as existsSync8 } from "fs";
|
|
4105
4134
|
import { appendFile as appendFile5, copyFile, mkdir as mkdir11, readFile as readFile8, rename as rename2, rm } from "fs/promises";
|
|
4106
4135
|
import { homedir as homedir13 } from "os";
|
|
4107
4136
|
import { join as join15 } from "path";
|
|
@@ -6085,7 +6114,7 @@ var AspClient = class {
|
|
|
6085
6114
|
// src/managers/codex-asp/app-server-process.ts
|
|
6086
6115
|
var DEFAULT_CODEX_BINARY = "codex";
|
|
6087
6116
|
var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
6088
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
6117
|
+
var ENGINE_PACKAGE_VERSION = "0.1.245";
|
|
6089
6118
|
var INITIALIZE_METHOD = "initialize";
|
|
6090
6119
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
6091
6120
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -6352,6 +6381,8 @@ function isCodexAuthError(error) {
|
|
|
6352
6381
|
}
|
|
6353
6382
|
|
|
6354
6383
|
// src/managers/codex-asp/mappers.ts
|
|
6384
|
+
import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
|
|
6385
|
+
var localImageCache = /* @__PURE__ */ new Map();
|
|
6355
6386
|
var DEFAULT_MODEL = DEFAULT_CODEX_MODEL;
|
|
6356
6387
|
var THREAD_START_METHOD = "thread/start";
|
|
6357
6388
|
var THREAD_RESUME_METHOD = "thread/resume";
|
|
@@ -6424,6 +6455,22 @@ function transcriptItemsForTurn(turn) {
|
|
|
6424
6455
|
const otherItems = turn.items.filter((item) => item.type !== "userMessage");
|
|
6425
6456
|
return [...userItems, ...otherItems];
|
|
6426
6457
|
}
|
|
6458
|
+
function userImageForLocalPath(path4) {
|
|
6459
|
+
const cached = localImageCache.get(path4);
|
|
6460
|
+
if (cached) return cached;
|
|
6461
|
+
if (!existsSync6(path4)) return null;
|
|
6462
|
+
const image = {
|
|
6463
|
+
type: "image",
|
|
6464
|
+
mediaType: inferMediaType(path4),
|
|
6465
|
+
data: readFileSync3(path4).toString("base64")
|
|
6466
|
+
};
|
|
6467
|
+
if (image.data.length > 0) localImageCache.set(path4, image);
|
|
6468
|
+
return image;
|
|
6469
|
+
}
|
|
6470
|
+
function userImagesForInput(input) {
|
|
6471
|
+
const images = input.filter((item) => item.type === "localImage").map((item) => userImageForLocalPath(item.path)).filter((image) => image !== null && image.data.length > 0);
|
|
6472
|
+
return images.length > 0 ? images : void 0;
|
|
6473
|
+
}
|
|
6427
6474
|
function itemToTranscriptItem(item, timestamp, status) {
|
|
6428
6475
|
if (item.type === "userMessage") {
|
|
6429
6476
|
const content = item.content.filter((input) => input.type === "text").map((input) => input.text).join("\n");
|
|
@@ -6431,6 +6478,7 @@ function itemToTranscriptItem(item, timestamp, status) {
|
|
|
6431
6478
|
type: "userMessage",
|
|
6432
6479
|
id: item.id,
|
|
6433
6480
|
content,
|
|
6481
|
+
images: userImagesForInput(item.content),
|
|
6434
6482
|
timestamp
|
|
6435
6483
|
};
|
|
6436
6484
|
}
|
|
@@ -6690,6 +6738,7 @@ function mergeCodexAspTranscriptItem(current, candidate) {
|
|
|
6690
6738
|
...current,
|
|
6691
6739
|
...candidate,
|
|
6692
6740
|
id: current.id,
|
|
6741
|
+
...current.type === "userMessage" && candidate.type === "userMessage" && !candidate.images && current.images ? { images: current.images } : {},
|
|
6693
6742
|
timestamp: current.timestamp,
|
|
6694
6743
|
sequence: current.sequence ?? candidate.sequence
|
|
6695
6744
|
};
|
|
@@ -6985,9 +7034,11 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
6985
7034
|
const recordUserMessage = (extraPayload = {}) => {
|
|
6986
7035
|
if (userMessageRecorded) return;
|
|
6987
7036
|
userMessageRecorded = true;
|
|
7037
|
+
const images = imageContentToUserMessageImages(request.images);
|
|
6988
7038
|
this.recordHistoryEvent("event_msg", {
|
|
6989
7039
|
type: "user_message",
|
|
6990
7040
|
message: request.message,
|
|
7041
|
+
...images ? { images } : {},
|
|
6991
7042
|
...extraPayload
|
|
6992
7043
|
});
|
|
6993
7044
|
};
|
|
@@ -7598,7 +7649,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
7598
7649
|
// src/managers/codex-manager.ts
|
|
7599
7650
|
import { Codex } from "@openai/codex-sdk";
|
|
7600
7651
|
import { readdir as readdir3, stat as stat2, writeFile as writeFile6, mkdir as mkdir10, readFile as readFile7 } from "fs/promises";
|
|
7601
|
-
import { existsSync as
|
|
7652
|
+
import { existsSync as existsSync7 } from "fs";
|
|
7602
7653
|
import { join as join14 } from "path";
|
|
7603
7654
|
import { homedir as homedir12 } from "os";
|
|
7604
7655
|
import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
@@ -7683,7 +7734,7 @@ var CodexManager = class extends CodingAgentManager {
|
|
|
7683
7734
|
const codexDir = join14(homedir12(), ".codex");
|
|
7684
7735
|
await mkdir10(codexDir, { recursive: true });
|
|
7685
7736
|
let config = {};
|
|
7686
|
-
if (
|
|
7737
|
+
if (existsSync7(CODEX_CONFIG_PATH)) {
|
|
7687
7738
|
try {
|
|
7688
7739
|
const existingContent = await readFile7(CODEX_CONFIG_PATH, "utf-8");
|
|
7689
7740
|
const parsed = parseToml(existingContent);
|
|
@@ -8612,7 +8663,7 @@ function isChatMessageSender(value) {
|
|
|
8612
8663
|
return typeof value.senderUserId === "string" && typeof value.senderEmail === "string" && typeof value.recordedAt === "string";
|
|
8613
8664
|
}
|
|
8614
8665
|
function isCodexAvailable() {
|
|
8615
|
-
return
|
|
8666
|
+
return existsSync8(CODEX_AUTH_PATH2) || Boolean(ENGINE_ENV.OPENAI_API_KEY);
|
|
8616
8667
|
}
|
|
8617
8668
|
function isSameAcceptedUserEvent(event, acceptedEvent) {
|
|
8618
8669
|
if (areSameUserMessageEvents(event, acceptedEvent)) return true;
|
|
@@ -8671,7 +8722,8 @@ function parsePersistedChatsContent(content) {
|
|
|
8671
8722
|
function corruptChatsFilePath() {
|
|
8672
8723
|
return `${CHATS_FILE}.corrupt-${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}`;
|
|
8673
8724
|
}
|
|
8674
|
-
function createUserMessageEvent(message, messageId) {
|
|
8725
|
+
function createUserMessageEvent(message, messageId, images) {
|
|
8726
|
+
const eventImages = imageContentToUserMessageImages(images);
|
|
8675
8727
|
return {
|
|
8676
8728
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8677
8729
|
type: "event_msg",
|
|
@@ -8679,7 +8731,8 @@ function createUserMessageEvent(message, messageId) {
|
|
|
8679
8731
|
type: "user_message",
|
|
8680
8732
|
message,
|
|
8681
8733
|
source: ACCEPTED_USER_MESSAGE_SOURCE,
|
|
8682
|
-
[USER_MESSAGE_ID_PAYLOAD_KEY]: messageId
|
|
8734
|
+
[USER_MESSAGE_ID_PAYLOAD_KEY]: messageId,
|
|
8735
|
+
...eventImages ? { images: eventImages } : {}
|
|
8683
8736
|
}
|
|
8684
8737
|
};
|
|
8685
8738
|
}
|
|
@@ -8761,7 +8814,7 @@ var ChatService = class {
|
|
|
8761
8814
|
async sendMessage(chatId, request) {
|
|
8762
8815
|
const chat = this.requireChat(chatId);
|
|
8763
8816
|
const result = await chat.provider.enqueueMessage(request);
|
|
8764
|
-
const acceptedEvent = createUserMessageEvent(request.message, result.messageId);
|
|
8817
|
+
const acceptedEvent = createUserMessageEvent(request.message, result.messageId, request.images);
|
|
8765
8818
|
chat.pendingMessageIds.push(result.messageId);
|
|
8766
8819
|
chat.acceptedUserEvents.set(result.messageId, acceptedEvent);
|
|
8767
8820
|
this.touch(chat);
|
|
@@ -9581,7 +9634,7 @@ var planService = new PlanService();
|
|
|
9581
9634
|
// src/services/warm-hooks-service.ts
|
|
9582
9635
|
import { spawn as spawn3 } from "child_process";
|
|
9583
9636
|
import { readFile as readFile12 } from "fs/promises";
|
|
9584
|
-
import { existsSync as
|
|
9637
|
+
import { existsSync as existsSync9 } from "fs";
|
|
9585
9638
|
import { join as join19 } from "path";
|
|
9586
9639
|
|
|
9587
9640
|
// src/services/warm-hook-logs-service.ts
|
|
@@ -9703,7 +9756,7 @@ var warmHookLogsService = new WarmHookLogsService();
|
|
|
9703
9756
|
async function readRepoWarmHook(repoPath) {
|
|
9704
9757
|
for (const filename of REPLICAS_CONFIG_FILENAMES) {
|
|
9705
9758
|
const configPath = join19(repoPath, filename);
|
|
9706
|
-
if (!
|
|
9759
|
+
if (!existsSync9(configPath)) {
|
|
9707
9760
|
continue;
|
|
9708
9761
|
}
|
|
9709
9762
|
try {
|