@melaya/runner 1.0.2 → 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.
- package/dist/sharedVendor.js +15 -8
- package/package.json +1 -1
package/dist/sharedVendor.js
CHANGED
|
@@ -15,14 +15,18 @@ 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
|
-
|
|
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(
|
|
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(
|
|
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
|
}
|
|
@@ -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(
|
|
48
|
-
if (!filepath.startsWith(
|
|
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
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
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
|
}
|