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

Function getNativeWebAssetsDir

apps/kimi-code/src/native/web-assets.ts:163–183  ·  view source on GitHub ↗
(options: WebAssetOptions = {})

Source from the content-addressed store, hash-verified

161}
162
163export function getNativeWebAssetsDir(options: WebAssetOptions = {}): string | null {
164 const source = options.source ?? getSeaAssetSource();
165 if (source === null) return null;
166
167 const manifest = options.manifest ?? getEmbeddedWebAssetManifest(source, currentTarget());
168 if (manifest === null) return null;
169
170 const cacheRoot = getWebAssetCacheRoot(manifest, options);
171 for (const file of manifest.files) {
172 assertSafeRelativePath(file.relativePath);
173 const bytes = toBuffer(source.getRawAsset(file.assetKey));
174 const actualSha256 = sha256(bytes);
175 if (actualSha256 !== file.sha256) {
176 throw new Error(
177 `Web asset checksum mismatch for ${file.assetKey}: ${actualSha256} !== ${file.sha256}`,
178 );
179 }
180 ensureFile(join(cacheRoot, file.relativePath), bytes, file.sha256);
181 }
182 return cacheRoot;
183}

Callers 2

web-assets.test.tsFile · 0.90

Calls 9

getSeaAssetSourceFunction · 0.90
getWebAssetCacheRootFunction · 0.85
assertSafeRelativePathFunction · 0.85
currentTargetFunction · 0.70
toBufferFunction · 0.70
sha256Function · 0.70
ensureFileFunction · 0.70
getRawAssetMethod · 0.65

Tested by

no test coverage detected