@melaya/runner 1.1.34 → 1.1.36
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/pythonEnv.js +52 -5
- package/package.json +1 -1
package/dist/pythonEnv.js
CHANGED
|
@@ -73,7 +73,15 @@ const PIP_DEPS = [
|
|
|
73
73
|
"filetype",
|
|
74
74
|
"json5",
|
|
75
75
|
"json_repair",
|
|
76
|
-
|
|
76
|
+
// PINNED <2: mcp 2.x renamed `streamablehttp_client` →
|
|
77
|
+
// `streamable_http_client` in mcp.client.streamable_http, which the in-house
|
|
78
|
+
// agentscope imports by the OLD name (agentscope/mcp/_http_state*_client.py).
|
|
79
|
+
// Unpinned `mcp>=1.13` let a FRESH venv pull 2.x → `import agentscope` fails
|
|
80
|
+
// with "cannot import name 'streamablehttp_client'", so the assistant host
|
|
81
|
+
// never boots. Old cached venvs kept 1.x and worked, which is why this only
|
|
82
|
+
// bit fresh installs (e.g. the Mac 3.14→3.12 rebuild). Keep on the 1.x line
|
|
83
|
+
// until agentscope is updated to the 2.x API.
|
|
84
|
+
"mcp>=1.13,<2",
|
|
77
85
|
"numpy",
|
|
78
86
|
"openai",
|
|
79
87
|
"python-datauri",
|
|
@@ -440,14 +448,27 @@ export async function ensurePythonEnv(systemPython, expectedVersion, onProgress
|
|
|
440
448
|
}
|
|
441
449
|
// Step 2: upgrade pip + wheel so wheel-based deps install cleanly.
|
|
442
450
|
onProgress("upgrading pip / wheel inside the venv");
|
|
443
|
-
|
|
451
|
+
// --use-feature=truststore makes pip verify TLS against the OS trust store
|
|
452
|
+
// instead of its bundled roots — required behind TLS-intercepting proxies /
|
|
453
|
+
// antivirus (else "CERTIFICATE_VERIFY_FAILED: unable to get local issuer
|
|
454
|
+
// certificate" and the whole venv build fails → agentscope import breaks).
|
|
455
|
+
// Same fix as uv's UV_SYSTEM_CERTS. Needs pip>=23.2, which every Python we
|
|
456
|
+
// provision (uv-managed 3.12) or accept (3.11/3.12) bundles.
|
|
457
|
+
await runProc(venvPython(), ["-m", "pip", "install", "--use-feature=truststore", "--quiet", "--upgrade", "pip", "wheel"], onProgress);
|
|
444
458
|
// Step 3: install agentscope's transitive deps + tool extras directly.
|
|
445
459
|
// We do NOT pip-install agentscope itself — the shared bundle ships
|
|
446
460
|
// only *.py files (no pyproject.toml), so PYTHONPATH-based import is
|
|
447
461
|
// the only path. The cached agentscope source under
|
|
448
462
|
// ~/.melaya-runner/agentscope/ resolves via PYTHONPATH at spawn time.
|
|
449
463
|
onProgress(`installing ${PIP_DEPS.length} python deps (anthropic, openai, opentelemetry, …) — first run can take 1-2 min`);
|
|
450
|
-
const acode = await runProc(venvPython(),
|
|
464
|
+
const acode = await runProc(venvPython(),
|
|
465
|
+
// --no-cache-dir: skip pip's on-disk HTTP/wheel cache. It silences the
|
|
466
|
+
// "Cache entry deserialization failed, entry ignored" warning flood (stale
|
|
467
|
+
// entries left by other Python versions in the shared user cache) and, more
|
|
468
|
+
// importantly, guarantees a corrupt cached wheel can never install a subtly
|
|
469
|
+
// broken package into a fresh runner venv. Costs a re-download on rebuild,
|
|
470
|
+
// which is rare (only on a deps change or a manual clear).
|
|
471
|
+
["-m", "pip", "install", "--use-feature=truststore", "--no-cache-dir", "--quiet", "--disable-pip-version-check", ...PIP_DEPS], onProgress);
|
|
451
472
|
if (acode !== 0) {
|
|
452
473
|
return {
|
|
453
474
|
ok: false,
|
|
@@ -496,12 +517,38 @@ export async function ensurePythonEnv(systemPython, expectedVersion, onProgress
|
|
|
496
517
|
// this passes, so a half-built venv is never cached as valid: the next
|
|
497
518
|
// launch re-enters this rebuild path and self-heals instead of returning a
|
|
498
519
|
// broken venv as ok.
|
|
499
|
-
|
|
520
|
+
// Importing the in-house agentscope eagerly loads its full submodule tree
|
|
521
|
+
// (model/tool/rag/embedding/…), so it drags in every third-party dep at load
|
|
522
|
+
// time. A single broken wheel therefore surfaces here as an "agentscope"
|
|
523
|
+
// failure even though our package is fine. Import each name in turn and, on
|
|
524
|
+
// the FIRST failure, emit a machine-parseable PROBE_FAIL line naming the exact
|
|
525
|
+
// module + error — captured below so the reason names the real culprit instead
|
|
526
|
+
// of the useless "agentscope import failed" (which sent every Mac 3.14→3.12
|
|
527
|
+
// dep breakage back as an unactionable message).
|
|
528
|
+
let probeErr = "";
|
|
529
|
+
const probe = await runProc(venvPython(), ["-c",
|
|
530
|
+
"import sys\n" +
|
|
531
|
+
"for _m in ('shortuuid','agentscope','anthropic','openai'):\n" +
|
|
532
|
+
" try:\n" +
|
|
533
|
+
" __import__(_m)\n" +
|
|
534
|
+
" except Exception as _e:\n" +
|
|
535
|
+
" import traceback\n" +
|
|
536
|
+
" sys.stderr.write('PROBE_FAIL module=%s %s: %s\\n' % (_m, type(_e).__name__, _e))\n" +
|
|
537
|
+
" traceback.print_exc()\n" +
|
|
538
|
+
" sys.exit(1)\n",
|
|
539
|
+
], (line) => {
|
|
540
|
+
if (/^PROBE_FAIL /.test(line))
|
|
541
|
+
probeErr = line.replace(/^PROBE_FAIL\s+/, "").trim();
|
|
542
|
+
onProgress(line);
|
|
543
|
+
}, { PYTHONPATH: CACHE_DIR });
|
|
500
544
|
if (probe !== 0) {
|
|
545
|
+
const where = venvMinorVersion() === null ? "" : `Python 3.${venvMinorVersion()} `;
|
|
501
546
|
return {
|
|
502
547
|
ok: false,
|
|
503
548
|
pythonPath: systemPython,
|
|
504
|
-
reason:
|
|
549
|
+
reason: probeErr
|
|
550
|
+
? `${where}venv import probe failed — ${probeErr}. Importing agentscope loads its whole dependency tree, so this is the dep that broke (not agentscope itself). See the traceback above; the venv will be rebuilt on next launch.`
|
|
551
|
+
: `agentscope import probe failed on the ${where}venv — a dependency did not import. See the lines above; the venv will be rebuilt on next launch.`,
|
|
505
552
|
};
|
|
506
553
|
}
|
|
507
554
|
writeFileSync(VENV_MARK, venvMarkerValue(expectedVersion), "utf-8");
|