mirror of
https://github.com/github/awesome-copilot.git
synced 2026-03-20 08:05:12 +00:00
Update .NET Copilot SDK recipes for explicit permission (fix for SDK v0.1.28) (#1033)
* Update .NET Copilot SDK recipes for explicit permission handling (fix breaking change in SDK v0.1.28) * Update .NET Copilot SDK recipes for explicit permission handling
This commit is contained in:
@@ -32,6 +32,7 @@ await using var session = await client.CreateSessionAsync(new SessionConfig
|
||||
{
|
||||
Model = "claude-opus-4.6",
|
||||
Streaming = true,
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll,
|
||||
McpServers = new Dictionary<string, object>()
|
||||
{
|
||||
["playwright"] =
|
||||
|
||||
@@ -10,7 +10,8 @@ try
|
||||
await client.StartAsync();
|
||||
var session = await client.CreateSessionAsync(new SessionConfig
|
||||
{
|
||||
Model = "gpt-5"
|
||||
Model = "gpt-5",
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll
|
||||
});
|
||||
|
||||
var done = new TaskCompletionSource<string>();
|
||||
|
||||
@@ -10,7 +10,8 @@ await client.StartAsync();
|
||||
// Define tools for file operations
|
||||
var session = await client.CreateSessionAsync(new SessionConfig
|
||||
{
|
||||
Model = "gpt-5"
|
||||
Model = "gpt-5",
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll
|
||||
});
|
||||
|
||||
// Wait for completion
|
||||
@@ -36,8 +37,7 @@ session.On(evt =>
|
||||
});
|
||||
|
||||
// Ask Copilot to organize files
|
||||
// Change this to your target folder
|
||||
var targetFolder = @"C:\Users\Me\Downloads";
|
||||
var targetFolder = args.FirstOrDefault() ?? Environment.CurrentDirectory;
|
||||
|
||||
await session.SendAsync(new MessageOptions
|
||||
{
|
||||
|
||||
@@ -7,9 +7,21 @@ await using var client = new CopilotClient();
|
||||
await client.StartAsync();
|
||||
|
||||
// Create multiple independent sessions
|
||||
var session1 = await client.CreateSessionAsync(new SessionConfig { Model = "gpt-5" });
|
||||
var session2 = await client.CreateSessionAsync(new SessionConfig { Model = "gpt-5" });
|
||||
var session3 = await client.CreateSessionAsync(new SessionConfig { Model = "claude-sonnet-4.5" });
|
||||
var session1 = await client.CreateSessionAsync(new SessionConfig
|
||||
{
|
||||
Model = "gpt-5",
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll
|
||||
});
|
||||
var session2 = await client.CreateSessionAsync(new SessionConfig
|
||||
{
|
||||
Model = "gpt-5",
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll
|
||||
});
|
||||
var session3 = await client.CreateSessionAsync(new SessionConfig
|
||||
{
|
||||
Model = "claude-sonnet-4.5",
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll
|
||||
});
|
||||
|
||||
Console.WriteLine("Created 3 independent sessions");
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ await client.StartAsync();
|
||||
var session = await client.CreateSessionAsync(new SessionConfig
|
||||
{
|
||||
SessionId = "user-123-conversation",
|
||||
Model = "gpt-5"
|
||||
Model = "gpt-5",
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll
|
||||
});
|
||||
|
||||
await session.SendAsync(new MessageOptions { Prompt = "Let's discuss TypeScript generics" });
|
||||
|
||||
@@ -132,6 +132,7 @@ await client.StartAsync();
|
||||
var session = await client.CreateSessionAsync(new SessionConfig
|
||||
{
|
||||
Model = "gpt-5",
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll,
|
||||
SystemMessage = new SystemMessageConfig
|
||||
{
|
||||
Content = $"""
|
||||
|
||||
@@ -48,8 +48,7 @@ try
|
||||
// Pin the agent to the project directory
|
||||
WorkingDirectory = Environment.CurrentDirectory,
|
||||
// Auto-approve tool calls for unattended operation
|
||||
OnPermissionRequest = (_, _) => Task.FromResult(
|
||||
new PermissionRequestResult { Kind = "approved" }),
|
||||
OnPermissionRequest = PermissionHandler.ApproveAll,
|
||||
});
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user