replicas-engine 0.1.493 → 0.1.495
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 +86 -21
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -602,7 +602,7 @@ var WORKSPACE_SIZES = ["small", "large"];
|
|
|
602
602
|
var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
|
|
603
603
|
|
|
604
604
|
// ../shared/src/e2b.ts
|
|
605
|
-
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-24-
|
|
605
|
+
var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-07-24-v3";
|
|
606
606
|
|
|
607
607
|
// ../shared/src/runtime-env.ts
|
|
608
608
|
function shellQuotePosix(value) {
|
|
@@ -3306,6 +3306,15 @@ function isTerminalBackgroundTaskStatus(status) {
|
|
|
3306
3306
|
// ../shared/src/display-message/constants.ts
|
|
3307
3307
|
var USER_MESSAGE_MATCH_GRACE_PERIOD_MS = 3e4;
|
|
3308
3308
|
|
|
3309
|
+
// ../shared/src/user-message-matching.ts
|
|
3310
|
+
function parseTimestampMs(timestamp) {
|
|
3311
|
+
const value = Date.parse(timestamp);
|
|
3312
|
+
return Number.isFinite(value) ? value : 0;
|
|
3313
|
+
}
|
|
3314
|
+
function areUserMessagesWithinMatchWindow(a, b) {
|
|
3315
|
+
return a.content === b.content && Math.abs(parseTimestampMs(a.timestamp) - parseTimestampMs(b.timestamp)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
|
|
3316
|
+
}
|
|
3317
|
+
|
|
3309
3318
|
// ../shared/src/agent-event-utils.ts
|
|
3310
3319
|
function getUserMessage(event) {
|
|
3311
3320
|
return event.type === "event_msg" && event.payload.type === "user_message" && typeof event.payload.message === "string" ? event.payload.message : null;
|
|
@@ -3318,10 +3327,6 @@ function getUserMessageItemId(event) {
|
|
|
3318
3327
|
const itemId = event.payload[CODEX_ASP_ITEM_ID_PAYLOAD_KEY];
|
|
3319
3328
|
return typeof itemId === "string" ? itemId : null;
|
|
3320
3329
|
}
|
|
3321
|
-
function parseTimestampMs(timestamp) {
|
|
3322
|
-
const value = Date.parse(timestamp);
|
|
3323
|
-
return Number.isFinite(value) ? value : 0;
|
|
3324
|
-
}
|
|
3325
3330
|
function getEventTimestampMs(event) {
|
|
3326
3331
|
return parseTimestampMs(event.timestamp);
|
|
3327
3332
|
}
|
|
@@ -3335,7 +3340,10 @@ function areSameUserMessageEvents(a, b) {
|
|
|
3335
3340
|
const aItemId = getUserMessageItemId(a);
|
|
3336
3341
|
const bItemId = getUserMessageItemId(b);
|
|
3337
3342
|
if (aItemId || bItemId) return aItemId === bItemId;
|
|
3338
|
-
return
|
|
3343
|
+
return areUserMessagesWithinMatchWindow(
|
|
3344
|
+
{ content: aMessage, timestamp: a.timestamp },
|
|
3345
|
+
{ content: bMessage, timestamp: b.timestamp }
|
|
3346
|
+
);
|
|
3339
3347
|
}
|
|
3340
3348
|
function parseAgentEventJsonl(content, options = {}) {
|
|
3341
3349
|
const events = [];
|
|
@@ -4200,6 +4208,13 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
4200
4208
|
const assistantThinking = /* @__PURE__ */ new Map();
|
|
4201
4209
|
const assistantTextCounts = /* @__PURE__ */ new Map();
|
|
4202
4210
|
const acceptedUserMessageIndexes = /* @__PURE__ */ new Set();
|
|
4211
|
+
const canonicalUserMessageIndexes = /* @__PURE__ */ new Set();
|
|
4212
|
+
const findMatchingUserMessageIndex = (indexes, content, timestamp) => {
|
|
4213
|
+
return [...indexes].find((index) => {
|
|
4214
|
+
const message = messages[index];
|
|
4215
|
+
return message?.type === "user" && areUserMessagesWithinMatchWindow(message, { content, timestamp });
|
|
4216
|
+
});
|
|
4217
|
+
};
|
|
4203
4218
|
let turnWasInterrupted = false;
|
|
4204
4219
|
const taskAccumulator = new TaskAccumulator();
|
|
4205
4220
|
const taskSnapshot = () => taskAccumulator.getTasks().map((task) => ({
|
|
@@ -4213,13 +4228,21 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
4213
4228
|
const images = userMessageImages(event.payload.images);
|
|
4214
4229
|
if (content || images) {
|
|
4215
4230
|
const messageId = event.payload[USER_MESSAGE_ID_PAYLOAD_KEY];
|
|
4216
|
-
|
|
4231
|
+
const canonicalIndex = findMatchingUserMessageIndex(canonicalUserMessageIndexes, content, event.timestamp);
|
|
4232
|
+
const canonical = canonicalIndex === void 0 ? void 0 : messages[canonicalIndex];
|
|
4233
|
+
const message = {
|
|
4217
4234
|
id: typeof messageId === "string" ? messageId : `user-${event.timestamp}`,
|
|
4218
4235
|
type: "user",
|
|
4219
4236
|
content,
|
|
4220
|
-
images,
|
|
4237
|
+
images: images?.length ? images : canonical?.type === "user" ? canonical.images : void 0,
|
|
4221
4238
|
timestamp: event.timestamp
|
|
4222
|
-
}
|
|
4239
|
+
};
|
|
4240
|
+
if (canonicalIndex === void 0) {
|
|
4241
|
+
acceptedUserMessageIndexes.add(messages.push(message) - 1);
|
|
4242
|
+
} else {
|
|
4243
|
+
messages[canonicalIndex] = message;
|
|
4244
|
+
canonicalUserMessageIndexes.delete(canonicalIndex);
|
|
4245
|
+
}
|
|
4223
4246
|
}
|
|
4224
4247
|
return;
|
|
4225
4248
|
}
|
|
@@ -4281,10 +4304,11 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
4281
4304
|
};
|
|
4282
4305
|
}).filter((img) => img.data);
|
|
4283
4306
|
if (textContent || images.length > 0) {
|
|
4284
|
-
const acceptedIndex =
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4307
|
+
const acceptedIndex = findMatchingUserMessageIndex(
|
|
4308
|
+
acceptedUserMessageIndexes,
|
|
4309
|
+
textContent,
|
|
4310
|
+
event.timestamp
|
|
4311
|
+
);
|
|
4288
4312
|
const accepted = acceptedIndex === void 0 ? void 0 : messages[acceptedIndex];
|
|
4289
4313
|
const message = {
|
|
4290
4314
|
id: accepted?.id ?? `user-${event.timestamp}`,
|
|
@@ -4294,7 +4318,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
4294
4318
|
timestamp: event.timestamp
|
|
4295
4319
|
};
|
|
4296
4320
|
if (acceptedIndex === void 0) {
|
|
4297
|
-
messages.push(message);
|
|
4321
|
+
canonicalUserMessageIndexes.add(messages.push(message) - 1);
|
|
4298
4322
|
} else {
|
|
4299
4323
|
messages[acceptedIndex] = message;
|
|
4300
4324
|
acceptedUserMessageIndexes.delete(acceptedIndex);
|
|
@@ -9884,7 +9908,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
|
9884
9908
|
var MIN_CODEX_CLI_VERSION = "0.144.6";
|
|
9885
9909
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
9886
9910
|
var codexCliVersionEnsured = null;
|
|
9887
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
9911
|
+
var ENGINE_PACKAGE_VERSION = "0.1.495";
|
|
9888
9912
|
var INITIALIZE_METHOD = "initialize";
|
|
9889
9913
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
9890
9914
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -10240,6 +10264,29 @@ function stringifyCollabAgentStates(states) {
|
|
|
10240
10264
|
});
|
|
10241
10265
|
return entries.length > 0 ? truncateCodexAspTranscriptOutput(entries.join("\n")) : void 0;
|
|
10242
10266
|
}
|
|
10267
|
+
function codexSubagentTranscriptItem({
|
|
10268
|
+
id,
|
|
10269
|
+
description,
|
|
10270
|
+
prompt,
|
|
10271
|
+
receiverThreadIds,
|
|
10272
|
+
model,
|
|
10273
|
+
output,
|
|
10274
|
+
timestamp,
|
|
10275
|
+
status
|
|
10276
|
+
}) {
|
|
10277
|
+
return {
|
|
10278
|
+
type: "subagent",
|
|
10279
|
+
id,
|
|
10280
|
+
description,
|
|
10281
|
+
prompt,
|
|
10282
|
+
subagentType: "codex",
|
|
10283
|
+
receiverThreadIds,
|
|
10284
|
+
...model ? { model } : {},
|
|
10285
|
+
...output ? { output } : {},
|
|
10286
|
+
timestamp,
|
|
10287
|
+
status
|
|
10288
|
+
};
|
|
10289
|
+
}
|
|
10243
10290
|
function truncateCodexAspTranscriptOutput(output, maxChars = MAX_CODEX_ASP_TRANSCRIPT_OUTPUT_CHARS) {
|
|
10244
10291
|
return buildOutputPreview(output, {
|
|
10245
10292
|
maxChars,
|
|
@@ -10343,6 +10390,9 @@ function itemToTranscriptItem(item, timestamp, status) {
|
|
|
10343
10390
|
};
|
|
10344
10391
|
}
|
|
10345
10392
|
if (item.type === "dynamicToolCall") {
|
|
10393
|
+
if (item.namespace === "collab" && item.tool === "wait") {
|
|
10394
|
+
return null;
|
|
10395
|
+
}
|
|
10346
10396
|
return {
|
|
10347
10397
|
type: "toolCall",
|
|
10348
10398
|
id: item.id,
|
|
@@ -10356,18 +10406,19 @@ function itemToTranscriptItem(item, timestamp, status) {
|
|
|
10356
10406
|
}
|
|
10357
10407
|
if (item.type === "collabAgentToolCall") {
|
|
10358
10408
|
if (item.tool === "spawnAgent" && item.receiverThreadIds.length > 0) {
|
|
10359
|
-
return {
|
|
10360
|
-
type: "subagent",
|
|
10409
|
+
return codexSubagentTranscriptItem({
|
|
10361
10410
|
id: item.id,
|
|
10362
10411
|
description: item.receiverThreadIds.length === 1 ? "Codex subagent" : `Codex subagents (${item.receiverThreadIds.length})`,
|
|
10363
10412
|
prompt: item.prompt ?? "",
|
|
10364
|
-
subagentType: "codex",
|
|
10365
10413
|
receiverThreadIds: item.receiverThreadIds,
|
|
10366
|
-
|
|
10414
|
+
model: item.model ?? void 0,
|
|
10367
10415
|
output: stringifyCollabAgentStates(item.agentsStates),
|
|
10368
10416
|
timestamp,
|
|
10369
10417
|
status: normalizeCodexAspTranscriptStatus(item.status, item.status === "failed")
|
|
10370
|
-
};
|
|
10418
|
+
});
|
|
10419
|
+
}
|
|
10420
|
+
if (item.tool === "wait") {
|
|
10421
|
+
return null;
|
|
10371
10422
|
}
|
|
10372
10423
|
return {
|
|
10373
10424
|
type: "toolCall",
|
|
@@ -10380,6 +10431,16 @@ function itemToTranscriptItem(item, timestamp, status) {
|
|
|
10380
10431
|
status: normalizeCodexAspTranscriptStatus(item.status, item.status === "failed")
|
|
10381
10432
|
};
|
|
10382
10433
|
}
|
|
10434
|
+
if (item.type === "subAgentActivity" && item.kind === "started") {
|
|
10435
|
+
return codexSubagentTranscriptItem({
|
|
10436
|
+
id: item.id,
|
|
10437
|
+
description: item.agentPath,
|
|
10438
|
+
prompt: "",
|
|
10439
|
+
receiverThreadIds: [item.agentThreadId],
|
|
10440
|
+
timestamp,
|
|
10441
|
+
status
|
|
10442
|
+
});
|
|
10443
|
+
}
|
|
10383
10444
|
if (item.type === "webSearch") {
|
|
10384
10445
|
return {
|
|
10385
10446
|
type: "webSearch",
|
|
@@ -14435,7 +14496,11 @@ function isSameAcceptedUserEvent(event, acceptedEvent) {
|
|
|
14435
14496
|
if (areSameUserMessageEvents(event, acceptedEvent)) return true;
|
|
14436
14497
|
const eventMessage = getUserMessage(event);
|
|
14437
14498
|
const acceptedMessage = getUserMessage(acceptedEvent);
|
|
14438
|
-
|
|
14499
|
+
if (!eventMessage || !acceptedMessage) return false;
|
|
14500
|
+
return areUserMessagesWithinMatchWindow(
|
|
14501
|
+
{ content: eventMessage, timestamp: event.timestamp },
|
|
14502
|
+
{ content: acceptedMessage, timestamp: acceptedEvent.timestamp }
|
|
14503
|
+
);
|
|
14439
14504
|
}
|
|
14440
14505
|
function getCodexTranscriptUserMessages(transcript) {
|
|
14441
14506
|
if (!transcript) return [];
|