npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-sdk-provider-copilot

v0.1.4

Published

Community AI SDK provider for GitHub Copilot CLI

Readme

ai-sdk-provider-copilot

Community AI SDK provider for GitHub Copilot CLI.

⚠️ Note: This provider spawns a local Copilot CLI process and will not work in serverless environments (Vercel, AWS Lambda, etc.). Use it in long-running environments like local development, Docker containers, or traditional servers.

Installation

npm install ai-sdk-provider-copilot @github/copilot-sdk

Prerequisites

  • Node.js 20+
  • GitHub Copilot CLI installed globally: npm install -g @github/copilot
  • Valid GitHub Copilot subscription
  • Authenticated via copilot auth login or gh auth login

Quick Start

import { createCopilotProvider } from 'ai-sdk-provider-copilot';
import { generateText, streamText } from 'ai';

// Create the provider
const copilot = createCopilotProvider();

// Generate text
const result = await generateText({
  model: copilot('gpt-4'),
  prompt: 'Hello, world!'
});
console.log(result.text);

// Stream text
const stream = await streamText({
  model: copilot('gpt-4'),
  prompt: 'Tell me a story'
});
for await (const chunk of stream.textStream) {
  process.stdout.write(chunk);
}

// Always dispose when done
await copilot.dispose();

Configuration

Provider Options

const copilot = createCopilotProvider({
  // Enable verbose logging
  verbose: true,

  // Retry configuration
  retry: {
    maxRetries: 3,
    initialDelayMs: 100,
  },

  // BYOK - Bring Your Own Key
  provider: {
    type: 'openai',
    baseUrl: 'https://api.openai.com/v1',
    apiKey: process.env.OPENAI_API_KEY,
  },

  // Custom agents
  customAgents: [
    {
      name: 'code-reviewer',
      displayName: 'Code Reviewer',
      description: 'An expert code reviewer focused on best practices',
      prompt: 'You are an expert code reviewer...',
    },
  ],

  // Session pooling for efficiency
  sessionPool: {
    enabled: true,
    maxIdleSessions: 3,
  },

  // Health monitoring for reliability
  healthMonitor: {
    failureThreshold: 3,
    onHealthChange: (healthy, reason) => console.log(`Health: ${healthy}`),
  },

  // OpenTelemetry
  telemetry: {
    serviceName: 'my-app',
    recordContent: false,
  }
});

Model Settings

const model = copilot('gpt-4', {
  systemMessage: {
    mode: 'append',
    content: 'Be concise and helpful.',
  },
  // Control which built-in tools are available
  availableTools: ['web_fetch'],
  excludedTools: ['report_intent'],
});

Features

Custom Agents

Define specialized agents with custom prompts:

const copilot = createCopilotProvider({
  customAgents: [{
    name: 'explainer',
    displayName: 'Code Explainer',
    prompt: 'You are a helpful teacher...'
  }]
});

// Use via model ID or provider options
const model = copilot('agent/explainer');
// OR
const result = await generateText({
  model: copilot('gpt-4'),
  providerOptions: { copilot: { agent: 'explainer' } }
});

Tool Calling

Support for both built-in Copilot tools and custom tools via Zod schemas:

const result = await generateText({
  model: copilot('gpt-4'),
  tools: {
    weather: {
      description: 'Get weather',
      parameters: z.object({ location: z.string() })
    }
  }
});

Session Management

Reuse sessions for better performance:

const copilot = createCopilotProvider({
  sessionPool: {
    enabled: true,
    maxIdleSessions: 3,
    idleTimeoutMs: 300_000,
  }
});

Supported Features

| Feature | Status | |---------|--------| | generateText() | ✅ | | streamText() | ✅ | | Tool calling | ✅ (Custom & Built-in) | | Custom agents | ✅ | | BYOK (Bring Your Own Key) | ✅ | | MCP server integration | ✅ | | Response caching | ✅ | | Session pooling | ✅ | | Health monitoring | ✅ | | Retry with backoff | ✅ | | OpenTelemetry integration | ✅ | | generateObject() | ⚠️ Prompt-based only |

Examples

See the examples/ directory:

  • basic-usage.ts - Simple text generation
  • streaming.ts - Real-time streaming
  • tool-calling.ts - Custom tool definitions
  • custom-agent.ts - Custom agent personas
  • caching.ts - Response caching
  • error-handling.ts - Retry and error handling
  • http-server-sse.ts - SSE streaming server

Run any example with:

npx tsx examples/basic-usage.ts

Windows Notes

On Windows, the provider automatically detects the Copilot CLI path. If you encounter issues, ensure the CLI is installed globally:

npm install -g @github/copilot

License

MIT