@lih-x-x/kmr 1.0.10 → 1.0.12
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.js +20 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -924,25 +924,30 @@ var SessionManager = class {
|
|
|
924
924
|
extractReply(output) {
|
|
925
925
|
const lines = output.split("\n");
|
|
926
926
|
const metaPrefixes = ["[client]", "[tool]", "[thinking]", "[done]", "[error]", "[warn]", "[info]"];
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
if (current.length > 0) {
|
|
933
|
-
blocks.push(current.join("\n").trim());
|
|
934
|
-
current = [];
|
|
935
|
-
}
|
|
927
|
+
let endIdx = lines.length - 1;
|
|
928
|
+
while (endIdx >= 0) {
|
|
929
|
+
const t = lines[endIdx].trim();
|
|
930
|
+
if (t.length === 0 || metaPrefixes.some((p) => t.startsWith(p))) {
|
|
931
|
+
endIdx--;
|
|
936
932
|
} else {
|
|
937
|
-
|
|
933
|
+
break;
|
|
938
934
|
}
|
|
939
935
|
}
|
|
940
|
-
if (
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
936
|
+
if (endIdx < 0) return output.trim();
|
|
937
|
+
let startIdx = endIdx;
|
|
938
|
+
while (startIdx > 0) {
|
|
939
|
+
const prevLine = lines[startIdx - 1];
|
|
940
|
+
const prevTrimmed = prevLine.trim();
|
|
941
|
+
const isToolOrMeta = metaPrefixes.some((p) => prevTrimmed.startsWith(p)) || /^\s{2,}(kind|input|output):/.test(prevLine) || /\(completed\)/.test(prevLine) || /^\s{2,}```/.test(prevLine) || prevLine.startsWith(" ") && /^\s{2,}\S/.test(prevLine);
|
|
942
|
+
if (isToolOrMeta) break;
|
|
943
|
+
if (prevTrimmed.length === 0) {
|
|
944
|
+
startIdx--;
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
startIdx--;
|
|
945
948
|
}
|
|
949
|
+
const reply = lines.slice(startIdx, endIdx + 1).join("\n").trim();
|
|
950
|
+
if (reply.length > 0) return reply;
|
|
946
951
|
return output.trim();
|
|
947
952
|
}
|
|
948
953
|
async appendSummary(userId, userText, aiReply) {
|