MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / smokePiTuiNativeLoad

Function smokePiTuiNativeLoad

apps/kimi-code/src/native/smoke.ts:12–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10// those paths do not exist next to the SEA binary, so this only succeeds when
11// installNativeModuleHook() redirects the require into the native-asset cache.
12function smokePiTuiNativeLoad(): void {
13 const platform = process.platform;
14 const arch = process.arch;
15 let rel: string | undefined;
16 if (platform === 'darwin' && (arch === 'x64' || arch === 'arm64')) {
17 rel = join('native', 'darwin', 'prebuilds', `darwin-${arch}`, 'darwin-modifiers.node');
18 } else if (platform === 'win32' && (arch === 'x64' || arch === 'arm64')) {
19 rel = join('native', 'win32', 'prebuilds', `win32-${arch}`, 'win32-console-mode.node');
20 }
21 if (rel === undefined) return; // Linux: no native helper, nothing to load.
22
23 const req = createRequire(import.meta.url);
24 const bogusPath = join(dirname(process.execPath), rel);
25 const helper = req(bogusPath) as {
26 isModifierPressed?: unknown;
27 enableVirtualTerminalInput?: unknown;
28 };
29 const ok =
30 typeof helper.isModifierPressed === 'function' ||
31 typeof helper.enableVirtualTerminalInput === 'function';
32 if (!ok) {
33 throw new Error(`pi-tui native helper loaded but exports are unexpected: ${rel}`);
34 }
35}
36
37export function runNativeAssetSmokeIfRequested(): boolean {
38 if (process.env['KIMI_CODE_NATIVE_ASSET_SMOKE'] !== '1') return false;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected