feat(plugins): share native session handoff and soften memory search

This commit is contained in:
kartik-mem0
2026-09-10 18:20:36 +05:30
parent 02f7a9b2c4
commit 82c32f993e
130 changed files with 16430 additions and 379 deletions
@@ -0,0 +1,28 @@
import { buildSessionContext, convertToLlm, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { buildHandoffBundle, runHandoff } from "../../agent-plugin-core/typescript/src/handoff.ts";
export function registerHandoffCommand(pi: ExtensionAPI): void {
pi.registerCommand("mem0-handoff", {
description: "Continue this Pi session in a new Codex task",
handler: async (args, ctx) => {
if (args.trim() !== "codex") {
ctx.ui.notify("Usage: /mem0-handoff codex", "warning");
return;
}
try {
if (!ctx.isIdle()) throw new Error("Finish the current response before handing off this session.");
const session = ctx.sessionManager;
const context = buildSessionContext(session.getEntries(), session.getLeafId());
const bundle = await buildHandoffBundle({
host: "pi-agent", session_id: session.getSessionId(),
title: session.getSessionName() || `Pi session ${session.getSessionId()}`,
cwd: session.getCwd(), path: session.getSessionFile(),
}, convertToLlm(context.messages));
const content = await runHandoff(new URL("./session_handoff.py", import.meta.url), bundle);
pi.sendMessage({ customType: "mem0-handoff", content, display: true });
} catch (error) {
ctx.ui.notify(error instanceof Error ? error.message : String(error), "error");
}
},
});
}