deepline 0.1.149 → 0.1.151

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.
Files changed (29) hide show
  1. package/dist/bundling-sources/apps/play-runner-workers/src/entry.ts +157 -140
  2. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/csv-rows.ts +2 -19
  3. package/dist/bundling-sources/apps/play-runner-workers/src/runtime/row-isolation.ts +5 -53
  4. package/dist/bundling-sources/sdk/src/client.ts +5 -0
  5. package/dist/bundling-sources/sdk/src/config.ts +2 -2
  6. package/dist/bundling-sources/sdk/src/release.ts +2 -2
  7. package/dist/bundling-sources/sdk/src/tool-output.ts +63 -17
  8. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +100 -158
  9. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +3 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/durability-store.ts +54 -0
  11. package/dist/bundling-sources/shared_libs/play-runtime/map-row-outcome.ts +167 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/pacing.ts +79 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/row-isolation.ts +39 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +19 -86
  15. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-transition.ts +90 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-session.ts +43 -0
  17. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +142 -11
  18. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +3 -2
  19. package/dist/bundling-sources/shared_libs/play-runtime/tool-result-types.ts +17 -4
  20. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +343 -26
  21. package/dist/bundling-sources/shared_libs/plays/bundling/index.ts +20 -23
  22. package/dist/cli/index.js +186 -105
  23. package/dist/cli/index.mjs +193 -106
  24. package/dist/index.d.mts +12 -9
  25. package/dist/index.d.ts +12 -9
  26. package/dist/index.js +33 -20
  27. package/dist/index.mjs +40 -21
  28. package/dist/plays/bundle-play-file.mjs +22 -19
  29. package/package.json +1 -1
@@ -405,7 +405,7 @@ function loadProjectEnvCandidates(startDir = process.cwd()) {
405
405
  }));
406
406
  }
