Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ See [GitHub Releases](https://github.com/github/copilot-sdk/releases) for the fu
SDK applications written against the v3 API now also work when connected to a v2 CLI server, with no code changes required. The SDK detects the server's protocol version and automatically adapts v2 `tool.call` and `permission.request` messages into the same user-facing handlers used by v3. ([#706](https://github.com/github/copilot-sdk/pull/706))

```ts
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();

const session = await client.createSession({
tools: [myTool], // unchanged — works with v2 and v3 servers
onPermissionRequest: approveAll,
Expand Down Expand Up @@ -84,7 +88,9 @@ if result.Kind == copilot.PermissionKindApproved { /* ... */ }
Applications can now override built-in tools such as `grep`, `edit_file`, or `read_file`. To do this, register a custom tool with the same name and set the override flag. Without the flag, the runtime will return an error if the name clashes with a built-in. ([#636](https://github.com/github/copilot-sdk/pull/636))

```ts
import { defineTool } from "@github/copilot-sdk";
import { CopilotClient, defineTool, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();

const session = await client.createSession({
tools: [defineTool("grep", {
Expand Down
15 changes: 12 additions & 3 deletions docs/auth/byok.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ asyncio.run(main())
<summary><strong>Node.js / TypeScript</strong></summary>

```typescript
import { CopilotClient } from "@github/copilot-sdk";
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const FOUNDRY_MODEL_URL = "https://your-resource.openai.azure.com/openai/v1/";

Expand All @@ -76,6 +76,7 @@ const session = await client.createSession({
wireApi: "responses", // Use "completions" for older models
apiKey: process.env.FOUNDRY_API_KEY,
},
onPermissionRequest: approveAll
});

session.on("assistant.message", (event) => {
Expand Down Expand Up @@ -454,15 +455,21 @@ Some Copilot features may behave differently with BYOK:
When using BYOK, the `model` parameter is **required**:

```typescript
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();

// ❌ Error: Model required with custom provider
const session = await client.createSession({
provider: { type: "openai", baseUrl: "..." },
onPermissionRequest: approveAll,
});

// ✅ Correct: Model specified
const session = await client.createSession({
model: "gpt-4", // Required!
provider: { type: "openai", baseUrl: "..." },
onPermissionRequest: approveAll,
});
```

Expand All @@ -472,7 +479,7 @@ For Azure OpenAI endpoints (`*.openai.azure.com`), use the correct type:

<!-- docs-validate: hidden -->
```typescript
import { CopilotClient } from "@github/copilot-sdk";
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
const session = await client.createSession({
Expand All @@ -481,6 +488,7 @@ const session = await client.createSession({
type: "azure",
baseUrl: "https://my-resource.openai.azure.com",
},
onPermissionRequest: approveAll
});
```
<!-- /docs-validate: hidden -->
Expand All @@ -503,7 +511,7 @@ However, if your Azure AI Foundry deployment provides an OpenAI-compatible endpo

<!-- docs-validate: hidden -->
```typescript
import { CopilotClient } from "@github/copilot-sdk";
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
const session = await client.createSession({
Expand All @@ -512,6 +520,7 @@ const session = await client.createSession({
type: "openai",
baseUrl: "https://your-resource.openai.azure.com/openai/v1/",
},
onPermissionRequest: approveAll
});
```
<!-- /docs-validate: hidden -->
Expand Down
16 changes: 14 additions & 2 deletions docs/features/custom-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Pass `customAgents` when creating a session. Each agent needs at minimum a `name
<summary><strong>Node.js / TypeScript</strong></summary>

```typescript
import { CopilotClient } from "@github/copilot-sdk";
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
await client.start();
Expand All @@ -54,7 +54,7 @@ const session = await client.createSession({
prompt: "You are a code editor. Make minimal, surgical changes to files as requested.",
},
],
onPermissionRequest: async () => ({ kind: "approved" }),
onPermissionRequest: approveAll,
});
```

Expand Down Expand Up @@ -236,6 +236,9 @@ This is equivalent to calling `session.rpc.agent.select()` after creation, but a

<!-- docs-validate: skip -->
```typescript
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
const session = await client.createSession({
customAgents: [
{
Expand All @@ -248,6 +251,7 @@ const session = await client.createSession({
},
],
agent: "researcher", // Pre-select the researcher agent
onPermissionRequest: approveAll,
});
```

Expand Down Expand Up @@ -618,6 +622,9 @@ session.on((event) => {
Use the `tools` property to restrict which tools an agent can access. This is essential for security and for keeping agents focused:

```typescript
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
const session = await client.createSession({
customAgents: [
{
Expand All @@ -639,6 +646,7 @@ const session = await client.createSession({
prompt: "You handle complex multi-step tasks using any available tools.",
},
],
onPermissionRequest: approveAll,
});
```

Expand All @@ -649,6 +657,9 @@ const session = await client.createSession({
Each custom agent can have its own MCP (Model Context Protocol) servers, giving it access to specialized data sources:

```typescript
import { CopilotClient, approveAll } from "@github/copilot-sdk";

const client = new CopilotClient();
const session = await client.createSession({
customAgents: [
{
Expand All @@ -663,6 +674,7 @@ const session = await client.createSession({
},
},
],
onPermissionRequest: approveAll,
});
```

Expand Down
Loading