Skip to content

Commit e441f04

Browse files
committed
Merge remote-tracking branch 'origin/main' into mackinnonbuck/prompt-customization
# Conflicts: # nodejs/src/index.ts # python/copilot/__init__.py # python/copilot/types.py
2 parents a63c606 + ea90f07 commit e441f04

File tree

154 files changed

+3834
-675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+3834
-675
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "Python 3",
55
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6-
"image": "mcr.microsoft.com/devcontainers/python:2-3.14-trixie",
6+
"image": "mcr.microsoft.com/devcontainers/python:3-3.14-trixie",
77
"features": {
88
"ghcr.io/devcontainers/features/copilot-cli:1": {},
99
"ghcr.io/devcontainers/features/github-cli:1": {},

CONTRIBUTING.md

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,71 @@
1-
## Contributing
1+
# Contributing
22

3-
[fork]: https://github.com/github/copilot-sdk/fork
4-
[pr]: https://github.com/github/copilot-sdk/compare
3+
Thanks for your interest in contributing!
54

6-
Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
5+
This repository contains the Copilot SDK, a set of multi-language SDKs (Node/TypeScript, Python, Go, .NET) for building applications with the GitHub Copilot agent, maintained by the GitHub Copilot team.
76

87
Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
98

109
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
1110

12-
## What kinds of contributions we're looking for
11+
## Before You Submit a PR
1312

14-
We'd love your help with:
13+
**Please discuss any feature work with us before writing code.**
1514

16-
* Fixing any bugs in the existing feature set
17-
* Making the SDKs more idiomatic and nice to use for each supported language
18-
* Improving documentation
15+
The team already has a committed product roadmap, and features must be maintained in sync across all supported languages. Pull requests that introduce features not previously aligned with the team are unlikely to be accepted, regardless of their quality or scope.
1916

20-
If you have ideas for entirely new features, please post an issue or start a discussion. We're very open to new features but need to make sure they align with the direction of the underlying Copilot CLI and can be maintained in sync across all our supported languages.
17+
If you submit a PR, **be sure to link to an associated issue describing the bug or agreed feature**. No PRs without context :)
2118

22-
Currently **we are not looking to add SDKs for other languages**. If you want to create a Copilot SDK for another language, we'd love to hear from you, and we may offer to link to your SDK from our repo. However we do not plan to add further language-specific SDKs to this repo in the short term, since we need to retain our maintenance capacity for moving forwards quickly with the existing language set. So, for any other languages, please consider running your own external project.
19+
## What We're Looking For
2320

