fix(coding-agent): dispose SDK example sessions

This commit is contained in:
Michael Yu
2026-05-10 23:40:12 +08:00
parent f348a06294
commit d68011dab1
12 changed files with 101 additions and 65 deletions

View File

@@ -13,32 +13,36 @@
import { createAgentSession, SessionManager } from "@earendil-works/pi-coding-agent";
// Read-only mode (no edit/write)
await createAgentSession({
const { session: readOnlySession } = await createAgentSession({
tools: ["read", "grep", "find", "ls"],
sessionManager: SessionManager.inMemory(),
});
console.log("Read-only session created");
readOnlySession.dispose();
// Custom tool selection
await createAgentSession({
const { session: customToolsSession } = await createAgentSession({
tools: ["read", "bash", "grep"],
sessionManager: SessionManager.inMemory(),
});
console.log("Custom tools session created");
customToolsSession.dispose();
// With custom cwd
const customCwd = "/path/to/project";
await createAgentSession({
const { session: customCwdSession } = await createAgentSession({
cwd: customCwd,
tools: ["read", "bash", "edit", "write"],
sessionManager: SessionManager.inMemory(customCwd),
});
console.log("Custom cwd session created");
customCwdSession.dispose();
// Or pick specific tools for custom cwd
await createAgentSession({
const { session: specificToolsSession } = await createAgentSession({
cwd: customCwd,
tools: ["read", "bash", "grep"],
sessionManager: SessionManager.inMemory(customCwd),
});
console.log("Specific tools with custom cwd session created");
specificToolsSession.dispose();