diff --git a/.changeset/v2-server-host-headers.md b/.changeset/v2-server-host-headers.md new file mode 100644 index 000000000..e19b86c80 --- /dev/null +++ b/.changeset/v2-server-host-headers.md @@ -0,0 +1,5 @@ +--- +"@moonshot-ai/kimi-code": patch +--- + +Send the CLI identity headers (User-Agent and device identity) with outbound requests from the experimental v2 server, matching direct CLI runs. diff --git a/apps/kimi-code/src/cli/sub/server/run.ts b/apps/kimi-code/src/cli/sub/server/run.ts index 1828d4049..63386b7a6 100644 --- a/apps/kimi-code/src/cli/sub/server/run.ts +++ b/apps/kimi-code/src/cli/sub/server/run.ts @@ -26,7 +26,12 @@ import { openUrl as defaultOpenUrl } from '#/utils/open-url'; import { getDataDir } from '#/utils/paths'; import { initializeServerTelemetry } from '../../telemetry'; -import { createKimiCodeHostIdentity, getHostPackageRoot, getVersion } from '../../version'; +import { + buildKimiDefaultHeaders, + createKimiCodeHostIdentity, + getHostPackageRoot, + getVersion, +} from '../../version'; import { accessUrlLines, buildOpenableUrl, @@ -406,6 +411,7 @@ async function runServerInProcess( // its agent-core-v2 engine are only resolved when the flag is on. const { createServerLogger: createServerV2Logger, startServer: startServerV2 } = await import('@moonshot-ai/kap-server'); + const { hostRequestHeadersSeed } = await import('@moonshot-ai/agent-core-v2'); const logger = createServerV2Logger({ level: options.logLevel }); const v2 = await startServerV2({ host: options.host, @@ -418,6 +424,10 @@ async function runServerInProcess( allowRemoteTerminals: options.allowRemoteTerminals, allowedHosts: options.allowedHosts, disableAuth: options.dangerousBypassAuth, + // Seed the CLI's Kimi identity headers so the v2 engine's outbound + // requests (model, WebSearch, FetchURL) carry the same User-Agent + + // X-Msh-* identity as direct CLI runs. + seeds: hostRequestHeadersSeed(buildKimiDefaultHeaders(version)), webAssetsDir: serverWebAssetsDir(), }); // v2's connection registry exposes no count-change hook, so forward