@melaya/runner 1.0.1 → 1.0.3

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.
@@ -15,20 +15,24 @@ const CACHE_DIR = join(homedir(), ".melaya-runner");
15
15
  const SHARED_DIR = join(CACHE_DIR, "shared");
16
16
  const VERSION_FILE = join(CACHE_DIR, "shared-version.txt");
17
17
  export function getSharedDir() {
18
- return SHARED_DIR;
18
+ // Return the CACHE_DIR root (not shared/ subdir) because the bundle
19
+ // now includes agentscope/ and crews/ alongside shared/. PYTHONPATH
20
+ // needs to be the parent so `import agentscope`, `import shared.*`,
21
+ // and `from crews.X.main import ...` all resolve.
22
+ return CACHE_DIR;
19
23
  }
20
24
  export async function ensureSharedModules(serverUrl, expectedVersion) {
21
- mkdirSync(SHARED_DIR, { recursive: true });
25
+ mkdirSync(CACHE_DIR, { recursive: true });
22
26
  // Check cached version
23
27
  if (existsSync(VERSION_FILE)) {
24
28
  const cached = readFileSync(VERSION_FILE, "utf-8").trim();
25
- if (cached === expectedVersion && existsSync(join(SHARED_DIR, "events.py"))) {
29
+ if (cached === expectedVersion && existsSync(join(CACHE_DIR, "shared", "events.py")) && existsSync(join(CACHE_DIR, "agentscope", "__init__.py"))) {
26
30
  return; // cache is up-to-date
27
31
  }
28
32
  }
29
33
  // Fetch from server
30
34
  const httpUrl = serverUrl.replace(/^wss:/, "https:").replace(/^ws:/, "http:");
31
- const url = `${httpUrl}/api/v1/agents/shared-bundle?v=${expectedVersion}`;
35
+ const url = `${httpUrl}/api/v1/runner/shared-bundle?v=${expectedVersion}`;
32
36
  const res = await fetch(url, { signal: AbortSignal.timeout(30_000) });
33
37
  if (!res.ok) {
34
38
  throw new Error(`Failed to fetch shared modules: HTTP ${res.status}`);
@@ -44,16 +48,19 @@ export async function ensureSharedModules(serverUrl, expectedVersion) {
44
48
  const safe = filename.replace(/\.\./g, "").replace(/^\//, "").replace(/\\/g, "/");
45
49
  if (safe.includes("..") || safe.startsWith("/"))
46
50
  continue;
47
- const filepath = join(SHARED_DIR, safe);
48
- if (!filepath.startsWith(SHARED_DIR))
51
+ const filepath = join(CACHE_DIR, safe);
52
+ if (!filepath.startsWith(CACHE_DIR))
49
53
  continue;
50
54
  const dir = join(filepath, "..");
51
55
  mkdirSync(dir, { recursive: true });
52
56
  writeFileSync(filepath, content, "utf-8");
53
57
  }
54
- // Write __init__.py if missing
55
- if (!existsSync(join(SHARED_DIR, "__init__.py"))) {
56
- writeFileSync(join(SHARED_DIR, "__init__.py"), "", "utf-8");
58
+ // Ensure __init__.py in shared/ and crews/ if missing
59
+ for (const sub of ["shared", "crews"]) {
60
+ const init = join(CACHE_DIR, sub, "__init__.py");
61
+ if (existsSync(join(CACHE_DIR, sub)) && !existsSync(init)) {
62
+ writeFileSync(init, "", "utf-8");
63
+ }
57
64
  }
58
65
  writeFileSync(VERSION_FILE, expectedVersion, "utf-8");
59
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melaya/runner",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Run Melaya AI pipelines locally with your own LM Studio or Ollama models",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,