copilot-relay 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -0
- package/config.default.yaml +45 -0
- package/dist/main.js +2212 -0
- package/dist/main.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# copilot-relay
|
|
2
|
+
|
|
3
|
+
[](https://github.com/D0n9X1n/copilot-relay/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/copilot-relay)
|
|
5
|
+
[](https://www.npmjs.com/package/copilot-relay)
|
|
6
|
+
[](https://github.com/D0n9X1n/copilot-relay/pkgs/npm/copilot-relay)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
[](https://docs.anthropic.com/en/docs/claude-code/overview)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
12
|
+
Yet, just another relay for Claude Code to use a GitHub Copilot subscription.
|
|
13
|
+
|
|
14
|
+
Public API:
|
|
15
|
+
|
|
16
|
+
- `POST /v1/messages`
|
|
17
|
+
- `POST /v1/messages/count_tokens`
|
|
18
|
+
- `GET /v1/models`
|
|
19
|
+
- `GET /healthz`
|
|
20
|
+
|
|
21
|
+
Routing:
|
|
22
|
+
|
|
23
|
+
| Requested model | Upstream model |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| contains `opus` | `claude-opus-4.8` |
|
|
26
|
+
| anything else | `gpt-5.5` |
|
|
27
|
+
|
|
28
|
+
## Install & run
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npx copilot-relay@latest auth
|
|
32
|
+
npx copilot-relay@latest start
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`start` writes `ANTHROPIC_BASE_URL` and a dummy `ANTHROPIC_AUTH_TOKEN` into `~/.claude/settings.json`.
|
|
36
|
+
|
|
37
|
+
## Config
|
|
38
|
+
|
|
39
|
+
Config lives at `~/.copilot-relay/config.yaml` and is hot-reloaded:
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
host: 127.0.0.1
|
|
43
|
+
port: 4142
|
|
44
|
+
copilotBaseUrl: https://api.githubcopilot.com
|
|
45
|
+
claudeSetup: true
|
|
46
|
+
logLevel: info
|
|
47
|
+
logRetentionDays: 3
|
|
48
|
+
thinkEffort: xhigh
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`logLevel` controls verbosity:
|
|
52
|
+
|
|
53
|
+
| Level | Logs |
|
|
54
|
+
| --- | --- |
|
|
55
|
+
| `silent` | Nothing |
|
|
56
|
+
| `error` | Startup, preflight, and request failures |
|
|
57
|
+
| `warn` | Errors plus recoverable warnings |
|
|
58
|
+
| `info` | Warnings plus startup status, preflight status, HTTP requests, and model routing summaries |
|
|
59
|
+
| `debug` | Info plus Copilot upstream timings, token refresh scheduling, and upstream error request summaries |
|
|
60
|
+
| `trace` | Debug plus full Claude request payloads and full upstream Copilot request payloads without redaction |
|
|
61
|
+
|
|
62
|
+
Valid `thinkEffort`: `none`, `low`, `medium`, `high`, `xhigh`.
|
|
63
|
+
|
|
64
|
+
The same folder stores `copilot_token.json` for the cached Copilot bearer token, `github_token` for refresh/login, and `logs/` for runtime logs.
|
|
65
|
+
|
|
66
|
+
## CLI
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
copilot-relay auth
|
|
70
|
+
copilot-relay start
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Logging
|
|
74
|
+
|
|
75
|
+
At `info`, every model request logs the requested model, upstream model, requested think effort, requested thinking, and effective think effort.
|
|
76
|
+
|
|
77
|
+
At `trace`, copilot-relay logs the full Claude request payload and full upstream request payload without redaction.
|
|
78
|
+
|
|
79
|
+
Logs are written to `~/.copilot-relay/logs/copilot-relay.log`; old `.log` files are cleaned according to `logRetentionDays`.
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
Developer notes live in [`docs/development.md`](docs/development.md).
|
|
84
|
+
Architecture notes live in [`docs/architecture.md`](docs/architecture.md).
|
|
85
|
+
Logging notes live in [`docs/logging.md`](docs/logging.md).
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
npm install
|
|
89
|
+
npm run typecheck
|
|
90
|
+
npm run build
|
|
91
|
+
npm test
|
|
92
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# copilot-relay configuration
|
|
2
|
+
#
|
|
3
|
+
# This file is copied to ~/.copilot-relay/config.yaml on first start.
|
|
4
|
+
# Edit the user config file, not this template, for local changes.
|
|
5
|
+
|
|
6
|
+
# Local host for the Claude Code-compatible HTTP server.
|
|
7
|
+
host: 127.0.0.1
|
|
8
|
+
|
|
9
|
+
# Local port for the HTTP server.
|
|
10
|
+
port: 4142
|
|
11
|
+
|
|
12
|
+
# GitHub Copilot API base URL.
|
|
13
|
+
# Keep this default unless you know your Copilot tenant uses a custom endpoint.
|
|
14
|
+
copilotBaseUrl: https://api.githubcopilot.com
|
|
15
|
+
|
|
16
|
+
# When true, start updates ~/.claude/settings.json with ANTHROPIC_BASE_URL
|
|
17
|
+
# and a dummy ANTHROPIC_AUTH_TOKEN so Claude Code can use this proxy.
|
|
18
|
+
claudeSetup: true
|
|
19
|
+
|
|
20
|
+
# Log verbosity:
|
|
21
|
+
# silent - no logs
|
|
22
|
+
# error - startup/preflight/request failures only
|
|
23
|
+
# warn - error logs plus recoverable warnings
|
|
24
|
+
# info - warn logs plus startup status, preflight status, HTTP requests,
|
|
25
|
+
# and model routing summaries
|
|
26
|
+
# debug - info logs plus Copilot upstream timings, token refresh scheduling,
|
|
27
|
+
# and upstream error request summaries
|
|
28
|
+
# trace - debug logs plus full Claude request payloads and full upstream
|
|
29
|
+
# Copilot request payloads without redaction
|
|
30
|
+
logLevel: info
|
|
31
|
+
|
|
32
|
+
# Number of days to keep files in ~/.copilot-relay/logs.
|
|
33
|
+
logRetentionDays: 3
|
|
34
|
+
|
|
35
|
+
# Default upstream thinking/reasoning effort sent to Copilot.
|
|
36
|
+
# Valid values: none, low, medium, high, xhigh.
|
|
37
|
+
thinkEffort: xhigh
|
|
38
|
+
|
|
39
|
+
# Model routing: requests containing "opus" use opusModel; all others use gptModel.
|
|
40
|
+
#
|
|
41
|
+
# Upstream Copilot model used for non-Opus requests.
|
|
42
|
+
gptModel: gpt-5.5
|
|
43
|
+
|
|
44
|
+
# Upstream Copilot model used for requests containing "opus".
|
|
45
|
+
opusModel: claude-opus-4.8
|