Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@hex4c59/pi-ext-copilot-auto

Latest version: v0.1.1

Overview

Last scanned
27 Nov 2026
Published
27 Nov 2026
npm package Publisher: hex4c59
1 Versions
249 Downloads

Scan summary

@hex4c59/pi-ext-copilot-auto was last scanned on 27 Nov 2026 at version 0.1.1. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: First and only release on 27 Nov 2026.
  • Findings: No rules fired in version 0.1.1.
  • Downloads: 249 downloads.

Versions

1 version published
Versions and the rules that fired in each
VersionPublishedStatus
0.1.1 LATEST 27 Nov 2026 No rules fired

No rules fired in 0.1.1

Findings

Findings for v0.1.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.1.1; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

copilot-auto

让 pi 使用 GitHub Copilot 的 Auto 通道,可以直接选 auto-routed(显示名 Auto)交给服务端路由,也可以直接调用 gpt-5.3-codex、mai-code-1.1-flash 这类在普通调用下会返回 400 model_not_supported 的模型。

解决什么问题

GitHub Copilot 有两条相互隔离的 Auto 路由通道:

通道 如何调用 令牌覆盖范围
/auto(新) POST /auto,版本头 2026-08-01 仅它选中的那个模型
/models/session(旧) POST /models/session,版本头 2025-07-16 响应里的 available_models

两者都下发 session_token,都必须以 Copilot-Session-Token 头发给 /responses。 不带该头时,这些模型一律返回 400 model_not_supported(已实测)。

pi 内置的 github-copilot provider 只实现了普通通道,因此这些模型在 pi 里 始终不可用。本扩展补上 Auto 通道。

工作原理

pi 请求
  │
  ├─ 选了 auto?
  │    ├─ 1. POST /auto  {"prompt":"...","has_image":true?}
  │    │      ← {selected_model:<完整对象>, session_token, expires_at}
  │    └─ 失败时退回 POST /models/session
  │
  ├─ 选了具体模型?
  │    ├─ 1. POST /models/session  {"auto_mode":{"enabled":true},"prompt":"..."}
  │    │      ← {selected_model, available_models, session_token}
  │    │      命中条件:available_models 包含该模型
  │    └─ 未命中则试 /auto(仅当它恰好选中该模型时可用)
  │
  ├─ 2. POST /responses  模型 = 上面确定的模型
  │      Headers: Copilot-Session-Token: <session_token>
  │               X-GitHub-Api-Version: 2025-07-16
  │               X-Initiator: user | agent
  │
  └─ 3. SSE 流式响应 → 交给 pi-ai 的 openai-responses 实现解析

为什么不能只用一个通道: 两个通道的令牌作用域不同。实测带 /auto 的令牌 去请求 mai-code-1.1-flash 会得到 Requested model not available for session。 所以“选了具体模型”必须拿到能覆盖该模型的令牌,否则宁可报错也不静默 换成另一个模型。

会话按对话缓存(不是按提示词),与 VS Code 的行为一致:同一次对话的多轮 请求复用同一个模型,避免上下文在不同模型间跳转。缓存上限 50 条。

令牌失效的时机:

  • 服务端过期前 5 分钟(与 OpenCode 一致);
  • 上下文压缩后立即作废(对齐 OpenCode 的 compaction hook);
  • /tree 跳转分支后作废;
  • 用户切换模型后不复用。
两个凭据各管一段
凭据 字段 用于
Copilot access access /auto、/models/session、/responses
GitHub OAuth refresh /models、/copilot_internal/user、/copilot_internal/v2/token

实测存储里的 access 常常已过期:直接用它 GET /models 得到 401 IDE token expired,而用 refresh 是 200。OpenCode v2 就是用 refresh 拉目录的,本扩展照此实现。

启动时扩展会用 refresh 换一个新的 access(/copilot_internal/v2/token), 只保存在内存,不写回 auth.json——避免与内置 provider 的刷新链路竞争 同一个 refresh token。

API 根地址优先取 /copilot_internal/user 的 endpoints.api(企业版/区域部署 会不同),失败才用 access 令牌的 proxy-ep,最后回退固定地址。

模型列表:auto-routed + 已授权真实模型

/models 目录会把未开通的模型也标成 policy.state = "enabled" 并带齐 capabilities,但请求时一律返回 model_not_supported。因此本扩展在启动时 用 access 令牌调一次 /models/session,用返回的 available_models 裁剪目录:

