@vscode/copilot-api
v0.2.16
Published
A module used for interacting with the GitHub Copilot API.
Readme
@vscode/copilot-api
A module used for interacting with the GitHub Copilot API.
Installation
With npm:
npm install @vscode/copilot-apiWith yarn:
yarn add @vscode/copilot-apiUsage
Basic Setup
import { CAPIClient, RequestType } from '@vscode/copilot-api';
// Create a new client instance
const client = new CAPIClient(editorDetails, license, optionalFetcherService);
// Update domains (if needed)
const domainChanges = client.updateDomains(copilotToken, enterpriseUrlConfig);
// Make requests
const response = await client.makeRequest(fetchOptions, RequestType.ChatCompletions);Available Request Types
RequestType.CopilotToken- Get Copilot tokenRequestType.ChatCompletions- Chat completionsRequestType.RemoteAgent- Remote agent requestsRequestType.Embeddings- EmbeddingsRequestType.Models- Available modelsRequestType.CCAModelsList- Get available models for Copilot coding agentRequestType.Chunks- Code chunksRequestType.EmbeddingsCodeSearch- Embeddings code searchRequestType.ListSkills- List available skillsRequestType.SearchSkill- Search skillsRequestType.ContentExclusion- Content exclusionRequestType.Telemetry- TelemetryRequestType.CopilotUserInfo- User infoRequestType.OriginTracker- Origin tracking
Development
Building
The package is built using esbuild to create a single platform-neutral ESM module that works in both Node.js and web environments:
# Build for production (minified)
npm run build
# Build for development (unminified)
npm run build:dev
# Clean build artifacts
npm run cleanBuild Output
dist/index.js- Platform-neutral ESM builddist/index.d.ts- TypeScript declarations
Package Exports
The package is configured with a simplified ESM export structure:
{
"exports": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
}Testing
This project uses Vitest for testing. Run tests with:
# Run tests once
npm test
# Run tests in watch mode
npm run test:watch