- Removed extension post-transition events
session_switch and session_fork. Use session_start with event.reason ("startup" | "reload" | "new" | "resume" | "fork"). For "new", "resume", and "fork", session_start includes previousSessionFile.
- Removed session-replacement methods from
AgentSession. Use AgentSessionRuntime for newSession(), switchSession(), fork(), and importFromJsonl(). Cross-cwd session replacement rebuilds all cwd-bound runtime state and replaces the live AgentSession instance.
- Removed
session_directory from extension and settings APIs.
- Unknown single-dash CLI flags (e.g.
-s) now produce an error instead of being silently ignored.
Migration: Extensions
Before:
pi.on("session_switch", async (event, ctx) => { ... });
pi.on("session_fork", async (_event, ctx) => { ... });
After:
pi.on("session_start", async (event, ctx) => {
// event.reason: "startup" | "reload" | "new" | "resume" | "fork"
// event.previousSessionFile: set for "new", "resume", "fork"
});
Migration: SDK session replacement
Before:
await session.newSession();
await session.switchSession("/path/to/session.jsonl");
After:
import {
type CreateAgentSessionRuntimeFactory,
createAgentSessionFromServices,
createAgentSessionRuntime,
createAgentSessionServices,
getAgentDir,
SessionManager,
} from "@mariozechner/pi-coding-agent";
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
const services = await createAgentSessionServices({ cwd });
return {
...(await createAgentSessionFromServices({ services, sessionManager, sessionStartEvent })),
services,
diagnostics: services.diagnostics,
};
};
const runtime = await createAgentSessionRuntime(createRuntime, {
cwd: process.cwd(),
agentDir: getAgentDir(),
sessionManager: SessionManager.create(process.cwd()),
});
await runtime.newSession();
await runtime.switchSession("/path/to/session.jsonl");
await runtime.fork("entry-id");
// After replacement, runtime.session is the new live session.
// Rebind any session-local subscriptions or extension bindings.