24-
## Prerequisites for running and testing code
21+
We welcome:
22+
23+
- Bug fixes with clear reproduction steps
24+
- Improvements to documentation
25+
- Making the SDKs more idiomatic and nice to use for each supported language
26+
- Bug reports and feature suggestions on [our issue tracker](https://github.com/github/copilot-sdk/issues) — especially for bugs with repro steps
27+
28+
We are generally **not** looking for:
29+
30+
- New features, capabilities, or UX changes that haven't been discussed and agreed with the team
31+
- Refactors or architectural changes
32+
- Integrations with external tools or services
33+
- Additional documentation
34+
- **SDKs for other languages** — if you want to create a Copilot SDK for another language, we'd love to hear from you and may offer to link to your SDK from our repo. However we do not plan to add further language-specific SDKs to this repo in the short term, since we need to retain our maintenance capacity for moving forwards quickly with the existing language set. For other languages, please consider running your own external project.
35+
36+
## Prerequisites for Running and Testing Code
2537

2638
This is a multi-language SDK repository. Install the tools for the SDK(s) you plan to work on:
2739

2840
### All SDKs
29-
1. (Optional) Install [just](https://github.com/casey/just) command runner for convenience
41+
42+
1. The end-to-end tests across all languages use a shared test harness written in Node.js. Before running tests in any language, `cd test/harness && npm ci`.
3043

3144
### Node.js/TypeScript SDK
45+
3246
1. Install [Node.js](https://nodejs.org/) (v18+)
3347
1. Install dependencies: `cd nodejs && npm ci`
3448

3549
### Python SDK
50+
3651
1. Install [Python 3.8+](https://www.python.org/downloads/)
3752
1. Install [uv](https://github.com/astral-sh/uv)
3853
1. Install dependencies: `cd python && uv pip install -e ".[dev]"`
3954

4055
### Go SDK
56+
4157
1. Install [Go 1.24+](https://go.dev/doc/install)
4258
1. Install [golangci-lint](https://golangci-lint.run/welcome/install/#local-installation)
4359
1. Install dependencies: `cd go && go mod download`
4460

4561
### .NET SDK
62+
4663
1. Install [.NET 8.0+](https://dotnet.microsoft.com/download)
47-
1. Install [Node.js](https://nodejs.org/) (v18+) (the .NET tests depend on a TypeScript-based test harness)
48-
1. Install npm dependencies (from the repository root):
49-
```bash
50-
cd nodejs && npm ci
51-
cd test/harness && npm ci
52-
```
5364
1. Install .NET dependencies: `cd dotnet && dotnet restore`
5465

55-
## Submitting a pull request
66+
## Submitting a Pull Request
5667

57-
1. [Fork][fork] and clone the repository
68+
1. Fork and clone the repository
5869
1. Install dependencies for the SDK(s) you're modifying (see above)
5970
1. Make sure the tests pass on your machine (see commands below)
6071
1. Make sure linter passes on your machine (see commands below)
@@ -63,29 +74,7 @@ This is a multi-language SDK repository. Install the tools for the SDK(s) you pl
6374
1. Push to your fork and [submit a pull request][pr]
6475
1. Pat yourself on the back and wait for your pull request to be reviewed and merged.
6576

66-
### Running tests and linters
67-
68-
If you installed `just`, you can use it to run tests and linters across all SDKs or for specific languages:
69-
70-
```bash
71-
# All SDKs
72-
just test # Run all tests
73-
just lint # Run all linters
74-
just format # Format all code
75-
76-
# Individual SDKs
77-
just test-nodejs # Node.js tests
78-
just test-python # Python tests
79-
just test-go # Go tests
80-
just test-dotnet # .NET tests
81-
82-
just lint-nodejs # Node.js linting
83-
just lint-python # Python linting
84-
just lint-go # Go linting
85-
just lint-dotnet # .NET linting
86-
```
87-
88-
Or run commands directly in each SDK directory:
77+
### Running Tests and Linters
8978

9079
```bash
9180
# Node.js

docs/getting-started.md

Lines changed: 126 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,18 @@ Create `main.py`:
129129

130130
```python
131131
import asyncio
132-
from copilot import CopilotClient
132+
from copilot import CopilotClient, PermissionHandler
133133

134134
async def main():
135135
client = CopilotClient()
136136
await client.start()
137137

138-
session = await client.create_session({"model": "gpt-4.1"})
139-
response = await session.send_and_wait({"prompt": "What is 2 + 2?"})
138+
session = await client.create_session({
139+
"model": "gpt-4.1",
140+
"on_permission_request": PermissionHandler.approve_all,
141+
})
140142

143+
response = await session.send_and_wait({"prompt": "What is 2 + 2?"})
141144
print(response.data.content)
142145

143146
await client.stop()
@@ -274,7 +277,7 @@ Update `main.py`:
274277
```python
275278
import asyncio
276279
import sys
277-
from copilot import CopilotClient
280+
from copilot import CopilotClient, PermissionHandler
278281
from copilot.generated.session_events import SessionEventType
279282

280283
async def main():
@@ -283,6 +286,7 @@ async def main():
283286

284287
session = await client.create_session({
285288
"model": "gpt-4.1",
289+
"on_permission_request": PermissionHandler.approve_all,
286290
"streaming": True,
287291
})
288292

@@ -653,7 +657,7 @@ Update `main.py`:
653657
import asyncio
654658
import random
655659
import sys
656-
from copilot import CopilotClient
660+
from copilot import CopilotClient, PermissionHandler
657661
from copilot.tools import define_tool
658662
from copilot.generated.session_events import SessionEventType
659663
from pydantic import BaseModel, Field
@@ -678,6 +682,7 @@ async def main():
678682

679683
session = await client.create_session({
680684
"model": "gpt-4.1",
685+
"on_permission_request": PermissionHandler.approve_all,
681686
"streaming": True,
682687
"tools": [get_weather],
683688
})
@@ -925,7 +930,7 @@ Create `weather_assistant.py`:
925930
import asyncio
926931
import random
927932
import sys
928-
from copilot import CopilotClient
933+
from copilot import CopilotClient, PermissionHandler
929934
from copilot.tools import define_tool
930935
from copilot.generated.session_events import SessionEventType
931936
from pydantic import BaseModel, Field
@@ -947,6 +952,7 @@ async def main():
947952

948953
session = await client.create_session({
949954
"model": "gpt-4.1",
955+
"on_permission_request": PermissionHandler.approve_all,
950956
"streaming": True,
951957
"tools": [get_weather],
952958
})
@@ -1417,6 +1423,119 @@ await using var session = await client.CreateSessionAsync(new()
14171423

14181424
---
14191425

1426+
## Telemetry & Observability
1427+
1428+
The Copilot SDK supports [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. Provide a `telemetry` configuration to the client to enable trace export from the CLI process and automatic [W3C Trace Context](https://www.w3.org/TR/trace-context/) propagation between the SDK and CLI.
1429+
1430+
### Enabling Telemetry
1431+
1432+
Pass a `telemetry` (or `Telemetry`) config when creating the client. This is the opt-in — no separate "enabled" flag is needed.
1433+
1434+
<details open>
1435+
<summary><strong>Node.js / TypeScript</strong></summary>
1436+
1437+
<!-- docs-validate: skip -->
1438+
```typescript
1439+
import { CopilotClient } from "@github/copilot-sdk";
1440+
1441+
const client = new CopilotClient({
1442+
telemetry: {
1443+
otlpEndpoint: "http://localhost:4318",
1444+
},
1445+
});
1446+
```
1447+
1448+
Optional peer dependency: `@opentelemetry/api`
1449+
1450+
</details>
1451+
1452+
<details>
1453+
<summary><strong>Python</strong></summary>
1454+
1455+
<!-- docs-validate: skip -->
1456+
```python
1457+
from copilot import CopilotClient, SubprocessConfig
1458+
1459+
client = CopilotClient(SubprocessConfig(
1460+
telemetry={
1461+
"otlp_endpoint": "http://localhost:4318",
1462+
},
1463+
))
1464+
```
1465+
1466+
Install with telemetry extras: `pip install copilot-sdk[telemetry]` (provides `opentelemetry-api`)
1467+
1468+
</details>
1469+
1470+
<details>
1471+
<summary><strong>Go</strong></summary>
1472+
1473+
<!-- docs-validate: skip -->
1474+
```go
1475+
client, err := copilot.NewClient(copilot.ClientOptions{
1476+
Telemetry: &copilot.TelemetryConfig{
1477+
OTLPEndpoint: "http://localhost:4318",
1478+
},
1479+
})
1480+
```
1481+
1482+
Dependency: `go.opentelemetry.io/otel`
1483+
1484+
</details>
1485+
1486+
<details>
1487+
<summary><strong>.NET</strong></summary>
1488+
1489+
<!-- docs-validate: skip -->
1490+
```csharp
1491+
var client = new CopilotClient(new CopilotClientOptions
1492+
{
1493+
Telemetry = new TelemetryConfig
1494+
{
1495+
OtlpEndpoint = "http://localhost:4318",
1496+
},
1497+
});
1498+
```
1499+
1500+
No extra dependencies — uses built-in `System.Diagnostics.Activity`.
1501+
1502+
</details>
1503+
1504+
### TelemetryConfig Options
1505+
1506+
| Option | Node.js | Python | Go | .NET | Description |
1507+
|---|---|---|---|---|---|
1508+
| OTLP endpoint | `otlpEndpoint` | `otlp_endpoint` | `OTLPEndpoint` | `OtlpEndpoint` | OTLP HTTP endpoint URL |
1509+
| File path | `filePath` | `file_path` | `FilePath` | `FilePath` | File path for JSON-lines trace output |
1510+
| Exporter type | `exporterType` | `exporter_type` | `ExporterType` | `ExporterType` | `"otlp-http"` or `"file"` |
1511+
| Source name | `sourceName` | `source_name` | `SourceName` | `SourceName` | Instrumentation scope name |
1512+
| Capture content | `captureContent` | `capture_content` | `CaptureContent` | `CaptureContent` | Whether to capture message content |
1513+
1514+
### File Export
1515+
1516+
To write traces to a local file instead of an OTLP endpoint:
1517+
1518+
<!-- docs-validate: skip -->
1519+
```typescript
1520+
const client = new CopilotClient({
1521+
telemetry: {
1522+
filePath: "./traces.jsonl",
1523+
exporterType: "file",
1524+
},
1525+
});
1526+
```
1527+
1528+
### Trace Context Propagation
1529+
1530+
Trace context is propagated automatically — no manual instrumentation is needed:
1531+
1532+
- **SDK → CLI**: `traceparent` and `tracestate` headers from the current span/activity are included in `session.create`, `session.resume`, and `session.send` RPC calls.
1533+
- **CLI → SDK**: When the CLI invokes tool handlers, the trace context from the CLI's span is propagated so your tool code runs under the correct parent span.
1534+
1535+
📖 **[OpenTelemetry Instrumentation Guide →](./observability/opentelemetry.md)** — detailed GenAI semantic conventions, event-to-attribute mapping, and complete examples.
1536+
1537+
---
1538+
14201539
## Learn More
14211540

14221541
- [Authentication Guide](./auth/index.md) - GitHub OAuth, environment variables, and BYOK
@@ -1428,6 +1547,7 @@ await using var session = await client.CreateSessionAsync(new()
14281547
- [Using MCP Servers](./features/mcp.md) - Integrate external tools via Model Context Protocol
14291548
- [GitHub MCP Server Documentation](https://github.com/github/github-mcp-server)
14301549
- [MCP Servers Directory](https://github.com/modelcontextprotocol/servers) - Explore more MCP servers
1550+
- [OpenTelemetry Instrumentation](./observability/opentelemetry.md) - Add tracing to your SDK usage
14311551

14321552
---
14331553

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Detailed API reference for each session hook.
6767

6868
### [Observability](./observability/opentelemetry.md)
6969

70-
- [OpenTelemetry Instrumentation](./observability/opentelemetry.md)add tracing to your SDK usage
70+
- [OpenTelemetry Instrumentation](./observability/opentelemetry.md)built-in TelemetryConfig, trace context propagation, and application-level tracing
7171

7272
### [Integrations](./integrations/microsoft-agent-framework.md)
7373

0 commit comments

Comments
 (0)