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

Function downloadZip

packages/agent-core/src/plugin/archive.ts:7–21  ·  view source on GitHub ↗
(url: string, signal?: AbortSignal)

Source from the content-addressed store, hash-verified

5import { type Entry, fromBuffer as yauzlFromBuffer } from 'yauzl';
6
7export async function downloadZip(url: string, signal?: AbortSignal): Promise<Buffer> {
8 const controller = new AbortController();
9 const timeoutHandle = setTimeout(() => {
10 controller.abort();
11 }, 5 * 60 * 1000);
12 try {
13 const resp = await fetch(url, { signal: signal ?? controller.signal });
14 if (!resp.ok) {
15 throw new Error(`Failed to download zip: HTTP ${resp.status} ${resp.statusText}`);
16 }
17 return Buffer.from(await resp.arrayBuffer());
18 } finally {
19 clearTimeout(timeoutHandle);
20 }
21}
22
23export async function extractZip(buffer: Buffer, destDir: string): Promise<string> {
24 await mkdir(destDir, { recursive: true });

Callers 2

archive.test.tsFile · 0.90
installMethod · 0.90

Calls 1

abortMethod · 0.65

Tested by

no test coverage detected