MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / fetchToTempFile

Method fetchToTempFile

apps/cli/src/sync/adapters.ts:28–47  ·  view source on GitHub ↗
(baseUrl: string, remoteSessionId: string, token: string, params: FetchParams)

Source from the content-addressed store, hash-verified

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 ====================

Callers

nothing calls this directly

Calls 3

buildPullUrlFunction · 0.90
getTempFilePathFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected