mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-08-14 19:25:35 +00:00
feat(cli): tag kimi web requests with a (web) User-Agent suffix
kimi web shares the CLI product token and platform, so its outbound requests were indistinguishable from direct CLI runs upstream. Its host identity now carries userAgentSuffix 'web', putting web-UI traffic at kimi-code-cli/<version> (web) while X-Msh-Platform stays kimi_code_cli.
This commit is contained in:
parent
5ee5c01b58
commit
f2a293c026
3 changed files with 13 additions and 4 deletions
|
|
@ -2,4 +2,4 @@
|
|||
"@moonshot-ai/kimi-code": patch
|
||||
---
|
||||
|
||||
Send the CLI's device identity headers with OAuth login and token refresh requests from kimi web, and record the host product version in session export manifests.
|
||||
Send the CLI's device identity headers with OAuth login and token refresh requests from kimi web, tag web-UI requests with a `(web)` User-Agent suffix so upstream can tell them apart from direct CLI traffic, and record the host product version in session export manifests.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { shutdownTelemetry, track } from '@moonshot-ai/kimi-telemetry';
|
|||
import chalk from 'chalk';
|
||||
import { type Command } from 'commander';
|
||||
|
||||
import { CLI_SHUTDOWN_TIMEOUT_MS } from '#/constant/app';
|
||||
import { CLI_SHUTDOWN_TIMEOUT_MS, WEB_USER_AGENT_SUFFIX } from '#/constant/app';
|
||||
import { getNativeWebAssetsDir } from '#/native/web-assets';
|
||||
import { darkColors } from '#/tui/theme/colors';
|
||||
import { openUrl as defaultOpenUrl } from '#/utils/open-url';
|
||||
|
|
@ -280,8 +280,13 @@ async function runServerInProcess(
|
|||
serverVersion: version,
|
||||
// The CLI's host identity: feeds the engine's bootstrap client identity
|
||||
// and the derived outbound headers (User-Agent + X-Msh-*), so web-UI
|
||||
// OAuth flows and model / WebSearch requests carry the CLI identity.
|
||||
hostIdentity: createKimiCodeHostIdentity(version),
|
||||
// OAuth flows and model / WebSearch requests carry the CLI identity. The
|
||||
// `web` User-Agent suffix distinguishes web-UI traffic from direct CLI
|
||||
// runs upstream (same product token, same platform).
|
||||
hostIdentity: {
|
||||
...createKimiCodeHostIdentity(version),
|
||||
userAgentSuffix: WEB_USER_AGENT_SUFFIX,
|
||||
},
|
||||
logLevel: options.logLevel,
|
||||
logger,
|
||||
debugEndpoints: options.debugEndpoints,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ export const CLI_UI_MODE = 'shell';
|
|||
// Telemetry ui_mode for the `kimi web` host. Same product
|
||||
// as the CLI (CLI_USER_AGENT_PRODUCT); the surface is distinguished by ui_mode.
|
||||
export const WEB_UI_MODE = 'web';
|
||||
// User-Agent suffix for the `kimi web` host: its requests go out as
|
||||
// `kimi-code-cli/<version> (web)` so upstream can tell web-UI traffic
|
||||
// apart from direct CLI runs without changing the product token or platform.
|
||||
export const WEB_USER_AGENT_SUFFIX = 'web';
|
||||
|
||||
// Give telemetry a short flush window without making CLI exit feel stuck.
|
||||
export const CLI_SHUTDOWN_TIMEOUT_MS = 3000;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue