fix(plugins): share one cached handoff runtime and use version 0.3.2

This commit is contained in:
kartik-mem0
2026-09-10 18:52:09 +05:30
parent 0fb924051f
commit 19a71bbacf
97 changed files with 946 additions and 11890 deletions
@@ -2,6 +2,7 @@
from __future__ import annotations
import argparse
import hashlib
import json
import re
import shutil
@@ -18,6 +19,7 @@ CORE_ROOT = Path(__file__).resolve().parents[1]
REPOSITORY_ROOT = CORE_ROOT.parents[1]
INTEGRATIONS_ROOT = REPOSITORY_ROOT / "integrations"
SHARED_SKILLS = CORE_ROOT / "skills"
HANDOFF_MANIFEST = CORE_ROOT / "build" / "handoff-runtime.json"
PORTABLE_PLUGIN = "mem0-agent-plugin"
NATIVE_PLUGINS = {
"claude-code": INTEGRATIONS_ROOT / "claude-code-plugin",
@@ -116,7 +118,14 @@ def _bundle_python(
) -> None:
core = staged / "core"
core.mkdir()
handoff = json.loads(HANDOFF_MANIFEST.read_text(encoding="utf-8"))
for name, digest in handoff["files"].items():
if hashlib.sha256((CORE_ROOT / "python" / name).read_bytes()).hexdigest() != digest:
raise ValueError(f"Update the shared handoff runtime pin after changing {name}")
shutil.copy2(HANDOFF_MANIFEST, core / HANDOFF_MANIFEST.name)
for source in sorted((CORE_ROOT / "python").glob("*.py")):
if source.name in handoff["files"]:
continue
if portable and source.name in {"flush_worker.py", "hook_runner.py"}:
continue
shutil.copy2(source, core / source.name)
@@ -1,5 +1,8 @@
[
"claude_to_codex.py",
"session_handoff.py",
"handoff_sources.py"
]
{
"revision": "0fb924051fa876b5d6311fe3378794cc92fb6ff8",
"files": {
"claude_to_codex.py": "48b23958b890836f2c84b74de45a1f5a430c27dc238b80bf1a8fd67e4c7cd705",
"handoff_sources.py": "9ae209949473a215de8424004c7ea296e775e11743b5e7bfb77acc9630346a3b"
},
"artifacts": ["session_handoff.py", "handoff-runtime.json"]
}
@@ -1,12 +1,19 @@
import { copyFile, mkdir, readFile } from "node:fs/promises";
import { createHash } from "node:crypto";
import { copyFile, mkdir, readFile, rm } from "node:fs/promises";
import { resolve } from "node:path";
import { fileURLToPath } from "node:url";
export async function packageHandoff(output = "dist") {
const files = JSON.parse(await readFile(new URL("./handoff-runtime.json", import.meta.url), "utf8"));
const manifest = JSON.parse(await readFile(new URL("./handoff-runtime.json", import.meta.url), "utf8"));
await mkdir(output, { recursive: true });
for (const name of files) {
await copyFile(new URL(`../python/${name}`, import.meta.url), resolve(output, name));
for (const [name, digest] of Object.entries(manifest.files)) {
const bytes = await readFile(new URL(`../python/${name}`, import.meta.url));
if (createHash("sha256").update(bytes).digest("hex") !== digest) throw new Error(`Update the shared handoff runtime pin after changing ${name}`);
}
for (const name of Object.keys(manifest.files)) await rm(resolve(output, name), { force: true });
for (const name of manifest.artifacts) {
const source = name.endsWith(".py") ? `../python/${name}` : `./${name}`;
await copyFile(new URL(source, import.meta.url), resolve(output, name));
}
}