Moving the copilot-sdk cookbook content in here

This commit is contained in:
Aaron Powell
2026-01-29 14:29:36 +11:00
parent ccdfd66cc2
commit f59e0b4080
53 changed files with 5385 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import { CopilotClient } from "@github/copilot-sdk";
const client = new CopilotClient();
await client.start();
// Create a session with a memorable ID
const session = await client.createSession({
sessionId: "user-123-conversation",
model: "gpt-5",
});
await session.sendAndWait({ prompt: "Let's discuss TypeScript generics" });
console.log(`Session created: ${session.sessionId}`);
// Destroy session but keep data on disk
await session.destroy();
console.log("Session destroyed (state persisted)");
// Resume the previous session
const resumed = await client.resumeSession("user-123-conversation");
console.log(`Resumed: ${resumed.sessionId}`);
await resumed.sendAndWait({ prompt: "What were we discussing?" });
// List sessions
const sessions = await client.listSessions();
console.log(
"Sessions:",
sessions.map((s) => s.sessionId)
);
// Delete session permanently
await client.deleteSession("user-123-conversation");
console.log("Session deleted");
await resumed.destroy();
await client.stop();