@tiens.nguyen/gonext-local-worker 1.0.146 → 1.0.148
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/gonext-local-worker.mjs +23 -1
- package/package.json +1 -1
package/gonext-local-worker.mjs
CHANGED
|
@@ -1538,6 +1538,19 @@ async function runAgentChatJob(job) {
|
|
|
1538
1538
|
|
|
1539
1539
|
let inThink = false;
|
|
1540
1540
|
let finalText = "";
|
|
1541
|
+
// Raw model-stream tokens (event.type === "stream") are Python code + `Thought:`
|
|
1542
|
+
// prose + <code>/<|"|> fragments. The web Thought panel renders reasoning as
|
|
1543
|
+
// markdown, which turns `#`-prefixed code comments into <h1> headings and
|
|
1544
|
+
// swallows the tag fragments. Wrap only the raw stream in a fenced code block so
|
|
1545
|
+
// it renders verbatim; `step` labels stay outside the fence as normal prose.
|
|
1546
|
+
// Tilde fences (~~~) avoid colliding with any ``` the model itself emits.
|
|
1547
|
+
let inStreamFence = false;
|
|
1548
|
+
const closeStreamFence = () => {
|
|
1549
|
+
if (inStreamFence) {
|
|
1550
|
+
inStreamFence = false;
|
|
1551
|
+
enqueueText("\n~~~\n\n");
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1541
1554
|
|
|
1542
1555
|
// The create_pdf tool uses WeasyPrint, whose Homebrew libs (pango/cairo/gobject)
|
|
1543
1556
|
// live in /opt/homebrew/lib (Apple Silicon) or /usr/local/lib (Intel). macOS doesn't
|
|
@@ -1557,19 +1570,27 @@ async function runAgentChatJob(job) {
|
|
|
1557
1570
|
} else if (event.type === "stream" && typeof event.text === "string") {
|
|
1558
1571
|
// Live model token stream (the agent's Thought / reasoning as it generates).
|
|
1559
1572
|
// Goes inside the same <think> block as the step summaries, but RAW — no
|
|
1560
|
-
// "\n\n" separator, so the tokens concatenate into flowing text.
|
|
1573
|
+
// "\n\n" separator, so the tokens concatenate into flowing text. Wrapped in
|
|
1574
|
+
// a code fence (opened lazily on the first stream token) so the web viewer
|
|
1575
|
+
// renders it verbatim instead of as markdown.
|
|
1561
1576
|
if (!inThink) {
|
|
1562
1577
|
inThink = true;
|
|
1563
1578
|
enqueueText("<think>");
|
|
1564
1579
|
}
|
|
1580
|
+
if (!inStreamFence) {
|
|
1581
|
+
inStreamFence = true;
|
|
1582
|
+
enqueueText("~~~\n");
|
|
1583
|
+
}
|
|
1565
1584
|
enqueueText(event.text);
|
|
1566
1585
|
} else if (event.type === "step" && typeof event.text === "string") {
|
|
1586
|
+
closeStreamFence();
|
|
1567
1587
|
if (!inThink) {
|
|
1568
1588
|
inThink = true;
|
|
1569
1589
|
enqueueText("<think>");
|
|
1570
1590
|
}
|
|
1571
1591
|
enqueueText(event.text + "\n\n");
|
|
1572
1592
|
} else if (event.type === "final" && typeof event.text === "string") {
|
|
1593
|
+
closeStreamFence();
|
|
1573
1594
|
if (inThink) {
|
|
1574
1595
|
inThink = false;
|
|
1575
1596
|
enqueueText("</think>");
|
|
@@ -1579,6 +1600,7 @@ async function runAgentChatJob(job) {
|
|
|
1579
1600
|
}
|
|
1580
1601
|
}, pdfEnv);
|
|
1581
1602
|
|
|
1603
|
+
closeStreamFence();
|
|
1582
1604
|
if (inThink) {
|
|
1583
1605
|
enqueueText("</think>");
|
|
1584
1606
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiens.nguyen/gonext-local-worker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.148",
|
|
4
4
|
"description": "Polls GoNext cloud API for async local LLM jobs and runs them against Ollama/OpenAI-compatible servers on this Mac",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|