MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / NodeFetcher

Class NodeFetcher

apps/cli/src/sync/adapters.ts:27–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25// ==================== NodeFetcher ====================
26
27export class NodeFetcher implements HttpFetcher {
28 async fetchToTempFile(baseUrl: string, remoteSessionId: string, token: string, params: FetchParams): Promise<string> {
29 const url = buildPullUrl(baseUrl, remoteSessionId, params)
30 const headers: Record<string, string> = {
31 Accept: 'application/json',
32 }
33 if (token) headers['Authorization'] = `Bearer ${token}`
34
35 const response = await fetch(url, { headers, signal: AbortSignal.timeout(120_000) })
36 if (!response.ok) {
37 throw new Error(`HTTP ${response.status}`)
38 }
39
40 const contentType = response.headers.get('content-type') || 'application/json'
41 const isJsonl = contentType.includes('ndjson') || contentType.includes('jsonl')
42 const tempFile = getTempFilePath(isJsonl ? '.jsonl' : '.json')
43
44 const buffer = Buffer.from(await response.arrayBuffer())
45 fs.writeFileSync(tempFile, buffer)
46 return tempFile
47 }
48}
49
50// ==================== DirectImporter ====================
51

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected