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

Function streamingImport

packages/node-runtime/src/import/streaming-importer.ts:97–122  ·  view source on GitHub ↗
(
  filePath: string,
  deps: StreamImportDeps,
  formatOptions?: Record<string, unknown>,
  externalSessionId?: string
)

Source from the content-addressed store, hash-verified

95 * with batched transactions. Supports format auto-detection with fallback.
96 */
97export async function streamingImport(
98 filePath: string,
99 deps: StreamImportDeps,
100 formatOptions?: Record<string, unknown>,
101 externalSessionId?: string
102): Promise<StreamImportResult> {
103 if (formatOptions?.formatId) {
104 const formatId = formatOptions.formatId as string
105 const feature = getFormatFeatureById(formatId)
106 if (!feature) {
107 return { success: false, error: 'error.unknown_format_id' }
108 }
109 return streamImportSingle(filePath, deps, feature, formatOptions, externalSessionId)
110 }
111
112 const candidates = detectAllFormats(filePath)
113 if (candidates.length === 0) {
114 return { success: false, error: 'error.unrecognized_format' }
115 }
116
117 if (candidates.length > 1) {
118 return streamImportWithFallback(filePath, deps, candidates, formatOptions, externalSessionId)
119 }
120
121 return streamImportSingle(filePath, deps, candidates[0], formatOptions, externalSessionId)
122}
123
124async function streamImportWithFallback(
125 filePath: string,

Callers 3

electronStreamImportFunction · 0.90
streamImportFunction · 0.90
streamImportFunction · 0.90

Calls 4

getFormatFeatureByIdFunction · 0.90
detectAllFormatsFunction · 0.90
streamImportSingleFunction · 0.85
streamImportWithFallbackFunction · 0.85

Tested by

no test coverage detected