deepline 0.1.160 → 0.1.162

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.
@@ -222,8 +222,6 @@ var PROD_URL = "https://code.deepline.com";
222
222
  var DEFAULT_TIMEOUT = 6e4;
223
223
  var DEFAULT_MAX_RETRIES = 3;
224
224
  var PROJECT_DEEPLINE_ENV_FILE = ".env.deepline";
225
- var WORKSPACE_RESTORE_ENV_DIR = ".deepline";
226
- var WORKSPACE_RESTORE_ENV_FILE = ".env";
227
225
  var COWORK_IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
228
226
  ".auto-memory",
229
227
  ".claude",
@@ -538,18 +536,6 @@ function ensureProjectEnvIsIgnored(dir) {
538
536
  writeFileSync(gitignorePath, `${existing}${prefix}${entry}
539
537
  `, "utf-8");
540
538
  }
541
- function ensureWorkspaceRestoreEnvIsIgnored(workspaceDir) {
542
- const gitignorePath = join(workspaceDir, ".gitignore");
543
- const entry = `${WORKSPACE_RESTORE_ENV_DIR}/`;
544
- const existing = existsSync(gitignorePath) ? readFileSync(gitignorePath, "utf-8") : "";
545
- const alreadyIgnored = existing.split(/\r?\n/).map((line) => line.trim()).some(
546
- (line) => line === entry || line === `/${entry}` || line === WORKSPACE_RESTORE_ENV_DIR || line === `/${WORKSPACE_RESTORE_ENV_DIR}`
547
- );
548
- if (alreadyIgnored) return;
549
- const prefix = existing && !existing.endsWith("\n") ? "\n" : "";
550
- writeFileSync(gitignorePath, `${existing}${prefix}${entry}
551
- `, "utf-8");
552
- }
553
539
  function saveProjectDeeplineEnvValues(values, startDir = process.cwd()) {
554
540
  const target = resolveProjectPinTarget(startDir);
555
541
  if (!target.ok) {
@@ -563,27 +549,6 @@ function saveProjectDeeplineEnvValues(values, startDir = process.cwd()) {
563
549
  mergeProjectEnvFile(filePath, values);
564
550
  return [filePath];
565
551
  }
566
- function saveCoworkWorkspaceRestoreEnvValues(values, startDir = process.cwd()) {
567
- if (!isCoworkLikeSandbox()) return [];
568
- const target = resolveProjectPinTarget(startDir);
569
- if (!target.ok || target.source === "cwd") return [];
570
- const workspaceDir = target.dir;
571
- const filePath = join(
572
- workspaceDir,
573
- WORKSPACE_RESTORE_ENV_DIR,
574
- WORKSPACE_RESTORE_ENV_FILE
575
- );
576
- const existing = parseEnvFile(filePath);
577
- const merged = { ...existing, ...values };
578
- const dir = dirname(filePath);
579
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
580
- ensureWorkspaceRestoreEnvIsIgnored(workspaceDir);
581
- const allowedKeys = /* @__PURE__ */ new Set([HOST_URL_ENV, API_KEY_ENV]);
582
- const lines = Object.entries(merged).filter(([key, value]) => allowedKeys.has(key) && value !== "").map(([key, value]) => `${key}=${value}`);
583
- writeFileSync(filePath, `${lines.join("\n")}
584
- `, "utf-8");
585
- return [filePath];
586
- }
587
552
  function resolveProjectPinTarget(startDir = process.cwd()) {
588
553
  const nearestFile = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
589
554
  if (nearestFile && !isInIgnoredCoworkMount(nearestFile)) {
@@ -642,10 +607,10 @@ var SDK_RELEASE = {
642
607
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
643
608
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
644
609
  // fields shipped in 0.1.153.
645
- version: "0.1.160",
610
+ version: "0.1.162",
646
611
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
647
612
  supportPolicy: {
648
- latest: "0.1.160",
613
+ latest: "0.1.162",
649
614
  minimumSupported: "0.1.53",
650
615
  deprecatedBelow: "0.1.53",
651
616
  commandMinimumSupported: [
@@ -4745,9 +4710,6 @@ function saveEnvValues(values, baseUrl) {
4745
4710
  ...values[API_KEY_ENV] ? { [API_KEY_ENV]: values[API_KEY_ENV] } : {}
4746
4711
  };
4747
4712
  saveHostEnvValues(baseUrl, filtered);
4748
- if (filtered[API_KEY_ENV]) {
4749
- saveCoworkWorkspaceRestoreEnvValues(filtered);
4750
- }
4751
4713
  }
4752
4714
  async function httpJson(method, url, apiKey, body) {
4753
4715
  const headers = {
@@ -17807,7 +17769,7 @@ function fallbackRowsInfoForGeneratedEnrichExport(status, options) {
17807
17769
  columns: [],
17808
17770
  columnsExplicit: false,
17809
17771
  complete: false,
17810
- source: GENERATED_ENRICH_ROWS_TABLE_NAMESPACE,
17772
+ source: null,
17811
17773
  tableNamespace: GENERATED_ENRICH_ROWS_TABLE_NAMESPACE
17812
17774
  };
17813
17775
  }
@@ -17828,10 +17790,45 @@ function hasLossyPreviewPlaceholder(value, depth = 0) {
17828
17790
  }
17829
17791
  return false;
17830
17792
  }
17793
+ function statusReferencesGeneratedEnrichRows(value, depth = 0) {
17794
+ if (depth > 12 || value === null || value === void 0) {
17795
+ return false;
17796
+ }
17797
+ if (typeof value === "string") {
17798
+ return value.trim() === GENERATED_ENRICH_ROWS_TABLE_NAMESPACE;
17799
+ }
17800
+ if (Array.isArray(value)) {
17801
+ return value.some(
17802
+ (item) => statusReferencesGeneratedEnrichRows(item, depth + 1)
17803
+ );
17804
+ }
17805
+ if (typeof value === "object") {
17806
+ return Object.values(value).some(
17807
+ (item) => statusReferencesGeneratedEnrichRows(item, depth + 1)
17808
+ );
17809
+ }
17810
+ return false;
17811
+ }
17812
+ function generatedEnrichRowsTableNamespaceForExport(rowsInfo, status) {
17813
+ const tableNamespace = rowsInfo.tableNamespace?.trim() || null;
17814
+ if (tableNamespace === "result.rows") {
17815
+ return GENERATED_ENRICH_ROWS_TABLE_NAMESPACE;
17816
+ }
17817
+ if (!tableNamespace && statusReferencesGeneratedEnrichRows(status)) {
17818
+ return GENERATED_ENRICH_ROWS_TABLE_NAMESPACE;
17819
+ }
17820
+ return tableNamespace;
17821
+ }
17831
17822
  function shouldFetchBackingRowsForEnrichExport(rowsInfo, status, options = {}) {
17832
17823
  const terminalStatus = readEnrichRunStatus(status);
17833
- const tableNamespace = rowsInfo.tableNamespace?.trim();
17824
+ const tableNamespace = generatedEnrichRowsTableNamespaceForExport(
17825
+ rowsInfo,
17826
+ status
17827
+ );
17834
17828
  if (terminalStatus === "failed" || terminalStatus === "cancelled") {
17829
+ if (tableNamespace === GENERATED_ENRICH_ROWS_TABLE_NAMESPACE && rowsInfo.source !== null && typeof options.selectedSourceRows === "number" && rowsInfo.rows.length < options.selectedSourceRows) {
17830
+ return true;
17831
+ }
17835
17832
  return tableNamespace === GENERATED_ENRICH_ROWS_TABLE_NAMESPACE && (rowsInfo.recovered === true || hasPartialRunOutputWarning(status));
17836
17833
  }
17837
17834
  if (tableNamespace === GENERATED_ENRICH_ROWS_TABLE_NAMESPACE && typeof options.selectedSourceRows === "number" && rowsInfo.rows.length < options.selectedSourceRows) {
@@ -17959,6 +17956,45 @@ function exportableSheetRow2(row, sourceRowStart = 0) {
17959
17956
  }
17960
17957
  return fallback;
17961
17958
  }
17959
+ function mergeExportedSheetRow(target, next) {
17960
+ const baseMetadata = target._metadata;
17961
+ const nextMetadata = next._metadata;
17962
+ for (const [key, value] of Object.entries(next)) {
17963
+ const existing = target[key];
17964
+ if (isNonEmptyCsvCell(existing) && !isNonEmptyCsvCell(value)) {
17965
+ continue;
17966
+ }
17967
+ target[key] = value;
17968
+ }
17969
+ const metadata = mergeLegacyMetadataCell(baseMetadata, nextMetadata);
17970
+ if (metadata !== void 0) {
17971
+ target._metadata = metadata;
17972
+ }
17973
+ }
17974
+ function coalesceExportableSheetRows(rows, sourceRowStart = 0) {
17975
+ const mergedRows = [];
17976
+ const bySourceRowIndex = /* @__PURE__ */ new Map();
17977
+ for (const row of rows) {
17978
+ const rowIndex = sourceRowIndexFromEnrichRow(
17979
+ row,
17980
+ sourceRowStart,
17981
+ Number.MAX_SAFE_INTEGER
17982
+ );
17983
+ if (rowIndex === null) {
17984
+ mergedRows.push(row);
17985
+ continue;
17986
+ }
17987
+ const existing = bySourceRowIndex.get(rowIndex);
17988
+ if (existing) {
17989
+ mergeExportedSheetRow(existing, row);
17990
+ continue;
17991
+ }
17992
+ const next = { ...row };
17993
+ bySourceRowIndex.set(rowIndex, next);
17994
+ mergedRows.push(next);
17995
+ }
17996
+ return mergedRows;
17997
+ }
17962
17998
  function sourceRowIndexFromEnrichRow(row, start, end) {
17963
17999
  const value = row[ENRICH_SOURCE_ROW_INDEX_COLUMN];
17964
18000
  const parsed = typeof value === "number" ? value : typeof value === "string" && value.trim() ? Number(value) : Number.NaN;
@@ -18063,7 +18099,11 @@ function aliasFailureCellCandidates(row, alias) {
18063
18099
  if (key.startsWith(dottedPrefix)) {
18064
18100
  assignFlattenedFailurePath(nested, key.slice(dottedPrefix.length), value);
18065
18101
  } else if (key.startsWith(underscorePrefix)) {
18066
- assignFlattenedFailurePath(nested, key.slice(underscorePrefix.length), value);
18102
+ assignFlattenedFailurePath(
18103
+ nested,
18104
+ key.slice(underscorePrefix.length),
18105
+ value
18106
+ );
18067
18107
  }
18068
18108
  }
18069
18109
  if (Object.keys(nested).length > 0) {
@@ -18441,13 +18481,14 @@ function mergePreferredColumns(preferredColumns, rows) {
18441
18481
  async function fetchBackingRowsForCsvExport(input2) {
18442
18482
  const runId = extractRunId(input2.status);
18443
18483
  const playName = extractPlayName2(input2.status);
18444
- const tableNamespace = input2.rowsInfo.tableNamespace?.trim() || GENERATED_ENRICH_ROWS_TABLE_NAMESPACE;
18484
+ const tableNamespace = generatedEnrichRowsTableNamespaceForExport(input2.rowsInfo, input2.status) || GENERATED_ENRICH_ROWS_TABLE_NAMESPACE;
18445
18485
  if (!runId || !playName || !tableNamespace) {
18446
18486
  return null;
18447
18487
  }
18448
18488
  const deadline = Date.now() + enrichExportBackingRowsWaitMs();
18449
18489
  let lastRows = [];
18450
- const minimumExpectedRows = typeof input2.expectedRows === "number" && input2.expectedRows > 0 ? Math.trunc(input2.expectedRows) : input2.rowsInfo.totalRows;
18490
+ const hasExplicitExpectedRows = typeof input2.expectedRows === "number" && input2.expectedRows > 0;
18491
+ const minimumExpectedRows = hasExplicitExpectedRows ? Math.trunc(Number(input2.expectedRows)) : input2.rowsInfo.totalRows;
18451
18492
  let lastExpectedTotal = minimumExpectedRows;
18452
18493
  for (; ; ) {
18453
18494
  const sheetRows = [];
@@ -18472,10 +18513,15 @@ async function fetchBackingRowsForCsvExport(input2) {
18472
18513
  }
18473
18514
  offset += page.rows.length;
18474
18515
  }
18475
- const rows = sheetRows.map((row) => exportableSheetRow2(row, input2.sourceRowStart ?? 0)).filter((row) => Boolean(row));
18516
+ const rawRows = sheetRows.map((row) => exportableSheetRow2(row, input2.sourceRowStart ?? 0)).filter((row) => Boolean(row));
18517
+ const rows = coalesceExportableSheetRows(
18518
+ rawRows,
18519
+ input2.sourceRowStart ?? 0
18520
+ );
18476
18521
  lastRows = rows;
18477
18522
  lastExpectedTotal = expectedTotal;
18478
- if (expectedTotal > 0 && rows.length >= expectedTotal || expectedTotal === 0 && rows.length > 0) {
18523
+ const requiredExportRows = hasExplicitExpectedRows ? minimumExpectedRows : expectedTotal;
18524
+ if (requiredExportRows > 0 && rows.length >= requiredExportRows || requiredExportRows === 0 && rows.length > 0) {
18479
18525
  return {
18480
18526
  ...input2.rowsInfo,
18481
18527
  rows,
@@ -18483,7 +18529,7 @@ async function fetchBackingRowsForCsvExport(input2) {
18483
18529
  input2.rowsInfo.columnsExplicit ? input2.rowsInfo.columns : [],
18484
18530
  rows
18485
18531
  ),
18486
- totalRows: Math.max(rows.length, expectedTotal),
18532
+ totalRows: hasExplicitExpectedRows ? Math.max(rows.length, minimumExpectedRows) : Math.max(rows.length, expectedTotal),
18487
18533
  complete: true,
18488
18534
  source: `${input2.rowsInfo.source ?? "result.rows"} -> /api/v2/plays/${playName}/sheet?tableNamespace=${tableNamespace}`
18489
18535
  };
@@ -18503,7 +18549,7 @@ async function fetchBackingRowsForCsvExport(input2) {
18503
18549
  input2.rowsInfo.columnsExplicit ? input2.rowsInfo.columns : [],
18504
18550
  lastRows
18505
18551
  ),
18506
- totalRows: Math.max(lastExpectedTotal, input2.rowsInfo.totalRows),
18552
+ totalRows: hasExplicitExpectedRows ? Math.max(lastRows.length, minimumExpectedRows) : Math.max(lastExpectedTotal, input2.rowsInfo.totalRows),
18507
18553
  complete: false,
18508
18554
  source: `${input2.rowsInfo.source ?? "result.rows"} -> /api/v2/plays/${playName}/sheet?tableNamespace=${tableNamespace}`
18509
18555
  };
@@ -18691,8 +18737,13 @@ function materializeAliasSuccessCell(row, alias) {
18691
18737
  directCells.push({ field, value });
18692
18738
  }
18693
18739
  }
18694
- for (const preferredField of [alias, ...ENRICH_FLATTENED_SUCCESS_FIELD_PRIORITY]) {
18695
- const preferred = directCells.find(({ field }) => field === preferredField);
18740
+ for (const preferredField of [
18741
+ alias,
18742
+ ...ENRICH_FLATTENED_SUCCESS_FIELD_PRIORITY
18743
+ ]) {
18744
+ const preferred = directCells.find(
18745
+ ({ field }) => field === preferredField
18746
+ );
18696
18747
  if (preferred) {
18697
18748
  return materializeCsvCellValue(preferred.value);
18698
18749
  }
@@ -18894,7 +18945,7 @@ function assertCompleteRowsForCsvExport(rowsInfo, status, outputPath, options =
18894
18945
  return;
18895
18946
  }
18896
18947
  const runId = status && typeof status === "object" && !Array.isArray(status) && typeof status.runId === "string" ? status.runId : null;
18897
- const dataset = rowsInfo.source ?? "result.rows";
18948
+ const dataset = rowsInfo.source ?? rowsInfo.tableNamespace ?? "result.rows";
18898
18949
  const retry = runId ? ` Retry after the run finalizes its backing dataset with: deepline runs export ${runId} --dataset ${dataset} --out ${outputPath}` : "";
18899
18950
  throw new Error(
18900
18951
  `Refusing to write a partial CSV export: the run returned ${rowsInfo.rows.length} preview row(s) out of ${rowsInfo.totalRows}.${retry}`
@@ -20536,7 +20587,9 @@ async function handleOrgStatus(options) {
20536
20587
  const config = resolveConfig();
20537
20588
  const http = new HttpClient(config);
20538
20589
  const payload = await fetchOrganizations(http, config.apiKey);
20539
- const current = payload.organizations.find((org) => org.is_current) ?? payload.organizations.find((org) => org.org_id === payload.current_org_id) ?? null;
20590
+ const current = payload.organizations.find((org) => org.is_current) ?? payload.organizations.find(
20591
+ (org) => org.org_id === payload.current_org_id
20592
+ ) ?? null;
20540
20593
  const projectCandidate = getActiveProjectAuthSource();
20541
20594
  const activeProject = getResolvedProjectAuthSource(
20542
20595
  config.baseUrl,
@@ -20668,15 +20721,14 @@ async function handleOrgSwitch(selection, options) {
20668
20721
  } else {
20669
20722
  saveHostEnvValues(config.baseUrl, authValues2);
20670
20723
  }
20671
- if (authTarget.kind === "folder") {
20672
- saveCoworkWorkspaceRestoreEnvValues(authValues2);
20673
- }
20674
20724
  const renderLines2 = [`Already on ${target.name}.`];
20675
20725
  for (const projectPath of project_env_paths2) {
20676
20726
  renderLines2.push(`Saved folder auth in ${projectPath}`);
20677
20727
  }
20678
20728
  if (authTarget.kind === "global") {
20679
- renderLines2.push(`Saved global auth in ${hostEnvFilePath(config.baseUrl)}`);
20729
+ renderLines2.push(
20730
+ `Saved global auth in ${hostEnvFilePath(config.baseUrl)}`
20731
+ );
20680
20732
  }
20681
20733
  renderLines2.push(
20682
20734
  `Scope: ${authTarget.requested_scope} -> ${authTarget.effective_scope} (${authTarget.reason})`
@@ -20731,9 +20783,6 @@ async function handleOrgSwitch(selection, options) {
20731
20783
  DEEPLINE_ACTIVE_ORG_NAME: switched.org_name
20732
20784
  });
20733
20785
  }
20734
- if (authTarget.kind === "folder") {
20735
- saveCoworkWorkspaceRestoreEnvValues(authValues);
20736
- }
20737
20786
  const { api_key: _apiKey, ...publicSwitched } = switched;
20738
20787
  const renderLines = [`Switched to ${switched.org_name}.`];
20739
20788
  if (authTarget.kind === "folder") {
@@ -20798,7 +20847,6 @@ async function handleOrgCreate(name, options) {
20798
20847
  DEEPLINE_ACTIVE_ORG_ID: created.org_id,
20799
20848
  DEEPLINE_ACTIVE_ORG_NAME: created.org_name
20800
20849
  });
20801
- saveCoworkWorkspaceRestoreEnvValues(authValues);
20802
20850
  const { api_key: _apiKey, ...publicCreated } = created;
20803
20851
  printCommandEnvelope(
20804
20852
  {
@@ -20907,7 +20955,10 @@ Examples:
20907
20955
  "--auth-scope <scope>",
20908
20956
  "Where to save auth: auto, folder, or global",
20909
20957
  "auto"
20910
- ).option("--json", "Emit JSON output. Also automatic when stdout is piped");
20958
+ ).option(
20959
+ "--json",
20960
+ "Emit JSON output. Also automatic when stdout is piped"
20961
+ );
20911
20962
  addOrgSetOptions(
20912
20963
  org.command("set [selection]").description("Set the organization for the selected auth scope.").addHelpText(
20913
20964
  "after",
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.160",
424
+ version: "0.1.162",
425
425
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
426
426
  supportPolicy: {
427
- latest: "0.1.160",
427
+ latest: "0.1.162",
428
428
  minimumSupported: "0.1.53",
429
429
  deprecatedBelow: "0.1.53",
430
430
  commandMinimumSupported: [
package/dist/index.mjs CHANGED
@@ -351,10 +351,10 @@ var SDK_RELEASE = {
351
351
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
352
352
  // 0.1.154 removes the short-lived generated enrich StepOptions recompute
353
353
  // fields shipped in 0.1.153.
354
- version: "0.1.160",
354
+ version: "0.1.162",
355
355
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
356
356
  supportPolicy: {
357
- latest: "0.1.160",
357
+ latest: "0.1.162",
358
358
  minimumSupported: "0.1.53",
359
359
  deprecatedBelow: "0.1.53",
360
360
  commandMinimumSupported: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.160",
3
+ "version": "0.1.162",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {