deepline 0.1.185 → 0.1.186

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.
@@ -650,6 +650,7 @@ type DynamicWorkflowMetadata = {
650
650
  artifactStorageKey: string;
651
651
  artifactHash?: string | null;
652
652
  dynamicWorkerCode?: string | null;
653
+ dynamicWorkerCodeHash?: string | null;
653
654
  integrationMode?: 'live' | 'eval_stub' | 'fixture' | null;
654
655
  packagedFiles?: Array<{
655
656
  playPath: string;
@@ -682,12 +683,18 @@ function normalizeIntegrationMode(
682
683
  function buildDynamicWorkflowMetadata(
683
684
  params: PlayWorkflowParams,
684
685
  ): DynamicWorkflowMetadata {
686
+ const dynamicWorkerCodeHash =
687
+ typeof params.dynamicWorkerCode === 'string' &&
688
+ params.dynamicWorkerCode.length > 0
689
+ ? stableHash(params.dynamicWorkerCode)
690
+ : null;
685
691
  return {
686
692
  runId: params.runId ?? null,
687
693
  graphHash: params.graphHash,
688
694
  artifactStorageKey: params.artifactStorageKey,
689
695
  artifactHash: params.artifactHash ?? null,
690
696
  dynamicWorkerCode: null,
697
+ dynamicWorkerCodeHash,
691
698
  integrationMode: normalizeIntegrationMode(params.integrationMode),
692
699
  packagedFiles: normalizePackagedFiles(params.packagedFiles),
693
700
  };
@@ -3684,6 +3691,10 @@ export class DynamicWorkflow extends WorkflowEntrypoint<
3684
3691
  typeof metadata.dynamicWorkerCode === 'string'
3685
3692
  ? metadata.dynamicWorkerCode
3686
3693
  : null,
3694
+ dynamicWorkerCodeHash:
3695
+ typeof metadata.dynamicWorkerCodeHash === 'string'
3696
+ ? metadata.dynamicWorkerCodeHash
3697
+ : null,
3687
3698
  integrationMode: normalizeIntegrationMode(
3688
3699
  metadata.integrationMode,
3689
3700
  ),
@@ -5287,6 +5298,36 @@ function dynamicPlayWorkerCacheKey(input: {
5287
5298
  ].join(':');
5288
5299
  }
5289
5300
 
5301
+ function dynamicPlayWorkerArtifactIdentity(
5302
+ metadata: Pick<
5303
+ DynamicWorkflowMetadata,
5304
+ | 'artifactHash'
5305
+ | 'artifactStorageKey'
5306
+ | 'dynamicWorkerCode'
5307
+ | 'dynamicWorkerCodeHash'
5308
+ >,
5309
+ ): string {
5310
+ const artifactHash = metadata.artifactHash?.trim();
5311
+ const inlineCodeHash =
5312
+ typeof metadata.dynamicWorkerCodeHash === 'string' &&
5313
+ metadata.dynamicWorkerCodeHash.length > 0
5314
+ ? metadata.dynamicWorkerCodeHash
5315
+ : typeof metadata.dynamicWorkerCode === 'string' &&
5316
+ metadata.dynamicWorkerCode.length > 0
5317
+ ? stableHash(metadata.dynamicWorkerCode)
5318
+ : null;
5319
+ if (artifactHash && inlineCodeHash) {
5320
+ return `${artifactHash}:inline=${inlineCodeHash}`;
5321
+ }
5322
+ if (artifactHash) {
5323
+ return artifactHash;
5324
+ }
5325
+ if (inlineCodeHash) {
5326
+ return `inline=${inlineCodeHash}`;
5327
+ }
5328
+ return stableHash(metadata.artifactStorageKey);
5329
+ }
5330
+
5290
5331
  function dynamicWorkerBundledCodeCacheKey(input: {
5291
5332
  artifactStorageKey: string;
5292
5333
  artifactHash?: string | null;
@@ -5350,8 +5391,7 @@ function loadDynamicPlayWorkerSync(
5350
5391
  'Dynamic play worker requires artifactStorageKey metadata.',
5351
5392
  );
5352
5393
  }
5353
- const artifactIdentity =
5354
- metadata.artifactHash?.trim() || stableHash(artifactStorageKey);
5394
+ const artifactIdentity = dynamicPlayWorkerArtifactIdentity(metadata);
5355
5395
  const workerCacheKey = dynamicPlayWorkerCacheKey({
5356
5396
  env,
5357
5397
  graphHash,
@@ -5439,8 +5479,7 @@ async function loadDynamicPlayWorker(
5439
5479
  'Dynamic play worker requires artifactStorageKey metadata.',
5440
5480
  );
5441
5481
  }
5442
- const artifactIdentity =
5443
- metadata.artifactHash?.trim() || stableHash(artifactStorageKey);
5482
+ const artifactIdentity = dynamicPlayWorkerArtifactIdentity(metadata);
5444
5483
  const workerCacheKey = dynamicPlayWorkerCacheKey({
5445
5484
  env,
5446
5485
  graphHash,
@@ -540,8 +540,8 @@ type WorkerEnv = {
540
540
  /**
541
541
  * In-process Fetcher constructed by the coordinator and handed to the
542
542
  * per-graphHash play Worker. When present, runtime callbacks
543
- * (`/api/v2/internal/play-runtime`,
544
- * `/api/v2/internal/play-runtime/*`,
543
+ * (`/api/v2/plays/internal/runtime`,
544
+ * `/api/v2/plays/internal/*`,
545
545
  * `/api/v2/plays/runtime-tools/*`) skip the public callback URL and route
546
546
  * directly through the coordinator's process to the configured app — saves
547
547
  * the *.workers.dev → CF edge → cloudflared → localhost chain on every
@@ -105,10 +105,10 @@ export const SDK_RELEASE = {
105
105
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
106
106
  // fields shipped in 0.1.153.
107
107
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
108
- version: '0.1.185',
108
+ version: '0.1.186',
109
109
  apiContract: '2026-06-dataset-handle-results-hard-cutover',
110
110
  supportPolicy: {
111
- latest: '0.1.185',
111
+ latest: '0.1.186',
112
112
  minimumSupported: '0.1.53',
113
113
  deprecatedBelow: '0.1.53',
114
114
  commandMinimumSupported: [
package/dist/cli/index.js CHANGED
@@ -623,10 +623,10 @@ var SDK_RELEASE = {
623
623
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
624
624
  // fields shipped in 0.1.153.
625
625
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
626
- version: "0.1.185",
626
+ version: "0.1.186",
627
627
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
628
628
  supportPolicy: {
629
- latest: "0.1.185",
629
+ latest: "0.1.186",
630
630
  minimumSupported: "0.1.53",
631
631
  deprecatedBelow: "0.1.53",
632
632
  commandMinimumSupported: [
@@ -16188,7 +16188,7 @@ function canInlineRunJavascript(command) {
16188
16188
  return true;
16189
16189
  }
16190
16190
  function renderExtractFunction(command, indentSpaces) {
16191
- return command.extract_js ? `({ row, result, data, raw, pick, extract, extractList, target, get }) => { const input = row; const context = row;
16191
+ return command.extract_js ? `({ row, result, data, raw, pick, extract, extractList, target, get }) => { const input = row; const context = row; const output_data = __dlLegacyOutputData(result, raw);
16192
16192
  ${indent(renderJavascriptBody(command.extract_js), indentSpaces)}
16193
16193
  }` : "null";
16194
16194
  }
@@ -16816,8 +16816,13 @@ function helperSource() {
16816
16816
  ` __dlPushCandidate(candidates, record.data);`,
16817
16817
  ` __dlPushCandidate(candidates, record.result);`,
16818
16818
  ` __dlPushCandidate(candidates, record.output);`,
16819
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'data.data'));`,
16819
16820
  ` __dlPushCandidate(candidates, __dlGetByPath(record, 'result.data'));`,
16821
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'result.data.data'));`,
16822
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'output.data'));`,
16823
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'output.data.data'));`,
16820
16824
  ` __dlPushCandidate(candidates, __dlGetByPath(record, 'output.body'));`,
16825
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'output.body.data'));`,
16821
16826
  ` __dlPushCandidate(candidates, __dlGetByPath(record, 'toolResponse.raw'));`,
16822
16827
  ` __dlPushCandidate(candidates, __dlGetByPath(record, 'toolOutput.raw'));`,
16823
16828
  ` return candidates;`,
@@ -17214,13 +17219,37 @@ function helperSource() {
17214
17219
  ` return { ...defaults, ...(existing as Record<string, unknown>) };`,
17215
17220
  `}`,
17216
17221
  ``,
17222
+ `function __dlCompactJavascriptContext(value: unknown, depth = 0): unknown {`,
17223
+ ` if (depth > 8) return '[Object]';`,
17224
+ ` if (typeof value === 'string') return value.length > 20000 ? value.slice(0, 20000) + '...[truncated]' : value;`,
17225
+ ` if (!value || typeof value !== 'object') return value;`,
17226
+ ` if (Array.isArray(value)) {`,
17227
+ ` const limit = depth <= 2 ? 25 : 10;`,
17228
+ ` const items = value.slice(0, limit).map((entry) => __dlCompactJavascriptContext(entry, depth + 1));`,
17229
+ ` if (value.length > limit) items.push({ __deepline_truncated_items: value.length - limit });`,
17230
+ ` return items;`,
17231
+ ` }`,
17232
+ ` const out: Record<string, unknown> = {};`,
17233
+ ` let count = 0;`,
17234
+ ` for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {`,
17235
+ ` count += 1;`,
17236
+ ` if (count > 80) {`,
17237
+ ` out.__deepline_truncated_fields = count - 80;`,
17238
+ ` break;`,
17239
+ ` }`,
17240
+ ` out[key] = __dlCompactJavascriptContext(entry, depth + 1);`,
17241
+ ` }`,
17242
+ ` return out;`,
17243
+ `}`,
17244
+ ``,
17217
17245
  `function __dlRuntimePayload(tool: string, payload: Record<string, unknown>, row: Record<string, unknown>): Record<string, unknown> {`,
17218
17246
  ` if (tool !== 'run_javascript') return payload;`,
17247
+ ` const compactRow = __dlCompactJavascriptContext(row) as Record<string, unknown>;`,
17219
17248
  ` return {`,
17220
17249
  ` ...payload,`,
17221
- ` row: __dlMergeContextRecord(payload.row, row),`,
17222
- ` input: __dlMergeContextRecord(payload.input, row),`,
17223
- ` context: __dlMergeContextRecord(payload.context, row),`,
17250
+ ` row: __dlMergeContextRecord(payload.row, compactRow),`,
17251
+ ` input: __dlMergeContextRecord(payload.input, compactRow),`,
17252
+ ` context: __dlMergeContextRecord(payload.context, compactRow),`,
17224
17253
  ` };`,
17225
17254
  `}`,
17226
17255
  ``,
@@ -18223,6 +18252,125 @@ function enrichOutputJson(exportResult) {
18223
18252
  ...exportResult.partial ? { rows: exportResult.rows, partial: true } : {}
18224
18253
  };
18225
18254
  }
18255
+ function readFirstEnrichDatasetActions(value) {
18256
+ const seen = /* @__PURE__ */ new Set();
18257
+ const walk = (candidate, options) => {
18258
+ if (!candidate || typeof candidate !== "object" || seen.has(candidate)) {
18259
+ return null;
18260
+ }
18261
+ seen.add(candidate);
18262
+ if (Array.isArray(candidate)) {
18263
+ for (const entry of candidate) {
18264
+ const found = walk(entry, options);
18265
+ if (found) return found;
18266
+ }
18267
+ return null;
18268
+ }
18269
+ const record = candidate;
18270
+ const actions = isRecord7(record.actions) ? record.actions : null;
18271
+ const query = isRecord7(actions?.query) ? actions.query : null;
18272
+ if (query?.kind === "deepline_db_query") {
18273
+ return {
18274
+ dataset: record,
18275
+ query,
18276
+ ...isRecord7(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
18277
+ };
18278
+ }
18279
+ if (options.allowLegacy && record.kind === "dataset" && typeof record.queryDatasetCommand === "string" && record.queryDatasetCommand.trim()) {
18280
+ return {
18281
+ dataset: record,
18282
+ queryDatasetCommand: record.queryDatasetCommand.trim(),
18283
+ ...typeof record.slowExportAsCsvCommand === "string" && record.slowExportAsCsvCommand.trim() ? { slowExportAsCsvCommand: record.slowExportAsCsvCommand.trim() } : {}
18284
+ };
18285
+ }
18286
+ for (const [key, entry] of Object.entries(record)) {
18287
+ if (key === "preview") {
18288
+ continue;
18289
+ }
18290
+ const found = walk(entry, options);
18291
+ if (found) return found;
18292
+ }
18293
+ return null;
18294
+ };
18295
+ const modern = walk(value, { allowLegacy: false });
18296
+ if (modern) {
18297
+ return modern;
18298
+ }
18299
+ seen.clear();
18300
+ return walk(value, { allowLegacy: true });
18301
+ }
18302
+ function actionStringField(record, key) {
18303
+ const value = record[key];
18304
+ return typeof value === "string" && value.trim() ? value.trim() : null;
18305
+ }
18306
+ function parseSqlFromDbQueryCommand(command) {
18307
+ if (!command) {
18308
+ return null;
18309
+ }
18310
+ const match = command.match(/\s--sql\s+('(?:'\\''|[^'])*'|"(?:"\\"|[^"])*")/);
18311
+ if (!match?.[1]) {
18312
+ return null;
18313
+ }
18314
+ const raw = match[1];
18315
+ if (raw.startsWith("'") && raw.endsWith("'")) {
18316
+ return raw.slice(1, -1).replace(/'\\''/g, "'");
18317
+ }
18318
+ return decodeStringLiteral(raw);
18319
+ }
18320
+ function enrichCustomerDbJson(input2) {
18321
+ const actions = readFirstEnrichDatasetActions(input2.status);
18322
+ if (!actions) {
18323
+ return null;
18324
+ }
18325
+ const query = actions.query ?? {};
18326
+ const dataset = actions.dataset;
18327
+ const sql = actionStringField(query, "sql") ?? parseSqlFromDbQueryCommand(actions.queryDatasetCommand);
18328
+ const datasetPath = actionStringField(query, "datasetPath") ?? actionStringField(dataset, "path") ?? actionStringField(dataset, "tableNamespace");
18329
+ const api = isRecord7(query.api) ? query.api : null;
18330
+ const apiPath = actionStringField(api ?? {}, "path") ?? "/api/v2/db/query";
18331
+ const apiMethod = actionStringField(api ?? {}, "method") ?? "POST";
18332
+ if (!datasetPath) {
18333
+ return null;
18334
+ }
18335
+ const maxRows = typeof query.maxRows === "number" && Number.isFinite(query.maxRows) ? Math.trunc(query.maxRows) : void 0;
18336
+ const runId = extractRunId(input2.status) ?? actionStringField(actions.exportCsv ?? {}, "runId");
18337
+ const exportDatasetPath = actionStringField(actions.exportCsv ?? {}, "datasetPath") ?? datasetPath;
18338
+ const tableNamespace = actionStringField(query, "tableNamespace") ?? actionStringField(dataset, "tableNamespace");
18339
+ const sqlTableName = actionStringField(query, "sqlTableName");
18340
+ const sqlQualifiedTableName = actionStringField(
18341
+ query,
18342
+ "sqlQualifiedTableName"
18343
+ );
18344
+ const command = actions.queryDatasetCommand ?? (sql ? `deepline db query --sql ${shellSingleQuote2(sql)}${maxRows !== void 0 ? ` --max-rows ${maxRows}` : ""} --json` : null);
18345
+ return {
18346
+ runId,
18347
+ datasetPath,
18348
+ ...tableNamespace ? { tableNamespace } : {},
18349
+ ...sqlTableName ? { sqlTableName } : {},
18350
+ ...sqlQualifiedTableName ? { sqlQualifiedTableName } : {},
18351
+ ...sql ? { sql } : {},
18352
+ ...actions.query ? {
18353
+ api: {
18354
+ method: apiMethod,
18355
+ path: apiPath,
18356
+ url: `${input2.client.baseUrl.replace(/\/$/, "")}${apiPath}`
18357
+ }
18358
+ } : {},
18359
+ ...maxRows !== void 0 ? { maxRows } : {},
18360
+ ...command ? { command } : {},
18361
+ ...actions.exportCsv || actions.slowExportAsCsvCommand ? {
18362
+ export: {
18363
+ datasetPath: exportDatasetPath,
18364
+ ...actions.slowExportAsCsvCommand ? { command: actions.slowExportAsCsvCommand } : runId && input2.outputPath ? {
18365
+ command: `deepline runs export ${runId} --dataset ${shellSingleQuote2(
18366
+ exportDatasetPath
18367
+ )} --out ${shellSingleQuote2((0, import_node_path12.resolve)(input2.outputPath))}`
18368
+ } : {},
18369
+ action: actions.exportCsv ?? {}
18370
+ }
18371
+ } : {}
18372
+ };
18373
+ }
18226
18374
  function enrichReportJson(report) {
18227
18375
  if (!report) {
18228
18376
  return {};
@@ -18243,6 +18391,78 @@ function enrichReportJson(report) {
18243
18391
  } : {}
18244
18392
  };
18245
18393
  }
18394
+ function sqlStringLiteral(value) {
18395
+ return `'${value.replace(/'/g, "''")}'`;
18396
+ }
18397
+ function failureAliasFromCellMeta(cellMeta) {
18398
+ if (!isRecord7(cellMeta)) {
18399
+ return null;
18400
+ }
18401
+ for (const [alias, meta] of Object.entries(cellMeta)) {
18402
+ if (!isRecord7(meta)) {
18403
+ continue;
18404
+ }
18405
+ const failure = failureCellFromMeta(meta, {});
18406
+ if (!failure) {
18407
+ continue;
18408
+ }
18409
+ return {
18410
+ alias,
18411
+ ...typeof failure.error === "string" ? { error: failure.error } : {},
18412
+ ...typeof failure.operation === "string" ? { operation: failure.operation } : {},
18413
+ ...typeof failure.provider === "string" ? { provider: failure.provider } : {}
18414
+ };
18415
+ }
18416
+ return null;
18417
+ }
18418
+ async function collectCustomerDbFailureJobs(input2) {
18419
+ const customerDb = enrichCustomerDbJson({
18420
+ status: input2.status,
18421
+ client: input2.client
18422
+ });
18423
+ if (!customerDb?.runId || !customerDb.sqlQualifiedTableName) {
18424
+ return [];
18425
+ }
18426
+ const fallbackAliases = collectHardFailureAliasSpecs(input2.config);
18427
+ const fallbackAlias = fallbackAliases[0]?.alias ?? "enrich";
18428
+ const aliasIndexByName = new Map(
18429
+ fallbackAliases.map((spec, index) => [normalizeAlias2(spec.alias), index])
18430
+ );
18431
+ const sql = `select _input_index, _status, _error, _cell_meta from ${customerDb.sqlQualifiedTableName} where _run_id = ${sqlStringLiteral(customerDb.runId)} and (_error is not null or lower(coalesce(_status, '')) in ('failed', 'error')) order by _input_index limit 1000`;
18432
+ const result = await input2.client.queryCustomerDb({
18433
+ sql,
18434
+ maxRows: 1e3
18435
+ });
18436
+ const rows = Array.isArray(result.rows) ? result.rows : [];
18437
+ const failedRows = rows.filter((row) => {
18438
+ const status = typeof row._status === "string" ? row._status.trim().toLowerCase() : "";
18439
+ return typeof row._error === "string" && row._error.trim() || status === "failed" || status === "error";
18440
+ });
18441
+ return failedRows.map((row, index) => {
18442
+ const metaFailure = failureAliasFromCellMeta(row._cell_meta);
18443
+ const alias = metaFailure?.alias ?? fallbackAlias;
18444
+ const normalizedAlias = normalizeAlias2(alias);
18445
+ const rowId = typeof row._input_index === "number" ? row._input_index : typeof row._input_index === "string" && row._input_index.trim() ? Number.parseInt(row._input_index, 10) : index;
18446
+ const rawError = metaFailure?.error ?? (typeof row._error === "string" && row._error.trim() ? row._error.trim() : `Column status: ${String(row._status ?? "failed")}`);
18447
+ const message = enrichFailureMessageWithOperation(
18448
+ rawError,
18449
+ metaFailure?.operation ?? fallbackAliases.find(
18450
+ (spec) => normalizeAlias2(spec.alias) === normalizedAlias
18451
+ )?.operation
18452
+ );
18453
+ return {
18454
+ job_id: `row-${Number.isFinite(rowId) ? rowId : index}-${normalizedAlias || "enrich"}`,
18455
+ row_id: Number.isFinite(rowId) ? rowId : index,
18456
+ col_index: aliasIndexByName.get(normalizedAlias) ?? 0,
18457
+ column: alias,
18458
+ status: "failed",
18459
+ last_error: message,
18460
+ error: message,
18461
+ ...metaFailure?.operation ? { operation: metaFailure.operation } : {},
18462
+ ...metaFailure?.provider ? { provider: metaFailure.provider } : {}
18463
+ };
18464
+ });
18465
+ }
18246
18466
  async function buildEnrichFailureReport(input2) {
18247
18467
  const fallbackRowsInfo = input2.exportResult ? null : extractCanonicalRowsInfo(input2.status);
18248
18468
  return maybeEmitEnrichFailureReport({
@@ -18344,9 +18564,7 @@ async function writeSlimBatchedRuntimeCsv(input2) {
18344
18564
  };
18345
18565
  cleanRows[rowIndex] = {
18346
18566
  ...baseRow,
18347
- ...Object.fromEntries(
18348
- Object.entries(mergeRow).map(compactOverlayCell)
18349
- )
18567
+ ...Object.fromEntries(Object.entries(mergeRow).map(compactOverlayCell))
18350
18568
  };
18351
18569
  }
18352
18570
  const columns = dataExportColumns(
@@ -18770,6 +18988,11 @@ function collectWaterfallAliasSpecs(config) {
18770
18988
  aliases.push({
18771
18989
  alias,
18772
18990
  childAliases: activeChildren.map((child) => child.alias).filter(Boolean),
18991
+ childRunIfJsByAlias: new Map(
18992
+ activeChildren.map(
18993
+ (child) => [child.alias, child.run_if_js]
18994
+ )
18995
+ ),
18773
18996
  childToolsByAlias: new Map(
18774
18997
  activeChildren.map(
18775
18998
  (child) => [child.alias, child.tool.trim()]
@@ -19004,7 +19227,8 @@ function collectEmptyWaterfallIssues(input2) {
19004
19227
  });
19005
19228
  const issues = [];
19006
19229
  aliases.forEach((spec) => {
19007
- if (waterfallExecutionSignal(input2.status, spec) === "all_condition_skipped") {
19230
+ const executionSignal = waterfallExecutionSignal(input2.status, spec);
19231
+ if (executionSignal === "all_condition_skipped" || executionSignal === "unknown" && waterfallChildrenAreStaticallySkipped(spec)) {
19008
19232
  return;
19009
19233
  }
19010
19234
  const logicalRows = /* @__PURE__ */ new Map();
@@ -19046,6 +19270,22 @@ function collectEmptyWaterfallIssues(input2) {
19046
19270
  });
19047
19271
  return issues;
19048
19272
  }
19273
+ function waterfallChildrenAreStaticallySkipped(spec) {
19274
+ const childAliases = spec.childAliases ?? [];
19275
+ if (childAliases.length === 0 || !spec.childRunIfJsByAlias) {
19276
+ return false;
19277
+ }
19278
+ return childAliases.every(
19279
+ (alias) => runIfJsAlwaysReturnsFalse(spec.childRunIfJsByAlias?.get(alias))
19280
+ );
19281
+ }
19282
+ function runIfJsAlwaysReturnsFalse(source) {
19283
+ if (typeof source !== "string") {
19284
+ return false;
19285
+ }
19286
+ const normalized = source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|\s)\/\/.*$/gm, "").trim();
19287
+ return /^(?:return\s+)?\(?\s*false\s*\)?\s*;?$/.test(normalized);
19288
+ }
19049
19289
  function waterfallExecutionSignal(status, spec) {
19050
19290
  const childAliases = spec.childAliases ?? [];
19051
19291
  if (childAliases.length === 0) {
@@ -19322,10 +19562,11 @@ function rewriteEnrichJsonStatus(input2) {
19322
19562
  if (failedRows === 0 || !isRecord7(rewritten)) {
19323
19563
  return rewritten;
19324
19564
  }
19565
+ const partialStatus = selectedRows > 0 && failedRows < selectedRows ? "partial_success" : "failed";
19325
19566
  return {
19326
19567
  ...rewritten,
19327
- ...rewritten.status === "completed" ? { status: "failed" } : {},
19328
- ...isRecord7(rewritten.run) && rewritten.run.status === "completed" ? { run: { ...rewritten.run, status: "failed" } } : {}
19568
+ ...rewritten.status === "completed" || rewritten.status === "failed" ? { status: partialStatus } : {},
19569
+ ...isRecord7(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
19329
19570
  };
19330
19571
  }
19331
19572
  function summarizeFailedJobError(value) {
@@ -19361,6 +19602,12 @@ function collectEnrichFollowUpCommands(input2) {
19361
19602
  command: `deepline runs get ${input2.runId} --full --json`
19362
19603
  });
19363
19604
  }
19605
+ if (input2.runId && input2.outputPath) {
19606
+ addEnrichRowsExportFollowUpCommand(commands, seen, {
19607
+ runId: input2.runId,
19608
+ outputPath: input2.outputPath
19609
+ });
19610
+ }
19364
19611
  collectDatasetFollowUpCommands(input2.status, {
19365
19612
  runId: input2.runId,
19366
19613
  outputPath: input2.outputPath,
@@ -19369,17 +19616,17 @@ function collectEnrichFollowUpCommands(input2) {
19369
19616
  path: "result",
19370
19617
  depth: 0
19371
19618
  });
19372
- if (input2.runId && input2.outputPath && !commands.some((command) => command.label === "export enrich rows")) {
19373
- addEnrichFollowUpCommand(commands, seen, {
19374
- label: "export enrich rows",
19375
- path: GENERATED_ENRICH_ROWS_TABLE_NAMESPACE,
19376
- command: `deepline runs export ${input2.runId} --dataset ${GENERATED_ENRICH_ROWS_TABLE_NAMESPACE} --out ${shellSingleQuote2(
19377
- (0, import_node_path12.resolve)(input2.outputPath)
19378
- )}`
19379
- });
19380
- }
19381
19619
  return commands.slice(0, 8);
19382
19620
  }
19621
+ function addEnrichRowsExportFollowUpCommand(commands, seen, input2) {
19622
+ addEnrichFollowUpCommand(commands, seen, {
19623
+ label: "export enrich rows",
19624
+ path: GENERATED_ENRICH_ROWS_TABLE_NAMESPACE,
19625
+ command: `deepline runs export ${input2.runId} --dataset ${GENERATED_ENRICH_ROWS_TABLE_NAMESPACE} --out ${shellSingleQuote2(
19626
+ (0, import_node_path12.resolve)(input2.outputPath)
19627
+ )}`
19628
+ });
19629
+ }
19383
19630
  function sidecarEnrichRowsExportPath(outputPath) {
19384
19631
  const resolved = (0, import_node_path12.resolve)(outputPath);
19385
19632
  const ext = (0, import_node_path12.extname)(resolved) || ".csv";
@@ -19520,7 +19767,15 @@ async function maybeEmitEnrichFailureReport(input2) {
19520
19767
  status: input2.status,
19521
19768
  rowRange: input2.statusRowRange ?? input2.rowRange
19522
19769
  });
19523
- const jobs = rowJobs.length > 0 || statusJobs.length > 0 || input2.status === void 0 ? mergeEnrichFailureJobs(rowJobs, statusJobs) : [];
19770
+ const customerDbJobs = input2.status === void 0 || rowJobs.length > 0 || statusJobs.length > 0 ? [] : await collectCustomerDbFailureJobs({
19771
+ client: input2.client,
19772
+ status: input2.status,
19773
+ config: input2.config
19774
+ });
19775
+ const jobs = rowJobs.length > 0 || statusJobs.length > 0 || customerDbJobs.length > 0 || input2.status === void 0 ? mergeEnrichFailureJobs(
19776
+ mergeEnrichFailureJobs(rowJobs, statusJobs),
19777
+ customerDbJobs
19778
+ ) : [];
19524
19779
  if (jobs.length === 0 && enrichIssues.length === 0) {
19525
19780
  return null;
19526
19781
  }
@@ -19626,6 +19881,8 @@ async function fetchBackingRowsForCsvExport(input2) {
19626
19881
  const hasExplicitExpectedRows = typeof input2.expectedRows === "number" && input2.expectedRows > 0;
19627
19882
  const minimumExpectedRows = hasExplicitExpectedRows ? Math.trunc(Number(input2.expectedRows)) : input2.rowsInfo.totalRows;
19628
19883
  let lastExpectedTotal = minimumExpectedRows;
19884
+ const expectedSourceRowStart = input2.sourceRowStart ?? 0;
19885
+ const expectedSourceRowEnd = expectedSourceRowStart + Math.max(0, minimumExpectedRows) - 1;
19629
19886
  for (; ; ) {
19630
19887
  const sheetRows = [];
19631
19888
  let offset = 0;
@@ -19641,19 +19898,39 @@ async function fetchBackingRowsForCsvExport(input2) {
19641
19898
  });
19642
19899
  sheetRows.push(...page.rows);
19643
19900
  const summaryTotal = page.summary?.stats?.total;
19644
- if (typeof summaryTotal === "number" && Number.isFinite(summaryTotal)) {
19901
+ if (!hasExplicitExpectedRows && typeof summaryTotal === "number" && Number.isFinite(summaryTotal)) {
19645
19902
  expectedTotal = Math.max(expectedTotal, Math.trunc(summaryTotal));
19646
19903
  }
19647
- if (page.rows.length < ENRICH_EXPORT_PAGE_SIZE || sheetRows.length >= expectedTotal) {
19904
+ let hasRequiredRows = sheetRows.length >= expectedTotal;
19905
+ if (hasExplicitExpectedRows) {
19906
+ const exportableRows = coalesceExportableSheetRows(
19907
+ sheetRows.map((row) => exportableSheetRow2(row, input2.sourceRowStart ?? 0)).filter((row) => Boolean(row)),
19908
+ input2.sourceRowStart ?? 0
19909
+ ).filter(
19910
+ (row) => sourceRowIndexFromEnrichRow(
19911
+ row,
19912
+ expectedSourceRowStart,
19913
+ expectedSourceRowEnd
19914
+ ) !== null
19915
+ );
19916
+ hasRequiredRows = exportableRows.length >= minimumExpectedRows;
19917
+ }
19918
+ if (page.rows.length < ENRICH_EXPORT_PAGE_SIZE || hasRequiredRows) {
19648
19919
  break;
19649
19920
  }
19650
19921
  offset += page.rows.length;
19651
19922
  }
19652
19923
  const rawRows = sheetRows.map((row) => exportableSheetRow2(row, input2.sourceRowStart ?? 0)).filter((row) => Boolean(row));
19653
- const rows = coalesceExportableSheetRows(
19654
- rawRows,
19655
- input2.sourceRowStart ?? 0
19656
- );
19924
+ let rows = coalesceExportableSheetRows(rawRows, input2.sourceRowStart ?? 0);
19925
+ if (hasExplicitExpectedRows) {
19926
+ rows = rows.filter(
19927
+ (row) => sourceRowIndexFromEnrichRow(
19928
+ row,
19929
+ expectedSourceRowStart,
19930
+ expectedSourceRowEnd
19931
+ ) !== null
19932
+ );
19933
+ }
19657
19934
  lastRows = rows;
19658
19935
  lastExpectedTotal = expectedTotal;
19659
19936
  const requiredExportRows = hasExplicitExpectedRows ? minimumExpectedRows : expectedTotal;
@@ -20307,6 +20584,7 @@ function registerEnrichCommand(program) {
20307
20584
  }
20308
20585
  if (input2.json) {
20309
20586
  runArgs.push("--json");
20587
+ runArgs.push("--full");
20310
20588
  } else {
20311
20589
  runArgs.push("--logs");
20312
20590
  }
@@ -20429,6 +20707,11 @@ function registerEnrichCommand(program) {
20429
20707
  partial: true
20430
20708
  } : {}
20431
20709
  } : null,
20710
+ customer_db: enrichCustomerDbJson({
20711
+ status: chunk.status,
20712
+ client: client2,
20713
+ outputPath: enrichIssueFollowUpOutputPath ?? committedExportResult2?.path ?? outputPath
20714
+ }),
20432
20715
  ...enrichReportJson(failureReport3)
20433
20716
  });
20434
20717
  } else {
@@ -20503,6 +20786,11 @@ function registerEnrichCommand(program) {
20503
20786
  enrichedRows: totalEnrichedRows,
20504
20787
  path: finalExportResult.path
20505
20788
  } : null,
20789
+ customer_db: enrichCustomerDbJson({
20790
+ status: lastStatus,
20791
+ client: client2,
20792
+ outputPath: enrichIssueFollowUpOutputPath ?? finalExportResult?.path ?? outputPath
20793
+ }),
20506
20794
  ...enrichReportJson(failureReport2)
20507
20795
  });
20508
20796
  }
@@ -20542,6 +20830,11 @@ function registerEnrichCommand(program) {
20542
20830
  ok: false,
20543
20831
  run: status,
20544
20832
  output: enrichOutputJson(committedExportResult2),
20833
+ customer_db: enrichCustomerDbJson({
20834
+ status,
20835
+ client: client2,
20836
+ outputPath: enrichIssueFollowUpOutputPath ?? committedExportResult2?.path ?? outputPath
20837
+ }),
20545
20838
  ...enrichReportJson(failureReport2)
20546
20839
  });
20547
20840
  }
@@ -20572,6 +20865,11 @@ function registerEnrichCommand(program) {
20572
20865
  ok: !failureReport2,
20573
20866
  run,
20574
20867
  output: enrichOutputJson(committedExportResult2),
20868
+ customer_db: enrichCustomerDbJson({
20869
+ status,
20870
+ client: client2,
20871
+ outputPath: enrichIssueFollowUpOutputPath ?? committedExportResult2?.path ?? outputPath
20872
+ }),
20575
20873
  ...enrichReportJson(failureReport2)
20576
20874
  });
20577
20875
  if (failureReport2) {
@@ -608,10 +608,10 @@ var SDK_RELEASE = {
608
608
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
609
609
  // fields shipped in 0.1.153.
610
610
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
611
- version: "0.1.185",
611
+ version: "0.1.186",
612
612
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
613
613
  supportPolicy: {
614
- latest: "0.1.185",
614
+ latest: "0.1.186",
615
615
  minimumSupported: "0.1.53",
616
616
  deprecatedBelow: "0.1.53",
617
617
  commandMinimumSupported: [
@@ -16215,7 +16215,7 @@ function canInlineRunJavascript(command) {
16215
16215
  return true;
16216
16216
  }
16217
16217
  function renderExtractFunction(command, indentSpaces) {
16218
- return command.extract_js ? `({ row, result, data, raw, pick, extract, extractList, target, get }) => { const input = row; const context = row;
16218
+ return command.extract_js ? `({ row, result, data, raw, pick, extract, extractList, target, get }) => { const input = row; const context = row; const output_data = __dlLegacyOutputData(result, raw);
16219
16219
  ${indent(renderJavascriptBody(command.extract_js), indentSpaces)}
16220
16220
  }` : "null";
16221
16221
  }
@@ -16843,8 +16843,13 @@ function helperSource() {
16843
16843
  ` __dlPushCandidate(candidates, record.data);`,
16844
16844
  ` __dlPushCandidate(candidates, record.result);`,
16845
16845
  ` __dlPushCandidate(candidates, record.output);`,
16846
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'data.data'));`,
16846
16847
  ` __dlPushCandidate(candidates, __dlGetByPath(record, 'result.data'));`,
16848
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'result.data.data'));`,
16849
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'output.data'));`,
16850
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'output.data.data'));`,
16847
16851
  ` __dlPushCandidate(candidates, __dlGetByPath(record, 'output.body'));`,
16852
+ ` __dlPushCandidate(candidates, __dlGetByPath(record, 'output.body.data'));`,
16848
16853
  ` __dlPushCandidate(candidates, __dlGetByPath(record, 'toolResponse.raw'));`,
16849
16854
  ` __dlPushCandidate(candidates, __dlGetByPath(record, 'toolOutput.raw'));`,
16850
16855
  ` return candidates;`,
@@ -17241,13 +17246,37 @@ function helperSource() {
17241
17246
  ` return { ...defaults, ...(existing as Record<string, unknown>) };`,
17242
17247
  `}`,
17243
17248
  ``,
17249
+ `function __dlCompactJavascriptContext(value: unknown, depth = 0): unknown {`,
17250
+ ` if (depth > 8) return '[Object]';`,
17251
+ ` if (typeof value === 'string') return value.length > 20000 ? value.slice(0, 20000) + '...[truncated]' : value;`,
17252
+ ` if (!value || typeof value !== 'object') return value;`,
17253
+ ` if (Array.isArray(value)) {`,
17254
+ ` const limit = depth <= 2 ? 25 : 10;`,
17255
+ ` const items = value.slice(0, limit).map((entry) => __dlCompactJavascriptContext(entry, depth + 1));`,
17256
+ ` if (value.length > limit) items.push({ __deepline_truncated_items: value.length - limit });`,
17257
+ ` return items;`,
17258
+ ` }`,
17259
+ ` const out: Record<string, unknown> = {};`,
17260
+ ` let count = 0;`,
17261
+ ` for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {`,
17262
+ ` count += 1;`,
17263
+ ` if (count > 80) {`,
17264
+ ` out.__deepline_truncated_fields = count - 80;`,
17265
+ ` break;`,
17266
+ ` }`,
17267
+ ` out[key] = __dlCompactJavascriptContext(entry, depth + 1);`,
17268
+ ` }`,
17269
+ ` return out;`,
17270
+ `}`,
17271
+ ``,
17244
17272
  `function __dlRuntimePayload(tool: string, payload: Record<string, unknown>, row: Record<string, unknown>): Record<string, unknown> {`,
17245
17273
  ` if (tool !== 'run_javascript') return payload;`,
17274
+ ` const compactRow = __dlCompactJavascriptContext(row) as Record<string, unknown>;`,
17246
17275
  ` return {`,
17247
17276
  ` ...payload,`,
17248
- ` row: __dlMergeContextRecord(payload.row, row),`,
17249
- ` input: __dlMergeContextRecord(payload.input, row),`,
17250
- ` context: __dlMergeContextRecord(payload.context, row),`,
17277
+ ` row: __dlMergeContextRecord(payload.row, compactRow),`,
17278
+ ` input: __dlMergeContextRecord(payload.input, compactRow),`,
17279
+ ` context: __dlMergeContextRecord(payload.context, compactRow),`,
17251
17280
  ` };`,
17252
17281
  `}`,
17253
17282
  ``,
@@ -18250,6 +18279,125 @@ function enrichOutputJson(exportResult) {
18250
18279
  ...exportResult.partial ? { rows: exportResult.rows, partial: true } : {}
18251
18280
  };
18252
18281
  }
18282
+ function readFirstEnrichDatasetActions(value) {
18283
+ const seen = /* @__PURE__ */ new Set();
18284
+ const walk = (candidate, options) => {
18285
+ if (!candidate || typeof candidate !== "object" || seen.has(candidate)) {
18286
+ return null;
18287
+ }
18288
+ seen.add(candidate);
18289
+ if (Array.isArray(candidate)) {
18290
+ for (const entry of candidate) {
18291
+ const found = walk(entry, options);
18292
+ if (found) return found;
18293
+ }
18294
+ return null;
18295
+ }
18296
+ const record = candidate;
18297
+ const actions = isRecord7(record.actions) ? record.actions : null;
18298
+ const query = isRecord7(actions?.query) ? actions.query : null;
18299
+ if (query?.kind === "deepline_db_query") {
18300
+ return {
18301
+ dataset: record,
18302
+ query,
18303
+ ...isRecord7(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
18304
+ };
18305
+ }
18306
+ if (options.allowLegacy && record.kind === "dataset" && typeof record.queryDatasetCommand === "string" && record.queryDatasetCommand.trim()) {
18307
+ return {
18308
+ dataset: record,
18309
+ queryDatasetCommand: record.queryDatasetCommand.trim(),
18310
+ ...typeof record.slowExportAsCsvCommand === "string" && record.slowExportAsCsvCommand.trim() ? { slowExportAsCsvCommand: record.slowExportAsCsvCommand.trim() } : {}
18311
+ };
18312
+ }
18313
+ for (const [key, entry] of Object.entries(record)) {
18314
+ if (key === "preview") {
18315
+ continue;
18316
+ }
18317
+ const found = walk(entry, options);
18318
+ if (found) return found;
18319
+ }
18320
+ return null;
18321
+ };
18322
+ const modern = walk(value, { allowLegacy: false });
18323
+ if (modern) {
18324
+ return modern;
18325
+ }
18326
+ seen.clear();
18327
+ return walk(value, { allowLegacy: true });
18328
+ }
18329
+ function actionStringField(record, key) {
18330
+ const value = record[key];
18331
+ return typeof value === "string" && value.trim() ? value.trim() : null;
18332
+ }
18333
+ function parseSqlFromDbQueryCommand(command) {
18334
+ if (!command) {
18335
+ return null;
18336
+ }
18337
+ const match = command.match(/\s--sql\s+('(?:'\\''|[^'])*'|"(?:"\\"|[^"])*")/);
18338
+ if (!match?.[1]) {
18339
+ return null;
18340
+ }
18341
+ const raw = match[1];
18342
+ if (raw.startsWith("'") && raw.endsWith("'")) {
18343
+ return raw.slice(1, -1).replace(/'\\''/g, "'");
18344
+ }
18345
+ return decodeStringLiteral(raw);
18346
+ }
18347
+ function enrichCustomerDbJson(input2) {
18348
+ const actions = readFirstEnrichDatasetActions(input2.status);
18349
+ if (!actions) {
18350
+ return null;
18351
+ }
18352
+ const query = actions.query ?? {};
18353
+ const dataset = actions.dataset;
18354
+ const sql = actionStringField(query, "sql") ?? parseSqlFromDbQueryCommand(actions.queryDatasetCommand);
18355
+ const datasetPath = actionStringField(query, "datasetPath") ?? actionStringField(dataset, "path") ?? actionStringField(dataset, "tableNamespace");
18356
+ const api = isRecord7(query.api) ? query.api : null;
18357
+ const apiPath = actionStringField(api ?? {}, "path") ?? "/api/v2/db/query";
18358
+ const apiMethod = actionStringField(api ?? {}, "method") ?? "POST";
18359
+ if (!datasetPath) {
18360
+ return null;
18361
+ }
18362
+ const maxRows = typeof query.maxRows === "number" && Number.isFinite(query.maxRows) ? Math.trunc(query.maxRows) : void 0;
18363
+ const runId = extractRunId(input2.status) ?? actionStringField(actions.exportCsv ?? {}, "runId");
18364
+ const exportDatasetPath = actionStringField(actions.exportCsv ?? {}, "datasetPath") ?? datasetPath;
18365
+ const tableNamespace = actionStringField(query, "tableNamespace") ?? actionStringField(dataset, "tableNamespace");
18366
+ const sqlTableName = actionStringField(query, "sqlTableName");
18367
+ const sqlQualifiedTableName = actionStringField(
18368
+ query,
18369
+ "sqlQualifiedTableName"
18370
+ );
18371
+ const command = actions.queryDatasetCommand ?? (sql ? `deepline db query --sql ${shellSingleQuote2(sql)}${maxRows !== void 0 ? ` --max-rows ${maxRows}` : ""} --json` : null);
18372
+ return {
18373
+ runId,
18374
+ datasetPath,
18375
+ ...tableNamespace ? { tableNamespace } : {},
18376
+ ...sqlTableName ? { sqlTableName } : {},
18377
+ ...sqlQualifiedTableName ? { sqlQualifiedTableName } : {},
18378
+ ...sql ? { sql } : {},
18379
+ ...actions.query ? {
18380
+ api: {
18381
+ method: apiMethod,
18382
+ path: apiPath,
18383
+ url: `${input2.client.baseUrl.replace(/\/$/, "")}${apiPath}`
18384
+ }
18385
+ } : {},
18386
+ ...maxRows !== void 0 ? { maxRows } : {},
18387
+ ...command ? { command } : {},
18388
+ ...actions.exportCsv || actions.slowExportAsCsvCommand ? {
18389
+ export: {
18390
+ datasetPath: exportDatasetPath,
18391
+ ...actions.slowExportAsCsvCommand ? { command: actions.slowExportAsCsvCommand } : runId && input2.outputPath ? {
18392
+ command: `deepline runs export ${runId} --dataset ${shellSingleQuote2(
18393
+ exportDatasetPath
18394
+ )} --out ${shellSingleQuote2(resolve9(input2.outputPath))}`
18395
+ } : {},
18396
+ action: actions.exportCsv ?? {}
18397
+ }
18398
+ } : {}
18399
+ };
18400
+ }
18253
18401
  function enrichReportJson(report) {
18254
18402
  if (!report) {
18255
18403
  return {};
@@ -18270,6 +18418,78 @@ function enrichReportJson(report) {
18270
18418
  } : {}
18271
18419
  };
18272
18420
  }
18421
+ function sqlStringLiteral(value) {
18422
+ return `'${value.replace(/'/g, "''")}'`;
18423
+ }
18424
+ function failureAliasFromCellMeta(cellMeta) {
18425
+ if (!isRecord7(cellMeta)) {
18426
+ return null;
18427
+ }
18428
+ for (const [alias, meta] of Object.entries(cellMeta)) {
18429
+ if (!isRecord7(meta)) {
18430
+ continue;
18431
+ }
18432
+ const failure = failureCellFromMeta(meta, {});
18433
+ if (!failure) {
18434
+ continue;
18435
+ }
18436
+ return {
18437
+ alias,
18438
+ ...typeof failure.error === "string" ? { error: failure.error } : {},
18439
+ ...typeof failure.operation === "string" ? { operation: failure.operation } : {},
18440
+ ...typeof failure.provider === "string" ? { provider: failure.provider } : {}
18441
+ };
18442
+ }
18443
+ return null;
18444
+ }
18445
+ async function collectCustomerDbFailureJobs(input2) {
18446
+ const customerDb = enrichCustomerDbJson({
18447
+ status: input2.status,
18448
+ client: input2.client
18449
+ });
18450
+ if (!customerDb?.runId || !customerDb.sqlQualifiedTableName) {
18451
+ return [];
18452
+ }
18453
+ const fallbackAliases = collectHardFailureAliasSpecs(input2.config);
18454
+ const fallbackAlias = fallbackAliases[0]?.alias ?? "enrich";
18455
+ const aliasIndexByName = new Map(
18456
+ fallbackAliases.map((spec, index) => [normalizeAlias2(spec.alias), index])
18457
+ );
18458
+ const sql = `select _input_index, _status, _error, _cell_meta from ${customerDb.sqlQualifiedTableName} where _run_id = ${sqlStringLiteral(customerDb.runId)} and (_error is not null or lower(coalesce(_status, '')) in ('failed', 'error')) order by _input_index limit 1000`;
18459
+ const result = await input2.client.queryCustomerDb({
18460
+ sql,
18461
+ maxRows: 1e3
18462
+ });
18463
+ const rows = Array.isArray(result.rows) ? result.rows : [];
18464
+ const failedRows = rows.filter((row) => {
18465
+ const status = typeof row._status === "string" ? row._status.trim().toLowerCase() : "";
18466
+ return typeof row._error === "string" && row._error.trim() || status === "failed" || status === "error";
18467
+ });
18468
+ return failedRows.map((row, index) => {
18469
+ const metaFailure = failureAliasFromCellMeta(row._cell_meta);
18470
+ const alias = metaFailure?.alias ?? fallbackAlias;
18471
+ const normalizedAlias = normalizeAlias2(alias);
18472
+ const rowId = typeof row._input_index === "number" ? row._input_index : typeof row._input_index === "string" && row._input_index.trim() ? Number.parseInt(row._input_index, 10) : index;
18473
+ const rawError = metaFailure?.error ?? (typeof row._error === "string" && row._error.trim() ? row._error.trim() : `Column status: ${String(row._status ?? "failed")}`);
18474
+ const message = enrichFailureMessageWithOperation(
18475
+ rawError,
18476
+ metaFailure?.operation ?? fallbackAliases.find(
18477
+ (spec) => normalizeAlias2(spec.alias) === normalizedAlias
18478
+ )?.operation
18479
+ );
18480
+ return {
18481
+ job_id: `row-${Number.isFinite(rowId) ? rowId : index}-${normalizedAlias || "enrich"}`,
18482
+ row_id: Number.isFinite(rowId) ? rowId : index,
18483
+ col_index: aliasIndexByName.get(normalizedAlias) ?? 0,
18484
+ column: alias,
18485
+ status: "failed",
18486
+ last_error: message,
18487
+ error: message,
18488
+ ...metaFailure?.operation ? { operation: metaFailure.operation } : {},
18489
+ ...metaFailure?.provider ? { provider: metaFailure.provider } : {}
18490
+ };
18491
+ });
18492
+ }
18273
18493
  async function buildEnrichFailureReport(input2) {
18274
18494
  const fallbackRowsInfo = input2.exportResult ? null : extractCanonicalRowsInfo(input2.status);
18275
18495
  return maybeEmitEnrichFailureReport({
@@ -18371,9 +18591,7 @@ async function writeSlimBatchedRuntimeCsv(input2) {
18371
18591
  };
18372
18592
  cleanRows[rowIndex] = {
18373
18593
  ...baseRow,
18374
- ...Object.fromEntries(
18375
- Object.entries(mergeRow).map(compactOverlayCell)
18376
- )
18594
+ ...Object.fromEntries(Object.entries(mergeRow).map(compactOverlayCell))
18377
18595
  };
18378
18596
  }
18379
18597
  const columns = dataExportColumns(
@@ -18797,6 +19015,11 @@ function collectWaterfallAliasSpecs(config) {
18797
19015
  aliases.push({
18798
19016
  alias,
18799
19017
  childAliases: activeChildren.map((child) => child.alias).filter(Boolean),
19018
+ childRunIfJsByAlias: new Map(
19019
+ activeChildren.map(
19020
+ (child) => [child.alias, child.run_if_js]
19021
+ )
19022
+ ),
18800
19023
  childToolsByAlias: new Map(
18801
19024
  activeChildren.map(
18802
19025
  (child) => [child.alias, child.tool.trim()]
@@ -19031,7 +19254,8 @@ function collectEmptyWaterfallIssues(input2) {
19031
19254
  });
19032
19255
  const issues = [];
19033
19256
  aliases.forEach((spec) => {
19034
- if (waterfallExecutionSignal(input2.status, spec) === "all_condition_skipped") {
19257
+ const executionSignal = waterfallExecutionSignal(input2.status, spec);
19258
+ if (executionSignal === "all_condition_skipped" || executionSignal === "unknown" && waterfallChildrenAreStaticallySkipped(spec)) {
19035
19259
  return;
19036
19260
  }
19037
19261
  const logicalRows = /* @__PURE__ */ new Map();
@@ -19073,6 +19297,22 @@ function collectEmptyWaterfallIssues(input2) {
19073
19297
  });
19074
19298
  return issues;
19075
19299
  }
19300
+ function waterfallChildrenAreStaticallySkipped(spec) {
19301
+ const childAliases = spec.childAliases ?? [];
19302
+ if (childAliases.length === 0 || !spec.childRunIfJsByAlias) {
19303
+ return false;
19304
+ }
19305
+ return childAliases.every(
19306
+ (alias) => runIfJsAlwaysReturnsFalse(spec.childRunIfJsByAlias?.get(alias))
19307
+ );
19308
+ }
19309
+ function runIfJsAlwaysReturnsFalse(source) {
19310
+ if (typeof source !== "string") {
19311
+ return false;
19312
+ }
19313
+ const normalized = source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|\s)\/\/.*$/gm, "").trim();
19314
+ return /^(?:return\s+)?\(?\s*false\s*\)?\s*;?$/.test(normalized);
19315
+ }
19076
19316
  function waterfallExecutionSignal(status, spec) {
19077
19317
  const childAliases = spec.childAliases ?? [];
19078
19318
  if (childAliases.length === 0) {
@@ -19349,10 +19589,11 @@ function rewriteEnrichJsonStatus(input2) {
19349
19589
  if (failedRows === 0 || !isRecord7(rewritten)) {
19350
19590
  return rewritten;
19351
19591
  }
19592
+ const partialStatus = selectedRows > 0 && failedRows < selectedRows ? "partial_success" : "failed";
19352
19593
  return {
19353
19594
  ...rewritten,
19354
- ...rewritten.status === "completed" ? { status: "failed" } : {},
19355
- ...isRecord7(rewritten.run) && rewritten.run.status === "completed" ? { run: { ...rewritten.run, status: "failed" } } : {}
19595
+ ...rewritten.status === "completed" || rewritten.status === "failed" ? { status: partialStatus } : {},
19596
+ ...isRecord7(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
19356
19597
  };
19357
19598
  }
19358
19599
  function summarizeFailedJobError(value) {
@@ -19388,6 +19629,12 @@ function collectEnrichFollowUpCommands(input2) {
19388
19629
  command: `deepline runs get ${input2.runId} --full --json`
19389
19630
  });
19390
19631
  }
19632
+ if (input2.runId && input2.outputPath) {
19633
+ addEnrichRowsExportFollowUpCommand(commands, seen, {
19634
+ runId: input2.runId,
19635
+ outputPath: input2.outputPath
19636
+ });
19637
+ }
19391
19638
  collectDatasetFollowUpCommands(input2.status, {
19392
19639
  runId: input2.runId,
19393
19640
  outputPath: input2.outputPath,
@@ -19396,17 +19643,17 @@ function collectEnrichFollowUpCommands(input2) {
19396
19643
  path: "result",
19397
19644
  depth: 0
19398
19645
  });
19399
- if (input2.runId && input2.outputPath && !commands.some((command) => command.label === "export enrich rows")) {
19400
- addEnrichFollowUpCommand(commands, seen, {
19401
- label: "export enrich rows",
19402
- path: GENERATED_ENRICH_ROWS_TABLE_NAMESPACE,
19403
- command: `deepline runs export ${input2.runId} --dataset ${GENERATED_ENRICH_ROWS_TABLE_NAMESPACE} --out ${shellSingleQuote2(
19404
- resolve9(input2.outputPath)
19405
- )}`
19406
- });
19407
- }
19408
19646
  return commands.slice(0, 8);
19409
19647
  }
19648
+ function addEnrichRowsExportFollowUpCommand(commands, seen, input2) {
19649
+ addEnrichFollowUpCommand(commands, seen, {
19650
+ label: "export enrich rows",
19651
+ path: GENERATED_ENRICH_ROWS_TABLE_NAMESPACE,
19652
+ command: `deepline runs export ${input2.runId} --dataset ${GENERATED_ENRICH_ROWS_TABLE_NAMESPACE} --out ${shellSingleQuote2(
19653
+ resolve9(input2.outputPath)
19654
+ )}`
19655
+ });
19656
+ }
19410
19657
  function sidecarEnrichRowsExportPath(outputPath) {
19411
19658
  const resolved = resolve9(outputPath);
19412
19659
  const ext = extname(resolved) || ".csv";
@@ -19547,7 +19794,15 @@ async function maybeEmitEnrichFailureReport(input2) {
19547
19794
  status: input2.status,
19548
19795
  rowRange: input2.statusRowRange ?? input2.rowRange
19549
19796
  });
19550
- const jobs = rowJobs.length > 0 || statusJobs.length > 0 || input2.status === void 0 ? mergeEnrichFailureJobs(rowJobs, statusJobs) : [];
19797
+ const customerDbJobs = input2.status === void 0 || rowJobs.length > 0 || statusJobs.length > 0 ? [] : await collectCustomerDbFailureJobs({
19798
+ client: input2.client,
19799
+ status: input2.status,
19800
+ config: input2.config
19801
+ });
19802
+ const jobs = rowJobs.length > 0 || statusJobs.length > 0 || customerDbJobs.length > 0 || input2.status === void 0 ? mergeEnrichFailureJobs(
19803
+ mergeEnrichFailureJobs(rowJobs, statusJobs),
19804
+ customerDbJobs
19805
+ ) : [];
19551
19806
  if (jobs.length === 0 && enrichIssues.length === 0) {
19552
19807
  return null;
19553
19808
  }
@@ -19653,6 +19908,8 @@ async function fetchBackingRowsForCsvExport(input2) {
19653
19908
  const hasExplicitExpectedRows = typeof input2.expectedRows === "number" && input2.expectedRows > 0;
19654
19909
  const minimumExpectedRows = hasExplicitExpectedRows ? Math.trunc(Number(input2.expectedRows)) : input2.rowsInfo.totalRows;
19655
19910
  let lastExpectedTotal = minimumExpectedRows;
19911
+ const expectedSourceRowStart = input2.sourceRowStart ?? 0;
19912
+ const expectedSourceRowEnd = expectedSourceRowStart + Math.max(0, minimumExpectedRows) - 1;
19656
19913
  for (; ; ) {
19657
19914
  const sheetRows = [];
19658
19915
  let offset = 0;
@@ -19668,19 +19925,39 @@ async function fetchBackingRowsForCsvExport(input2) {
19668
19925
  });
19669
19926
  sheetRows.push(...page.rows);
19670
19927
  const summaryTotal = page.summary?.stats?.total;
19671
- if (typeof summaryTotal === "number" && Number.isFinite(summaryTotal)) {
19928
+ if (!hasExplicitExpectedRows && typeof summaryTotal === "number" && Number.isFinite(summaryTotal)) {
19672
19929
  expectedTotal = Math.max(expectedTotal, Math.trunc(summaryTotal));
19673
19930
  }
19674
- if (page.rows.length < ENRICH_EXPORT_PAGE_SIZE || sheetRows.length >= expectedTotal) {
19931
+ let hasRequiredRows = sheetRows.length >= expectedTotal;
19932
+ if (hasExplicitExpectedRows) {
19933
+ const exportableRows = coalesceExportableSheetRows(
19934
+ sheetRows.map((row) => exportableSheetRow2(row, input2.sourceRowStart ?? 0)).filter((row) => Boolean(row)),
19935
+ input2.sourceRowStart ?? 0
19936
+ ).filter(
19937
+ (row) => sourceRowIndexFromEnrichRow(
19938
+ row,
19939
+ expectedSourceRowStart,
19940
+ expectedSourceRowEnd
19941
+ ) !== null
19942
+ );
19943
+ hasRequiredRows = exportableRows.length >= minimumExpectedRows;
19944
+ }
19945
+ if (page.rows.length < ENRICH_EXPORT_PAGE_SIZE || hasRequiredRows) {
19675
19946
  break;
19676
19947
  }
19677
19948
  offset += page.rows.length;
19678
19949
  }
19679
19950
  const rawRows = sheetRows.map((row) => exportableSheetRow2(row, input2.sourceRowStart ?? 0)).filter((row) => Boolean(row));
19680
- const rows = coalesceExportableSheetRows(
19681
- rawRows,
19682
- input2.sourceRowStart ?? 0
19683
- );
19951
+ let rows = coalesceExportableSheetRows(rawRows, input2.sourceRowStart ?? 0);
19952
+ if (hasExplicitExpectedRows) {
19953
+ rows = rows.filter(
19954
+ (row) => sourceRowIndexFromEnrichRow(
19955
+ row,
19956
+ expectedSourceRowStart,
19957
+ expectedSourceRowEnd
19958
+ ) !== null
19959
+ );
19960
+ }
19684
19961
  lastRows = rows;
19685
19962
  lastExpectedTotal = expectedTotal;
19686
19963
  const requiredExportRows = hasExplicitExpectedRows ? minimumExpectedRows : expectedTotal;
@@ -20334,6 +20611,7 @@ function registerEnrichCommand(program) {
20334
20611
  }
20335
20612
  if (input2.json) {
20336
20613
  runArgs.push("--json");
20614
+ runArgs.push("--full");
20337
20615
  } else {
20338
20616
  runArgs.push("--logs");
20339
20617
  }
@@ -20456,6 +20734,11 @@ function registerEnrichCommand(program) {
20456
20734
  partial: true
20457
20735
  } : {}
20458
20736
  } : null,
20737
+ customer_db: enrichCustomerDbJson({
20738
+ status: chunk.status,
20739
+ client: client2,
20740
+ outputPath: enrichIssueFollowUpOutputPath ?? committedExportResult2?.path ?? outputPath
20741
+ }),
20459
20742
  ...enrichReportJson(failureReport3)
20460
20743
  });
20461
20744
  } else {
@@ -20530,6 +20813,11 @@ function registerEnrichCommand(program) {
20530
20813
  enrichedRows: totalEnrichedRows,
20531
20814
  path: finalExportResult.path
20532
20815
  } : null,
20816
+ customer_db: enrichCustomerDbJson({
20817
+ status: lastStatus,
20818
+ client: client2,
20819
+ outputPath: enrichIssueFollowUpOutputPath ?? finalExportResult?.path ?? outputPath
20820
+ }),
20533
20821
  ...enrichReportJson(failureReport2)
20534
20822
  });
20535
20823
  }
@@ -20569,6 +20857,11 @@ function registerEnrichCommand(program) {
20569
20857
  ok: false,
20570
20858
  run: status,
20571
20859
  output: enrichOutputJson(committedExportResult2),
20860
+ customer_db: enrichCustomerDbJson({
20861
+ status,
20862
+ client: client2,
20863
+ outputPath: enrichIssueFollowUpOutputPath ?? committedExportResult2?.path ?? outputPath
20864
+ }),
20572
20865
  ...enrichReportJson(failureReport2)
20573
20866
  });
20574
20867
  }
@@ -20599,6 +20892,11 @@ function registerEnrichCommand(program) {
20599
20892
  ok: !failureReport2,
20600
20893
  run,
20601
20894
  output: enrichOutputJson(committedExportResult2),
20895
+ customer_db: enrichCustomerDbJson({
20896
+ status,
20897
+ client: client2,
20898
+ outputPath: enrichIssueFollowUpOutputPath ?? committedExportResult2?.path ?? outputPath
20899
+ }),
20602
20900
  ...enrichReportJson(failureReport2)
20603
20901
  });
20604
20902
  if (failureReport2) {
package/dist/index.js CHANGED
@@ -422,10 +422,10 @@ var SDK_RELEASE = {
422
422
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
423
423
  // fields shipped in 0.1.153.
424
424
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
425
- version: "0.1.185",
425
+ version: "0.1.186",
426
426
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
427
427
  supportPolicy: {
428
- latest: "0.1.185",
428
+ latest: "0.1.186",
429
429
  minimumSupported: "0.1.53",
430
430
  deprecatedBelow: "0.1.53",
431
431
  commandMinimumSupported: [
package/dist/index.mjs CHANGED
@@ -352,10 +352,10 @@ var SDK_RELEASE = {
352
352
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
353
353
  // fields shipped in 0.1.153.
354
354
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
355
- version: "0.1.185",
355
+ version: "0.1.186",
356
356
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
357
357
  supportPolicy: {
358
- latest: "0.1.185",
358
+ latest: "0.1.186",
359
359
  minimumSupported: "0.1.53",
360
360
  deprecatedBelow: "0.1.53",
361
361
  commandMinimumSupported: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.185",
3
+ "version": "0.1.186",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {