@alvin0/ai-agent-sdk-provider-copilot 0.1.1
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 +61 -0
- package/dist/index.d.ts +1297 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2680 -0
- package/dist/index.js.map +1 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 alvin0 (chaulamdinhai) <chaulamdinhai@gmail.com>
|
|
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,61 @@
|
|
|
1
|
+
# @alvin0/ai-agent-sdk-provider-copilot
|
|
2
|
+
|
|
3
|
+
Runtime: **Universal** (Edge/Worker, browser, Deno, Bun, and Node with an injected credential store).
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add @alvin0/ai-agent-sdk-core @alvin0/ai-agent-sdk-provider-copilot
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Universal GitHub Copilot adapter: OAuth device flow, the two-tier credential
|
|
10
|
+
contract, Copilot token exchange, model-driven endpoint routing across
|
|
11
|
+
`/responses` and `/chat/completions`, catalog discovery, and a transactional
|
|
12
|
+
provider plugin. A `CopilotCredentialStore` must be injected; filesystem and
|
|
13
|
+
environment defaults belong to the Node auth package.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { ModelRegistry } from '@alvin0/ai-agent-sdk-core'
|
|
17
|
+
import { copilotPlugin, memoryCopilotCredentialStore } from '@alvin0/ai-agent-sdk-provider-copilot'
|
|
18
|
+
|
|
19
|
+
const registry = new ModelRegistry()
|
|
20
|
+
registry.install(copilotPlugin({ authStore: memoryCopilotCredentialStore(tokens) }))
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Use `copilotAdapter()` for manual route registration. The store contract is
|
|
24
|
+
Universal; a browser, Worker, secret manager, or Node package owns persistence.
|
|
25
|
+
|
|
26
|
+
Composition: `runtime.providers`. Lifecycle:
|
|
27
|
+
`inert-runtime-owned-registration`; the runtime owns registration while the
|
|
28
|
+
injected credential store remains caller-owned.
|
|
29
|
+
|
|
30
|
+
## Client identity
|
|
31
|
+
|
|
32
|
+
Three exported constants decide which client this SDK presents itself as:
|
|
33
|
+
|
|
34
|
+
| Constant | Module | Override |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `COPILOT_OAUTH_CLIENT_ID` | `src/oauth.ts` | `clientId` option |
|
|
37
|
+
| `COPILOT_EDITOR_VERSION` | `src/adapter.ts` | `editorHeaders.editorVersion` |
|
|
38
|
+
| `COPILOT_EDITOR_PLUGIN_VERSION` | `src/adapter.ts` | `editorHeaders.editorPluginVersion` |
|
|
39
|
+
|
|
40
|
+
Their defaults make this SDK identify itself as an editor client. That is required
|
|
41
|
+
for the surface to answer: `copilot_internal/v2/token` only accepts a token minted
|
|
42
|
+
by an OAuth App on GitHub's allowlist, and the Copilot endpoints answer HTTP 400
|
|
43
|
+
when either editor header is missing.
|
|
44
|
+
|
|
45
|
+
They are exported and overridable rather than hidden precisely because presenting
|
|
46
|
+
as another client is a decision you should be able to read off the source and
|
|
47
|
+
change. Use your own account, and prefer a provider's official first-party surface
|
|
48
|
+
for production workloads.
|
|
49
|
+
|
|
50
|
+
**Two of the three default values are confirmed against a live Copilot account; one
|
|
51
|
+
is not.** A live run on 2026-09-10 sent both editor headers on the token exchange,
|
|
52
|
+
`GET /models`, a streaming `/chat/completions` call and `POST /embeddings`, and none
|
|
53
|
+
answered HTTP 400 — so `COPILOT_EDITOR_VERSION` and `COPILOT_EDITOR_PLUGIN_VERSION`
|
|
54
|
+
are confirmed as of that date. `COPILOT_OAUTH_CLIENT_ID` is still unconfirmed: that
|
|
55
|
+
run used an existing user token rather than the device flow, so this client id never
|
|
56
|
+
reached GitHub's allowlist check. The source carries a `copilot-identity` comment
|
|
57
|
+
naming what must be confirmed and how.
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|