@skydiveai/pi-extensions 0.1.258-beta.130 → 0.1.258-beta.131
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 +24 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2623,6 +2623,28 @@ function assistantMessage(entry) {
|
|
|
2623
2623
|
function isSdkToolResult(entry) {
|
|
2624
2624
|
return entry.type === "user" && sdkToolResultSchema.safeParse(entry.message).success;
|
|
2625
2625
|
}
|
|
2626
|
+
/**
|
|
2627
|
+
* On resume, the pinned CLI inserts a `<synthetic>` "No response requested."
|
|
2628
|
+
* assistant turn after a trailing tool_result, before the continuation prompt.
|
|
2629
|
+
* Each tool step therefore stores one placeholder pair. Inside the current turn
|
|
2630
|
+
* the pair must stay so the cached prefix is byte-identical between steps, but
|
|
2631
|
+
* once a newer user message exists it is dropped: otherwise the model rereads
|
|
2632
|
+
* itself saying "No response requested." once per historical tool step.
|
|
2633
|
+
*/
|
|
2634
|
+
function withoutResumePlaceholders(entries) {
|
|
2635
|
+
let dropPrompt = false;
|
|
2636
|
+
return entries.filter((entry) => {
|
|
2637
|
+
if (assistantMessage(entry)?.model === "<synthetic>") {
|
|
2638
|
+
dropPrompt = true;
|
|
2639
|
+
return false;
|
|
2640
|
+
}
|
|
2641
|
+
if (dropPrompt && entry.type === "user") {
|
|
2642
|
+
dropPrompt = false;
|
|
2643
|
+
return false;
|
|
2644
|
+
}
|
|
2645
|
+
return true;
|
|
2646
|
+
});
|
|
2647
|
+
}
|
|
2626
2648
|
function contentHash(message) {
|
|
2627
2649
|
return createHash("sha256").update(JSON.stringify(message.content)).digest("hex");
|
|
2628
2650
|
}
|
|
@@ -2780,6 +2802,7 @@ async function prepareSeatHistory({ context, configDir, cwd, toolName, model })
|
|
|
2780
2802
|
resume: null,
|
|
2781
2803
|
boundaryId: null
|
|
2782
2804
|
};
|
|
2805
|
+
const lastUserIndex = context.messages.findLastIndex((message) => message.role === "user");
|
|
2783
2806
|
const sessionId = randomUUID();
|
|
2784
2807
|
let parentUuid = null;
|
|
2785
2808
|
const entries = messages.flatMap((message, index) => {
|
|
@@ -2789,7 +2812,7 @@ async function prepareSeatHistory({ context, configDir, cwd, toolName, model })
|
|
|
2789
2812
|
const nextHash = hashes[index + 1];
|
|
2790
2813
|
if (message.role === "user" && next?.role === "assistant" && nextHash && seatTranscript(next, nextHash)?.replacesUser) return [];
|
|
2791
2814
|
const preserved = message.role === "assistant" ? seatTranscript(message, prefixHash) : null;
|
|
2792
|
-
if (preserved) return preserved.entries.map((entry) => {
|
|
2815
|
+
if (preserved) return (index < lastUserIndex ? withoutResumePlaceholders(preserved.entries) : preserved.entries).map((entry) => {
|
|
2793
2816
|
const uuid = randomUUID();
|
|
2794
2817
|
const replay = {
|
|
2795
2818
|
...entry,
|