目录中支持 /responses 的条目
            ↓ 按 available_models 裁剪
可选:auto-routed(显示名 Auto)、gpt-5.3-codex、mai-code-1.1-flash

auto-routed 条目单独列出,它的上下文窗口/输出上限取所有可路由候选的最小值 (判定依据是 billing.auto_discount 存在),避免选择器报出超过实际模型的 上下文。

为什么 id 不叫 auto:pi 的模型目录里已有 openrouter 的同名物理模型, 同名条目会被过滤掉,导致 --model auto 解析失败。显示名仍是 Auto。

协商失败时跳过裁剪并保留候选列表,避免一次网络抖动就清空选择器。

安装

pi install npm:@hex4c59/pi-ext-copilot-auto

调试本地源码时在本仓库根目录执行 pi install ./copilot-auto。

不需要重新登录。 扩展复用 pi 已保存的 github-copilot OAuth 凭据。 如果还没登录过 Copilot:

/login      # 选择 "GitHub Copilot"

也可以完全不用凭据文件,改用环境变量:

COPILOT_GITHUB_TOKEN=<Copilot access token> pi

使用

# 列出本扩展提供的模型
pi --list-models copilot-auto

# 交给服务端路由(推荐;能用到目录之外的模型)
pi --provider copilot-auto --model auto-routed

# 用确定的 Auto 模型
pi --provider copilot-auto --model gpt-5.3-codex

会话内用 /model 选择 copilot-auto 下的模型,或用 Ctrl+P 循环切换。

查看当前状态与额度:

/copilot-auto

输出示例:

provider: copilot-auto
凭据: github-copilot OAuth
API: https://api.individual.githubcopilot.com
账号: sample-user (free_educational_quota)
高级请求: <remaining>/<total> (<percent>%),已用 <used>
计费方式: 按 token 折算(约 3 万 token ≈ 1 次)
额度重置: <reset-date>
目录: 47 个条目
Auto 可路由: 19 个
已授权模型: gpt-5.3-codex, mai-code-1.1-flash
可选: auto-routed, gpt-5.3-codex, mai-code-1.1-flash
会话缓存: 0 条

额度结果缓存 60 秒,频繁执行命令不会反复请求;查询失败不影响 其余信息的展示。

额度怎么算

所有 Auto 模型共用 premium_interactions 一个池子,按 token 折算, 没有免费的模型。 实测 mai-code-1.1-flash(最便宜的一款):

输入 tokens 扣减
~30 0(未达最小计费单位)
10,000 约 0.2 次
30,000 约 1 次

gpt-5.3-codex 单价约是它的 9 倍,同样 token 量扣得更多。

两个容易误判的点:

  • 扣减延迟 40-50 秒。刚用完立即查会看到旧值,像“没扣费”。
  • remaining 是取整值。0.4 这类消耗会被抹成 0,本扩展优先 显示浮点的 quota_remaining。
为什么看不到“对话”和“代码补全”的额度

quota_snapshots 里确实有 chat 和 completions 两项,它们标着 unlimited: true。但按 VS Code 的判定,只有 free_limited_copilot 这个 SKU 才读 chat 维度,其它套餐(含 free_educational_quota) 统一读 premium_interactions。

所以对多数账号来说,那两项的“无限”不构成额外免费通道,展示出来 只会让人误以为存在一个不计费的对话入口。本扩展只显示真正计费的维度。

详情见 docs/PROTOCOL.md 第 15 章。

限制

  • 依赖未公开 API。 /models/session 没有官方文档,请求体字段由实测确定 (auto_mode 必须是对象 {"enabled": true},用 true 或 "auto" 都会 返回 Invalid request body)。GitHub 改动协议时本扩展会失效。
  • 模型清单随账号变化。 /models/session 返回的可用模型由服务端按套餐 决定。免费教育版(free_educational_quota)实测为 gpt-5.3-codex 与 mai-code-1.1-flash,其他套餐可能不同。列表只显示当前真正可用的模型。
  • 不能指定具体模型绕过路由。 available_models 就是授权边界,超出范围 的模型即使带上有效 session_token 也返回 400。
  • 客户端版本会被校验。 请求头模拟 copilot-chat/0.72.0 与 vscode/1.144.1;版本过旧时服务端可能减少可用模型。升级 VS Code 后建议 同步更新 lib/protocol.ts 中的 CLIENT_HEADERS。
  • 计费走 Copilot 配额,按 token 折算。 所有 Auto 模型共用 premium_interactions 池,没有免费的模型。实测约 3 万 token ≈ 1 次, gpt-5.3-codex 单价约为 mai-code-1.1-flash 的 9 倍。
  • 仅支持 Responses API。 只注册声明支持 /responses 的模型;只能走 /chat/completions 的条目(如 gpt-4o)不属于本扩展范围,请继续使用 内置 github-copilot provider。

