@melaya/runner 1.0.56 → 1.0.58
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/connection.js +41 -2
- package/package.json +1 -1
package/dist/connection.js
CHANGED
|
@@ -490,6 +490,12 @@ export async function connect(opts) {
|
|
|
490
490
|
const runId = payload.run_id;
|
|
491
491
|
const sid = payload.strategy_id;
|
|
492
492
|
const cfg = payload.cfg ?? {};
|
|
493
|
+
// Live bundle hash from the server's getSharedBundleVersion. Falls
|
|
494
|
+
// back to "latest" for backward compat with older servers — but
|
|
495
|
+
// that path cache-locks the runner's ~/.melaya-runner/shared dir
|
|
496
|
+
// to whatever it first downloaded, so every server-side persona
|
|
497
|
+
// fix sits unused. Updated servers always pass this.
|
|
498
|
+
const sharedVersion = String(payload.shared_version ?? "latest");
|
|
493
499
|
console.log(chalk.hex("#10b981")(`\n ▶ Trading crew: ${sid.slice(0, 16)}… (run ${runId.slice(0, 10)}…)`));
|
|
494
500
|
try {
|
|
495
501
|
const mainPyContent = String(cfg.generated_code ?? "").trim();
|
|
@@ -522,10 +528,10 @@ export async function connect(opts) {
|
|
|
522
528
|
// `shared.runtime.trading_crew_personas` (per the codegen
|
|
523
529
|
// template's import_path) which lives in the same shared/ tree
|
|
524
530
|
// the pipeline runner uses.
|
|
525
|
-
await ensureSharedModules(opts.serverUrl,
|
|
531
|
+
await ensureSharedModules(opts.serverUrl, sharedVersion);
|
|
526
532
|
// Dedicated venv with agentscope + anthropic + openai installed.
|
|
527
533
|
const { ensurePythonEnv } = await import("./pythonEnv.js");
|
|
528
|
-
const envResult = await ensurePythonEnv(opts.pythonPath,
|
|
534
|
+
const envResult = await ensurePythonEnv(opts.pythonPath, sharedVersion, (msg) => {
|
|
529
535
|
console.log(chalk.gray(` [venv] ${msg}`));
|
|
530
536
|
socket.emit("runner:event", {
|
|
531
537
|
run_id: runId,
|
|
@@ -572,6 +578,39 @@ export async function connect(opts) {
|
|
|
572
578
|
mkdirSync(runDir, { recursive: true });
|
|
573
579
|
writeFileSync(join(runDir, "main.py"), mainPyContent, "utf-8");
|
|
574
580
|
writeFileSync(join(runDir, "config.json"), JSON.stringify(cfg, null, 2), "utf-8");
|
|
581
|
+
// Materialise static-context bag from the cfg into <runDir>/rag/.
|
|
582
|
+
// The Node server collected these via POST/PUT /pipelines (which
|
|
583
|
+
// ran _materialise_inline_rag_docs on the builder box) and shipped
|
|
584
|
+
// them inline so the runner doesn't need a second HTTP fetch.
|
|
585
|
+
// Without this the spawned crew worker logs "RAG_DIR missing" and
|
|
586
|
+
// _load_rag_context() returns empty — every wizard Context card
|
|
587
|
+
// is silently lost.
|
|
588
|
+
const ragFilesFromCfg = cfg.rag_files;
|
|
589
|
+
if (ragFilesFromCfg && typeof ragFilesFromCfg === "object") {
|
|
590
|
+
const ragDir = join(runDir, "rag");
|
|
591
|
+
mkdirSync(ragDir, { recursive: true });
|
|
592
|
+
let wrote = 0;
|
|
593
|
+
for (const [fname, b64] of Object.entries(ragFilesFromCfg)) {
|
|
594
|
+
if (typeof b64 !== "string" || !fname)
|
|
595
|
+
continue;
|
|
596
|
+
// Filename traversal guard — server-side helper already
|
|
597
|
+
// sanitises but defense in depth: drop any name containing a
|
|
598
|
+
// slash or starting with a dot.
|
|
599
|
+
const safe = fname.replace(/[\\/]/g, "").replace(/^\.+/, "");
|
|
600
|
+
if (!safe)
|
|
601
|
+
continue;
|
|
602
|
+
try {
|
|
603
|
+
writeFileSync(join(ragDir, safe), Buffer.from(b64, "base64"));
|
|
604
|
+
wrote++;
|
|
605
|
+
}
|
|
606
|
+
catch (e) {
|
|
607
|
+
console.log(chalk.yellow(` ! could not write rag/${safe}: ${e.message}`));
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
if (wrote > 0) {
|
|
611
|
+
console.log(chalk.gray(` [rag] wrote ${wrote} static-context file(s) to ${ragDir}`));
|
|
612
|
+
}
|
|
613
|
+
}
|
|
575
614
|
// Preflight the first persona's model so we surface an early
|
|
576
615
|
// failure if (e.g.) LM Studio hasn't loaded the requested
|
|
577
616
|
// qwen3.6-27b. Same flow as pipelines — it just reads the
|