diff --git a/docs/debugging.md b/docs/debugging.md index 893d2c05..dffd85a3 100644 --- a/docs/debugging.md +++ b/docs/debugging.md @@ -47,7 +47,7 @@ client = CopilotClient(log_level="debug") ```go import copilot "github.com/github/copilot-sdk/go" -client, err := copilot.NewClient(copilot.ClientOptions{ +client := copilot.NewClient(&copilot.ClientOptions{ LogLevel: "debug", }) ``` @@ -169,7 +169,7 @@ var client = new CopilotClient(new CopilotClientOptions Go ```go - client, _ := copilot.NewClient(copilot.ClientOptions{ + client := copilot.NewClient(&copilot.ClientOptions{ CLIPath: "/usr/local/bin/copilot", }) ``` @@ -222,7 +222,7 @@ var client = new CopilotClient(new CopilotClientOptions Go ```go - client, _ := copilot.NewClient(copilot.ClientOptions{ + client := copilot.NewClient(&copilot.ClientOptions{ GithubToken: os.Getenv("GITHUB_TOKEN"), }) ``` diff --git a/docs/getting-started.md b/docs/getting-started.md index 1a730905..7aea1e06 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1020,7 +1020,7 @@ const session = await client.createSession({ }); ``` -📖 **[Full MCP documentation →](./mcp.md)** - Learn about local vs remote servers, all configuration options, and troubleshooting. +📖 **[Full MCP documentation →](./mcp/overview.md)** - Learn about local vs remote servers, all configuration options, and troubleshooting. ### Create Custom Agents diff --git a/docs/guides/session-persistence.md b/docs/guides/session-persistence.md index 865031cc..4586201e 100644 --- a/docs/guides/session-persistence.md +++ b/docs/guides/session-persistence.md @@ -37,7 +37,7 @@ const session = await client.createSession({ }); // Do some work... -await session.sendPrompt({ content: "Analyze my codebase" }); +await session.sendAndWait({ prompt: "Analyze my codebase" }); // Session state is automatically persisted // You can safely close the client @@ -57,7 +57,7 @@ session = await client.create_session( ) # Do some work... -await session.send_prompt(content="Analyze my codebase") +await session.send_and_wait({"prompt": "Analyze my codebase"}) # Session state is automatically persisted ``` @@ -65,16 +65,16 @@ await session.send_prompt(content="Analyze my codebase") ### Go ```go -client, _ := copilot.NewClient() +client := copilot.NewClient(nil) // Create a session with a meaningful ID -session, _ := client.CreateSession(copilot.CreateSessionOptions{ +session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{ SessionID: "user-123-task-456", Model: "gpt-5.2-codex", }) // Do some work... -session.SendPrompt(copilot.PromptOptions{Content: "Analyze my codebase"}) +session.SendAndWait(context.Background(), copilot.MessageOptions{Prompt: "Analyze my codebase"}) // Session state is automatically persisted ``` @@ -94,7 +94,7 @@ var session = await client.CreateSessionAsync(new CreateSessionOptions }); // Do some work... -await session.SendPromptAsync(new PromptOptions { Content = "Analyze my codebase" }); +await session.SendAndWaitAsync(new MessageOptions { Prompt = "Analyze my codebase" }); // Session state is automatically persisted ``` @@ -124,7 +124,7 @@ flowchart LR const session = await client.resumeSession("user-123-task-456"); // Continue where you left off -await session.sendPrompt({ content: "What did we discuss earlier?" }); +await session.sendAndWait({ prompt: "What did we discuss earlier?" }); ``` ### Python @@ -134,17 +134,17 @@ await session.sendPrompt({ content: "What did we discuss earlier?" }); session = await client.resume_session("user-123-task-456") # Continue where you left off -await session.send_prompt(content="What did we discuss earlier?") +await session.send_and_wait({"prompt": "What did we discuss earlier?"}) ``` ### Go ```go // Resume from a different client instance (or after restart) -session, _ := client.ResumeSession("user-123-task-456", copilot.ResumeSessionOptions{}) +session, _ := client.ResumeSession(context.Background(), "user-123-task-456", nil) // Continue where you left off -session.SendPrompt(copilot.PromptOptions{Content: "What did we discuss earlier?"}) +session.SendAndWait(context.Background(), copilot.MessageOptions{Prompt: "What did we discuss earlier?"}) ``` ### C# (.NET) @@ -154,7 +154,7 @@ session.SendPrompt(copilot.PromptOptions{Content: "What did we discuss earlier?" var session = await client.ResumeSessionAsync("user-123-task-456"); // Continue where you left off -await session.SendPromptAsync(new PromptOptions { Content = "What did we discuss earlier?" }); +await session.SendAndWaitAsync(new MessageOptions { Prompt = "What did we discuss earlier?" }); ``` ## Using BYOK (Bring Your Own Key) with Resumed Sessions @@ -290,7 +290,7 @@ When a task completes, destroy the session explicitly rather than waiting for ti ```typescript try { // Do work... - await session.sendPrompt({ content: "Complete the task" }); + await session.sendAndWait({ prompt: "Complete the task" }); // Task complete - clean up await session.destroy(); @@ -472,7 +472,7 @@ async function withSessionLock( // Usage await withSessionLock("user-123-task-456", async () => { const session = await client.resumeSession("user-123-task-456"); - await session.sendPrompt({ content: "Continue the task" }); + await session.sendAndWait({ prompt: "Continue the task" }); }); ``` diff --git a/docs/hooks/error-handling.md b/docs/hooks/error-handling.md index 8aedd32e..572455b1 100644 --- a/docs/hooks/error-handling.md +++ b/docs/hooks/error-handling.md @@ -120,7 +120,7 @@ session = await client.create_session({ Go ```go -session, _ := client.CreateSession(ctx, copilot.SessionConfig{ +session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{ Hooks: &copilot.SessionHooks{ OnErrorOccurred: func(input copilot.ErrorOccurredHookInput, inv copilot.HookInvocation) (*copilot.ErrorOccurredHookOutput, error) { fmt.Printf("[%s] Error: %s\n", inv.SessionID, input.Error) diff --git a/docs/hooks/overview.md b/docs/hooks/overview.md index 0d365846..be04b417 100644 --- a/docs/hooks/overview.md +++ b/docs/hooks/overview.md @@ -87,14 +87,15 @@ async def main(): package main import ( + "context" "fmt" copilot "github.com/github/copilot-sdk/go" ) func main() { - client, _ := copilot.NewClient(copilot.ClientOptions{}) + client := copilot.NewClient(nil) - session, _ := client.CreateSession(ctx, copilot.SessionConfig{ + session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{ Hooks: &copilot.SessionHooks{ OnPreToolUse: func(input copilot.PreToolUseHookInput, inv copilot.HookInvocation) (*copilot.PreToolUseHookOutput, error) { fmt.Printf("Tool called: %s\n", input.ToolName) @@ -113,6 +114,7 @@ func main() { }, }, }) + _ = session } ``` diff --git a/docs/hooks/post-tool-use.md b/docs/hooks/post-tool-use.md index 24ee7ebe..ecaf41ae 100644 --- a/docs/hooks/post-tool-use.md +++ b/docs/hooks/post-tool-use.md @@ -119,7 +119,7 @@ session = await client.create_session({ Go ```go -session, _ := client.CreateSession(ctx, copilot.SessionConfig{ +session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{ Hooks: &copilot.SessionHooks{ OnPostToolUse: func(input copilot.PostToolUseHookInput, inv copilot.HookInvocation) (*copilot.PostToolUseHookOutput, error) { fmt.Printf("[%s] Tool: %s\n", inv.SessionID, input.ToolName) diff --git a/docs/hooks/pre-tool-use.md b/docs/hooks/pre-tool-use.md index 37a6c3d0..43bb63be 100644 --- a/docs/hooks/pre-tool-use.md +++ b/docs/hooks/pre-tool-use.md @@ -126,7 +126,7 @@ session = await client.create_session({ Go ```go -session, _ := client.CreateSession(ctx, copilot.SessionConfig{ +session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{ Hooks: &copilot.SessionHooks{ OnPreToolUse: func(input copilot.PreToolUseHookInput, inv copilot.HookInvocation) (*copilot.PreToolUseHookOutput, error) { fmt.Printf("[%s] Calling %s\n", inv.SessionID, input.ToolName) diff --git a/docs/hooks/user-prompt-submitted.md b/docs/hooks/user-prompt-submitted.md index fc2d14a7..af013022 100644 --- a/docs/hooks/user-prompt-submitted.md +++ b/docs/hooks/user-prompt-submitted.md @@ -113,7 +113,7 @@ session = await client.create_session({ Go ```go -session, _ := client.CreateSession(ctx, copilot.SessionConfig{ +session, _ := client.CreateSession(context.Background(), &copilot.SessionConfig{ Hooks: &copilot.SessionHooks{ OnUserPromptSubmitted: func(input copilot.UserPromptSubmittedHookInput, inv copilot.HookInvocation) (*copilot.UserPromptSubmittedHookOutput, error) { fmt.Printf("[%s] User: %s\n", inv.SessionID, input.Prompt)