@openhoo/hoopilot 0.2.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/LICENSE +21 -0
- package/README.md +144 -0
- package/dist/cli.js +1162 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +1078 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +72 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.js +1038 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenHoo contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# hoopilot
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@openhoo/hoopilot)
|
|
4
|
+
[](https://github.com/openhoo/hoopilot/actions/workflows/ci.yml)
|
|
5
|
+
|
|
6
|
+
OpenAI-compatible local proxy for GitHub Copilot accounts. It runs on Bun and exposes `/v1/chat/completions`, `/v1/responses`, `/v1/completions`, and `/v1/models` for clients that can point at a custom OpenAI base URL.
|
|
7
|
+
|
|
8
|
+
This project uses GitHub Copilot's service endpoints and is not an official GitHub product. The upstream API can change without notice. Use it only with accounts and usage patterns you are allowed to use.
|
|
9
|
+
|
|
10
|
+
## Run
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx @openhoo/hoopilot
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Before the npm package is published, run the same binary directly from GitHub:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npx github:openhoo/hoopilot
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
By default Hoopilot listens on `127.0.0.1:4141`, reads a GitHub token from `COPILOT_GITHUB_TOKEN`, `GITHUB_TOKEN`, `GH_TOKEN`, or `gh auth token`, and exchanges it for a Copilot API token when GitHub supports the exchange endpoint for the account.
|
|
23
|
+
|
|
24
|
+
For a local API key:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
HOOPILOT_API_KEY=local-key npx @openhoo/hoopilot --port 4141
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Point OpenAI-compatible clients at:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
OPENAI_BASE_URL=http://127.0.0.1:4141/v1
|
|
34
|
+
OPENAI_API_KEY=local-key
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Use with Codex CLI after Hoopilot is running:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
OPENAI_API_KEY=local-key codex -m claude-sonnet-4.6 -c 'openai_base_url="http://127.0.0.1:4141/v1"'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
$env:OPENAI_API_KEY="local-key"; codex -m claude-sonnet-4.6 -c 'openai_base_url="http://127.0.0.1:4141/v1"'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If no `HOOPILOT_API_KEY` is configured, Hoopilot accepts local requests without client authentication. Binding to a non-loopback host requires `HOOPILOT_API_KEY` unless `--allow-unauthenticated` is set.
|
|
48
|
+
|
|
49
|
+
## Authentication
|
|
50
|
+
|
|
51
|
+
Preferred options:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
gh auth login
|
|
55
|
+
npx @openhoo/hoopilot
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
or:
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
COPILOT_GITHUB_TOKEN=$(gh auth token) npx @openhoo/hoopilot
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
You can also [create a fine-grained personal access token](https://github.com/settings/personal-access-tokens/new) for the GitHub account that has Copilot access. GitHub's [personal access token documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) explains how fine-grained tokens and permissions work.
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
COPILOT_GITHUB_TOKEN=github_pat_... HOOPILOT_API_KEY=local-key npx @openhoo/hoopilot
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Supported credential environment variables:
|
|
71
|
+
|
|
72
|
+
- `COPILOT_GITHUB_TOKEN`, `GITHUB_COPILOT_GITHUB_TOKEN`, `GITHUB_TOKEN`, or `GH_TOKEN`: GitHub OAuth token for an account with Copilot access.
|
|
73
|
+
- `COPILOT_API_TOKEN`, `GITHUB_COPILOT_API_TOKEN`, or `GITHUB_COPILOT_TOKEN`: short-lived Copilot API bearer token.
|
|
74
|
+
- `COPILOT_API_BASE_URL`: upstream Copilot API base URL override.
|
|
75
|
+
- `COPILOT_TOKEN_EXCHANGE_URL`: GitHub token exchange endpoint override.
|
|
76
|
+
|
|
77
|
+
Auth modes:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
npx @openhoo/hoopilot --auth-mode auto
|
|
81
|
+
npx @openhoo/hoopilot --auth-mode github-token
|
|
82
|
+
npx @openhoo/hoopilot --auth-mode direct-github-token
|
|
83
|
+
npx @openhoo/hoopilot --auth-mode copilot-token
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`auto` first tries the GitHub Copilot token exchange endpoint, then falls back to direct GitHub-token mode against the individual Copilot API base URL. Use `github-token` when you want exchange failures to fail fast.
|
|
87
|
+
|
|
88
|
+
## CLI
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
hoopilot [serve] [options]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Options:
|
|
95
|
+
|
|
96
|
+
```txt
|
|
97
|
+
-p, --port <port> Port to listen on. Default: 4141
|
|
98
|
+
--host <host> Host to listen on. Default: 127.0.0.1
|
|
99
|
+
--api-key <key> Require clients to send Authorization: Bearer <key>
|
|
100
|
+
--auth-mode <mode> auto, github-token, direct-github-token, copilot-token
|
|
101
|
+
--github-token <token> GitHub OAuth token for a Copilot account
|
|
102
|
+
--github-token-command <cmd> Command used to read a GitHub token. Default: gh auth token
|
|
103
|
+
--copilot-token <token> Short-lived Copilot API bearer token
|
|
104
|
+
--copilot-api-base-url <url> Copilot API base URL override
|
|
105
|
+
--no-gh Do not try gh auth token
|
|
106
|
+
--allow-unauthenticated Allow non-loopback bind without --api-key
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Endpoints
|
|
110
|
+
|
|
111
|
+
- `GET /healthz`
|
|
112
|
+
- `GET /v1/models`
|
|
113
|
+
- `POST /v1/chat/completions`
|
|
114
|
+
- `POST /v1/responses`
|
|
115
|
+
- `POST /v1/completions`
|
|
116
|
+
|
|
117
|
+
`/v1/chat/completions` is proxied to Copilot as directly as possible. `/v1/responses` and `/v1/completions` translate requests and responses to the closest chat completions equivalent, including basic function-tool calls.
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
bun install
|
|
123
|
+
bun run check
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Useful scripts:
|
|
127
|
+
|
|
128
|
+
```sh
|
|
129
|
+
bun run test
|
|
130
|
+
bun run test:coverage
|
|
131
|
+
bun run typecheck
|
|
132
|
+
bun run build
|
|
133
|
+
bun run biome:fix
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Release
|
|
137
|
+
|
|
138
|
+
Commits merged to `main` are evaluated by hooversion after CI passes. When a release is produced, the release workflow creates the release commit, tag, and GitHub release automatically, then publishes the package through npm trusted publishing.
|
|
139
|
+
|
|
140
|
+
Configure npm trusted publishing for `@openhoo/hoopilot` on npmjs.com before relying on automatic publication. The workflow uses GitHub Actions OIDC with `npm publish --access public --provenance`.
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
MIT. See [LICENSE](LICENSE).
|