与内置 provider 的关系

两者并存,互不干扰:

  • github-copilot:常规模型,由 pi 内置实现负责,凭据自动刷新
  • copilot-auto:Auto 专属模型,由本扩展负责路由

本扩展只读 github-copilot 的凭据,不写入、不刷新它,避免与内置 provider 争抢同一个 refresh token。

网络请求

扩展只访问一个域名:api.individual.githubcopilot.com(企业版会由令牌中的 proxy-ep 推导出其他主机)。具体端点:

端点 用途
GET /models 启动时拉取模型目录与能力元数据
POST /models/session 协商 Auto 会话,取得 session_token
POST /responses 实际对话,由 pi-ai 的 openai-responses 实施
GET api.github.com/copilot_internal/user 查询套餐与额度(需 GitHub OAuth 令牌)

前三个端点在 api.individual.githubcopilot.com;额度查询在 api.github.com, 用的是凭据里的 refresh(GitHub OAuth 令牌),不是 Copilot 访问令牌。 两者不能混用,用错会得到 401。

不向任何第三方域名发送数据。

调试

COPILOT_AUTO_DEBUG=1 pi --provider copilot-auto --model gpt-5.3-codex

输出路由决策(选中模型、授权范围)与请求体结构(字段名、消息角色序列)。 不会输出访问令牌、session token 或消息正文。

已知问题排查

现象 原因 处理
Auto-compaction failed: Summarization failed: terminated (UND_ERR_SOCKET) 压缩时把整段历史当作 /auto 的 prompt 发出,服务端长处理后断连;且 maxTokens 沿用了目录里的 128000,摘要输出上限过大 升级后已修复:压缩请求改用短路由提示词,Auto 条目 maxTokens 收敛到 16k(见下文)
model_not_supported 缺 X-GitHub-Api-Version 头,或模型不在 Auto 授权范围 扩展已自动带上该头;确认模型在 /copilot-auto 列出的清单中
“模型 … 无法通过 Auto 通道授权” 该模型需要服务端路由才能可用 改用 /model 选 auto-routed(显示名 Auto)
/auto 报 404 invalid apiVersion 版本头不是 2026-08-01 扩展已固定该版本;自写脚本时注意(见 PROTOCOL 第 3 章)
400 invalid_request_body max_output_tokens 太小(实测 8 不行) 调到 16 以上;pi 自身不会发这么小的值
prompt_cache_options is not supported on this model 服务端不支持该参数 属于 pi 与模型能力的差异,通常不影响主流程
No API key found for copilot-auto 存储里的 access 已过期且刷新失败 检查网络后重启 pi;或 /login 重新登录
未找到 GitHub Copilot 凭据 未登录 /login 选择 "GitHub Copilot"
模型列表为空 启动时拉取目录失败 /copilot-auto 查看原因;/model 触发重新拉取
列表里没有 gpt-5.6-luna 这类模型 它们只能由 /auto 选中,不在 available_models 里 选 auto-routed 即可用到;直接指定也能跑,但不在选择器中
长会话触发压缩后卡住约 175 秒再报断连 旧版本把整段 <conversation> 发给 /auto,且摘要输出上限 128000 已改为短 prompt + 16k 输出上限;必要时 /new 开新会话
额度: 查询失败(401) GitHub OAuth 令牌失效 重新 /login;额度查询不能使用 Copilot 访问令牌
高级请求: 未知 套餐未返回该额度快照 不同套餐的 quota_snapshots 字段不同,属正常降级
模型说自己不是当前模型 蒸馏模型的自我认知错误 正常现象。以请求体 model 与路由响应的 selected_model 为准,不要采信模型自述

实现结构

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @hex4c59/pi-ext-copilot-auto

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

PolinRider Returns
Research

PolinRider Returns: Hijacked npm Packages Use Ethereum Blockchain to Conceal Malware Infrastructure

Vulnerability Insights

OpenSSH Password Authentication Bypass on Alpine Linux (*sshole) – CVE-2026-123158

Frame 2085668439 (1)
Group 1261154229