407
407
  function normalizeBaseUrl(baseUrl) {
408
- const trimmed = baseUrl.trim().replace(/\/+$/, "");
408
+ const trimmed = baseUrl?.trim().replace(/\/+$/, "") ?? "";
409
409
  if (!trimmed) return "";
410
410
  try {
411
411
  const parsed = new URL(trimmed);
@@ -640,10 +640,10 @@ var SDK_RELEASE = {
640
640
  // the SDK enrich generator's one-second stale policy.
641
641
  // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
642
642
  // 0.1.111 ships dataset-native tool list getters and result row datasets.
643
- version: "0.1.149",
643
+ version: "0.1.151",
644
644
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
645
645
  supportPolicy: {
646
- latest: "0.1.149",
646
+ latest: "0.1.151",
647
647
  minimumSupported: "0.1.53",
648
648
  deprecatedBelow: "0.1.53",
649
649
  commandMinimumSupported: [
@@ -2107,6 +2107,7 @@ async function* observeRunEvents(options) {
2107
2107
  var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
2108
2108
  var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
2109
2109
  var EXECUTE_RESPONSE_CONTRACT_HEADER = "x-deepline-execute-response-contract";
2110
+ var EXECUTE_RESPONSE_INTENT_HEADER = "x-deepline-execute-response-intent";
2110
2111
  var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-response";
2111
2112
  var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
2112
2113
  var REGISTER_PLAY_ARTIFACTS_COMPILE_CONCURRENCY = 3;
@@ -2591,7 +2592,8 @@ var DeeplineClient = class {
2591
2592
  async executeTool(toolId, input2, options) {
2592
2593
  const headers = {
2593
2594
  [EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
2594
- ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {}
2595
+ ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
2596
+ ...options?.responseIntent ? { [EXECUTE_RESPONSE_INTENT_HEADER]: options.responseIntent } : {}
2595
2597
  };
2596
2598
  return this.http.post(
2597
2599
  `/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
@@ -10805,6 +10807,23 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
10805
10807
  },
10806
10808
  Math.max(1, input2.waitTimeoutMs)
10807
10809
  );
10810
+ const fetchKnownTerminalStatus = async () => {
10811
+ if (!lastKnownWorkflowId) {
10812
+ return null;
10813
+ }
10814
+ let refreshed;
10815
+ try {
10816
+ refreshed = await input2.client.getPlayStatus(lastKnownWorkflowId, {
10817
+ billing: false
10818
+ });
10819
+ } catch (error) {
10820
+ if (isTransientPlayStreamError(error)) {
10821
+ return null;
10822
+ }
10823
+ throw error;
10824
+ }
10825
+ return TERMINAL_PLAY_STATUSES2.has(refreshed.status) ? { ...refreshed, dashboardUrl } : null;
10826
+ };
10808
10827
  try {
10809
10828
  for await (const event of input2.client.startPlayRunStream(input2.request, {
10810
10829
  signal: controller.signal
@@ -10900,6 +10919,21 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
10900
10919
  }
10901
10920
  } catch (error) {
10902
10921
  if (timedOut) {
10922
+ const terminal = await fetchKnownTerminalStatus();
10923
+ if (terminal) {
10924
+ recordCliTrace({
10925
+ phase: "cli.play_start_stream_timeout_status_reconcile",
10926
+ ms: Date.now() - startedAt,
10927
+ ok: true,
10928
+ playName: input2.playName,
10929
+ workflowId: lastKnownWorkflowId,
10930
+ eventCount,
10931
+ firstRunIdMs,
10932
+ lastPhase,
10933
+ status: terminal.status
10934
+ });
10935
+ return terminal;
10936
+ }
10903
10937
  assertPlayWaitNotTimedOut({
10904
10938
  workflowId: lastKnownWorkflowId,
10905
10939
  startedAt,
@@ -20561,7 +20595,13 @@ import { tmpdir as tmpdir3 } from "os";
20561
20595
  import { join as join10, resolve as resolve10 } from "path";
20562
20596
 
20563
20597
  // src/tool-output.ts
20564
- import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync11 } from "fs";
20598
+ import {
20599
+ closeSync as closeSync2,
20600
+ mkdirSync as mkdirSync7,
20601
+ openSync as openSync2,
20602
+ writeFileSync as writeFileSync11,
20603
+ writeSync
20604
+ } from "fs";
20565
20605
  import { homedir as homedir9 } from "os";
20566
20606
  import { dirname as dirname9, join as join9 } from "path";
20567
20607
  function isPlainObject(value) {
@@ -20584,6 +20624,19 @@ function normalizeRows(value) {
20584
20624
  return { value: entry };
20585
20625
  });
20586
20626
  }
20627
+ function columnsForRows(rows) {
20628
+ const seen = /* @__PURE__ */ new Set();
20629
+ const columns = [];
20630
+ for (const row of rows) {
20631
+ for (const key of Object.keys(row)) {
20632
+ if (!seen.has(key)) {
20633
+ seen.add(key);
20634
+ columns.push(key);
20635
+ }
20636
+ }
20637
+ }
20638
+ return columns;
20639
+ }
20587
20640
  function candidateRoots(payload) {
20588
20641
  const roots = [
20589
20642
  { path: null, value: payload }
@@ -20666,6 +20719,16 @@ function tryConvertToList(payload, options) {
20666
20719
  }
20667
20720
  return null;
20668
20721
  }
20722
+ function projectRowOutput(conversion) {
20723
+ return {
20724
+ rows: conversion.rows,
20725
+ rowCount: conversion.rows.length,
20726
+ columns: columnsForRows(conversion.rows),
20727
+ previewRows: conversion.rows.slice(0, 5),
20728
+ strategy: conversion.strategy,
20729
+ sourcePath: conversion.sourcePath
20730
+ };
20731
+ }
20669
20732
  function ensureOutputDir() {
20670
20733
  const outputDir = join9(homedir9(), ".local", "share", "deepline", "data");
20671
20734
  mkdirSync7(outputDir, { recursive: true });
@@ -20680,16 +20743,7 @@ function writeJsonOutputFile(payload, stem) {
20680
20743
  function writeCsvOutputFile(rows, stem, options) {
20681
20744
  const outputPath = options?.outPath ? options.outPath : join9(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
20682
20745
  mkdirSync7(dirname9(outputPath), { recursive: true });
20683
- const seen = /* @__PURE__ */ new Set();
20684
- const columns = [];
20685
- for (const row of rows) {
20686
- for (const key of Object.keys(row)) {
20687
- if (!seen.has(key)) {
20688
- seen.add(key);
20689
- columns.push(key);
20690
- }
20691
- }
20692
- }
20746
+ const columns = columnsForRows(rows);
20693
20747
  const escapeCell = (value) => {
20694
20748
  const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
20695
20749
  if (/[",\n]/.test(normalized)) {
@@ -20697,13 +20751,20 @@ function writeCsvOutputFile(rows, stem, options) {
20697
20751
  }
20698
20752
  return normalized;
20699
20753
  };
20700
- const lines = [];
20701
- lines.push(columns.map(escapeCell).join(","));
20702
- for (const row of rows) {
20703
- lines.push(columns.map((column) => escapeCell(row[column])).join(","));
20754
+ const fd = openSync2(outputPath, "w");
20755
+ try {
20756
+ writeSync(fd, `${columns.map(escapeCell).join(",")}
20757
+ `);
20758
+ for (const row of rows) {
20759
+ writeSync(
20760
+ fd,
20761
+ `${columns.map((column) => escapeCell(row[column])).join(",")}
20762
+ `
20763
+ );
20764
+ }
20765
+ } finally {
20766
+ closeSync2(fd);
20704
20767
  }
20705
- writeFileSync11(outputPath, `${lines.join("\n")}
20706
- `, "utf-8");
20707
20768
  const previewRows = rows.slice(0, 5);
20708
20769
  const previewColumns = columns.slice(0, 5);
20709
20770
  const preview = [
@@ -21230,10 +21291,7 @@ Examples:
21230
21291
  ).option(
21231
21292
  "--output-format <format>",
21232
21293
  "Output format: auto, csv, csv_file, json, or json_file"
21233
- ).option(
21234
- "-o, --out <path>",
21235
- "Write row-shaped tool output to this CSV path"
21236
- ).option(
21294
+ ).option("-o, --out <path>", "Write row-shaped tool output to this CSV path").option(
21237
21295
  "--no-preview",
21238
21296
  "Only print the extracted output path when applicable"
21239
21297
  ).action(async (toolId, options) => {
@@ -22087,6 +22145,100 @@ function buildToolExecuteBaseEnvelope(input2) {
22087
22145
  }
22088
22146
  };
22089
22147
  }
22148
+ function buildToolExecuteRowArtifactEnvelope(input2) {
22149
+ const {
22150
+ toolResponse: _toolResponse,
22151
+ result: _result,
22152
+ output: _output,
22153
+ output_preview: _outputPreview,
22154
+ render: _render,
22155
+ next: _next,
22156
+ local: _local,
22157
+ ...base
22158
+ } = input2.baseEnvelope;
22159
+ void _toolResponse;
22160
+ void _result;
22161
+ void _output;
22162
+ void _outputPreview;
22163
+ void _render;
22164
+ void _next;
22165
+ void _local;
22166
+ return {
22167
+ ...base,
22168
+ status: typeof base.status === "string" ? base.status : "completed",
22169
+ output_preview: {
22170
+ kind: "list",
22171
+ rowCount: input2.rowOutput.rowCount,
22172
+ columns: input2.rowOutput.columns,
22173
+ preview: input2.rowOutput.previewRows,
22174
+ listStrategy: input2.rowOutput.strategy,
22175
+ listSourcePath: input2.rowOutput.sourcePath
22176
+ },
22177
+ csv_path: input2.csv.path,
22178
+ row_count: input2.csv.rowCount,
22179
+ row_count_returned: input2.csv.rowCount,
22180
+ columns: input2.csv.columns,
22181
+ extracted_csv: input2.csv.path,
22182
+ extracted_csv_rows: input2.csv.rowCount,
22183
+ extracted_csv_columns: input2.csv.columns,
22184
+ preview: input2.csv.preview,
22185
+ list_strategy: input2.rowOutput.strategy,
22186
+ list_source_path: input2.rowOutput.sourcePath,
22187
+ summary: input2.summary,
22188
+ local: {
22189
+ extracted_csv: input2.csv.path,
22190
+ extracted_csv_rows: input2.csv.rowCount,
22191
+ extracted_csv_columns: input2.csv.columns,
22192
+ preview: input2.csv.preview,
22193
+ starter_script: input2.seededScript.path,
22194
+ project_dir: input2.seededScript.projectDir,
22195
+ copy_to_project: {
22196
+ macos_linux: input2.seededScript.macCopyCommand,
22197
+ windows_powershell: input2.seededScript.windowsCopyCommand
22198
+ }
22199
+ },
22200
+ starter_script: input2.seededScript.path,
22201
+ project_dir: input2.seededScript.projectDir,
22202
+ copy_to_project: {
22203
+ macos_linux: input2.seededScript.macCopyCommand,
22204
+ windows_powershell: input2.seededScript.windowsCopyCommand
22205
+ },
22206
+ next: {
22207
+ inspect: "Re-run with --json only when you need the raw provider/tool response.",
22208
+ listSourcePath: input2.rowOutput.sourcePath,
22209
+ expandToPlay: "Use stable map and step keys so reruns are idempotent: completed rows are reused, and only missing or stale work runs again."
22210
+ },
22211
+ render: {
22212
+ sections: [
22213
+ {
22214
+ title: `${input2.csv.path} (${input2.csv.rowCount} rows)`,
22215
+ lines: [
22216
+ ...input2.csv.columns.length > 0 ? [`columns: ${JSON.stringify(input2.csv.columns)}`] : [],
22217
+ ...Object.keys(input2.summary).length > 0 ? [
22218
+ `summary: ${Object.entries(input2.summary).map(([key, value]) => `${key}=${String(value)}`).join(", ")}`
22219
+ ] : [],
22220
+ `preview: ${JSON.stringify(input2.rowOutput.previewRows)}`,
22221
+ `starter script: ${input2.seededScript.path}`
22222
+ ]
22223
+ }
22224
+ ],
22225
+ actions: [
22226
+ {
22227
+ label: "next",
22228
+ command: "Move the script into a project folder and expand it into a Deepline play. Use stable map and step keys so reruns are idempotent: completed rows are reused, and only missing or stale work runs again."
22229
+ },
22230
+ {
22231
+ label: "macOS/Linux",
22232
+ command: input2.seededScript.macCopyCommand
22233
+ },
22234
+ {
22235
+ label: "Windows PowerShell",
22236
+ command: input2.seededScript.windowsCopyCommand
22237
+ }
22238
+ ]
22239
+ }
22240
+ };
22241
+ }
22090
22242
  async function executeTool(args) {
22091
22243
  let parsed;
22092
22244
  try {
@@ -22138,7 +22290,9 @@ async function executeTool(args) {
22138
22290
  }
22139
22291
  return 2;
22140
22292
  }
22141
- const rawResponse = await client2.executeTool(parsed.toolId, parsed.params);
22293
+ const rawResponse = await client2.executeTool(parsed.toolId, parsed.params, {
22294
+ responseIntent: parsed.outPath || parsed.outputFormat === "csv" || parsed.outputFormat === "csv_file" ? "row_artifact" : "raw"
22295
+ });
22142
22296
  const listConversion = tryConvertToList(rawResponse, {
22143
22297
  listExtractorPaths: listExtractorPathsFromUsageGuidance(metadata)
22144
22298
  });
@@ -22202,6 +22356,7 @@ async function executeTool(args) {
22202
22356
  printCommandEnvelope(baseEnvelope, { json: false });
22203
22357
  return 0;
22204
22358
  }
22359
+ const rowOutput = projectRowOutput(listConversion);
22205
22360
  const csv = writeCsvOutputFile(
22206
22361
  listConversion.rows,
22207
22362
  `${parsed.toolId}_output`,
@@ -22212,91 +22367,23 @@ async function executeTool(args) {
22212
22367
  payload: parsed.params,
22213
22368
  rows: listConversion.rows
22214
22369
  });
22215
- const materializedEnvelope = {
22216
- ...baseEnvelope,
22217
- local: {
22218
- extracted_csv: csv.path,
22219
- extracted_csv_rows: csv.rowCount,
22220
- extracted_csv_columns: csv.columns,
22221
- preview: csv.preview,
22222
- starter_script: seededScript.path,
22223
- project_dir: seededScript.projectDir,
22224
- copy_to_project: {
22225
- macos_linux: seededScript.macCopyCommand,
22226
- windows_powershell: seededScript.windowsCopyCommand
22227
- }
22228
- },
22229
- render: {
22230
- sections: [
22231
- {
22232
- title: `${csv.path} (${csv.rowCount} rows)`,
22233
- lines: [
22234
- ...csv.columns.length > 0 ? [`columns: ${JSON.stringify(csv.columns)}`] : [],
22235
- ...Object.keys(summary).length > 0 ? [
22236
- `summary: ${Object.entries(summary).map(([key, value]) => `${key}=${String(value)}`).join(", ")}`
22237
- ] : [],
22238
- `preview: ${JSON.stringify(csv.preview)}`,
22239
- `starter script: ${seededScript.path}`
22240
- ]
22241
- }
22242
- ],
22243
- actions: [
22244
- {
22245
- label: "next",
22246
- command: "Move the script into a project folder and expand it into a Deepline play. Use stable map and step keys so reruns are idempotent: completed rows are reused, and only missing or stale work runs again."
22247
- },
22248
- {
22249
- label: "macOS/Linux",
22250
- command: seededScript.macCopyCommand
22251
- },
22252
- {
22253
- label: "Windows PowerShell",
22254
- command: seededScript.windowsCopyCommand
22255
- }
22256
- ]
22257
- }
22258
- };
22370
+ const materializedEnvelope = buildToolExecuteRowArtifactEnvelope({
22371
+ baseEnvelope,
22372
+ csv,
22373
+ rowOutput,
22374
+ summary,
22375
+ seededScript
22376
+ });
22259
22377
  if (parsed.outputFormat === "csv_file") {
22260
- printCommandEnvelope(
22261
- {
22262
- ...materializedEnvelope,
22263
- extracted_csv: csv.path,
22264
- extracted_csv_rows: csv.rowCount,
22265
- extracted_csv_columns: csv.columns,
22266
- preview: csv.preview,
22267
- list_strategy: listConversion.strategy,
22268
- list_source_path: listConversion.sourcePath,
22269
- starter_script: seededScript.path,
22270
- project_dir: seededScript.projectDir,
22271
- copy_to_project: {
22272
- macos_linux: seededScript.macCopyCommand,
22273
- windows_powershell: seededScript.windowsCopyCommand
22274
- },
22275
- summary
22276
- },
22277
- { json: true }
22278
- );
22378
+ printCommandEnvelope(materializedEnvelope, { json: true });
22279
22379
  return 0;
22280
22380
  }
22281
22381
  if (parsed.outPath) {
22282
- printCommandEnvelope(
22283
- {
22284
- ...materializedEnvelope,
22285
- csv_path: csv.path,
22286
- row_count: csv.rowCount,
22287
- row_count_returned: csv.rowCount,
22288
- columns: csv.columns,
22289
- preview: csv.preview,
22290
- list_strategy: listConversion.strategy,
22291
- list_source_path: listConversion.sourcePath,
22292
- summary
22293
- },
22294
- {
22295
- json: argsWantJson(args) || shouldEmitJson(),
22296
- text: `Wrote ${csv.rowCount} row(s) to ${csv.path}
22382
+ printCommandEnvelope(materializedEnvelope, {
22383
+ json: argsWantJson(args) || shouldEmitJson(),
22384
+ text: `Wrote ${csv.rowCount} row(s) to ${csv.path}
22297
22385
  `
22298
- }
22299
- );
22386
+ });
22300
22387
  return 0;
22301
22388
  }
22302
22389
  if (parsed.noPreview) {
package/dist/index.d.mts CHANGED
@@ -1072,6 +1072,7 @@ type EnrichCompiledConfig = {
1072
1072
 
1073
1073
  type ExecuteToolRawOptions = {
1074
1074
  includeToolMetadata?: boolean;
1075
+ responseIntent?: 'raw' | 'row_artifact';
1075
1076
  };
1076
1077
  /**
1077
1078
  * Standard provider/tool execution envelope returned by low-level SDK calls.
@@ -2739,9 +2740,10 @@ type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Par
2739
2740
  * getters live under `extractedValues.<name>.get()`, and list getters live
2740
2741
  * under `extractedLists.<name>.get()`.
2741
2742
  *
2742
- * Use extractors first when a tool contract exposes them. Drop to
2743
- * `toolResponse.raw` when you need provider-specific fields or when debugging
2744
- * from persisted run rows.
2743
+ * Use extractors first when a tool contract exposes them. Use list getters for
2744
+ * row-shaped data. Drop to `toolResponse.raw` only for provider-specific scalar
2745
+ * fields or bounded debugging context; persisted rows may clip declared lists to
2746
+ * previews.
2745
2747
  *
2746
2748
  * @sdkReference runtime 200
2747
2749
  */
@@ -3951,6 +3953,12 @@ type ListConversionResult = {
3951
3953
  /** Dotted path to where the list was found (e.g. `"output.body"`, `"people"`). */
3952
3954
  sourcePath: string | null;
3953
3955
  };
3956
+ type CsvOutputArtifact = {
3957
+ path: string;
3958
+ rowCount: number;
3959
+ columns: string[];
3960
+ preview: string;
3961
+ };
3954
3962
  type Scalar = string | number | boolean | null;
3955
3963
  /**
3956
3964
  * Extract a list of records from a tool response.
@@ -4042,12 +4050,7 @@ declare function writeJsonOutputFile(payload: unknown, stem: string): string;
4042
4050
  */
4043
4051
  declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem: string, options?: {
4044
4052
  outPath?: string;
4045
- }): {
4046
- path: string;
4047
- rowCount: number;
4048
- columns: string[];
4049
- preview: string;
4050
- };
4053
+ }): CsvOutputArtifact;
4051
4054
  /**
4052
4055
  * Extract scalar (non-nested) fields from a tool response for summary display.
4053
4056
  *
package/dist/index.d.ts CHANGED
@@ -1072,6 +1072,7 @@ type EnrichCompiledConfig = {
1072
1072
 
1073
1073
  type ExecuteToolRawOptions = {
1074
1074
  includeToolMetadata?: boolean;
1075
+ responseIntent?: 'raw' | 'row_artifact';
1075
1076
  };
1076
1077
  /**
1077
1078
  * Standard provider/tool execution envelope returned by low-level SDK calls.
@@ -2739,9 +2740,10 @@ type ToolExecuteResultAccessors<TExtracted extends Record<string, unknown> = Par
2739
2740
  * getters live under `extractedValues.<name>.get()`, and list getters live
2740
2741
  * under `extractedLists.<name>.get()`.
2741
2742
  *
2742
- * Use extractors first when a tool contract exposes them. Drop to
2743
- * `toolResponse.raw` when you need provider-specific fields or when debugging
2744
- * from persisted run rows.
2743
+ * Use extractors first when a tool contract exposes them. Use list getters for
2744
+ * row-shaped data. Drop to `toolResponse.raw` only for provider-specific scalar
2745
+ * fields or bounded debugging context; persisted rows may clip declared lists to
2746
+ * previews.
2745
2747
  *
2746
2748
  * @sdkReference runtime 200
2747
2749
  */
@@ -3951,6 +3953,12 @@ type ListConversionResult = {
3951
3953
  /** Dotted path to where the list was found (e.g. `"output.body"`, `"people"`). */
3952
3954
  sourcePath: string | null;
3953
3955
  };
3956
+ type CsvOutputArtifact = {
3957
+ path: string;
3958
+ rowCount: number;
3959
+ columns: string[];
3960
+ preview: string;
3961
+ };
3954
3962
  type Scalar = string | number | boolean | null;
3955
3963
  /**
3956
3964
  * Extract a list of records from a tool response.
@@ -4042,12 +4050,7 @@ declare function writeJsonOutputFile(payload: unknown, stem: string): string;
4042
4050
  */
4043
4051
  declare function writeCsvOutputFile(rows: Array<Record<string, unknown>>, stem: string, options?: {
4044
4052
  outPath?: string;
4045
- }): {
4046
- path: string;
4047
- rowCount: number;
4048
- columns: string[];
4049
- preview: string;
4050
- };
4053
+ }): CsvOutputArtifact;
4051
4054
  /**
4052
4055
  * Extract scalar (non-nested) fields from a tool response for summary display.
4053
4056
  *
package/dist/index.js CHANGED
@@ -308,7 +308,7 @@ function loadProjectEnvCandidates(startDir = process.cwd()) {
308
308
  }));
309
309
  }
310
310
  function normalizeBaseUrl(baseUrl) {
311
- const trimmed = baseUrl.trim().replace(/\/+$/, "");
311
+ const trimmed = baseUrl?.trim().replace(/\/+$/, "") ?? "";
312
312
  if (!trimmed) return "";
313
313
  try {
314
314
  const parsed = new URL(trimmed);
@@ -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.149",
422
+ version: "0.1.151",
423
423
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
424
424
  supportPolicy: {
425
- latest: "0.1.149",
425
+ latest: "0.1.151",
426
426
  minimumSupported: "0.1.53",
427
427
  deprecatedBelow: "0.1.53",
428
428
  commandMinimumSupported: [
@@ -1886,6 +1886,7 @@ async function* observeRunEvents(options) {
1886
1886
  var TERMINAL_PLAY_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "cancelled"]);
1887
1887
  var INCLUDE_TOOL_METADATA_HEADER = "x-deepline-include-tool-metadata";
1888
1888
  var EXECUTE_RESPONSE_CONTRACT_HEADER = "x-deepline-execute-response-contract";
1889
+ var EXECUTE_RESPONSE_INTENT_HEADER = "x-deepline-execute-response-intent";
1889
1890
  var V2_EXECUTE_RESPONSE_CONTRACT = "v2-tool-response";
1890
1891
  var COMPILE_MANIFEST_RETRY_DELAYS_MS = [250, 1e3];
1891
1892
  var REGISTER_PLAY_ARTIFACTS_COMPILE_CONCURRENCY = 3;
@@ -2370,7 +2371,8 @@ var DeeplineClient = class {
2370
2371
  async executeTool(toolId, input, options) {
2371
2372
  const headers = {
2372
2373
  [EXECUTE_RESPONSE_CONTRACT_HEADER]: V2_EXECUTE_RESPONSE_CONTRACT,
2373
- ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {}
2374
+ ...options?.includeToolMetadata ? { [INCLUDE_TOOL_METADATA_HEADER]: "true" } : {},
2375
+ ...options?.responseIntent ? { [EXECUTE_RESPONSE_INTENT_HEADER]: options.responseIntent } : {}
2374
2376
  };
2375
2377
  return this.http.post(
2376
2378
  `/api/v2/integrations/${encodeURIComponent(toolId)}/execute`,
@@ -5592,6 +5594,19 @@ function normalizeRows2(value) {
5592
5594
  return { value: entry };
5593
5595
  });
5594
5596
  }
5597
+ function columnsForRows(rows) {
5598
+ const seen = /* @__PURE__ */ new Set();
5599
+ const columns = [];
5600
+ for (const row of rows) {
5601
+ for (const key of Object.keys(row)) {
5602
+ if (!seen.has(key)) {
5603
+ seen.add(key);
5604
+ columns.push(key);
5605
+ }
5606
+ }
5607
+ }
5608
+ return columns;
5609
+ }
5595
5610
  function candidateRoots(payload) {
5596
5611
  const roots = [
5597
5612
  { path: null, value: payload }
@@ -5688,16 +5703,7 @@ function writeJsonOutputFile(payload, stem) {
5688
5703
  function writeCsvOutputFile(rows, stem, options) {
5689
5704
  const outputPath = options?.outPath ? options.outPath : (0, import_node_path3.join)(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
5690
5705
  (0, import_node_fs3.mkdirSync)((0, import_node_path3.dirname)(outputPath), { recursive: true });
5691
- const seen = /* @__PURE__ */ new Set();
5692
- const columns = [];
5693
- for (const row of rows) {
5694
- for (const key of Object.keys(row)) {
5695
- if (!seen.has(key)) {
5696
- seen.add(key);
5697
- columns.push(key);
5698
- }
5699
- }
5700
- }
5706
+ const columns = columnsForRows(rows);
5701
5707
  const escapeCell = (value) => {
5702
5708
  const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
5703
5709
  if (/[",\n]/.test(normalized)) {
@@ -5705,13 +5711,20 @@ function writeCsvOutputFile(rows, stem, options) {
5705
5711
  }
5706
5712
  return normalized;
5707
5713
  };
5708
- const lines = [];
5709
- lines.push(columns.map(escapeCell).join(","));
5710
- for (const row of rows) {
5711
- lines.push(columns.map((column) => escapeCell(row[column])).join(","));
5714
+ const fd = (0, import_node_fs3.openSync)(outputPath, "w");
5715
+ try {
5716
+ (0, import_node_fs3.writeSync)(fd, `${columns.map(escapeCell).join(",")}
5717
+ `);
5718
+ for (const row of rows) {
5719
+ (0, import_node_fs3.writeSync)(
5720
+ fd,
5721
+ `${columns.map((column) => escapeCell(row[column])).join(",")}
5722
+ `
5723
+ );
5724
+ }
5725
+ } finally {
5726
+ (0, import_node_fs3.closeSync)(fd);
5712
5727
  }
5713
- (0, import_node_fs3.writeFileSync)(outputPath, `${lines.join("\n")}
5714
- `, "utf-8");
5715
5728
  const previewRows = rows.slice(0, 5);
5716
5729
  const previewColumns = columns.slice(0, 5);
5717
5730
  const preview = [