File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { randomUUID } from 'node:crypto' ;
2+ import { release } from 'node:os' ;
23
34import { runDeviceOAuthFlow , type DeviceCodeInfo } from './device-oauth' ;
45import { capabilitiesForModel , fetchOpenPlatformModels } from './open-platform' ;
@@ -18,6 +19,10 @@ const TOKEN_URL = 'https://auth.kimi.com/api/oauth/token';
1819export const KIMI_CODING_BASE_URL = 'https://api.kimi.com/coding/v1' ;
1920const KIMI_SCOPE = 'kimi-code' ;
2021
22+ function sanitizeHeaderValue ( value : string ) : string {
23+ return value . replace ( / [ ^ \x20 - \x7e ] / g, '' ) . trim ( ) ;
24+ }
25+
2126/**
2227 * kimi-cli fingerprints every request (OAuth and inference) with these
2328 * headers. `X-Msh-Device-Id` must stay stable across the OAuth flow and
@@ -30,7 +35,7 @@ function kimiHeaders(deviceId: string): Record<string, string> {
3035 'X-Msh-Version' : '1.0.0' ,
3136 'X-Msh-Device-Name' : 'pythinker-code' ,
3237 'X-Msh-Device-Model' : process . arch ,
33- 'X-Msh-Os-Version' : process . version ,
38+ 'X-Msh-Os-Version' : sanitizeHeaderValue ( release ( ) ) ,
3439 'X-Msh-Device-Id' : deviceId ,
3540 } ;
3641}
You can’t perform that action at this time.
0 commit comments