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

Function ensureNativeAssetTree

apps/kimi-code/src/native/native-assets.ts:218–241  ·  view source on GitHub ↗
(options: NativeAssetOptions = {})

Source from the content-addressed store, hash-verified

216}
217
218export function ensureNativeAssetTree(options: NativeAssetOptions = {}): string | null {
219 const source = options.source ?? getSeaAssetSource();
220 if (source === null) return null;
221
222 const manifest =
223 options.manifest ?? getEmbeddedNativeAssetManifest(source, currentTarget());
224 if (manifest === null) return null;
225
226 const cacheRoot = getNativeAssetCacheRoot(manifest, options);
227 for (const pkg of manifest.packages) {
228 for (const file of pkg.files) {
229 const bytes = toBuffer(source.getRawAsset(file.assetKey));
230 const actualSha256 = sha256(bytes);
231 if (actualSha256 !== file.sha256) {
232 throw new Error(
233 `Native asset checksum mismatch for ${file.assetKey}: ${actualSha256} !== ${file.sha256}`,
234 );
235 }
236 ensureFile(join(cacheRoot, file.relativePath), bytes, file.sha256, file.mode);
237 }
238 }
239 ensureEntryFile(cacheRoot);
240 return cacheRoot;
241}
242
243export function getNativePackageRoot(
244 packageName: string,

Callers 2

getNativePackageRootFunction · 0.85

Calls 9

getSeaAssetSourceFunction · 0.85
getNativeAssetCacheRootFunction · 0.85
ensureEntryFileFunction · 0.85
currentTargetFunction · 0.70
toBufferFunction · 0.70
sha256Function · 0.70
ensureFileFunction · 0.70
getRawAssetMethod · 0.65

Tested by

no test coverage detected