Repository navigation
Conversation
对齐 Kimi CLI 的 createKimiDeviceHeaders:OAuth 三个端点
(device_authorization/token/refresh)均携带六个 X-Msh-* 请求头,
账号中心"登录设备"列表由"未知设备"变为 <hostname> (gfcode/<os-type>),
便于区分同一账号下不同机器、不同操作系统的 gf pi 登录记录。
- 新增 (liii pi ai auth device-info):
- X-Msh-Device-Name: 主机名(COMPUTERNAME > HOSTNAME > hostname 命令)
加 gfcode/<os-type> 后缀,可打印 ASCII 清洗(中文主机名剔除非 ASCII)
- X-Msh-Device-Model: <os-type> <os-arch>
- X-Msh-Os-Version: Windows 取 OS 环境变量,其余 uname -sr
- X-Msh-Device-Id: ~/.gf/agent/device_id 持久化 UUID(uuid4,0600)
- X-Msh-Platform: gfcode;X-Msh-Version 与 gfproject.json 同步
- 文件/子进程失败静默降级,不影响登录流程
- %kimi-post-form 附加设备头,stub 新增 headers 回显场景
- 8 个 device-info 单测 + 1 个 OAuth 端到端测试,gf check 全绿
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
通过 gfcode OAuth 登录 Kimi Coding 后,账号中心的"登录设备"列表显示未知设备,无法区分同一账号下不同机器、不同操作系统的登录记录。
原因
gfcode(与上游 pi 一致)的 OAuth 请求只带
client_id,未携带设备信息头。Kimi 服务端依据X-Msh-Device-Name展示设备名——从本机 Kimi CLI(~/.kimi-code/bin/kimi.exe内嵌源码)确认其实现:createKimiDeviceHeaders在device_authorization、轮询token、refresh_token三个端点均附加六个X-Msh-*请求头。改动
新增
(liii pi ai auth device-info)库,%kimi-post-form自动附加:X-Msh-PlatformgfcodeX-Msh-VersionX-Msh-Device-Name<主机名> (gfcode/<os-type>),如LIII (gfcode/Windows)X-Msh-Device-Model<os-type> <os-arch>,如Windows x64X-Msh-Os-VersionOS环境变量,其余uname -srX-Msh-Device-Id~/.gf/agent/device_id持久化 UUID(首次 uuid4 生成,非 Windows chmod 0600)与 Kimi CLI 一致的细节:
COMPUTERNAME>HOSTNAME>hostname命令测试
headers场景回显请求头,验证服务端实际收到设备信息gf check无违规验证
合并后重新登录即可生效:
登录设备列表将显示
<主机名> (gfcode/Windows)/(gfcode/Linux)/(gfcode/Darwin),可据此区分操作系统。旧的"未知设备"记录为历史授权,可在账号中心移除。