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

opencode-codebuddy-auth

v1.0.1

Published

OpenCode plugin for CodeBuddy (IOA) authentication

Readme

opencode-codebuddy-auth

OpenCode 插件,用于 CodeBuddy (IOA) 认证。通过浏览器 OAuth 登录后,可在 OpenCode CLI 中使用 CodeBuddy 的对话模型。

安装

opencode.json 中添加:

{
  "plugin": ["opencode-codebuddy-auth"],
  "provider": {
    "codebuddy": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "CodeBuddy",
      "options": {
        "baseURL": "https://copilot.tencent.com/v2",
        "setCacheKey": true
      },
      "models": {
        "auto":                    { "name": "Auto", "contextLength": 168000 },
        "hy3-preview":             { "name": "Hunyuan3-Preview", "contextLength": 192000 },
        "glm-5v-turbo":            { "name": "GLM-5v-Turbo", "contextLength": 200000 },
        "glm-5.1":                 { "name": "GLM-5.1", "contextLength": 200000 },
        "glm-5.0-turbo":           { "name": "GLM-5.0-Turbo", "contextLength": 200000 },
        "glm-4.6":                 { "name": "GLM-4.6", "contextLength": 168000 },
        "kimi-k2.6":               { "name": "Kimi-K2.6", "contextLength": 256000 },
        "kimi-k2.5":               { "name": "Kimi-K2.5", "contextLength": 256000 },
        "deepseek-v4-flash":       { "name": "DeepSeek-V4-Flash", "contextLength": 1000000 },
        "deepseek-v3-2-volc":      { "name": "DeepSeek-V3.2", "contextLength": 96000 }
      }
    }
  }
}

登录

opencode auth codebuddy

浏览器会打开 IOA 登录页面,完成后 token 自动保存到本地。

可用模型

以下为 craft agent 支持的模型(来自 /v3/config 接口):

| 模型 ID | 名称 | 上下文长度 | 图片 | 推理 | |---------|------|-----------|------|------| | auto | Auto | 168K | Yes | - | | hy3-preview | Hunyuan3-Preview | 192K | Yes | Yes | | glm-5v-turbo | GLM-5v-Turbo | 200K | Yes | Yes | | glm-5.1 | GLM-5.1 | 200K | No | Yes | | glm-5.0-turbo | GLM-5.0-Turbo | 200K | No | Yes | | glm-4.6 | GLM-4.6 | 168K | No | - | | kimi-k2.6 | Kimi-K2.6 | 256K | Yes | Yes | | kimi-k2.5 | Kimi-K2.5 | 256K | Yes | Yes | | deepseek-v4-flash | DeepSeek-V4-Flash | 1M | Yes | Yes | | deepseek-v3-2-volc | DeepSeek-V3.2 | 96K | Yes | Yes |

模型列表来自 /v3/config 接口,可能随时更新。

动态获取模型列表

curl -H 'Accept: application/json, text/plain, */*' \
     -H 'X-Requested-With: XMLHttpRequest' \
     -H 'Authorization: Bearer <TOKEN>' \
     -H 'X-User-Id: <USER_ID>' \
     -H 'X-Domain: www.codebuddy.cn' \
     -H 'X-Product: SaaS' \
     -H 'X-IDE-Type: VSCode' \
     -H 'X-IDE-Name: VSCode' \
     -H 'X-IDE-Version: 1.119.0' \
     -H 'X-Product-Version: 4.3.20019762' \
     -H 'X-Request-Trace-Id: <UUID>' \
     -H 'X-Env-ID: production' \
     -H 'User-Agent: VSCode/1.119.0 CodeBuddy/4.3.20019762' \
     'https://copilot.tencent.com/v3/config'
  • data.models — 所有可用模型
  • data.agents[0].models — craft agent 可用的模型列表

环境变量

| 变量 | 说明 | 必需 | |------|------|------| | CODEBUDDY_TENANT_ID | 覆盖 tenant_id(不设置则从 JWT 自动提取) | 否 | | CODEBUDDY_ENTERPRISE_ID | 覆盖 enterprise_id(不设置则从 JWT 自动提取) | 否 | | CODEBUDDY_USER_ID | 覆盖 user_id(不设置则从 JWT 自动提取) | 否 | | CODEBUDDY_DEFAULT_MODEL | 强制使用指定模型 | 否 |

国内版 vs 国际版

本插件默认适配国内版 CodeBuddy 服务。serverUrlX-Domain 需匹配对应环境:

| 环境 | serverUrl | X-Domain | |------|-----------|----------| | 国内版(默认) | https://copilot.tencent.com | www.codebuddy.cn | | 国际版 | https://www.codebuddy.ai | www.codebuddy.ai |

切换环境时需同时修改源码中 CONFIG.serverUrlCONFIG.domain

工作原理

OpenCode CLI
  ├─ loader() → 返回 { apiKey, baseURL, fetch }
  │              fetch 拦截所有 /chat/completions 请求
  ├─ 认证流程 → 浏览器 IOA OAuth → 获取 access_token + refresh_token
  └─ 对话流程 → 拦截请求
                附加认证 headers(Authorization, B3 追踪等)
                转发到 https://copilot.tencent.com/v2/chat/completions
                直接透传 OpenAI 兼容 SSE 响应
  • 自定义 fetch 拦截所有 /chat/completions 请求,绕过 AI SDK 默认认证
  • 自动 token 刷新 — 遇到 401/403 时自动刷新 token 后重试
  • 无需 SSE 转换 — API 已直接返回标准 OpenAI 格式

开发

npm install
npm run build

许可证

MIT