replicas-cli 0.2.474 → 0.2.476
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/index.mjs +39 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -10084,7 +10084,7 @@ function formatTurnElapsed(ms) {
|
|
|
10084
10084
|
}
|
|
10085
10085
|
|
|
10086
10086
|
// ../shared/src/cli-version.ts
|
|
10087
|
-
var CLI_VERSION = "0.2.
|
|
10087
|
+
var CLI_VERSION = "0.2.476";
|
|
10088
10088
|
|
|
10089
10089
|
// ../shared/src/version.ts
|
|
10090
10090
|
function compareVersions(v1, v2) {
|
|
@@ -26759,12 +26759,48 @@ function mergeCodexAspDisplayMessages(primary, supplemental) {
|
|
|
26759
26759
|
}
|
|
26760
26760
|
function parseCodexAspTranscript(transcript) {
|
|
26761
26761
|
const messages = [];
|
|
26762
|
-
const orderedItems = transcript.turns.map((turn, turnIndex) => ({ turn, turnIndex })).flatMap(({ turn, turnIndex }) => turn.items.map((item, itemIndex) => ({ item, turnIndex, itemIndex }))).sort((a, b) => {
|
|
26762
|
+
const orderedItems = transcript.turns.map((turn, turnIndex) => ({ turn, turnIndex })).flatMap(({ turn, turnIndex }) => turn.items.map((item, itemIndex) => ({ item, turn, turnIndex, itemIndex }))).sort((a, b) => {
|
|
26763
26763
|
const aSequence = a.item.sequence ?? Number.MAX_SAFE_INTEGER;
|
|
26764
26764
|
const bSequence = b.item.sequence ?? Number.MAX_SAFE_INTEGER;
|
|
26765
26765
|
return aSequence - bSequence || parseTimestampMs(a.item.timestamp) - parseTimestampMs(b.item.timestamp) || a.turnIndex - b.turnIndex || a.itemIndex - b.itemIndex;
|
|
26766
26766
|
});
|
|
26767
|
-
|
|
26767
|
+
const reasoningByTurnId = /* @__PURE__ */ new Map();
|
|
26768
|
+
for (const { item, turn } of orderedItems) {
|
|
26769
|
+
if (item.type !== "reasoning" || !item.text.trim()) continue;
|
|
26770
|
+
const reasoning = reasoningByTurnId.get(turn.id) ?? [];
|
|
26771
|
+
reasoning.push(item);
|
|
26772
|
+
reasoningByTurnId.set(turn.id, reasoning);
|
|
26773
|
+
}
|
|
26774
|
+
const emittedReasoningTurnIds = /* @__PURE__ */ new Set();
|
|
26775
|
+
const coalescedItems = orderedItems.flatMap((entry) => {
|
|
26776
|
+
if (entry.item.type !== "reasoning") return [entry];
|
|
26777
|
+
const reasoning = reasoningByTurnId.get(entry.turn.id);
|
|
26778
|
+
if (!reasoning || emittedReasoningTurnIds.has(entry.turn.id)) return [];
|
|
26779
|
+
emittedReasoningTurnIds.add(entry.turn.id);
|
|
26780
|
+
return [{
|
|
26781
|
+
...entry,
|
|
26782
|
+
item: {
|
|
26783
|
+
type: "reasoning",
|
|
26784
|
+
id: entry.turn.id,
|
|
26785
|
+
text: reasoning.map(({ text }) => text.trim()).join("\n\n"),
|
|
26786
|
+
timestamp: entry.turn.startedAt,
|
|
26787
|
+
status: reasoning.at(-1)?.status ?? "completed",
|
|
26788
|
+
sequence: entry.item.sequence
|
|
26789
|
+
}
|
|
26790
|
+
}];
|
|
26791
|
+
});
|
|
26792
|
+
for (const turn of transcript.turns) {
|
|
26793
|
+
const reasoningIndex = coalescedItems.findIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "reasoning");
|
|
26794
|
+
if (reasoningIndex === -1) continue;
|
|
26795
|
+
let finalAnswerIndex = coalescedItems.findIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "agentMessage" && item.phase === "final_answer");
|
|
26796
|
+
if (finalAnswerIndex === -1 && normalizeCodexAspTranscriptStatus(turn.status) !== "in_progress") {
|
|
26797
|
+
finalAnswerIndex = coalescedItems.findLastIndex(({ item, turn: itemTurn }) => itemTurn.id === turn.id && item.type === "agentMessage");
|
|
26798
|
+
}
|
|
26799
|
+
if (finalAnswerIndex === -1 || reasoningIndex < finalAnswerIndex) continue;
|
|
26800
|
+
const [reasoning] = coalescedItems.splice(reasoningIndex, 1);
|
|
26801
|
+
coalescedItems.splice(finalAnswerIndex, 0, reasoning);
|
|
26802
|
+
}
|
|
26803
|
+
for (const { item } of coalescedItems) {
|
|
26768
26804
|
const message = messageForItem(item);
|
|
26769
26805
|
if (message) {
|
|
26770
26806
|
messages.push(message);
|