@aiwg/cli 2026.9.17 → 2026.9.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -45,7 +45,7 @@ declare abstract class LineAdapter<T extends FileConfig> extends LocalAdapter<T>
|
|
|
45
45
|
protected lineDiscovery(kind: string, config: T, request: AdapterRequest<T>, schema: Record<string, unknown>): Promise<AdapterDiscovery>;
|
|
46
46
|
protected lines(config: T, request: AdapterRequest<T> & {
|
|
47
47
|
checkpoint?: AdapterCheckpoint;
|
|
48
|
-
}, parse: (line: string, ordinal: number) => unknown): AsyncIterable<AdapterRecord>;
|
|
48
|
+
}, parse: (line: string, ordinal: number, maxDepth: number) => unknown): AsyncIterable<AdapterRecord>;
|
|
49
49
|
}
|
|
50
50
|
export declare class JsonlAdapter extends LineAdapter<FileConfig> {
|
|
51
51
|
#private;
|
|
@@ -108,6 +108,21 @@ function record(value, ordinal, sourceLocator) {
|
|
|
108
108
|
const serialized = typeof value === 'string' ? value : JSON.stringify(value);
|
|
109
109
|
return { logicalId: `sha256:${sha256Digest(`${sourceLocator}\0${ordinal}\0${serialized}`).value}`, ordinal, value, sourceLocator, contentDigest: sha256Digest(serialized) };
|
|
110
110
|
}
|
|
111
|
+
function valueDepth(value) {
|
|
112
|
+
let maximum = 0;
|
|
113
|
+
const pending = [{ value, depth: 0 }];
|
|
114
|
+
while (pending.length > 0) {
|
|
115
|
+
const current = pending.pop();
|
|
116
|
+
if (current.value === null || typeof current.value !== 'object')
|
|
117
|
+
continue;
|
|
118
|
+
const depth = current.depth + 1;
|
|
119
|
+
maximum = Math.max(maximum, depth);
|
|
120
|
+
const children = Array.isArray(current.value) ? current.value : Object.values(current.value);
|
|
121
|
+
for (const child of children)
|
|
122
|
+
pending.push({ value: child, depth });
|
|
123
|
+
}
|
|
124
|
+
return maximum;
|
|
125
|
+
}
|
|
111
126
|
function checkpoint(manifestValue, sourceIdentity, cursor) {
|
|
112
127
|
return {
|
|
113
128
|
contractVersion: DATASET_ADAPTER_CONTRACT_VERSION, kind: 'AdapterCheckpoint', adapter: { id: manifestValue.id, version: manifestValue.version },
|
|
@@ -227,7 +242,7 @@ class LineAdapter extends LocalAdapter {
|
|
|
227
242
|
if (Buffer.byteLength(line) > limits.maxRecordBytes || ordinal >= limits.maxRecords)
|
|
228
243
|
throw new AdapterFailure(diagnostic(operation, 'ADAPTER_RESOURCE_LIMIT', 'The record or record count exceeds configured limits.'));
|
|
229
244
|
if (line.trim() !== '')
|
|
230
|
-
yield record(parse(line, ordinal), ordinal, config.path);
|
|
245
|
+
yield record(parse(line, ordinal, limits.maxDepth), ordinal, config.path);
|
|
231
246
|
ordinal += 1;
|
|
232
247
|
}
|
|
233
248
|
}
|
|
@@ -243,12 +258,19 @@ export class JsonlAdapter extends LineAdapter {
|
|
|
243
258
|
valid(value) { return isFileConfig(value); }
|
|
244
259
|
discoverPath(config, request) { return this.lineDiscovery('jsonl', config, request, {}); }
|
|
245
260
|
records(config, request) {
|
|
246
|
-
return this.lines(config, request, (line, ordinal) => {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
261
|
+
return this.lines(config, request, (line, ordinal, maxDepth) => {
|
|
262
|
+
try {
|
|
263
|
+
const value = JSON.parse(line);
|
|
264
|
+
if (valueDepth(value) > maxDepth)
|
|
265
|
+
throw new AdapterFailure(diagnostic(request.checkpoint ? 'read' : 'preview', 'ADAPTER_RESOURCE_LIMIT', `JSONL record at ordinal ${ordinal} exceeds the configured nesting limit.`));
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
catch (error) {
|
|
269
|
+
if (error instanceof AdapterFailure)
|
|
270
|
+
throw error;
|
|
271
|
+
throw new AdapterFailure(diagnostic(request.checkpoint ? 'read' : 'preview', 'ADAPTER_SCHEMA_DRIFT', `Malformed JSONL record at ordinal ${ordinal}.`));
|
|
272
|
+
}
|
|
273
|
+
});
|
|
252
274
|
}
|
|
253
275
|
}
|
|
254
276
|
function parseCsvLine(line) {
|