deepline 0.1.170 → 0.1.172

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.
package/dist/cli/index.js CHANGED
@@ -622,10 +622,10 @@ var SDK_RELEASE = {
622
622
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
623
623
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
624
624
  // fields shipped in 0.1.153.
625
- version: "0.1.170",
625
+ version: "0.1.172",
626
626
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
627
627
  supportPolicy: {
628
- latest: "0.1.170",
628
+ latest: "0.1.172",
629
629
  minimumSupported: "0.1.53",
630
630
  deprecatedBelow: "0.1.53",
631
631
  commandMinimumSupported: [
@@ -4389,10 +4389,50 @@ end run
4389
4389
  `;
4390
4390
  return runAppleScript(script, [targetUrl, host], runner);
4391
4391
  }
4392
+ function hasOnlyHeadlessMacosBrowserInstances(appName, runner = defaultBrowserCommandRunner) {
4393
+ try {
4394
+ const output2 = runner.execFileSync("ps", ["-axo", "args="], {
4395
+ encoding: "utf-8",
4396
+ stdio: ["ignore", "pipe", "ignore"]
4397
+ });
4398
+ const executableSuffix = `/Contents/MacOS/${appName}`;
4399
+ const lines = String(output2).split(/\r?\n/).map((line) => line.trim()).filter((line) => {
4400
+ const executableIndex = line.indexOf(executableSuffix);
4401
+ if (executableIndex < 0 || !line.includes(".app/Contents/MacOS/")) {
4402
+ return false;
4403
+ }
4404
+ const rest = line.slice(executableIndex + executableSuffix.length);
4405
+ return rest === "" || /^\s+-/.test(rest);
4406
+ });
4407
+ if (lines.length === 0) return false;
4408
+ return lines.every(
4409
+ (line) => line.includes("--headless") || line.includes("--no-startup-window")
4410
+ );
4411
+ } catch {
4412
+ return false;
4413
+ }
4414
+ }
4415
+ function openNewVisibleMacosBrowserInstance(appName, targetUrl, runner = defaultBrowserCommandRunner) {
4416
+ try {
4417
+ runner.execFileSync(
4418
+ "open",
4419
+ ["-na", appName, "--args", "--new-window", targetUrl],
4420
+ {
4421
+ stdio: "ignore"
4422
+ }
4423
+ );
4424
+ return true;
4425
+ } catch {
4426
+ return false;
4427
+ }
4428
+ }
4392
4429
  function openUrlMacos(targetUrl, allowFocus, runner = defaultBrowserCommandRunner) {
4393
4430
  const defaultBundleId = readDefaultMacBrowserBundleId(runner);
4394
4431
  const appName = defaultBundleId ? browserAppNameFromBundleId(defaultBundleId) : "";
4395
4432
  const strategy = browserStrategyForBundleId(defaultBundleId);
4433
+ if (allowFocus && appName && strategy === "chromium" && hasOnlyHeadlessMacosBrowserInstances(appName, runner) && openNewVisibleMacosBrowserInstance(appName, targetUrl, runner)) {
4434
+ return true;
4435
+ }
4396
4436
  if (appName && strategy === "chromium" && retargetChromiumMacos(appName, targetUrl, allowFocus, runner)) {
4397
4437
  return true;
4398
4438
  }
@@ -16820,6 +16860,7 @@ function helperSource() {
16820
16860
  // src/cli/commands/enrich.ts
16821
16861
  var ENRICH_EXPORT_PAGE_SIZE = 5e3;
16822
16862
  var ENRICH_AUTO_BATCH_ROWS = 250;
16863
+ var ENRICH_HEAVY_PLAY_AUTO_BATCH_ROWS = 40;
16823
16864
  var ENRICH_EXPORT_BACKING_ROWS_WAIT_MS = 6e4;
16824
16865
  var ENRICH_EXPORT_BACKING_ROWS_POLL_MS = 1e3;
16825
16866
  var ENRICH_SOURCE_ROW_INDEX_COLUMN = "__deeplineSourceRowIndex";
@@ -16829,6 +16870,11 @@ var ENRICH_CELL_META_PATCH_FIELD = "__deeplineCellMetaPatch";
16829
16870
  var EXIT_SERVER2 = 5;
16830
16871
  var ENRICH_DEBUG_T0 = Date.now();
16831
16872
  var GENERATED_ENRICH_ROWS_TABLE_NAMESPACE = "deepline_enrich_rows";
16873
+ var HEAVY_ENRICH_AUTO_BATCH_PLAYS = /* @__PURE__ */ new Set([
16874
+ "company-to-contact",
16875
+ "company-to-contact-by-role-waterfall",
16876
+ "company_to_contact_by_role_waterfall"
16877
+ ]);
16832
16878
  var PLAN_SHAPING_OPTION_NAMES = [
16833
16879
  "with",
16834
16880
  "withWaterfall",
@@ -17605,6 +17651,52 @@ async function writeOutputCsv(outputPath, status, options) {
17605
17651
  function isMissingRowsForCsvExportError(error) {
17606
17652
  return error instanceof Error && (error.message.includes("did not return row-shaped output") || error.message.includes("run returned 0 preview row(s)"));
17607
17653
  }
17654
+ function normalizeEnrichPlayRef(value) {
17655
+ if (typeof value !== "string") {
17656
+ return null;
17657
+ }
17658
+ const normalized = value.trim().toLowerCase().replace(/^prebuilt\//, "");
17659
+ return normalized || null;
17660
+ }
17661
+ function configContainsHeavyEnrichPlay(config) {
17662
+ let hasNestedPlayStep = false;
17663
+ let hasSubrequestProviderStep = false;
17664
+ const visit = (commands) => {
17665
+ for (const command of commands) {
17666
+ if ("with_waterfall" in command) {
17667
+ if (visit(command.commands)) {
17668
+ return true;
17669
+ }
17670
+ continue;
17671
+ }
17672
+ if (command.disabled) {
17673
+ continue;
17674
+ }
17675
+ const candidates = [
17676
+ command.tool,
17677
+ command.operation,
17678
+ command.play?.ref,
17679
+ command.play?.ref?.replace(/^prebuilt\//, "")
17680
+ ];
17681
+ if (candidates.map(normalizeEnrichPlayRef).some(
17682
+ (candidate) => candidate !== null && HEAVY_ENRICH_AUTO_BATCH_PLAYS.has(candidate)
17683
+ )) {
17684
+ return true;
17685
+ }
17686
+ const normalizedTool = normalizeEnrichPlayRef(command.tool);
17687
+ if (command.play || normalizedTool === "test-play") {
17688
+ hasNestedPlayStep = true;
17689
+ } else if (normalizedTool !== null && normalizedTool !== "run_javascript") {
17690
+ hasSubrequestProviderStep = true;
17691
+ }
17692
+ }
17693
+ return false;
17694
+ };
17695
+ return visit(config.commands) || hasNestedPlayStep && hasSubrequestProviderStep;
17696
+ }
17697
+ function enrichAutoBatchRowsForConfig(config) {
17698
+ return configContainsHeavyEnrichPlay(config) ? ENRICH_HEAVY_PLAY_AUTO_BATCH_ROWS : ENRICH_AUTO_BATCH_ROWS;
17699
+ }
17608
17700
  async function maybeWriteOutputCsv(input2) {
17609
17701
  if (!input2.outputPath) return null;
17610
17702
  try {
@@ -18503,7 +18595,7 @@ async function maybeEmitEnrichFailureReport(input2) {
18503
18595
  const jobs = rowJobs.length > 0 || input2.status === void 0 ? rowJobs : collectStatusFailureJobs({
18504
18596
  config: input2.config,
18505
18597
  status: input2.status,
18506
- rowRange: input2.rowRange
18598
+ rowRange: input2.statusRowRange ?? input2.rowRange
18507
18599
  });
18508
18600
  if (jobs.length === 0) {
18509
18601
  return null;
@@ -19238,13 +19330,12 @@ function registerEnrichCommand(program) {
19238
19330
  return { captured: captured2, status: status2, exportResult: exportResult2 };
19239
19331
  };
19240
19332
  const selectedRange = selectedSourceCsvRange(sourceCsvPath, rows);
19241
- if (outputPath && selectedRange.count > ENRICH_AUTO_BATCH_ROWS) {
19242
- const chunkCount = Math.ceil(
19243
- selectedRange.count / ENRICH_AUTO_BATCH_ROWS
19244
- );
19333
+ const autoBatchRows = enrichAutoBatchRowsForConfig(config);
19334
+ if (outputPath && selectedRange.count > autoBatchRows) {
19335
+ const chunkCount = Math.ceil(selectedRange.count / autoBatchRows);
19245
19336
  if (!options.json) {
19246
19337
  process.stderr.write(
19247
- `Large enrich input selected ${selectedRange.count.toLocaleString()} rows. Running ${chunkCount.toLocaleString()} sequential batch runs of up to ${ENRICH_AUTO_BATCH_ROWS.toLocaleString()} rows and merging ${(0, import_node_path12.resolve)(outputPath)}.
19338
+ `Large enrich input selected ${selectedRange.count.toLocaleString()} rows. Running ${chunkCount.toLocaleString()} sequential batch runs of up to ${autoBatchRows.toLocaleString()} rows and merging ${(0, import_node_path12.resolve)(outputPath)}.
19248
19339
  `
19249
19340
  );
19250
19341
  }
@@ -19253,12 +19344,12 @@ function registerEnrichCommand(program) {
19253
19344
  let finalExportResult = null;
19254
19345
  let totalEnrichedRows = 0;
19255
19346
  const batchFailureRows = [];
19256
- for (let chunkStart = selectedRange.start, chunkIndex = 0; chunkStart <= selectedRange.end; chunkStart += ENRICH_AUTO_BATCH_ROWS, chunkIndex += 1) {
19347
+ for (let chunkStart = selectedRange.start, chunkIndex = 0; chunkStart <= selectedRange.end; chunkStart += autoBatchRows, chunkIndex += 1) {
19257
19348
  const chunkRows = {
19258
19349
  rowStart: chunkStart,
19259
19350
  rowEnd: Math.min(
19260
19351
  selectedRange.end,
19261
- chunkStart + ENRICH_AUTO_BATCH_ROWS - 1
19352
+ chunkStart + autoBatchRows - 1
19262
19353
  )
19263
19354
  };
19264
19355
  if (!options.json) {
@@ -19276,6 +19367,24 @@ function registerEnrichCommand(program) {
19276
19367
  });
19277
19368
  lastStatus = chunk.status;
19278
19369
  if (chunk.captured.result !== 0) {
19370
+ if (chunk.exportResult) {
19371
+ finalExportResult = chunk.exportResult;
19372
+ totalEnrichedRows += chunk.exportResult.enrichedRows;
19373
+ batchFailureRows.push(...chunk.exportResult.enrichedDataRows);
19374
+ }
19375
+ const failureReport3 = await maybeEmitEnrichFailureReport({
19376
+ config,
19377
+ rows: batchFailureRows,
19378
+ rowRange: {
19379
+ rowStart: selectedRange.start,
19380
+ rowEnd: selectedRange.end
19381
+ },
19382
+ statusRowRange: chunkRows,
19383
+ client: client2,
19384
+ outputPath: failureReportOutputPath ?? finalExportResult?.path ?? outputPath,
19385
+ status: chunk.status
19386
+ });
19387
+ const committedExportResult2 = finalExportResult ? await commitInPlaceOutput(finalExportResult) : null;
19279
19388
  if (options.json) {
19280
19389
  printJson({
19281
19390
  ok: false,
@@ -19285,12 +19394,27 @@ function registerEnrichCommand(program) {
19285
19394
  rows: chunkRows
19286
19395
  },
19287
19396
  result: chunk.status,
19288
- output: options.inPlace ? null : enrichOutputJson(chunk.exportResult)
19397
+ output: committedExportResult2 ? {
19398
+ sourceCsvRows: selectedRange.sourceRows,
19399
+ selectedRows: selectedRange.count,
19400
+ enrichedRows: totalEnrichedRows,
19401
+ path: committedExportResult2.path,
19402
+ ...committedExportResult2.partial ? {
19403
+ rows: committedExportResult2.rows,
19404
+ partial: true
19405
+ } : {}
19406
+ } : null,
19407
+ ...failureReport3 ? {
19408
+ failure_report: {
19409
+ path: failureReport3.path,
19410
+ jobs: failureReport3.jobs.length
19411
+ }
19412
+ } : {}
19289
19413
  });
19290
19414
  } else {
19291
- if (chunk.exportResult && !options.inPlace) {
19415
+ if (committedExportResult2) {
19292
19416
  process.stderr.write(
19293
- `Wrote ${chunk.exportResult.rows} row(s) to ${chunk.exportResult.path}${chunk.exportResult.partial ? " (partial run output)" : ""}
19417
+ `Wrote ${committedExportResult2.rows} row(s) to ${committedExportResult2.path}${committedExportResult2.partial ? " (partial run output)" : ""}
19294
19418
  `
19295
19419
  );
19296
19420
  }
@@ -19301,7 +19425,7 @@ function registerEnrichCommand(program) {
19301
19425
  status: chunk.status
19302
19426
  });
19303
19427
  }
19304
- process.exitCode = chunk.captured.result;
19428
+ process.exitCode = failureReport3 ? EXIT_SERVER2 : chunk.captured.result;
19305
19429
  return;
19306
19430
  }
19307
19431
  if (chunk.exportResult) {
@@ -19323,15 +19447,13 @@ function registerEnrichCommand(program) {
19323
19447
  outputPath: failureReportOutputPath ?? finalExportResult?.path ?? outputPath,
19324
19448
  status: lastStatus
19325
19449
  });
19326
- if (!failureReport2) {
19327
- finalExportResult = await commitInPlaceOutput(finalExportResult);
19328
- }
19450
+ finalExportResult = await commitInPlaceOutput(finalExportResult);
19329
19451
  if (options.json) {
19330
19452
  const run = rewriteEnrichJsonStatus({
19331
19453
  status: lastStatus,
19332
19454
  config,
19333
19455
  forceAliases,
19334
- output: finalExportResult && (!failureReport2 || !options.inPlace) ? {
19456
+ output: finalExportResult ? {
19335
19457
  ...finalExportResult,
19336
19458
  sourceCsvRows: selectedRange.sourceRows,
19337
19459
  selectedRows: selectedRange.count,
@@ -19346,10 +19468,10 @@ function registerEnrichCommand(program) {
19346
19468
  run,
19347
19469
  batch: {
19348
19470
  chunks: chunkCount,
19349
- chunkRows: ENRICH_AUTO_BATCH_ROWS,
19471
+ chunkRows: autoBatchRows,
19350
19472
  selectedRows: selectedRange.count
19351
19473
  },
19352
- output: finalExportResult && (!failureReport2 || !options.inPlace) ? {
19474
+ output: finalExportResult ? {
19353
19475
  sourceCsvRows: selectedRange.sourceRows,
19354
19476
  selectedRows: selectedRange.count,
19355
19477
  enrichedRows: totalEnrichedRows,
@@ -19376,9 +19498,10 @@ function registerEnrichCommand(program) {
19376
19498
  });
19377
19499
  const rowsForFailureReport = exportResult?.enrichedDataRows ?? extractCanonicalRowsInfo(status)?.rows ?? [];
19378
19500
  if (captured.result !== 0) {
19379
- if (exportResult && !options.inPlace) {
19501
+ const committedExportResult2 = exportResult ? await commitInPlaceOutput(exportResult) : null;
19502
+ if (committedExportResult2) {
19380
19503
  process.stderr.write(
19381
- `Wrote ${exportResult.rows} row(s) to ${exportResult.path}${exportResult.partial ? " (partial run output)" : ""}
19504
+ `Wrote ${committedExportResult2.rows} row(s) to ${committedExportResult2.path}${committedExportResult2.partial ? " (partial run output)" : ""}
19382
19505
  `
19383
19506
  );
19384
19507
  }
@@ -19387,7 +19510,7 @@ function registerEnrichCommand(program) {
19387
19510
  rows: rowsForFailureReport,
19388
19511
  rowRange: rows,
19389
19512
  client: client2,
19390
- exportResult,
19513
+ exportResult: committedExportResult2,
19391
19514
  outputPath,
19392
19515
  reportOutputPath: failureReportOutputPath,
19393
19516
  status
@@ -19396,7 +19519,7 @@ function registerEnrichCommand(program) {
19396
19519
  printJson({
19397
19520
  ok: false,
19398
19521
  run: status,
19399
- output: options.inPlace ? null : enrichOutputJson(exportResult),
19522
+ output: enrichOutputJson(committedExportResult2),
19400
19523
  ...failureReport2 ? {
19401
19524
  failure_report: {
19402
19525
  path: failureReport2.path,
@@ -19419,18 +19542,18 @@ function registerEnrichCommand(program) {
19419
19542
  reportOutputPath: failureReportOutputPath,
19420
19543
  status
19421
19544
  });
19422
- const committedExportResult2 = failureReport2 ? exportResult : await commitInPlaceOutput(exportResult);
19545
+ const committedExportResult2 = await commitInPlaceOutput(exportResult);
19423
19546
  const run = rewriteEnrichJsonStatus({
19424
19547
  status,
19425
19548
  config,
19426
19549
  forceAliases,
19427
- output: failureReport2 && options.inPlace ? null : committedExportResult2,
19550
+ output: committedExportResult2,
19428
19551
  failureReport: failureReport2
19429
19552
  });
19430
19553
  printJson({
19431
19554
  ok: !failureReport2,
19432
19555
  run,
19433
- output: failureReport2 && options.inPlace ? null : enrichOutputJson(committedExportResult2),
19556
+ output: enrichOutputJson(committedExportResult2),
19434
19557
  ...failureReport2 ? {
19435
19558
  failure_report: {
19436
19559
  path: failureReport2.path,
@@ -19451,7 +19574,7 @@ function registerEnrichCommand(program) {
19451
19574
  outputPath: failureReportOutputPath ?? exportResult?.path ?? null,
19452
19575
  status
19453
19576
  });
19454
- const committedExportResult = failureReport ? options.inPlace ? null : exportResult : await commitInPlaceOutput(exportResult);
19577
+ const committedExportResult = await commitInPlaceOutput(exportResult);
19455
19578
  if (committedExportResult) {
19456
19579
  process.stderr.write(
19457
19580
  `Wrote ${committedExportResult.rows} row(s) to ${committedExportResult.path}
@@ -607,10 +607,10 @@ var SDK_RELEASE = {
607
607
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
608
608
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
609
609
  // fields shipped in 0.1.153.
610
- version: "0.1.170",
610
+ version: "0.1.172",
611
611
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
612
612
  supportPolicy: {
613
- latest: "0.1.170",
613
+ latest: "0.1.172",
614
614
  minimumSupported: "0.1.53",
615
615
  deprecatedBelow: "0.1.53",
616
616
  commandMinimumSupported: [
@@ -4386,10 +4386,50 @@ end run
4386
4386
  `;
4387
4387
  return runAppleScript(script, [targetUrl, host], runner);
4388
4388
  }
4389
+ function hasOnlyHeadlessMacosBrowserInstances(appName, runner = defaultBrowserCommandRunner) {
4390
+ try {
4391
+ const output2 = runner.execFileSync("ps", ["-axo", "args="], {
4392
+ encoding: "utf-8",
4393
+ stdio: ["ignore", "pipe", "ignore"]
4394
+ });
4395
+ const executableSuffix = `/Contents/MacOS/${appName}`;
4396
+ const lines = String(output2).split(/\r?\n/).map((line) => line.trim()).filter((line) => {
4397
+ const executableIndex = line.indexOf(executableSuffix);
4398
+ if (executableIndex < 0 || !line.includes(".app/Contents/MacOS/")) {
4399
+ return false;
4400
+ }
4401
+ const rest = line.slice(executableIndex + executableSuffix.length);
4402
+ return rest === "" || /^\s+-/.test(rest);
4403
+ });
4404
+ if (lines.length === 0) return false;
4405
+ return lines.every(
4406
+ (line) => line.includes("--headless") || line.includes("--no-startup-window")
4407
+ );
4408
+ } catch {
4409
+ return false;
4410
+ }
4411
+ }
4412
+ function openNewVisibleMacosBrowserInstance(appName, targetUrl, runner = defaultBrowserCommandRunner) {
4413
+ try {
4414
+ runner.execFileSync(
4415
+ "open",
4416
+ ["-na", appName, "--args", "--new-window", targetUrl],
4417
+ {
4418
+ stdio: "ignore"
4419
+ }
4420
+ );
4421
+ return true;
4422
+ } catch {
4423
+ return false;
4424
+ }
4425
+ }
4389
4426
  function openUrlMacos(targetUrl, allowFocus, runner = defaultBrowserCommandRunner) {
4390
4427
  const defaultBundleId = readDefaultMacBrowserBundleId(runner);
4391
4428
  const appName = defaultBundleId ? browserAppNameFromBundleId(defaultBundleId) : "";
4392
4429
  const strategy = browserStrategyForBundleId(defaultBundleId);
4430
+ if (allowFocus && appName && strategy === "chromium" && hasOnlyHeadlessMacosBrowserInstances(appName, runner) && openNewVisibleMacosBrowserInstance(appName, targetUrl, runner)) {
4431
+ return true;
4432
+ }
4393
4433
  if (appName && strategy === "chromium" && retargetChromiumMacos(appName, targetUrl, allowFocus, runner)) {
4394
4434
  return true;
4395
4435
  }
@@ -16847,6 +16887,7 @@ function helperSource() {
16847
16887
  // src/cli/commands/enrich.ts
16848
16888
  var ENRICH_EXPORT_PAGE_SIZE = 5e3;
16849
16889
  var ENRICH_AUTO_BATCH_ROWS = 250;
16890
+ var ENRICH_HEAVY_PLAY_AUTO_BATCH_ROWS = 40;
16850
16891
  var ENRICH_EXPORT_BACKING_ROWS_WAIT_MS = 6e4;
16851
16892
  var ENRICH_EXPORT_BACKING_ROWS_POLL_MS = 1e3;
16852
16893
  var ENRICH_SOURCE_ROW_INDEX_COLUMN = "__deeplineSourceRowIndex";
@@ -16856,6 +16897,11 @@ var ENRICH_CELL_META_PATCH_FIELD = "__deeplineCellMetaPatch";
16856
16897
  var EXIT_SERVER2 = 5;
16857
16898
  var ENRICH_DEBUG_T0 = Date.now();
16858
16899
  var GENERATED_ENRICH_ROWS_TABLE_NAMESPACE = "deepline_enrich_rows";
16900
+ var HEAVY_ENRICH_AUTO_BATCH_PLAYS = /* @__PURE__ */ new Set([
16901
+ "company-to-contact",
16902
+ "company-to-contact-by-role-waterfall",
16903
+ "company_to_contact_by_role_waterfall"
16904
+ ]);
16859
16905
  var PLAN_SHAPING_OPTION_NAMES = [
16860
16906
  "with",
16861
16907
  "withWaterfall",
@@ -17632,6 +17678,52 @@ async function writeOutputCsv(outputPath, status, options) {
17632
17678
  function isMissingRowsForCsvExportError(error) {
17633
17679
  return error instanceof Error && (error.message.includes("did not return row-shaped output") || error.message.includes("run returned 0 preview row(s)"));
17634
17680
  }
17681
+ function normalizeEnrichPlayRef(value) {
17682
+ if (typeof value !== "string") {
17683
+ return null;
17684
+ }
17685
+ const normalized = value.trim().toLowerCase().replace(/^prebuilt\//, "");
17686
+ return normalized || null;
17687
+ }
17688
+ function configContainsHeavyEnrichPlay(config) {
17689
+ let hasNestedPlayStep = false;
17690
+ let hasSubrequestProviderStep = false;
17691
+ const visit = (commands) => {
17692
+ for (const command of commands) {
17693
+ if ("with_waterfall" in command) {
17694
+ if (visit(command.commands)) {
17695
+ return true;
17696
+ }
17697
+ continue;
17698
+ }
17699
+ if (command.disabled) {
17700
+ continue;
17701
+ }
17702
+ const candidates = [
17703
+ command.tool,
17704
+ command.operation,
17705
+ command.play?.ref,
17706
+ command.play?.ref?.replace(/^prebuilt\//, "")
17707
+ ];
17708
+ if (candidates.map(normalizeEnrichPlayRef).some(
17709
+ (candidate) => candidate !== null && HEAVY_ENRICH_AUTO_BATCH_PLAYS.has(candidate)
17710
+ )) {
17711
+ return true;
17712
+ }
17713
+ const normalizedTool = normalizeEnrichPlayRef(command.tool);
17714
+ if (command.play || normalizedTool === "test-play") {
17715
+ hasNestedPlayStep = true;
17716
+ } else if (normalizedTool !== null && normalizedTool !== "run_javascript") {
17717
+ hasSubrequestProviderStep = true;
17718
+ }
17719
+ }
17720
+ return false;
17721
+ };
17722
+ return visit(config.commands) || hasNestedPlayStep && hasSubrequestProviderStep;
17723
+ }
17724
+ function enrichAutoBatchRowsForConfig(config) {
17725
+ return configContainsHeavyEnrichPlay(config) ? ENRICH_HEAVY_PLAY_AUTO_BATCH_ROWS : ENRICH_AUTO_BATCH_ROWS;
17726
+ }
17635
17727
  async function maybeWriteOutputCsv(input2) {
17636
17728
  if (!input2.outputPath) return null;
17637
17729
  try {
@@ -18530,7 +18622,7 @@ async function maybeEmitEnrichFailureReport(input2) {
18530
18622
  const jobs = rowJobs.length > 0 || input2.status === void 0 ? rowJobs : collectStatusFailureJobs({
18531
18623
  config: input2.config,
18532
18624
  status: input2.status,
18533
- rowRange: input2.rowRange
18625
+ rowRange: input2.statusRowRange ?? input2.rowRange
18534
18626
  });
18535
18627
  if (jobs.length === 0) {
18536
18628
  return null;
@@ -19265,13 +19357,12 @@ function registerEnrichCommand(program) {
19265
19357
  return { captured: captured2, status: status2, exportResult: exportResult2 };
19266
19358
  };
19267
19359
  const selectedRange = selectedSourceCsvRange(sourceCsvPath, rows);
19268
- if (outputPath && selectedRange.count > ENRICH_AUTO_BATCH_ROWS) {
19269
- const chunkCount = Math.ceil(
19270
- selectedRange.count / ENRICH_AUTO_BATCH_ROWS
19271
- );
19360
+ const autoBatchRows = enrichAutoBatchRowsForConfig(config);
19361
+ if (outputPath && selectedRange.count > autoBatchRows) {
19362
+ const chunkCount = Math.ceil(selectedRange.count / autoBatchRows);
19272
19363
  if (!options.json) {
19273
19364
  process.stderr.write(
19274
- `Large enrich input selected ${selectedRange.count.toLocaleString()} rows. Running ${chunkCount.toLocaleString()} sequential batch runs of up to ${ENRICH_AUTO_BATCH_ROWS.toLocaleString()} rows and merging ${resolve9(outputPath)}.
19365
+ `Large enrich input selected ${selectedRange.count.toLocaleString()} rows. Running ${chunkCount.toLocaleString()} sequential batch runs of up to ${autoBatchRows.toLocaleString()} rows and merging ${resolve9(outputPath)}.
19275
19366
  `
19276
19367
  );
19277
19368
  }
@@ -19280,12 +19371,12 @@ function registerEnrichCommand(program) {
19280
19371
  let finalExportResult = null;
19281
19372
  let totalEnrichedRows = 0;
19282
19373
  const batchFailureRows = [];
19283
- for (let chunkStart = selectedRange.start, chunkIndex = 0; chunkStart <= selectedRange.end; chunkStart += ENRICH_AUTO_BATCH_ROWS, chunkIndex += 1) {
19374
+ for (let chunkStart = selectedRange.start, chunkIndex = 0; chunkStart <= selectedRange.end; chunkStart += autoBatchRows, chunkIndex += 1) {
19284
19375
  const chunkRows = {
19285
19376
  rowStart: chunkStart,
19286
19377
  rowEnd: Math.min(
19287
19378
  selectedRange.end,
19288
- chunkStart + ENRICH_AUTO_BATCH_ROWS - 1
19379
+ chunkStart + autoBatchRows - 1
19289
19380
  )
19290
19381
  };
19291
19382
  if (!options.json) {
@@ -19303,6 +19394,24 @@ function registerEnrichCommand(program) {
19303
19394
  });
19304
19395
  lastStatus = chunk.status;
19305
19396
  if (chunk.captured.result !== 0) {
19397
+ if (chunk.exportResult) {
19398
+ finalExportResult = chunk.exportResult;
19399
+ totalEnrichedRows += chunk.exportResult.enrichedRows;
19400
+ batchFailureRows.push(...chunk.exportResult.enrichedDataRows);
19401
+ }
19402
+ const failureReport3 = await maybeEmitEnrichFailureReport({
19403
+ config,
19404
+ rows: batchFailureRows,
19405
+ rowRange: {
19406
+ rowStart: selectedRange.start,
19407
+ rowEnd: selectedRange.end
19408
+ },
19409
+ statusRowRange: chunkRows,
19410
+ client: client2,
19411
+ outputPath: failureReportOutputPath ?? finalExportResult?.path ?? outputPath,
19412
+ status: chunk.status
19413
+ });
19414
+ const committedExportResult2 = finalExportResult ? await commitInPlaceOutput(finalExportResult) : null;
19306
19415
  if (options.json) {
19307
19416
  printJson({
19308
19417
  ok: false,
@@ -19312,12 +19421,27 @@ function registerEnrichCommand(program) {
19312
19421
  rows: chunkRows
19313
19422
  },
19314
19423
  result: chunk.status,
19315
- output: options.inPlace ? null : enrichOutputJson(chunk.exportResult)
19424
+ output: committedExportResult2 ? {
19425
+ sourceCsvRows: selectedRange.sourceRows,
19426
+ selectedRows: selectedRange.count,
19427
+ enrichedRows: totalEnrichedRows,
19428
+ path: committedExportResult2.path,
19429
+ ...committedExportResult2.partial ? {
19430
+ rows: committedExportResult2.rows,
19431
+ partial: true
19432
+ } : {}
19433
+ } : null,
19434
+ ...failureReport3 ? {
19435
+ failure_report: {
19436
+ path: failureReport3.path,
19437
+ jobs: failureReport3.jobs.length
19438
+ }
19439
+ } : {}
19316
19440
  });
19317
19441
  } else {
19318
- if (chunk.exportResult && !options.inPlace) {
19442
+ if (committedExportResult2) {
19319
19443
  process.stderr.write(
19320
- `Wrote ${chunk.exportResult.rows} row(s) to ${chunk.exportResult.path}${chunk.exportResult.partial ? " (partial run output)" : ""}
19444
+ `Wrote ${committedExportResult2.rows} row(s) to ${committedExportResult2.path}${committedExportResult2.partial ? " (partial run output)" : ""}
19321
19445
  `
19322
19446
  );
19323
19447
  }
@@ -19328,7 +19452,7 @@ function registerEnrichCommand(program) {
19328
19452
  status: chunk.status
19329
19453
  });
19330
19454
  }
19331
- process.exitCode = chunk.captured.result;
19455
+ process.exitCode = failureReport3 ? EXIT_SERVER2 : chunk.captured.result;
19332
19456
  return;
19333
19457
  }
19334
19458
  if (chunk.exportResult) {
@@ -19350,15 +19474,13 @@ function registerEnrichCommand(program) {
19350
19474
  outputPath: failureReportOutputPath ?? finalExportResult?.path ?? outputPath,
19351
19475
  status: lastStatus
19352
19476
  });
19353
- if (!failureReport2) {
19354
- finalExportResult = await commitInPlaceOutput(finalExportResult);
19355
- }
19477
+ finalExportResult = await commitInPlaceOutput(finalExportResult);
19356
19478
  if (options.json) {
19357
19479
  const run = rewriteEnrichJsonStatus({
19358
19480
  status: lastStatus,
19359
19481
  config,
19360
19482
  forceAliases,
19361
- output: finalExportResult && (!failureReport2 || !options.inPlace) ? {
19483
+ output: finalExportResult ? {
19362
19484
  ...finalExportResult,
19363
19485
  sourceCsvRows: selectedRange.sourceRows,
19364
19486
  selectedRows: selectedRange.count,
@@ -19373,10 +19495,10 @@ function registerEnrichCommand(program) {
19373
19495
  run,
19374
19496
  batch: {
19375
19497
  chunks: chunkCount,
19376
- chunkRows: ENRICH_AUTO_BATCH_ROWS,
19498
+ chunkRows: autoBatchRows,
19377
19499
  selectedRows: selectedRange.count
19378
19500
  },
19379
- output: finalExportResult && (!failureReport2 || !options.inPlace) ? {
19501
+ output: finalExportResult ? {
19380
19502
  sourceCsvRows: selectedRange.sourceRows,
19381
19503
  selectedRows: selectedRange.count,
19382
19504
  enrichedRows: totalEnrichedRows,
@@ -19403,9 +19525,10 @@ function registerEnrichCommand(program) {
19403
19525
  });
19404
19526
  const rowsForFailureReport = exportResult?.enrichedDataRows ?? extractCanonicalRowsInfo(status)?.rows ?? [];
19405
19527
  if (captured.result !== 0) {
19406
- if (exportResult && !options.inPlace) {
19528
+ const committedExportResult2 = exportResult ? await commitInPlaceOutput(exportResult) : null;
19529
+ if (committedExportResult2) {
19407
19530
  process.stderr.write(
19408
- `Wrote ${exportResult.rows} row(s) to ${exportResult.path}${exportResult.partial ? " (partial run output)" : ""}
19531
+ `Wrote ${committedExportResult2.rows} row(s) to ${committedExportResult2.path}${committedExportResult2.partial ? " (partial run output)" : ""}
19409
19532
  `
19410
19533
  );
19411
19534
  }
@@ -19414,7 +19537,7 @@ function registerEnrichCommand(program) {
19414
19537
  rows: rowsForFailureReport,
19415
19538
  rowRange: rows,
19416
19539
  client: client2,
19417
- exportResult,
19540
+ exportResult: committedExportResult2,
19418
19541
  outputPath,
19419
19542
  reportOutputPath: failureReportOutputPath,
19420
19543
  status
@@ -19423,7 +19546,7 @@ function registerEnrichCommand(program) {
19423
19546
  printJson({
19424
19547
  ok: false,
19425
19548
  run: status,
19426
- output: options.inPlace ? null : enrichOutputJson(exportResult),
19549
+ output: enrichOutputJson(committedExportResult2),
19427
19550
  ...failureReport2 ? {
19428
19551
  failure_report: {
19429
19552
  path: failureReport2.path,
@@ -19446,18 +19569,18 @@ function registerEnrichCommand(program) {
19446
19569
  reportOutputPath: failureReportOutputPath,
19447
19570
  status
19448
19571
  });
19449
- const committedExportResult2 = failureReport2 ? exportResult : await commitInPlaceOutput(exportResult);
19572
+ const committedExportResult2 = await commitInPlaceOutput(exportResult);
19450
19573
  const run = rewriteEnrichJsonStatus({
19451
19574
  status,
19452
19575
  config,
19453
19576
  forceAliases,
19454
- output: failureReport2 && options.inPlace ? null : committedExportResult2,
19577
+ output: committedExportResult2,
19455
19578
  failureReport: failureReport2
19456
19579
  });
19457
19580
  printJson({
19458
19581
  ok: !failureReport2,
19459
19582
  run,
19460
- output: failureReport2 && options.inPlace ? null : enrichOutputJson(committedExportResult2),
19583
+ output: enrichOutputJson(committedExportResult2),
19461
19584
  ...failureReport2 ? {
19462
19585
  failure_report: {
19463
19586
  path: failureReport2.path,
@@ -19478,7 +19601,7 @@ function registerEnrichCommand(program) {
19478
19601
  outputPath: failureReportOutputPath ?? exportResult?.path ?? null,
19479
19602
  status
19480
19603
  });
19481
- const committedExportResult = failureReport ? options.inPlace ? null : exportResult : await commitInPlaceOutput(exportResult);
19604
+ const committedExportResult = await commitInPlaceOutput(exportResult);
19482
19605
  if (committedExportResult) {
19483
19606
  process.stderr.write(
19484
19607
  `Wrote ${committedExportResult.rows} row(s) to ${committedExportResult.path}
package/dist/index.js CHANGED
@@ -421,10 +421,10 @@ var SDK_RELEASE = {
421
421
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
422
422
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
423
423
  // fields shipped in 0.1.153.
424
- version: "0.1.170",
424
+ version: "0.1.172",
425
425
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
426
426
  supportPolicy: {
427
- latest: "0.1.170",
427
+ latest: "0.1.172",
428
428
  minimumSupported: "0.1.53",
429
429
  deprecatedBelow: "0.1.53",
430
430
  commandMinimumSupported: [