replicas-engine 0.1.573 → 0.1.574
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 +40 -3
- package/package.json +1 -1
package/dist/src/index.js
CHANGED
|
@@ -5345,12 +5345,48 @@ function mergeCodexAspDisplayMessages(primary, supplemental) {
|
|
|
5345
5345
|
}
|
|
5346
5346
|
function parseCodexAspTranscript(transcript) {
|
|
5347
5347
|
const messages = [];
|
|
5348
|
-
const orderedItems = transcript.turns.map((turn, turnIndex) => ({ turn, turnIndex })).flatMap(({ turn, turnIndex }) => turn.items.map((item, itemIndex) => ({ item, turnIndex, itemIndex }))).sort((a, b) => {
|
|
5348
|
+
const orderedItems = transcript.turns.map((turn, turnIndex) => ({ turn, turnIndex })).flatMap(({ turn, turnIndex }) => turn.items.map((item, itemIndex) => ({ item, turn, turnIndex, itemIndex }))).sort((a, b) => {
|
|
5349
5349
|
const aSequence = a.item.sequence ?? Number.MAX_SAFE_INTEGER;
|
|
5350
5350
|
const bSequence = b.item.sequence ?? Number.MAX_SAFE_INTEGER;
|
|
5351
5351
|
return aSequence - bSequence || parseTimestampMs(a.item.timestamp) - parseTimestampMs(b.item.timestamp) || a.turnIndex - b.turnIndex || a.itemIndex - b.itemIndex;
|
|
5352
5352
|
});
|
|
5353
|
-
|
|
5353
|
+
const reasoningByTurnId = /* @__PURE__ */ new Map();
|
|
5354
|
+
for (const { item, turn } of orderedItems) {
|
|
5355
|
+
if (item.type !== "reasoning" || !item.text.trim()) continue;
|
|
5356
|
+
const reasoning = reasoningByTurnId.get(turn.id) ?? [];
|
|
5357
|
+
reasoning.push(item);
|
|
5358
|
+
reasoningByTurnId.set(turn.id, reasoning);
|
|
5359
|
+
}
|
|
5360
|
+
const emittedReasoningTurnIds = /* @__PURE__ */ new Set();
|
|
5361
|
+
const coalescedItems = orderedItems.flatMap((entry) => {
|
|
5362
|
+
if (entry.item.type !== "reasoning") return [entry];
|
|
5363
|
+
const reasoning = reasoningByTurnId.get(entry.turn.id);
|
|
5364
|
+
if (!reasoning || emittedReasoningTurnIds.has(entry.turn.id)) return [];
|
|
5365
|
+
emittedReasoningTurnIds.add(entry.turn.id);
|
|
5366
|
+
return [{
|
|
5367
|
+
...entry,
|
|
5368
|
+
item: {
|
|
5369
|
+
type: "reasoning",
|
|
5370
|
+
id: entry.turn.id,
|
|
5371
|
+
text: reasoning.map(({ text }) => text.trim()).join("\n\n"),
|
|
5372
|
+
timestamp: entry.turn.startedAt,
|
|
5373
|
+
status: reasoning.at(-1)?.status ?? "completed",
|
|
5374
|
+
sequence: entry.item.sequence
|
|
5375
|
+
}
|
|
5376
|
+
}];
|
|
5377
|
+
});
|
|
5378
|
+
for (const turn of transcript.turns) {
|
|
5379
|
+
const reasoningIndex = coalescedItems.findIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "reasoning");
|
|
5380
|
+
if (reasoningIndex === -1) continue;
|
|
5381
|
+
let finalAnswerIndex = coalescedItems.findIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "agentMessage" && item.phase === "final_answer");
|
|
5382
|
+
if (finalAnswerIndex === -1 && normalizeCodexAspTranscriptStatus(turn.status) !== "in_progress") {
|
|
5383
|
+
finalAnswerIndex = coalescedItems.findLastIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "agentMessage");
|
|
5384
|
+
}
|
|
5385
|
+
if (finalAnswerIndex === -1 || reasoningIndex < finalAnswerIndex) continue;
|
|
5386
|
+
const [reasoning] = coalescedItems.splice(reasoningIndex, 1);
|
|
5387
|
+
coalescedItems.splice(finalAnswerIndex, 0, reasoning);
|
|
5388
|
+
}
|
|
5389
|
+
for (const { item } of coalescedItems) {
|
|
5354
5390
|
const message = messageForItem(item);
|
|
5355
5391
|
if (message) {
|
|
5356
5392
|
messages.push(message);
|
|
@@ -10787,7 +10823,7 @@ var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
|
|
|
10787
10823
|
var MIN_CODEX_CLI_VERSION = "0.144.6";
|
|
10788
10824
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
10789
10825
|
var codexCliVersionEnsured = null;
|
|
10790
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
10826
|
+
var ENGINE_PACKAGE_VERSION = "0.1.574";
|
|
10791
10827
|
var INITIALIZE_METHOD = "initialize";
|
|
10792
10828
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
10793
10829
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -11222,6 +11258,7 @@ function itemToTranscriptItem(item, timestamp, status) {
|
|
|
11222
11258
|
type: "agentMessage",
|
|
11223
11259
|
id: item.id,
|
|
11224
11260
|
text: item.text,
|
|
11261
|
+
phase: item.phase,
|
|
11225
11262
|
timestamp
|
|
11226
11263
|
};
|
|
11227
11264
|
}
|