muuuuse 3.3.5 → 3.3.7
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/package.json +1 -1
- package/src/agents.js +37 -14
- package/src/runtime.js +6 -1
package/package.json
CHANGED
package/src/agents.js
CHANGED
|
@@ -735,33 +735,56 @@ function selectGeminiSessionFile(currentPath, processStartedAtMs, options = {})
|
|
|
735
735
|
return selectSessionCandidatePath(candidates, projectHash, processStartedAtMs);
|
|
736
736
|
}
|
|
737
737
|
|
|
738
|
-
function
|
|
738
|
+
function parseGeminiMessage(message, options = {}) {
|
|
739
|
+
const flowMode = options.flowMode === true;
|
|
740
|
+
if (!message || message.type !== "gemini" || typeof message.content !== "string") {
|
|
741
|
+
return null;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
const text = sanitizeRelayText(message.content);
|
|
745
|
+
if (!text) {
|
|
746
|
+
return null;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
const toolCalls = Array.isArray(message.toolCalls) ? message.toolCalls : [];
|
|
750
|
+
const phase = toolCalls.length > 0 ? "commentary" : "final_answer";
|
|
751
|
+
if (phase === "commentary" && !flowMode) {
|
|
752
|
+
return null;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
return {
|
|
756
|
+
id: message.id || hashText(JSON.stringify(message)),
|
|
757
|
+
text,
|
|
758
|
+
phase,
|
|
759
|
+
timestamp: message.timestamp || new Date().toISOString(),
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function readGeminiAnswers(filePath, lastMessageId = null, sinceMs = null, options = {}) {
|
|
739
764
|
try {
|
|
740
765
|
const entry = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
741
766
|
const messages = Array.isArray(entry.messages) ? entry.messages : [];
|
|
742
|
-
const finalMessages = messages.filter((message) => {
|
|
743
|
-
const toolCalls = Array.isArray(message.toolCalls) ? message.toolCalls : [];
|
|
744
|
-
return message.type === "gemini" && typeof message.content === "string" && message.content.trim() && toolCalls.length === 0;
|
|
745
|
-
});
|
|
746
767
|
|
|
747
768
|
let startIndex = 0;
|
|
748
769
|
if (lastMessageId) {
|
|
749
|
-
const previousIndex =
|
|
750
|
-
startIndex = previousIndex === -1 ?
|
|
770
|
+
const previousIndex = messages.findIndex((message) => message?.id === lastMessageId);
|
|
771
|
+
startIndex = previousIndex === -1 ? 0 : previousIndex + 1;
|
|
751
772
|
}
|
|
752
773
|
|
|
753
|
-
const answers =
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
774
|
+
const answers = messages
|
|
775
|
+
.slice(startIndex)
|
|
776
|
+
.map((message) => parseGeminiMessage(message, options))
|
|
777
|
+
.filter((answer) => answer !== null);
|
|
778
|
+
|
|
779
|
+
const lastSeenMessage = [...messages]
|
|
780
|
+
.reverse()
|
|
781
|
+
.find((message) => typeof message?.id === "string" && message.id.trim());
|
|
759
782
|
|
|
760
783
|
return {
|
|
761
784
|
answers: answers
|
|
762
785
|
.filter((answer) => answer.text.length > 0)
|
|
763
786
|
.filter((answer) => isAnswerNewEnough(answer, sinceMs)),
|
|
764
|
-
lastMessageId:
|
|
787
|
+
lastMessageId: lastSeenMessage?.id || lastMessageId,
|
|
765
788
|
fileSize: getFileSize(filePath),
|
|
766
789
|
};
|
|
767
790
|
} catch {
|
package/src/runtime.js
CHANGED
|
@@ -42,6 +42,7 @@ const {
|
|
|
42
42
|
// A short settle delay keeps interactive CLIs from treating submit as another newline.
|
|
43
43
|
const TYPE_CHUNK_DELAY_MS = 45;
|
|
44
44
|
const TYPE_CHUNK_SIZE = 24;
|
|
45
|
+
const GEMINI_PASTE_SETTLE_MS = 200;
|
|
45
46
|
const BRACKETED_PASTE_START = "\u001b[200~";
|
|
46
47
|
const BRACKETED_PASTE_END = "\u001b[201~";
|
|
47
48
|
const GEMINI_SHARED_ENTRY_NAMES = new Set([
|
|
@@ -761,7 +762,7 @@ async function sendTextAndEnter(child, text, shouldAbort = () => false) {
|
|
|
761
762
|
const payload = normalizeRelayPayloadForTyping(text);
|
|
762
763
|
|
|
763
764
|
if (payload.length > 0) {
|
|
764
|
-
if (agentType === "codex") {
|
|
765
|
+
if (agentType === "codex" || agentType === "gemini") {
|
|
765
766
|
if (shouldStop() || !child) {
|
|
766
767
|
return false;
|
|
767
768
|
}
|
|
@@ -771,6 +772,10 @@ async function sendTextAndEnter(child, text, shouldAbort = () => false) {
|
|
|
771
772
|
} catch {
|
|
772
773
|
return false;
|
|
773
774
|
}
|
|
775
|
+
|
|
776
|
+
if (agentType === "gemini") {
|
|
777
|
+
await sleep(GEMINI_PASTE_SETTLE_MS);
|
|
778
|
+
}
|
|
774
779
|
} else {
|
|
775
780
|
for (const chunk of chunkRelayPayloadForTyping(payload)) {
|
|
776
781
|
if (shouldStop() || !child) {
|