# microsoft/copilot-sdk architecture

> Architecture diagram of the GitHub repository microsoft/copilot-sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/copilot-sdk
- Repository: https://github.com/microsoft/copilot-sdk

## Overview

This is a multi-language SDK for embedding the Copilot agent runtime in applications. The principal workflow is application → client startup/runtime connection → JSON-RPC session creation or resume → message submission and session events. Session support also exposes tools, filesystem callbacks, canvas, permissions and hooks; model HTTP/WebSocket interception and workflow APIs are distinct capabilities. The README documents in-process C-ABI hosting and optional process/server connections. Source excerpts and index entries support several binding-level links, but unsampled implementations and some cross-binding details are represented only at subsystem level.

Main entry points: [`nodejs/src/client.ts`](https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/client.ts) (Client API), [`java/sdk/src/main/java/com/microsoft/copilot/JsonRpcClient.java`](https://github.com/microsoft/copilot-sdk/blob/main/java/sdk/src/main/java/com/microsoft/copilot/JsonRpcClient.java) (JSON-RPC transport), [`python/copilot/client.py`](https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/client.py) (Python client), [`nodejs/src/session.ts`](https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/session.ts) (Session API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["SDK clients"]
  node_client_api["Client API<br/>[client.ts]"]
  node_python_client["Python client<br/>[client.py]"]
  node_dotnet_client[".NET client<br/>[Client.cs]"]
  node_java_host["Java host manager"]
  node_rust_client["Rust client<br/>[lib.rs]"]
end

subgraph group_session["Sessions and agent features"]
  node_session_api["Session API<br/>[session.ts]"]
  node_python_session["Python session<br/>[session.py]"]
  node_session_fs["Session filesystem"]
  node_canvas["Canvas<br/>[canvas.ts]"]
  node_toolset["Tool sets<br/>[toolSet.ts]"]
  node_workflow["Workflows<br/>[workflow.ts]"]
end

subgraph group_runtime["Runtime connections"]
  node_runtime_host["Native runtime host<br/>[FfiRuntimeHost.cs]"]
  node_java_runtime["Java runtime manager"]
  node_runtime{{"Copilot runtime"}}
end

subgraph group_protocol["Protocol and events"]
  node_jsonrpc["JSON-RPC transport<br/>[JsonRpcClient.java]"]
  node_rust_router["Request router<br/>[router.rs]"]
  node_session_events["Session event types<br/>[session_events.py]"]
  node_rpc_types["Protocol types<br/>[types.rs]"]
end

subgraph group_integrations["Host integrations"]
  node_request_handler["Model request handler"]
  node_python_request["Python request handler"]
  node_auth["Authentication providers"]
  node_host_callbacks["Host callbacks<br/>[HostCallbacks.cs]"]
end

node_app(("Application"))

node_app -->|"uses"| node_client_api
node_app -->|"uses"| node_python_client
node_app -->|"uses"| node_dotnet_client
node_app -->|"uses"| node_java_host
node_app -->|"uses"| node_rust_client
node_client_api -->|"creates sessions"| node_session_api
node_client_api -->|"loads runtime"| node_runtime_host
node_python_client -->|"manages sessions"| node_python_session
node_python_client -->|"registers handler"| node_python_request
node_dotnet_client -->|"hosts runtime"| node_runtime_host
node_java_host -->|"starts host"| node_jsonrpc
node_java_runtime -->|"uses transport"| node_jsonrpc
node_rust_client -->|"routes requests"| node_rust_router
node_runtime_host -->|"loads in process"| node_runtime
node_java_runtime -.->|"connects runtime"| node_runtime
node_runtime -->|"exchanges messages"| node_jsonrpc
node_session_api -.->|"sends session requests"| node_jsonrpc
node_python_session -.->|"uses callbacks"| node_session_fs
node_rust_router -->|"routes typed payloads"| node_rpc_types
node_session_api -.->|"handles events"| node_session_events
node_client_api -->|"exposes feature"| node_canvas
node_client_api -->|"configures tools"| node_toolset
node_client_api -->|"exports workflow API"| node_workflow
node_runtime -->|"dispatches model traffic"| node_request_handler
node_runtime -.->|"requests model handling"| node_python_request
node_client_api -->|"configures credentials"| node_auth
node_client_api -.->|"wires callbacks"| node_host_callbacks

click node_client_api "https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/client.ts"
click node_python_client "https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/client.py"
click node_dotnet_client "https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/Client.cs"
click node_java_host "https://github.com/microsoft/copilot-sdk/blob/main/java/sdk/src/main/java/com/microsoft/copilot/AhpHostManager.java"
click node_rust_client "https://github.com/microsoft/copilot-sdk/blob/main/rust/src/lib.rs"
click node_session_api "https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/session.ts"
click node_python_session "https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/session.py"
click node_session_fs "https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/ResolvingSessionFsHandler.cs"
click node_canvas "https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/canvas.ts"
click node_toolset "https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/toolSet.ts"
click node_workflow "https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/workflow.ts"
click node_runtime_host "https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/FfiRuntimeHost.cs"
click node_java_runtime "https://github.com/microsoft/copilot-sdk/blob/main/java/sdk/src/main/java/com/microsoft/copilot/CliServerManager.java"
click node_jsonrpc "https://github.com/microsoft/copilot-sdk/blob/main/java/sdk/src/main/java/com/microsoft/copilot/JsonRpcClient.java"
click node_rust_router "https://github.com/microsoft/copilot-sdk/blob/main/rust/src/router.rs"
click node_session_events "https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/_generated/session_events.py"
click node_rpc_types "https://github.com/microsoft/copilot-sdk/blob/main/rust/src/types.rs"
click node_request_handler "https://github.com/microsoft/copilot-sdk/blob/main/rust/src/copilot_request_handler.rs"
click node_python_request "https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/copilot_request_handler.py"
click node_auth "https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/BearerTokenProvider.cs"
click node_host_callbacks "https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/HostCallbacks.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_api,node_python_client,node_dotnet_client,node_java_host,node_rust_client toneBlue
class node_session_api,node_python_session,node_session_fs,node_canvas,node_toolset,node_workflow toneAmber
class node_runtime_host,node_java_runtime,node_runtime toneMint
class node_jsonrpc,node_rust_router,node_session_events,node_rpc_types toneRose
class node_request_handler,node_python_request,node_auth,node_host_callbacks,node_app toneIndigo
```

## Components

### SDK clients

- [Client API](https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/client.ts): `nodejs/src/client.ts`
- [Python client](https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/client.py): `python/copilot/client.py`
- [.NET client](https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/Client.cs): `dotnet/src/Client.cs`
- [Java host manager](https://github.com/microsoft/copilot-sdk/blob/main/java/sdk/src/main/java/com/microsoft/copilot/AhpHostManager.java): `java/sdk/src/main/java/com/microsoft/copilot/AhpHostManager.java`
- [Rust client](https://github.com/microsoft/copilot-sdk/blob/main/rust/src/lib.rs): `rust/src/lib.rs`

### Sessions and agent features

- [Session API](https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/session.ts): `nodejs/src/session.ts`
- [Python session](https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/session.py): `python/copilot/session.py`
- [Session filesystem](https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/ResolvingSessionFsHandler.cs): `dotnet/src/ResolvingSessionFsHandler.cs`
- [Canvas](https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/canvas.ts): `nodejs/src/canvas.ts`
- [Tool sets](https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/toolSet.ts): `nodejs/src/toolSet.ts`
- [Workflows](https://github.com/microsoft/copilot-sdk/blob/main/nodejs/src/workflow.ts): `nodejs/src/workflow.ts`

### Runtime connections

- [Native runtime host](https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/FfiRuntimeHost.cs): `dotnet/src/FfiRuntimeHost.cs`
- [Java runtime manager](https://github.com/microsoft/copilot-sdk/blob/main/java/sdk/src/main/java/com/microsoft/copilot/CliServerManager.java): `java/sdk/src/main/java/com/microsoft/copilot/CliServerManager.java`
- **Copilot runtime**

### Protocol and events

- [JSON-RPC transport](https://github.com/microsoft/copilot-sdk/blob/main/java/sdk/src/main/java/com/microsoft/copilot/JsonRpcClient.java): `java/sdk/src/main/java/com/microsoft/copilot/JsonRpcClient.java`
- [Request router](https://github.com/microsoft/copilot-sdk/blob/main/rust/src/router.rs): `rust/src/router.rs`
- [Session event types](https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/_generated/session_events.py): `python/copilot/_generated/session_events.py`
- [Protocol types](https://github.com/microsoft/copilot-sdk/blob/main/rust/src/types.rs): `rust/src/types.rs`

### Host integrations

- [Model request handler](https://github.com/microsoft/copilot-sdk/blob/main/rust/src/copilot_request_handler.rs): `rust/src/copilot_request_handler.rs`
- [Python request handler](https://github.com/microsoft/copilot-sdk/blob/main/python/copilot/copilot_request_handler.py): `python/copilot/copilot_request_handler.py`
- [Authentication providers](https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/BearerTokenProvider.cs): `dotnet/src/BearerTokenProvider.cs`
- [Host callbacks](https://github.com/microsoft/copilot-sdk/blob/main/dotnet/src/HostCallbacks.cs): `dotnet/src/HostCallbacks.cs`

### Other components

- **Application**

## Connections

- Application → Client API: uses (evidence: `README.md`)
- Application → Python client: uses (evidence: `README.md`)
- Application → .NET client: uses (evidence: `README.md`)
- Application → Java host manager: uses (evidence: `README.md`)
- Application → Rust client: uses (evidence: `README.md`)
- Client API → Session API: creates sessions (evidence: `nodejs/src/client.ts`)
- Client API → Native runtime host: loads runtime (evidence: `nodejs/src/client.ts`)
- Python client → Python session: manages sessions (evidence: `python/copilot/client.py`)
- Python client → Python request handler: registers handler (evidence: `python/copilot/client.py`)
- .NET client → Native runtime host: hosts runtime (evidence: `dotnet/src/Client.cs`)
- Java host manager → JSON-RPC transport: starts host (evidence: `java/sdk/src/main/java/com/microsoft/copilot/AhpHostManager.java`)
- Java runtime manager → JSON-RPC transport: uses transport (evidence: `java/sdk/src/main/java/com/microsoft/copilot/CliServerManager.java`)
- Rust client → Request router: routes requests (evidence: `rust/src/lib.rs`)
- Native runtime host → Copilot runtime: loads in process (evidence: `README.md`)
- Java runtime manager → Copilot runtime: connects runtime (evidence: `README.md`)
- Copilot runtime → JSON-RPC transport: exchanges messages (evidence: `README.md`)
- Session API → JSON-RPC transport: sends session requests
- Python session → Session filesystem: uses callbacks
- Request router → Protocol types: routes typed payloads (evidence: `rust/src/router.rs`)
- Session API → Session event types: handles events
- Client API → Canvas: exposes feature (evidence: `nodejs/src/client.ts`)
- Client API → Tool sets: configures tools (evidence: `nodejs/src/client.ts`)
- Client API → Workflows: exports workflow API (evidence: `nodejs/src/index.ts`)
- Copilot runtime → Model request handler: dispatches model traffic (evidence: `rust/src/copilot_request_handler.rs`)
- Copilot runtime → Python request handler: requests model handling
- Client API → Authentication providers: configures credentials (evidence: `nodejs/src/client.ts`)
- Client API → Host callbacks: wires callbacks
