@mindstudio-ai/remy 0.1.57 → 0.1.58
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/headless.js +24 -1
- package/dist/index.js +24 -1
- package/package.json +1 -1
package/dist/headless.js
CHANGED
|
@@ -647,7 +647,7 @@ var CONVERSATION_SUMMARY_PROMPT = readAsset("compaction", "conversation.md");
|
|
|
647
647
|
var SUBAGENT_SUMMARY_PROMPT = readAsset("compaction", "subagent.md");
|
|
648
648
|
var SUMMARIZABLE_SUBAGENTS = ["visualDesignExpert", "productVision"];
|
|
649
649
|
async function compactConversation(state, apiConfig) {
|
|
650
|
-
const insertionIndex = state.messages
|
|
650
|
+
const insertionIndex = findSafeInsertionPoint(state.messages);
|
|
651
651
|
const summaries = [];
|
|
652
652
|
const tasks = [];
|
|
653
653
|
const conversationMessages = getConversationMessagesForSummary(
|
|
@@ -711,6 +711,29 @@ async function compactConversation(state, apiConfig) {
|
|
|
711
711
|
messagesAfter: state.messages.length - insertionIndex - checkpointMessages.length
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
|
+
function findSafeInsertionPoint(messages) {
|
|
715
|
+
let idx = messages.length;
|
|
716
|
+
while (idx > 0) {
|
|
717
|
+
const msg = messages[idx - 1];
|
|
718
|
+
if (msg.role === "user" && msg.toolCallId) {
|
|
719
|
+
idx--;
|
|
720
|
+
} else {
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (idx < messages.length && idx > 0) {
|
|
725
|
+
const msg = messages[idx - 1];
|
|
726
|
+
if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
727
|
+
const hasToolUse = msg.content.some(
|
|
728
|
+
(b) => b.type === "tool"
|
|
729
|
+
);
|
|
730
|
+
if (hasToolUse) {
|
|
731
|
+
idx--;
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return idx;
|
|
736
|
+
}
|
|
714
737
|
function getConversationMessagesForSummary(messages, endIndex) {
|
|
715
738
|
let startIdx = 0;
|
|
716
739
|
for (let i = endIndex - 1; i >= 0; i--) {
|
package/dist/index.js
CHANGED
|
@@ -5609,7 +5609,7 @@ var init_config = __esm({
|
|
|
5609
5609
|
|
|
5610
5610
|
// src/compaction/index.ts
|
|
5611
5611
|
async function compactConversation(state, apiConfig) {
|
|
5612
|
-
const insertionIndex = state.messages
|
|
5612
|
+
const insertionIndex = findSafeInsertionPoint(state.messages);
|
|
5613
5613
|
const summaries = [];
|
|
5614
5614
|
const tasks = [];
|
|
5615
5615
|
const conversationMessages = getConversationMessagesForSummary(
|
|
@@ -5673,6 +5673,29 @@ async function compactConversation(state, apiConfig) {
|
|
|
5673
5673
|
messagesAfter: state.messages.length - insertionIndex - checkpointMessages.length
|
|
5674
5674
|
});
|
|
5675
5675
|
}
|
|
5676
|
+
function findSafeInsertionPoint(messages) {
|
|
5677
|
+
let idx = messages.length;
|
|
5678
|
+
while (idx > 0) {
|
|
5679
|
+
const msg = messages[idx - 1];
|
|
5680
|
+
if (msg.role === "user" && msg.toolCallId) {
|
|
5681
|
+
idx--;
|
|
5682
|
+
} else {
|
|
5683
|
+
break;
|
|
5684
|
+
}
|
|
5685
|
+
}
|
|
5686
|
+
if (idx < messages.length && idx > 0) {
|
|
5687
|
+
const msg = messages[idx - 1];
|
|
5688
|
+
if (msg.role === "assistant" && Array.isArray(msg.content)) {
|
|
5689
|
+
const hasToolUse = msg.content.some(
|
|
5690
|
+
(b) => b.type === "tool"
|
|
5691
|
+
);
|
|
5692
|
+
if (hasToolUse) {
|
|
5693
|
+
idx--;
|
|
5694
|
+
}
|
|
5695
|
+
}
|
|
5696
|
+
}
|
|
5697
|
+
return idx;
|
|
5698
|
+
}
|
|
5676
5699
|
function getConversationMessagesForSummary(messages, endIndex) {
|
|
5677
5700
|
let startIdx = 0;
|
|
5678
5701
|
for (let i = endIndex - 1; i >= 0; i--) {
|