deepline 0.1.148 → 0.1.149

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.
@@ -58,6 +58,8 @@ const DEFAULT_TIMEOUT = 60_000;
58
58
  const DEFAULT_MAX_RETRIES = 3;
59
59
 
60
60
  const PROJECT_DEEPLINE_ENV_FILE = '.env.deepline';
61
+ const WORKSPACE_RESTORE_ENV_DIR = '.deepline';
62
+ const WORKSPACE_RESTORE_ENV_FILE = '.env';
61
63
  const COWORK_IGNORED_WORKSPACE_DIRS = new Set([
62
64
  '.auto-memory',
63
65
  '.claude',
@@ -505,6 +507,27 @@ function ensureProjectEnvIsIgnored(dir: string): void {
505
507
  writeFileSync(gitignorePath, `${existing}${prefix}${entry}\n`, 'utf-8');
506
508
  }
507
509
 
510
+ function ensureWorkspaceRestoreEnvIsIgnored(workspaceDir: string): void {
511
+ const gitignorePath = join(workspaceDir, '.gitignore');
512
+ const entry = `${WORKSPACE_RESTORE_ENV_DIR}/`;
513
+ const existing = existsSync(gitignorePath)
514
+ ? readFileSync(gitignorePath, 'utf-8')
515
+ : '';
516
+ const alreadyIgnored = existing
517
+ .split(/\r?\n/)
518
+ .map((line) => line.trim())
519
+ .some(
520
+ (line) =>
521
+ line === entry ||
522
+ line === `/${entry}` ||
523
+ line === WORKSPACE_RESTORE_ENV_DIR ||
524
+ line === `/${WORKSPACE_RESTORE_ENV_DIR}`,
525
+ );
526
+ if (alreadyIgnored) return;
527
+ const prefix = existing && !existing.endsWith('\n') ? '\n' : '';
528
+ writeFileSync(gitignorePath, `${existing}${prefix}${entry}\n`, 'utf-8');
529
+ }
530
+
508
531
  export function saveProjectDeeplineEnvValues(
509
532
  values: EnvValues,
510
533
  startDir: string = process.cwd(),
@@ -522,6 +545,32 @@ export function saveProjectDeeplineEnvValues(
522
545
  return [filePath];
523
546
  }
524
547
 
548
+ export function saveCoworkWorkspaceRestoreEnvValues(
549
+ values: EnvValues,
550
+ startDir: string = process.cwd(),
551
+ ): string[] {
552
+ if (!isCoworkLikeSandbox()) return [];
553
+ const target = resolveProjectPinTarget(startDir);
554
+ if (!target.ok || target.source === 'cwd') return [];
555
+ const workspaceDir = target.dir;
556
+ const filePath = join(
557
+ workspaceDir,
558
+ WORKSPACE_RESTORE_ENV_DIR,
559
+ WORKSPACE_RESTORE_ENV_FILE,
560
+ );
561
+ const existing = parseEnvFile(filePath);
562
+ const merged = { ...existing, ...values };
563
+ const dir = dirname(filePath);
564
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
565
+ ensureWorkspaceRestoreEnvIsIgnored(workspaceDir);
566
+ const allowedKeys = new Set([HOST_URL_ENV, API_KEY_ENV]);
567
+ const lines = Object.entries(merged)
568
+ .filter(([key, value]) => allowedKeys.has(key) && value !== '')
569
+ .map(([key, value]) => `${key}=${value}`);
570
+ writeFileSync(filePath, `${lines.join('\n')}\n`, 'utf-8');
571
+ return [filePath];
572
+ }
573
+
525
574
  export function resolveProjectPinDir(startDir: string = process.cwd()): string {
526
575
  const target = resolveProjectPinTarget(startDir);
527
576
  if (!target.ok) {
@@ -102,10 +102,10 @@ export const SDK_RELEASE = {
102
102
  // the SDK enrich generator's one-second stale policy.
103
103
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
104
104
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
105
- version: '0.1.148',
105
+ version: '0.1.149',
106
106
  apiContract: '2026-06-dataset-handle-results-hard-cutover',
107
107
  supportPolicy: {
108
- latest: '0.1.148',
108
+ latest: '0.1.149',
109
109
  minimumSupported: '0.1.53',
110
110
  deprecatedBelow: '0.1.53',
111
111
  commandMinimumSupported: [
@@ -98,7 +98,6 @@ interface NeonModule {
98
98
  query<R = Record<string, unknown>>(
99
99
  text: string,
100
100
  params?: unknown[],
101
- options?: { fullResults?: boolean },
102
101
  ): Promise<{ rows: R[] }>;
103
102
  };
104
103
  }
@@ -186,7 +185,7 @@ export function installNeonServerlessRuntimePoolDriver(): void {
186
185
  params?: unknown[],
187
186
  ) => {
188
187
  const sql = await getSql();
189
- return await sql.query<R>(text, params, { fullResults: true });
188
+ return await sql.query<R>(text, params);
190
189
  },
191
190
  };
192
191
  });
package/dist/cli/index.js CHANGED
@@ -237,6 +237,8 @@ var PROD_URL = "https://code.deepline.com";
237
237
  var DEFAULT_TIMEOUT = 6e4;
238
238
  var DEFAULT_MAX_RETRIES = 3;
239
239
  var PROJECT_DEEPLINE_ENV_FILE = ".env.deepline";
240
+ var WORKSPACE_RESTORE_ENV_DIR = ".deepline";
241
+ var WORKSPACE_RESTORE_ENV_FILE = ".env";
240
242
  var COWORK_IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
241
243
  ".auto-memory",
242
244
  ".claude",
@@ -551,6 +553,18 @@ function ensureProjectEnvIsIgnored(dir) {
551
553
  (0, import_node_fs.writeFileSync)(gitignorePath, `${existing}${prefix}${entry}
552
554
  `, "utf-8");
553
555
  }
556
+ function ensureWorkspaceRestoreEnvIsIgnored(workspaceDir) {
557
+ const gitignorePath = (0, import_node_path.join)(workspaceDir, ".gitignore");
558
+ const entry = `${WORKSPACE_RESTORE_ENV_DIR}/`;
559
+ const existing = (0, import_node_fs.existsSync)(gitignorePath) ? (0, import_node_fs.readFileSync)(gitignorePath, "utf-8") : "";
560
+ const alreadyIgnored = existing.split(/\r?\n/).map((line) => line.trim()).some(
561
+ (line) => line === entry || line === `/${entry}` || line === WORKSPACE_RESTORE_ENV_DIR || line === `/${WORKSPACE_RESTORE_ENV_DIR}`
562
+ );
563
+ if (alreadyIgnored) return;
564
+ const prefix = existing && !existing.endsWith("\n") ? "\n" : "";
565
+ (0, import_node_fs.writeFileSync)(gitignorePath, `${existing}${prefix}${entry}
566
+ `, "utf-8");
567
+ }
554
568
  function saveProjectDeeplineEnvValues(values, startDir = process.cwd()) {
555
569
  const target = resolveProjectPinTarget(startDir);
556
570
  if (!target.ok) {
@@ -564,6 +578,27 @@ function saveProjectDeeplineEnvValues(values, startDir = process.cwd()) {
564
578
  mergeProjectEnvFile(filePath, values);
565
579
  return [filePath];
566
580
  }
581
+ function saveCoworkWorkspaceRestoreEnvValues(values, startDir = process.cwd()) {
582
+ if (!isCoworkLikeSandbox()) return [];
583
+ const target = resolveProjectPinTarget(startDir);
584
+ if (!target.ok || target.source === "cwd") return [];
585
+ const workspaceDir = target.dir;
586
+ const filePath = (0, import_node_path.join)(
587
+ workspaceDir,
588
+ WORKSPACE_RESTORE_ENV_DIR,
589
+ WORKSPACE_RESTORE_ENV_FILE
590
+ );
591
+ const existing = parseEnvFile(filePath);
592
+ const merged = { ...existing, ...values };
593
+ const dir = (0, import_node_path.dirname)(filePath);
594
+ if (!(0, import_node_fs.existsSync)(dir)) (0, import_node_fs.mkdirSync)(dir, { recursive: true });
595
+ ensureWorkspaceRestoreEnvIsIgnored(workspaceDir);
596
+ const allowedKeys = /* @__PURE__ */ new Set([HOST_URL_ENV, API_KEY_ENV]);
597
+ const lines = Object.entries(merged).filter(([key, value]) => allowedKeys.has(key) && value !== "").map(([key, value]) => `${key}=${value}`);
598
+ (0, import_node_fs.writeFileSync)(filePath, `${lines.join("\n")}
599
+ `, "utf-8");
600
+ return [filePath];
601
+ }
567
602
  function resolveProjectPinTarget(startDir = process.cwd()) {
568
603
  const nearestFile = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
569
604
  if (nearestFile && !isInIgnoredCoworkMount(nearestFile)) {
@@ -620,10 +655,10 @@ var SDK_RELEASE = {
620
655
  // the SDK enrich generator's one-second stale policy.
621
656
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
622
657
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
623
- version: "0.1.148",
658
+ version: "0.1.149",
624
659
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
625
660
  supportPolicy: {
626
- latest: "0.1.148",
661
+ latest: "0.1.149",
627
662
  minimumSupported: "0.1.53",
628
663
  deprecatedBelow: "0.1.53",
629
664
  commandMinimumSupported: [
@@ -4693,6 +4728,9 @@ function saveEnvValues(values, baseUrl) {
4693
4728
  ...values[API_KEY_ENV] ? { [API_KEY_ENV]: values[API_KEY_ENV] } : {}
4694
4729
  };
4695
4730
  saveHostEnvValues(baseUrl, filtered);
4731
+ if (filtered[API_KEY_ENV]) {
4732
+ saveCoworkWorkspaceRestoreEnvValues(filtered);
4733
+ }
4696
4734
  }
4697
4735
  async function httpJson(method, url, apiKey, body) {
4698
4736
  const headers = {
@@ -6923,6 +6961,7 @@ Examples:
6923
6961
  var import_node_fs7 = require("fs");
6924
6962
  var import_node_path8 = require("path");
6925
6963
  var CUSTOMER_DB_QUERY_FORMATS = /* @__PURE__ */ new Set(["table", "json", "csv", "markdown"]);
6964
+ var CUSTOMER_DB_QUERY_MAX_ROWS = 1e3;
6926
6965
  function parsePositiveInteger(value, flagName) {
6927
6966
  const parsed = Number.parseInt(value, 10);
6928
6967
  if (!Number.isFinite(parsed) || parsed <= 0) {
@@ -6930,6 +6969,15 @@ function parsePositiveInteger(value, flagName) {
6930
6969
  }
6931
6970
  return parsed;
6932
6971
  }
6972
+ function parseMaxRows(value) {
6973
+ const parsed = parsePositiveInteger(value, "--max-rows");
6974
+ if (parsed > CUSTOMER_DB_QUERY_MAX_ROWS) {
6975
+ throw new Error(
6976
+ `--max-rows must be ${CUSTOMER_DB_QUERY_MAX_ROWS} or less. Add LIMIT/OFFSET to page larger exports.`
6977
+ );
6978
+ }
6979
+ return parsed;
6980
+ }
6933
6981
  function formatCell(value) {
6934
6982
  if (value === null || value === void 0) return "";
6935
6983
  const text = typeof value === "object" ? JSON.stringify(value) : String(value);
@@ -7075,7 +7123,7 @@ async function handleDbQuery(args) {
7075
7123
  return 1;
7076
7124
  }
7077
7125
  const maxRowsIndex = args.indexOf("--max-rows");
7078
- const maxRows = maxRowsIndex >= 0 && args[maxRowsIndex + 1] ? parsePositiveInteger(args[maxRowsIndex + 1], "--max-rows") : void 0;
7126
+ const maxRows = maxRowsIndex >= 0 && args[maxRowsIndex + 1] ? parseMaxRows(args[maxRowsIndex + 1]) : void 0;
7079
7127
  const formatIndex = args.indexOf("--format");
7080
7128
  const format = formatIndex >= 0 ? args[formatIndex + 1]?.trim().toLowerCase() : "";
7081
7129
  if (format && !CUSTOMER_DB_QUERY_FORMATS.has(format)) {
@@ -17029,8 +17077,14 @@ async function writeOutputCsv(outputPath, status, options) {
17029
17077
  rowsInfo
17030
17078
  }).catch(() => null) ?? rowsInfo;
17031
17079
  }
17032
- assertCompleteRowsForCsvExport(rowsInfo, status, outputPath);
17033
- const merged = mergeRowsForCsvExport(rowsInfo.rows, options);
17080
+ const allowPartial = options?.allowPartial === true && !rowsInfo.complete && rowsInfo.rows.length > 0 && Boolean(options?.sourceCsvPath);
17081
+ assertCompleteRowsForCsvExport(rowsInfo, status, outputPath, {
17082
+ allowPartial
17083
+ });
17084
+ const merged = mergeRowsForCsvExport(rowsInfo.rows, {
17085
+ ...options,
17086
+ allowPartial
17087
+ });
17034
17088
  const columns = orderEnrichCsvColumns(
17035
17089
  dataExportColumns(merged.rows, [
17036
17090
  ...merged.preferredColumns,
@@ -17050,9 +17104,52 @@ async function writeOutputCsv(outputPath, status, options) {
17050
17104
  enrichedRows: rowsInfo.rows.length,
17051
17105
  rows: merged.rows.length,
17052
17106
  path: (0, import_node_path11.resolve)(outputPath),
17107
+ partial: !rowsInfo.complete,
17053
17108
  enrichedDataRows: rowsInfo.rows
17054
17109
  };
17055
17110
  }
17111
+ function isMissingRowsForCsvExportError(error) {
17112
+ return error instanceof Error && (error.message.includes("did not return row-shaped output") || error.message.includes("run returned 0 preview row(s)"));
17113
+ }
17114
+ async function maybeWriteOutputCsv(input2) {
17115
+ if (!input2.outputPath) return null;
17116
+ try {
17117
+ return await writeOutputCsv(input2.outputPath, input2.status, {
17118
+ client: input2.client,
17119
+ config: input2.config,
17120
+ sourceCsvPath: input2.sourceCsvPath,
17121
+ rows: input2.rows,
17122
+ inPlace: input2.inPlace,
17123
+ allowPartial: input2.capturedResult !== 0
17124
+ });
17125
+ } catch (error) {
17126
+ if (input2.capturedResult !== 0 && isMissingRowsForCsvExportError(error)) {
17127
+ return null;
17128
+ }
17129
+ throw error;
17130
+ }
17131
+ }
17132
+ function enrichOutputJson(exportResult) {
17133
+ if (!exportResult) {
17134
+ return null;
17135
+ }
17136
+ return {
17137
+ sourceCsvRows: exportResult.sourceCsvRows,
17138
+ selectedRows: exportResult.selectedRows,
17139
+ enrichedRows: exportResult.enrichedRows,
17140
+ path: exportResult.path,
17141
+ ...exportResult.partial ? { rows: exportResult.rows, partial: true } : {}
17142
+ };
17143
+ }
17144
+ async function buildEnrichFailureReport(input2) {
17145
+ return maybeEmitEnrichFailureReport({
17146
+ config: input2.config,
17147
+ rows: input2.rows,
17148
+ rowRange: input2.rowRange,
17149
+ client: input2.client,
17150
+ outputPath: input2.exportResult?.path ?? input2.outputPath ?? null
17151
+ });
17152
+ }
17056
17153
  function recordField(value, key) {
17057
17154
  return value && typeof value === "object" && !Array.isArray(value) ? value[key] : void 0;
17058
17155
  }
@@ -17574,10 +17671,7 @@ async function fetchBackingRowsForCsvExport(input2) {
17574
17671
  function mergeRowsForCsvExport(enrichedRows, options) {
17575
17672
  const rows = dataExportRows(normalizeEnrichRowsForCsvExport(enrichedRows));
17576
17673
  const range = options?.rows;
17577
- if (!options?.inPlace && (range?.rowStart === null || range?.rowStart === void 0)) {
17578
- return { rows, preferredColumns: [] };
17579
- }
17580
- if (!options?.sourceCsvPath) {
17674
+ if (!options?.sourceCsvPath || !options.inPlace && !options.allowPartial && (range?.rowStart === null || range?.rowStart === void 0)) {
17581
17675
  return { rows, preferredColumns: [] };
17582
17676
  }
17583
17677
  const parsedBaseRows = readCsvRows(options.sourceCsvPath);
@@ -17589,7 +17683,7 @@ function mergeRowsForCsvExport(enrichedRows, options) {
17589
17683
  const maxEnd = Math.max(start, baseRows.length - 1);
17590
17684
  const inclusiveEnd = range?.rowEnd === null || range?.rowEnd === void 0 ? maxEnd : Math.min(maxEnd, range.rowEnd);
17591
17685
  const expectedSelectedRows = baseRows.length === 0 ? 0 : Math.max(0, inclusiveEnd - start + 1);
17592
- if (rows.length < expectedSelectedRows) {
17686
+ if (rows.length < expectedSelectedRows && !options.allowPartial) {
17593
17687
  throw new Error(
17594
17688
  `Refusing to write a partial in-place CSV export: the run returned ${rows.length} row(s) for ${expectedSelectedRows} selected source row(s).`
17595
17689
  );
@@ -17788,10 +17882,13 @@ function mergeLegacyMetadataCell(base, enriched) {
17788
17882
  }
17789
17883
  return void 0;
17790
17884
  }
17791
- function assertCompleteRowsForCsvExport(rowsInfo, status, outputPath) {
17885
+ function assertCompleteRowsForCsvExport(rowsInfo, status, outputPath, options = {}) {
17792
17886
  if (rowsInfo.complete) {
17793
17887
  return;
17794
17888
  }
17889
+ if (options.allowPartial) {
17890
+ return;
17891
+ }
17795
17892
  const runId = status && typeof status === "object" && !Array.isArray(status) && typeof status.runId === "string" ? status.runId : null;
17796
17893
  const dataset = rowsInfo.source ?? "result.rows";
17797
17894
  const retry = runId ? ` Retry after the run finalizes its backing dataset with: deepline runs export ${runId} --dataset ${dataset} --out ${outputPath}` : "";
@@ -17947,13 +18044,16 @@ function registerEnrichCommand(program) {
17947
18044
  stdout: captured2.stdout,
17948
18045
  exitCode: captured2.result
17949
18046
  });
17950
- const exportResult2 = captured2.result === 0 && outputPath ? await writeOutputCsv(outputPath, status2, {
18047
+ const exportResult2 = await maybeWriteOutputCsv({
18048
+ outputPath,
18049
+ status: status2,
18050
+ capturedResult: captured2.result,
17951
18051
  client: client2,
17952
18052
  config,
17953
18053
  sourceCsvPath: input2.sourceCsvPath,
17954
18054
  rows: input2.rows,
17955
18055
  inPlace: Boolean(options.inPlace)
17956
- }) : null;
18056
+ });
17957
18057
  return { captured: captured2, status: status2, exportResult: exportResult2 };
17958
18058
  };
17959
18059
  const selectedRange = selectedSourceCsvRange(sourceCsvPath, rows);
@@ -18003,9 +18103,16 @@ function registerEnrichCommand(program) {
18003
18103
  chunks: chunkCount,
18004
18104
  rows: chunkRows
18005
18105
  },
18006
- result: chunk.status
18106
+ result: chunk.status,
18107
+ output: enrichOutputJson(chunk.exportResult)
18007
18108
  });
18008
18109
  } else {
18110
+ if (chunk.exportResult) {
18111
+ process.stderr.write(
18112
+ `Wrote ${chunk.exportResult.rows} row(s) to ${chunk.exportResult.path}${chunk.exportResult.partial ? " (partial run output)" : ""}
18113
+ `
18114
+ );
18115
+ }
18009
18116
  emitPlainBatchRunFailure({
18010
18117
  chunkIndex,
18011
18118
  chunkCount,
@@ -18082,23 +18189,46 @@ function registerEnrichCommand(program) {
18082
18189
  json: Boolean(options.json),
18083
18190
  passthroughStdout: !options.json
18084
18191
  });
18192
+ const rowsForFailureReport = exportResult?.enrichedDataRows ?? extractCanonicalRowsInfo(status)?.rows ?? [];
18085
18193
  if (captured.result !== 0) {
18194
+ if (exportResult) {
18195
+ process.stderr.write(
18196
+ `Wrote ${exportResult.rows} row(s) to ${exportResult.path}${exportResult.partial ? " (partial run output)" : ""}
18197
+ `
18198
+ );
18199
+ }
18200
+ const failureReport2 = await buildEnrichFailureReport({
18201
+ config,
18202
+ rows: rowsForFailureReport,
18203
+ rowRange: rows,
18204
+ client: client2,
18205
+ exportResult,
18206
+ outputPath
18207
+ });
18086
18208
  if (options.json) {
18087
18209
  printJson({
18088
- result: status
18210
+ ok: false,
18211
+ run: status,
18212
+ output: enrichOutputJson(exportResult),
18213
+ ...failureReport2 ? {
18214
+ failure_report: {
18215
+ path: failureReport2.path,
18216
+ jobs: failureReport2.jobs.length
18217
+ }
18218
+ } : {}
18089
18219
  });
18090
18220
  }
18091
- process.exitCode = captured.result;
18221
+ process.exitCode = failureReport2 ? EXIT_SERVER2 : captured.result;
18092
18222
  return;
18093
18223
  }
18094
- const rowsForFailureReport = exportResult?.enrichedDataRows ?? extractCanonicalRowsInfo(status)?.rows ?? [];
18095
18224
  if (options.json) {
18096
- const failureReport2 = await maybeEmitEnrichFailureReport({
18225
+ const failureReport2 = await buildEnrichFailureReport({
18097
18226
  config,
18098
18227
  rows: rowsForFailureReport,
18099
18228
  rowRange: rows,
18100
18229
  client: client2,
18101
- outputPath: exportResult?.path ?? outputPath ?? null
18230
+ exportResult,
18231
+ outputPath
18102
18232
  });
18103
18233
  const run = rewriteEnrichJsonStatus({
18104
18234
  status,
@@ -18110,12 +18240,7 @@ function registerEnrichCommand(program) {
18110
18240
  printJson({
18111
18241
  ok: !failureReport2,
18112
18242
  run,
18113
- output: exportResult ? {
18114
- sourceCsvRows: exportResult.sourceCsvRows,
18115
- selectedRows: exportResult.selectedRows,
18116
- enrichedRows: exportResult.enrichedRows,
18117
- path: exportResult.path
18118
- } : null,
18243
+ output: enrichOutputJson(exportResult),
18119
18244
  ...failureReport2 ? {
18120
18245
  failure_report: {
18121
18246
  path: failureReport2.path,
@@ -19469,16 +19594,17 @@ async function handleOrgSwitch(selection, options) {
19469
19594
  const authTarget = resolveOrgSwitchAuthTarget(authScope, config);
19470
19595
  if (target.is_current) {
19471
19596
  let project_env_paths2 = [];
19597
+ const authValues2 = {
19598
+ [HOST_URL_ENV]: config.baseUrl,
19599
+ [API_KEY_ENV]: config.apiKey
19600
+ };
19472
19601
  if (authTarget.kind === "folder") {
19473
- project_env_paths2 = saveProjectDeeplineEnvValues({
19474
- DEEPLINE_HOST_URL: config.baseUrl,
19475
- DEEPLINE_API_KEY: config.apiKey
19476
- });
19602
+ project_env_paths2 = saveProjectDeeplineEnvValues(authValues2);
19477
19603
  } else {
19478
- saveHostEnvValues(config.baseUrl, {
19479
- DEEPLINE_HOST_URL: config.baseUrl,
19480
- DEEPLINE_API_KEY: config.apiKey
19481
- });
19604
+ saveHostEnvValues(config.baseUrl, authValues2);
19605
+ }
19606
+ if (authTarget.kind === "folder") {
19607
+ saveCoworkWorkspaceRestoreEnvValues(authValues2);
19482
19608
  }
19483
19609
  const renderLines2 = [`Already on ${target.name}.`];
19484
19610
  for (const projectPath of project_env_paths2) {
@@ -19527,19 +19653,22 @@ async function handleOrgSwitch(selection, options) {
19527
19653
  org_id: target.org_id
19528
19654
  });
19529
19655
  let project_env_paths = [];
19656
+ const authValues = {
19657
+ [HOST_URL_ENV]: config.baseUrl,
19658
+ [API_KEY_ENV]: switched.api_key
19659
+ };
19530
19660
  if (authTarget.kind === "folder") {
19531
- project_env_paths = saveProjectDeeplineEnvValues({
19532
- DEEPLINE_HOST_URL: config.baseUrl,
19533
- DEEPLINE_API_KEY: switched.api_key
19534
- });
19661
+ project_env_paths = saveProjectDeeplineEnvValues(authValues);
19535
19662
  } else {
19536
19663
  saveHostEnvValues(config.baseUrl, {
19537
- DEEPLINE_HOST_URL: config.baseUrl,
19538
- DEEPLINE_API_KEY: switched.api_key,
19664
+ ...authValues,
19539
19665
  DEEPLINE_ACTIVE_ORG_ID: switched.org_id,
19540
19666
  DEEPLINE_ACTIVE_ORG_NAME: switched.org_name
19541
19667
  });
19542
19668
  }
19669
+ if (authTarget.kind === "folder") {
19670
+ saveCoworkWorkspaceRestoreEnvValues(authValues);
19671
+ }
19543
19672
  const { api_key: _apiKey, ...publicSwitched } = switched;
19544
19673
  const renderLines = [`Switched to ${switched.org_name}.`];
19545
19674
  if (authTarget.kind === "folder") {
@@ -19595,12 +19724,16 @@ async function handleOrgCreate(name, options) {
19595
19724
  api_key: config.apiKey,
19596
19725
  name
19597
19726
  });
19727
+ const authValues = {
19728
+ [HOST_URL_ENV]: config.baseUrl,
19729
+ [API_KEY_ENV]: created.api_key
19730
+ };
19598
19731
  saveHostEnvValues(config.baseUrl, {
19599
- DEEPLINE_HOST_URL: config.baseUrl,
19600
- DEEPLINE_API_KEY: created.api_key,
19732
+ ...authValues,
19601
19733
  DEEPLINE_ACTIVE_ORG_ID: created.org_id,
19602
19734
  DEEPLINE_ACTIVE_ORG_NAME: created.org_name
19603
19735
  });
19736
+ saveCoworkWorkspaceRestoreEnvValues(authValues);
19604
19737
  const { api_key: _apiKey, ...publicCreated } = created;
19605
19738
  printCommandEnvelope(
19606
19739
  {
@@ -23314,7 +23447,7 @@ async function runAutomaticUpdatePlan(plan) {
23314
23447
  previousFailure
23315
23448
  };
23316
23449
  }
23317
- const exitCode = await runUpdatePlan(plan);
23450
+ const exitCode = await runUpdatePlan(plan, { stdio: "stderr" });
23318
23451
  return exitCode === 0 ? { status: "updated", exitCode: 0 } : { status: "failed", exitCode };
23319
23452
  }
23320
23453
  function safeVersionSegment(value) {
@@ -23345,13 +23478,21 @@ function installedPackageVersion(versionDir) {
23345
23478
  return "";
23346
23479
  }
23347
23480
  }
23348
- function runCommand(command, args, env = process.env) {
23481
+ function runCommand(command, args, env = process.env, options = {}) {
23349
23482
  return new Promise((resolveExitCode) => {
23350
23483
  const child = (0, import_node_child_process3.spawn)(command, args, {
23351
- stdio: "inherit",
23484
+ stdio: options.stdio === "stderr" ? ["inherit", "pipe", "pipe"] : "inherit",
23352
23485
  shell: process.platform === "win32",
23353
23486
  env
23354
23487
  });
23488
+ if (options.stdio === "stderr") {
23489
+ child.stdout?.on("data", (chunk) => {
23490
+ process.stderr.write(chunk);
23491
+ });
23492
+ child.stderr?.on("data", (chunk) => {
23493
+ process.stderr.write(chunk);
23494
+ });
23495
+ }
23355
23496
  child.on("error", (error) => {
23356
23497
  process.stderr.write(`Failed to start ${command}: ${error.message}
23357
23498
  `);
@@ -23389,7 +23530,7 @@ function writeSidecarLauncher(input2) {
23389
23530
  { encoding: "utf8", mode: 493 }
23390
23531
  );
23391
23532
  }
23392
- async function runPythonSidecarUpdatePlan(plan) {
23533
+ async function runPythonSidecarUpdatePlan(plan, options = {}) {
23393
23534
  const versionsDir = (0, import_node_path18.join)(plan.stateDir, "versions");
23394
23535
  const tempDir = (0, import_node_path18.join)(
23395
23536
  versionsDir,
@@ -23411,7 +23552,8 @@ async function runPythonSidecarUpdatePlan(plan) {
23411
23552
  ...NPM_SDK_INSTALL_COMMON_FLAGS,
23412
23553
  plan.packageSpec
23413
23554
  ],
23414
- env
23555
+ env,
23556
+ options
23415
23557
  );
23416
23558
  if (installExitCode !== 0) {
23417
23559
  (0, import_node_fs15.rmSync)(tempDir, { recursive: true, force: true });
@@ -23484,12 +23626,12 @@ async function runPythonSidecarUpdatePlan(plan) {
23484
23626
  );
23485
23627
  return 0;
23486
23628
  }
23487
- async function runUpdatePlan(plan) {
23629
+ async function runUpdatePlan(plan, options = {}) {
23488
23630
  let exitCode = 1;
23489
23631
  if (plan.kind === "npm-global") {
23490
- exitCode = await runCommand(plan.command, plan.args);
23632
+ exitCode = await runCommand(plan.command, plan.args, process.env, options);
23491
23633
  } else if (plan.kind === "python-sidecar") {
23492
- exitCode = await runPythonSidecarUpdatePlan(plan);
23634
+ exitCode = await runPythonSidecarUpdatePlan(plan, options);
23493
23635
  }
23494
23636
  if (exitCode === 0) {
23495
23637
  clearAutoUpdateFailure(plan);
@@ -222,6 +222,8 @@ 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";
225
227
  var COWORK_IGNORED_WORKSPACE_DIRS = /* @__PURE__ */ new Set([
226
228
  ".auto-memory",
227
229
  ".claude",
@@ -536,6 +538,18 @@ function ensureProjectEnvIsIgnored(dir) {
536
538
  writeFileSync(gitignorePath, `${existing}${prefix}${entry}
537
539
  `, "utf-8");
538
540
  }
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
+ }
539
553
  function saveProjectDeeplineEnvValues(values, startDir = process.cwd()) {
540
554
  const target = resolveProjectPinTarget(startDir);
541
555
  if (!target.ok) {
@@ -549,6 +563,27 @@ function saveProjectDeeplineEnvValues(values, startDir = process.cwd()) {
549
563
  mergeProjectEnvFile(filePath, values);
550
564
  return [filePath];
551
565
  }
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
+ }
552
587
  function resolveProjectPinTarget(startDir = process.cwd()) {
553
588
  const nearestFile = findNearestEnvFile(PROJECT_DEEPLINE_ENV_FILE, startDir);
554
589
  if (nearestFile && !isInIgnoredCoworkMount(nearestFile)) {
@@ -605,10 +640,10 @@ var SDK_RELEASE = {
605
640
  // the SDK enrich generator's one-second stale policy.
606
641
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
607
642
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
608
- version: "0.1.148",
643
+ version: "0.1.149",
609
644
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
610
645
  supportPolicy: {
611
- latest: "0.1.148",
646
+ latest: "0.1.149",
612
647
  minimumSupported: "0.1.53",
613
648
  deprecatedBelow: "0.1.53",
614
649
  commandMinimumSupported: [
@@ -4690,6 +4725,9 @@ function saveEnvValues(values, baseUrl) {
4690
4725
  ...values[API_KEY_ENV] ? { [API_KEY_ENV]: values[API_KEY_ENV] } : {}
4691
4726
  };
4692
4727
  saveHostEnvValues(baseUrl, filtered);
4728
+ if (filtered[API_KEY_ENV]) {
4729
+ saveCoworkWorkspaceRestoreEnvValues(filtered);
4730
+ }
4693
4731
  }
4694
4732
  async function httpJson(method, url, apiKey, body) {
4695
4733
  const headers = {
@@ -6920,6 +6958,7 @@ Examples:
6920
6958
  import { writeFileSync as writeFileSync6 } from "fs";
6921
6959
  import { resolve as resolve5 } from "path";
6922
6960
  var CUSTOMER_DB_QUERY_FORMATS = /* @__PURE__ */ new Set(["table", "json", "csv", "markdown"]);
6961
+ var CUSTOMER_DB_QUERY_MAX_ROWS = 1e3;
6923
6962
  function parsePositiveInteger(value, flagName) {
6924
6963
  const parsed = Number.parseInt(value, 10);
6925
6964
  if (!Number.isFinite(parsed) || parsed <= 0) {
@@ -6927,6 +6966,15 @@ function parsePositiveInteger(value, flagName) {
6927
6966
  }
6928
6967
  return parsed;
6929
6968
  }
6969
+ function parseMaxRows(value) {
6970
+ const parsed = parsePositiveInteger(value, "--max-rows");
6971
+ if (parsed > CUSTOMER_DB_QUERY_MAX_ROWS) {
6972
+ throw new Error(
6973
+ `--max-rows must be ${CUSTOMER_DB_QUERY_MAX_ROWS} or less. Add LIMIT/OFFSET to page larger exports.`
6974
+ );
6975
+ }
6976
+ return parsed;
6977
+ }
6930
6978
  function formatCell(value) {
6931
6979
  if (value === null || value === void 0) return "";
6932
6980
  const text = typeof value === "object" ? JSON.stringify(value) : String(value);
@@ -7072,7 +7120,7 @@ async function handleDbQuery(args) {
7072
7120
  return 1;
7073
7121
  }
7074
7122
  const maxRowsIndex = args.indexOf("--max-rows");
7075
- const maxRows = maxRowsIndex >= 0 && args[maxRowsIndex + 1] ? parsePositiveInteger(args[maxRowsIndex + 1], "--max-rows") : void 0;
7123
+ const maxRows = maxRowsIndex >= 0 && args[maxRowsIndex + 1] ? parseMaxRows(args[maxRowsIndex + 1]) : void 0;
7076
7124
  const formatIndex = args.indexOf("--format");
7077
7125
  const format = formatIndex >= 0 ? args[formatIndex + 1]?.trim().toLowerCase() : "";
7078
7126
  if (format && !CUSTOMER_DB_QUERY_FORMATS.has(format)) {
@@ -17046,8 +17094,14 @@ async function writeOutputCsv(outputPath, status, options) {
17046
17094
  rowsInfo
17047
17095
  }).catch(() => null) ?? rowsInfo;
17048
17096
  }
17049
- assertCompleteRowsForCsvExport(rowsInfo, status, outputPath);
17050
- const merged = mergeRowsForCsvExport(rowsInfo.rows, options);
17097
+ const allowPartial = options?.allowPartial === true && !rowsInfo.complete && rowsInfo.rows.length > 0 && Boolean(options?.sourceCsvPath);
17098
+ assertCompleteRowsForCsvExport(rowsInfo, status, outputPath, {
17099
+ allowPartial
17100
+ });
17101
+ const merged = mergeRowsForCsvExport(rowsInfo.rows, {
17102
+ ...options,
17103
+ allowPartial
17104
+ });
17051
17105
  const columns = orderEnrichCsvColumns(
17052
17106
  dataExportColumns(merged.rows, [
17053
17107
  ...merged.preferredColumns,
@@ -17067,9 +17121,52 @@ async function writeOutputCsv(outputPath, status, options) {
17067
17121
  enrichedRows: rowsInfo.rows.length,
17068
17122
  rows: merged.rows.length,
17069
17123
  path: resolve8(outputPath),
17124
+ partial: !rowsInfo.complete,
17070
17125
  enrichedDataRows: rowsInfo.rows
17071
17126
  };
17072
17127
  }
17128
+ function isMissingRowsForCsvExportError(error) {
17129
+ return error instanceof Error && (error.message.includes("did not return row-shaped output") || error.message.includes("run returned 0 preview row(s)"));
17130
+ }
17131
+ async function maybeWriteOutputCsv(input2) {
17132
+ if (!input2.outputPath) return null;
17133
+ try {
17134
+ return await writeOutputCsv(input2.outputPath, input2.status, {
17135
+ client: input2.client,
17136
+ config: input2.config,
17137
+ sourceCsvPath: input2.sourceCsvPath,
17138
+ rows: input2.rows,
17139
+ inPlace: input2.inPlace,
17140
+ allowPartial: input2.capturedResult !== 0
17141
+ });
17142
+ } catch (error) {
17143
+ if (input2.capturedResult !== 0 && isMissingRowsForCsvExportError(error)) {
17144
+ return null;
17145
+ }
17146
+ throw error;
17147
+ }
17148
+ }
17149
+ function enrichOutputJson(exportResult) {
17150
+ if (!exportResult) {
17151
+ return null;
17152
+ }
17153
+ return {
17154
+ sourceCsvRows: exportResult.sourceCsvRows,
17155
+ selectedRows: exportResult.selectedRows,
17156
+ enrichedRows: exportResult.enrichedRows,
17157
+ path: exportResult.path,
17158
+ ...exportResult.partial ? { rows: exportResult.rows, partial: true } : {}
17159
+ };
17160
+ }
17161
+ async function buildEnrichFailureReport(input2) {
17162
+ return maybeEmitEnrichFailureReport({
17163
+ config: input2.config,
17164
+ rows: input2.rows,
17165
+ rowRange: input2.rowRange,
17166
+ client: input2.client,
17167
+ outputPath: input2.exportResult?.path ?? input2.outputPath ?? null
17168
+ });
17169
+ }
17073
17170
  function recordField(value, key) {
17074
17171
  return value && typeof value === "object" && !Array.isArray(value) ? value[key] : void 0;
17075
17172
  }
@@ -17591,10 +17688,7 @@ async function fetchBackingRowsForCsvExport(input2) {
17591
17688
  function mergeRowsForCsvExport(enrichedRows, options) {
17592
17689
  const rows = dataExportRows(normalizeEnrichRowsForCsvExport(enrichedRows));
17593
17690
  const range = options?.rows;
17594
- if (!options?.inPlace && (range?.rowStart === null || range?.rowStart === void 0)) {
17595
- return { rows, preferredColumns: [] };
17596
- }
17597
- if (!options?.sourceCsvPath) {
17691
+ if (!options?.sourceCsvPath || !options.inPlace && !options.allowPartial && (range?.rowStart === null || range?.rowStart === void 0)) {
17598
17692
  return { rows, preferredColumns: [] };
17599
17693
  }
17600
17694
  const parsedBaseRows = readCsvRows(options.sourceCsvPath);
@@ -17606,7 +17700,7 @@ function mergeRowsForCsvExport(enrichedRows, options) {
17606
17700
  const maxEnd = Math.max(start, baseRows.length - 1);
17607
17701
  const inclusiveEnd = range?.rowEnd === null || range?.rowEnd === void 0 ? maxEnd : Math.min(maxEnd, range.rowEnd);
17608
17702
  const expectedSelectedRows = baseRows.length === 0 ? 0 : Math.max(0, inclusiveEnd - start + 1);
17609
- if (rows.length < expectedSelectedRows) {
17703
+ if (rows.length < expectedSelectedRows && !options.allowPartial) {
17610
17704
  throw new Error(
17611
17705
  `Refusing to write a partial in-place CSV export: the run returned ${rows.length} row(s) for ${expectedSelectedRows} selected source row(s).`
17612
17706
  );
@@ -17805,10 +17899,13 @@ function mergeLegacyMetadataCell(base, enriched) {
17805
17899
  }
17806
17900
  return void 0;
17807
17901
  }
17808
- function assertCompleteRowsForCsvExport(rowsInfo, status, outputPath) {
17902
+ function assertCompleteRowsForCsvExport(rowsInfo, status, outputPath, options = {}) {
17809
17903
  if (rowsInfo.complete) {
17810
17904
  return;
17811
17905
  }
17906
+ if (options.allowPartial) {
17907
+ return;
17908
+ }
17812
17909
  const runId = status && typeof status === "object" && !Array.isArray(status) && typeof status.runId === "string" ? status.runId : null;
17813
17910
  const dataset = rowsInfo.source ?? "result.rows";
17814
17911
  const retry = runId ? ` Retry after the run finalizes its backing dataset with: deepline runs export ${runId} --dataset ${dataset} --out ${outputPath}` : "";
@@ -17964,13 +18061,16 @@ function registerEnrichCommand(program) {
17964
18061
  stdout: captured2.stdout,
17965
18062
  exitCode: captured2.result
17966
18063
  });
17967
- const exportResult2 = captured2.result === 0 && outputPath ? await writeOutputCsv(outputPath, status2, {
18064
+ const exportResult2 = await maybeWriteOutputCsv({
18065
+ outputPath,
18066
+ status: status2,
18067
+ capturedResult: captured2.result,
17968
18068
  client: client2,
17969
18069
  config,
17970
18070
  sourceCsvPath: input2.sourceCsvPath,
17971
18071
  rows: input2.rows,
17972
18072
  inPlace: Boolean(options.inPlace)
17973
- }) : null;
18073
+ });
17974
18074
  return { captured: captured2, status: status2, exportResult: exportResult2 };
17975
18075
  };
17976
18076
  const selectedRange = selectedSourceCsvRange(sourceCsvPath, rows);
@@ -18020,9 +18120,16 @@ function registerEnrichCommand(program) {
18020
18120
  chunks: chunkCount,
18021
18121
  rows: chunkRows
18022
18122
  },
18023
- result: chunk.status
18123
+ result: chunk.status,
18124
+ output: enrichOutputJson(chunk.exportResult)
18024
18125
  });
18025
18126
  } else {
18127
+ if (chunk.exportResult) {
18128
+ process.stderr.write(
18129
+ `Wrote ${chunk.exportResult.rows} row(s) to ${chunk.exportResult.path}${chunk.exportResult.partial ? " (partial run output)" : ""}
18130
+ `
18131
+ );
18132
+ }
18026
18133
  emitPlainBatchRunFailure({
18027
18134
  chunkIndex,
18028
18135
  chunkCount,
@@ -18099,23 +18206,46 @@ function registerEnrichCommand(program) {
18099
18206
  json: Boolean(options.json),
18100
18207
  passthroughStdout: !options.json
18101
18208
  });
18209
+ const rowsForFailureReport = exportResult?.enrichedDataRows ?? extractCanonicalRowsInfo(status)?.rows ?? [];
18102
18210
  if (captured.result !== 0) {
18211
+ if (exportResult) {
18212
+ process.stderr.write(
18213
+ `Wrote ${exportResult.rows} row(s) to ${exportResult.path}${exportResult.partial ? " (partial run output)" : ""}
18214
+ `
18215
+ );
18216
+ }
18217
+ const failureReport2 = await buildEnrichFailureReport({
18218
+ config,
18219
+ rows: rowsForFailureReport,
18220
+ rowRange: rows,
18221
+ client: client2,
18222
+ exportResult,
18223
+ outputPath
18224
+ });
18103
18225
  if (options.json) {
18104
18226
  printJson({
18105
- result: status
18227
+ ok: false,
18228
+ run: status,
18229
+ output: enrichOutputJson(exportResult),
18230
+ ...failureReport2 ? {
18231
+ failure_report: {
18232
+ path: failureReport2.path,
18233
+ jobs: failureReport2.jobs.length
18234
+ }
18235
+ } : {}
18106
18236
  });
18107
18237
  }
18108
- process.exitCode = captured.result;
18238
+ process.exitCode = failureReport2 ? EXIT_SERVER2 : captured.result;
18109
18239
  return;
18110
18240
  }
18111
- const rowsForFailureReport = exportResult?.enrichedDataRows ?? extractCanonicalRowsInfo(status)?.rows ?? [];
18112
18241
  if (options.json) {
18113
- const failureReport2 = await maybeEmitEnrichFailureReport({
18242
+ const failureReport2 = await buildEnrichFailureReport({
18114
18243
  config,
18115
18244
  rows: rowsForFailureReport,
18116
18245
  rowRange: rows,
18117
18246
  client: client2,
18118
- outputPath: exportResult?.path ?? outputPath ?? null
18247
+ exportResult,
18248
+ outputPath
18119
18249
  });
18120
18250
  const run = rewriteEnrichJsonStatus({
18121
18251
  status,
@@ -18127,12 +18257,7 @@ function registerEnrichCommand(program) {
18127
18257
  printJson({
18128
18258
  ok: !failureReport2,
18129
18259
  run,
18130
- output: exportResult ? {
18131
- sourceCsvRows: exportResult.sourceCsvRows,
18132
- selectedRows: exportResult.selectedRows,
18133
- enrichedRows: exportResult.enrichedRows,
18134
- path: exportResult.path
18135
- } : null,
18260
+ output: enrichOutputJson(exportResult),
18136
18261
  ...failureReport2 ? {
18137
18262
  failure_report: {
18138
18263
  path: failureReport2.path,
@@ -19493,16 +19618,17 @@ async function handleOrgSwitch(selection, options) {
19493
19618
  const authTarget = resolveOrgSwitchAuthTarget(authScope, config);
19494
19619
  if (target.is_current) {
19495
19620
  let project_env_paths2 = [];
19621
+ const authValues2 = {
19622
+ [HOST_URL_ENV]: config.baseUrl,
19623
+ [API_KEY_ENV]: config.apiKey
19624
+ };
19496
19625
  if (authTarget.kind === "folder") {
19497
- project_env_paths2 = saveProjectDeeplineEnvValues({
19498
- DEEPLINE_HOST_URL: config.baseUrl,
19499
- DEEPLINE_API_KEY: config.apiKey
19500
- });
19626
+ project_env_paths2 = saveProjectDeeplineEnvValues(authValues2);
19501
19627
  } else {
19502
- saveHostEnvValues(config.baseUrl, {
19503
- DEEPLINE_HOST_URL: config.baseUrl,
19504
- DEEPLINE_API_KEY: config.apiKey
19505
- });
19628
+ saveHostEnvValues(config.baseUrl, authValues2);
19629
+ }
19630
+ if (authTarget.kind === "folder") {
19631
+ saveCoworkWorkspaceRestoreEnvValues(authValues2);
19506
19632
  }
19507
19633
  const renderLines2 = [`Already on ${target.name}.`];
19508
19634
  for (const projectPath of project_env_paths2) {
@@ -19551,19 +19677,22 @@ async function handleOrgSwitch(selection, options) {
19551
19677
  org_id: target.org_id
19552
19678
  });
19553
19679
  let project_env_paths = [];
19680
+ const authValues = {
19681
+ [HOST_URL_ENV]: config.baseUrl,
19682
+ [API_KEY_ENV]: switched.api_key
19683
+ };
19554
19684
  if (authTarget.kind === "folder") {
19555
- project_env_paths = saveProjectDeeplineEnvValues({
19556
- DEEPLINE_HOST_URL: config.baseUrl,
19557
- DEEPLINE_API_KEY: switched.api_key
19558
- });
19685
+ project_env_paths = saveProjectDeeplineEnvValues(authValues);
19559
19686
  } else {
19560
19687
  saveHostEnvValues(config.baseUrl, {
19561
- DEEPLINE_HOST_URL: config.baseUrl,
19562
- DEEPLINE_API_KEY: switched.api_key,
19688
+ ...authValues,
19563
19689
  DEEPLINE_ACTIVE_ORG_ID: switched.org_id,
19564
19690
  DEEPLINE_ACTIVE_ORG_NAME: switched.org_name
19565
19691
  });
19566
19692
  }
19693
+ if (authTarget.kind === "folder") {
19694
+ saveCoworkWorkspaceRestoreEnvValues(authValues);
19695
+ }
19567
19696
  const { api_key: _apiKey, ...publicSwitched } = switched;
19568
19697
  const renderLines = [`Switched to ${switched.org_name}.`];
19569
19698
  if (authTarget.kind === "folder") {
@@ -19619,12 +19748,16 @@ async function handleOrgCreate(name, options) {
19619
19748
  api_key: config.apiKey,
19620
19749
  name
19621
19750
  });
19751
+ const authValues = {
19752
+ [HOST_URL_ENV]: config.baseUrl,
19753
+ [API_KEY_ENV]: created.api_key
19754
+ };
19622
19755
  saveHostEnvValues(config.baseUrl, {
19623
- DEEPLINE_HOST_URL: config.baseUrl,
19624
- DEEPLINE_API_KEY: created.api_key,
19756
+ ...authValues,
19625
19757
  DEEPLINE_ACTIVE_ORG_ID: created.org_id,
19626
19758
  DEEPLINE_ACTIVE_ORG_NAME: created.org_name
19627
19759
  });
19760
+ saveCoworkWorkspaceRestoreEnvValues(authValues);
19628
19761
  const { api_key: _apiKey, ...publicCreated } = created;
19629
19762
  printCommandEnvelope(
19630
19763
  {
@@ -23353,7 +23486,7 @@ async function runAutomaticUpdatePlan(plan) {
23353
23486
  previousFailure
23354
23487
  };
23355
23488
  }
23356
- const exitCode = await runUpdatePlan(plan);
23489
+ const exitCode = await runUpdatePlan(plan, { stdio: "stderr" });
23357
23490
  return exitCode === 0 ? { status: "updated", exitCode: 0 } : { status: "failed", exitCode };
23358
23491
  }
23359
23492
  function safeVersionSegment(value) {
@@ -23384,13 +23517,21 @@ function installedPackageVersion(versionDir) {
23384
23517
  return "";
23385
23518
  }
23386
23519
  }
23387
- function runCommand(command, args, env = process.env) {
23520
+ function runCommand(command, args, env = process.env, options = {}) {
23388
23521
  return new Promise((resolveExitCode) => {
23389
23522
  const child = spawn3(command, args, {
23390
- stdio: "inherit",
23523
+ stdio: options.stdio === "stderr" ? ["inherit", "pipe", "pipe"] : "inherit",
23391
23524
  shell: process.platform === "win32",
23392
23525
  env
23393
23526
  });
23527
+ if (options.stdio === "stderr") {
23528
+ child.stdout?.on("data", (chunk) => {
23529
+ process.stderr.write(chunk);
23530
+ });
23531
+ child.stderr?.on("data", (chunk) => {
23532
+ process.stderr.write(chunk);
23533
+ });
23534
+ }
23394
23535
  child.on("error", (error) => {
23395
23536
  process.stderr.write(`Failed to start ${command}: ${error.message}
23396
23537
  `);
@@ -23428,7 +23569,7 @@ function writeSidecarLauncher(input2) {
23428
23569
  { encoding: "utf8", mode: 493 }
23429
23570
  );
23430
23571
  }
23431
- async function runPythonSidecarUpdatePlan(plan) {
23572
+ async function runPythonSidecarUpdatePlan(plan, options = {}) {
23432
23573
  const versionsDir = join13(plan.stateDir, "versions");
23433
23574
  const tempDir = join13(
23434
23575
  versionsDir,
@@ -23450,7 +23591,8 @@ async function runPythonSidecarUpdatePlan(plan) {
23450
23591
  ...NPM_SDK_INSTALL_COMMON_FLAGS,
23451
23592
  plan.packageSpec
23452
23593
  ],
23453
- env
23594
+ env,
23595
+ options
23454
23596
  );
23455
23597
  if (installExitCode !== 0) {
23456
23598
  rmSync3(tempDir, { recursive: true, force: true });
@@ -23523,12 +23665,12 @@ async function runPythonSidecarUpdatePlan(plan) {
23523
23665
  );
23524
23666
  return 0;
23525
23667
  }
23526
- async function runUpdatePlan(plan) {
23668
+ async function runUpdatePlan(plan, options = {}) {
23527
23669
  let exitCode = 1;
23528
23670
  if (plan.kind === "npm-global") {
23529
- exitCode = await runCommand(plan.command, plan.args);
23671
+ exitCode = await runCommand(plan.command, plan.args, process.env, options);
23530
23672
  } else if (plan.kind === "python-sidecar") {
23531
- exitCode = await runPythonSidecarUpdatePlan(plan);
23673
+ exitCode = await runPythonSidecarUpdatePlan(plan, options);
23532
23674
  }
23533
23675
  if (exitCode === 0) {
23534
23676
  clearAutoUpdateFailure(plan);
package/dist/index.js CHANGED
@@ -419,10 +419,10 @@ var SDK_RELEASE = {
419
419
  // the SDK enrich generator's one-second stale policy.
420
420
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
421
421
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
422
- version: "0.1.148",
422
+ version: "0.1.149",
423
423
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
424
424
  supportPolicy: {
425
- latest: "0.1.148",
425
+ latest: "0.1.149",
426
426
  minimumSupported: "0.1.53",
427
427
  deprecatedBelow: "0.1.53",
428
428
  commandMinimumSupported: [
package/dist/index.mjs CHANGED
@@ -349,10 +349,10 @@ var SDK_RELEASE = {
349
349
  // the SDK enrich generator's one-second stale policy.
350
350
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
351
351
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
352
- version: "0.1.148",
352
+ version: "0.1.149",
353
353
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
354
354
  supportPolicy: {
355
- latest: "0.1.148",
355
+ latest: "0.1.149",
356
356
  minimumSupported: "0.1.53",
357
357
  deprecatedBelow: "0.1.53",
358
358
  commandMinimumSupported: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepline",
3
- "version": "0.1.148",
3
+ "version": "0.1.149",
4
4
  "description": "Deepline SDK + CLI — B2B data enrichment powered by durable cloud execution",
5
5
  "license": "MIT",
6
6
  "repository": {