@hienlh/ppm 0.9.56 → 0.9.57
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -56,12 +56,19 @@ export interface StreamResult {
|
|
|
56
56
|
* - "md" = raw markdown from AI (needs conversion)
|
|
57
57
|
* - "html" = pre-formatted HTML (tool calls, thinking, errors — already escaped)
|
|
58
58
|
*/
|
|
59
|
-
type Segment =
|
|
59
|
+
type Segment =
|
|
60
|
+
| { type: "md"; text: string }
|
|
61
|
+
| { type: "html"; text: string }
|
|
62
|
+
| { type: "thinking"; text: string };
|
|
60
63
|
|
|
61
64
|
/** Render segments into Telegram HTML */
|
|
62
65
|
function renderSegments(segments: Segment[]): string {
|
|
63
66
|
return segments
|
|
64
|
-
.map((s) =>
|
|
67
|
+
.map((s) => {
|
|
68
|
+
if (s.type === "md") return markdownToTelegramHtml(s.text);
|
|
69
|
+
if (s.type === "thinking") return `\n<i>💭 ${escapeHtml(s.text)}</i>\n`;
|
|
70
|
+
return s.text;
|
|
71
|
+
})
|
|
65
72
|
.join("");
|
|
66
73
|
}
|
|
67
74
|
|
|
@@ -168,7 +175,12 @@ export async function streamToTelegram(
|
|
|
168
175
|
|
|
169
176
|
case "thinking": {
|
|
170
177
|
if (config.showThinking && event.content) {
|
|
171
|
-
|
|
178
|
+
const last = segments[segments.length - 1];
|
|
179
|
+
if (last?.type === "thinking") {
|
|
180
|
+
last.text += event.content;
|
|
181
|
+
} else {
|
|
182
|
+
segments.push({ type: "thinking", text: event.content });
|
|
183
|
+
}
|
|
172
184
|
await editCurrent();
|
|
173
185
|
}
|
|
174
186
|
break;
|