@melaya/runner 1.0.50 → 1.0.52

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.
@@ -580,30 +580,49 @@ export async function connect(opts) {
580
580
  "--embedder-model", payload.embedderModel,
581
581
  ];
582
582
  if (ingestMode === "cloud_files") {
583
- // Server bundled file bytes into the event. Unpack them to a
584
- // temp dir + a small manifest JSON so the Python script can
585
- // walk them with the same code path as Mode B reads from disk.
583
+ // Pull each file from the server via an ack-based `rag:fetch-file`
584
+ // round-trip. One file per Socket.IO frame keeps every message
585
+ // small regardless of total corpus size. The server reads from
586
+ // its loopback builder API and returns base64 bytes.
586
587
  const filesDir = join(workDir, "cloud-files");
587
588
  mkdirSync(filesDir, { recursive: true });
588
589
  const { writeFileSync } = await import("fs");
589
- const filesArr = payload.cloudFiles || [];
590
- for (const f of filesArr) {
590
+ const manifestFiles = payload.cloudManifest?.files || [];
591
+ const fetched = [];
592
+ let failed = 0;
593
+ for (const f of manifestFiles) {
594
+ const resp = await new Promise((resolve) => {
595
+ const timer = setTimeout(() => resolve({ ok: false, error: "ack timeout (60s)" }), 60_000);
596
+ socket.emit("rag:fetch-file", { session_id: sid, filename: f.name }, (r) => {
597
+ clearTimeout(timer);
598
+ resolve(r || { ok: false, error: "empty ack" });
599
+ });
600
+ });
601
+ if (!resp.ok || !resp.contentB64) {
602
+ failed += 1;
603
+ console.log(chalk.red(` [rag] fetch failed ${f.name}: ${resp.error || "unknown"}`));
604
+ emitProgress("file_failed", { file: f.name, error: resp.error || "fetch failed" });
605
+ continue;
606
+ }
591
607
  try {
592
- writeFileSync(join(filesDir, f.name), Buffer.from(f.contentB64, "base64"));
608
+ writeFileSync(join(filesDir, f.name), Buffer.from(resp.contentB64, "base64"));
609
+ fetched.push({ name: f.name, sha256: f.sha256, ext: f.ext });
593
610
  }
594
611
  catch (e) {
595
- console.log(chalk.red(` [rag] failed to unpack ${f.name}: ${e?.message || e}`));
612
+ failed += 1;
613
+ console.log(chalk.red(` [rag] write failed ${f.name}: ${e?.message || e}`));
614
+ emitProgress("file_failed", { file: f.name, error: String(e?.message || e) });
596
615
  }
597
616
  }
598
617
  const manifestPath = join(workDir, "cloud-manifest.json");
599
618
  writeFileSync(manifestPath, JSON.stringify({
600
- files: filesArr.map(f => ({ name: f.name, sha256: f.sha256, ext: f.ext })),
619
+ files: fetched,
601
620
  stored_embedder: payload.cloudManifest?.stored_embedder || {},
602
621
  previously_ingested: payload.cloudManifest?.previously_ingested || {},
603
622
  }, null, 2));
604
623
  ingestArgs.push("--files-dir", filesDir);
605
624
  ingestArgs.push("--manifest-json", manifestPath);
606
- console.log(chalk.gray(` [rag] unpacked ${filesArr.length} cloud file(s) → ${filesDir}`));
625
+ console.log(chalk.gray(` [rag] pulled ${fetched.length}/${manifestFiles.length} cloud file(s)${failed ? ` (${failed} failed)` : ""} → ${filesDir}`));
607
626
  }
608
627
  else {
609
628
  ingestArgs.push("--folder", payload.localFolderPath || "");
@@ -484,7 +484,10 @@ async def _ingest_cloud_files(args) -> int:
484
484
  first_emit = False
485
485
  continue
486
486
  vectors_resp = await embedder(text=texts)
487
- vectors = [eb.embedding for eb in vectors_resp.embeddings]
487
+ # agentscope's embedding adapters already unwrap to a flat list
488
+ # of vectors (list[list[float]]) via _openai_embedding.py L104 /
489
+ # _ollama_embedding.py — do NOT re-access `.embedding`.
490
+ vectors = list(vectors_resp.embeddings)
488
491
  if len(vectors) != len(texts):
489
492
  raise RuntimeError(
490
493
  f"embedder returned {len(vectors)} vectors for {len(texts)} chunks"
package/localRagIngest.py CHANGED
@@ -484,7 +484,10 @@ async def _ingest_cloud_files(args) -> int:
484
484
  first_emit = False
485
485
  continue
486
486
  vectors_resp = await embedder(text=texts)
487
- vectors = [eb.embedding for eb in vectors_resp.embeddings]
487
+ # agentscope's embedding adapters already unwrap to a flat list
488
+ # of vectors (list[list[float]]) via _openai_embedding.py L104 /
489
+ # _ollama_embedding.py — do NOT re-access `.embedding`.
490
+ vectors = list(vectors_resp.embeddings)
488
491
  if len(vectors) != len(texts):
489
492
  raise RuntimeError(
490
493
  f"embedder returned {len(vectors)} vectors for {len(texts)} chunks"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melaya/runner",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,