@tiens.nguyen/gonext-local-worker 1.0.97 → 1.0.99
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 +19 -3
- package/gonext_agent_chat.py +18 -1
- package/package.json +1 -1
package/gonext-local-worker.mjs
CHANGED
|
@@ -671,9 +671,13 @@ async function performHttpMeasurement(params) {
|
|
|
671
671
|
* line as they arrive. Resolves when the process exits cleanly; rejects on
|
|
672
672
|
* non-zero exit or timeout. stderr is collected and appended to error messages.
|
|
673
673
|
*/
|
|
674
|
-
function runProcessWithStreamingStdout(cmd, cmdArgs, stdinStr, timeoutMs, onLine) {
|
|
674
|
+
function runProcessWithStreamingStdout(cmd, cmdArgs, stdinStr, timeoutMs, onLine, extraEnv) {
|
|
675
675
|
return new Promise((resolve, reject) => {
|
|
676
|
-
const
|
|
676
|
+
const spawnOpts = { stdio: ["pipe", "pipe", "pipe"] };
|
|
677
|
+
if (extraEnv && Object.keys(extraEnv).length > 0) {
|
|
678
|
+
spawnOpts.env = { ...process.env, ...extraEnv };
|
|
679
|
+
}
|
|
680
|
+
const child = spawn(cmd, cmdArgs, spawnOpts);
|
|
677
681
|
let stderr = "";
|
|
678
682
|
let lineBuffer = "";
|
|
679
683
|
let timedOut = false;
|
|
@@ -1390,6 +1394,18 @@ async function runAgentChatJob(job) {
|
|
|
1390
1394
|
let inThink = false;
|
|
1391
1395
|
let finalText = "";
|
|
1392
1396
|
|
|
1397
|
+
// The create_pdf tool uses WeasyPrint, whose Homebrew libs (pango/cairo/gobject)
|
|
1398
|
+
// live in /opt/homebrew/lib (Apple Silicon) or /usr/local/lib (Intel). macOS doesn't
|
|
1399
|
+
// search those by default, so ctypes can't dlopen them. Inject the path for the child
|
|
1400
|
+
// so users don't have to set DYLD_FALLBACK_LIBRARY_PATH themselves.
|
|
1401
|
+
let pdfEnv;
|
|
1402
|
+
if (process.platform === "darwin") {
|
|
1403
|
+
const existing = process.env.DYLD_FALLBACK_LIBRARY_PATH ?? "";
|
|
1404
|
+
const brewLibs = ["/opt/homebrew/lib", "/usr/local/lib"];
|
|
1405
|
+
const merged = [existing, ...brewLibs].filter(Boolean).join(":");
|
|
1406
|
+
pdfEnv = { DYLD_FALLBACK_LIBRARY_PATH: merged };
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1393
1409
|
await runProcessWithStreamingStdout(python, [scriptPath], input, timeoutMs, (event) => {
|
|
1394
1410
|
if (event.type === "log" && typeof event.text === "string") {
|
|
1395
1411
|
console.log(`[gonext-agent] ${event.text}`);
|
|
@@ -1407,7 +1423,7 @@ async function runAgentChatJob(job) {
|
|
|
1407
1423
|
finalText = event.text;
|
|
1408
1424
|
enqueueText(event.text);
|
|
1409
1425
|
}
|
|
1410
|
-
});
|
|
1426
|
+
}, pdfEnv);
|
|
1411
1427
|
|
|
1412
1428
|
if (inThink) {
|
|
1413
1429
|
enqueueText("</think>");
|
package/gonext_agent_chat.py
CHANGED
|
@@ -368,6 +368,16 @@ _PDF_INSTALL_HINT = (
|
|
|
368
368
|
"then restart the worker. (See the Instructions page in the web app.)"
|
|
369
369
|
)
|
|
370
370
|
|
|
371
|
+
# WeasyPrint IS installed, but its system libraries (pango/cairo/gobject) couldn't be
|
|
372
|
+
# dlopen'd — almost always because the worker process predates the build that injects
|
|
373
|
+
# the Homebrew library path. A worker restart fixes it.
|
|
374
|
+
_PDF_LIBS_HINT = (
|
|
375
|
+
"PDF engine is installed but its system libraries could not be loaded. "
|
|
376
|
+
"Please RESTART the local worker — it automatically points WeasyPrint at the "
|
|
377
|
+
"Homebrew libraries (/opt/homebrew/lib on Apple Silicon, /usr/local/lib on Intel). "
|
|
378
|
+
"If it still fails, confirm `brew install pango libffi` succeeded."
|
|
379
|
+
)
|
|
380
|
+
|
|
371
381
|
# Font stack with color-emoji fallbacks last, so WeasyPrint resolves emoji/flag
|
|
372
382
|
# codepoints (🏆 🇿🇦) to a color font per-glyph while text uses a clean sans-serif.
|
|
373
383
|
_PDF_FONT_STACK = (
|
|
@@ -385,9 +395,16 @@ def _render_pdf_bytes(markdown_text: str, title: str = "") -> bytes:
|
|
|
385
395
|
"""
|
|
386
396
|
try:
|
|
387
397
|
import markdown as _md
|
|
398
|
+
except Exception: # noqa: BLE001 — markdown pip pkg missing
|
|
399
|
+
raise RuntimeError(_PDF_INSTALL_HINT)
|
|
400
|
+
try:
|
|
388
401
|
from weasyprint import HTML as _HTML # pulls pango/cairo via cffi at import
|
|
389
|
-
except
|
|
402
|
+
except ModuleNotFoundError:
|
|
403
|
+
# WeasyPrint itself isn't pip-installed.
|
|
390
404
|
raise RuntimeError(_PDF_INSTALL_HINT)
|
|
405
|
+
except Exception as e: # noqa: BLE001 — installed but cffi can't dlopen the system libs
|
|
406
|
+
_log(f"weasyprint lib load failed: {type(e).__name__}: {str(e)[:200]}")
|
|
407
|
+
raise RuntimeError(_PDF_LIBS_HINT)
|
|
391
408
|
|
|
392
409
|
body_html = _md.markdown(
|
|
393
410
|
markdown_text or "",
|
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.99",
|
|
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",
|