deepline 0.1.222 → 0.1.224

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -625,10 +625,10 @@ var SDK_RELEASE = {
625
625
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
626
626
  // 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
627
627
  // automatically without blocking their current command.
628
- version: "0.1.222",
628
+ version: "0.1.224",
629
629
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
630
630
  supportPolicy: {
631
- latest: "0.1.222",
631
+ latest: "0.1.224",
632
632
  minimumSupported: "0.1.53",
633
633
  deprecatedBelow: "0.1.219",
634
634
  commandMinimumSupported: [
@@ -1364,29 +1364,42 @@ function normalizePlayRunLedgerTerminalSource(value) {
1364
1364
  // ../shared_libs/play-runtime/secret-redaction.ts
1365
1365
  var SECRET_REDACTION_PLACEHOLDER = "[REDACTED_SECRET]";
1366
1366
  var BEARER_TOKEN_RE = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}\b/g;
1367
- var JWT_RE = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
1367
+ var BASIC_CREDENTIAL_RE = /\bBasic\s+[A-Za-z0-9+/]{4,}={0,2}\b/g;
1368
+ var JWT_RE = /\b[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{1,}\.[A-Za-z0-9_-]{8,}\b/g;
1368
1369
  var PRIVATE_KEY_RE = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g;
1369
- var COMMON_SECRET_RE = /\b(?:(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9_./+=:-]{12,}|(?:pat|ghp|github_pat)_[A-Za-z0-9_./+=:-]{12,}|xox[baprs]-[A-Za-z0-9_./+=:-]{12,})\b/gi;
1370
+ var SENSITIVE_FIELD_NAME = "authorization|cookie|password|(?:client[_-]?)?secret|(?:access|refresh)[_-]?token|(?:x[_-]?)?api[_-]?key|private[_-]?key|token|credentials";
1371
+ var COMMON_SECRET_RE = /\b(?:[prs]k_(?:live|test)_|(?:pat|ghp|github_pat)_|xox[baprs]-)[A-Za-z0-9_./+=:-]{12,}\b/gi;
1370
1372
  var GENERIC_PREFIXED_SECRET_RE = /\b(?:key|token|secret|api[_-]?key)_[A-Za-z0-9_./+=:-]{12,}\b/gi;
1371
- var URL_SECRET_VALUE_RE = /\b(?:sk|pk|rk|pat|ghp|github_pat|xox)[A-Za-z0-9_./+=:-]{12,}\b/i;
1373
+ var URL_SECRET_VALUE_RE = /\b(?:[spr]k|pat|ghp|github_pat|xox)[A-Za-z0-9_./+=:-]{12,}\b/i;
1372
1374
  var GENERIC_SECRET_ASSIGNMENT_RE = /\b(?:api[_-]?key|token|secret|password)\b\s*[:=]\s*["']?[^"',\s]{12,}["']?/gi;
1373
- var HIGH_ENTROPY_ASSIGNMENT_RE = /\b(?:api[_-]?key|token|secret|password|authorization|access[_-]?token|refresh[_-]?token)\b\s*[:=]\s*["']?[^"',\s]{16,}["']?/gi;
1375
+ var HIGH_ENTROPY_ASSIGNMENT_RE = /\b(?:api[_-]?key|token|secret|password|authorization|(?:access|refresh)[_-]?token)\b\s*[:=]\s*["']?[^"',\s]{16,}["']?/gi;
1374
1376
  var SENSITIVE_URL_PARAM_RE = /[?#&](?:\w*(?:key|token)|secret|password|authorization|credential|signature|sig)(?:=|$)/i;
1377
+ var SENSITIVE_FIELD_NAME_RE = new RegExp(
1378
+ `(^|[._-])(?:${SENSITIVE_FIELD_NAME})$`,
1379
+ "i"
1380
+ );
1381
+ var SERIALIZED_SECRET_FIELD_RE = new RegExp(
1382
+ `"(${SENSITIVE_FIELD_NAME})"\\s*:\\s*(?:"[^"\\\\]*"|\\{[^{}]*\\})`,
1383
+ "gi"
1384
+ );
1375
1385
  function escapeRegExp(value) {
1376
1386
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1377
1387
  }
1378
- function isRecord(value) {
1379
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1380
- }
1381
1388
  function redactSecretLikeString(value) {
1382
- const trimmed = value.trim();
1389
+ const serializedRedacted = value.replace(
1390
+ SERIALIZED_SECRET_FIELD_RE,
1391
+ `"$1":"${SECRET_REDACTION_PLACEHOLDER}"`
1392
+ );
1393
+ const trimmed = serializedRedacted.trim();
1383
1394
  if (/^https?:\/\/\S+$/i.test(trimmed)) {
1384
1395
  if (/^https?:\/\/[^/?#@]+@/i.test(trimmed) || SENSITIVE_URL_PARAM_RE.test(trimmed)) {
1385
1396
  return SECRET_REDACTION_PLACEHOLDER;
1386
1397
  }
1387
- if (!URL_SECRET_VALUE_RE.test(value)) return value;
1398
+ if (!URL_SECRET_VALUE_RE.test(serializedRedacted)) {
1399
+ return serializedRedacted;
1400
+ }
1388
1401
  }
1389
- return value.replace(PRIVATE_KEY_RE, SECRET_REDACTION_PLACEHOLDER).replace(BEARER_TOKEN_RE, `Bearer ${SECRET_REDACTION_PLACEHOLDER}`).replace(JWT_RE, SECRET_REDACTION_PLACEHOLDER).replace(COMMON_SECRET_RE, SECRET_REDACTION_PLACEHOLDER).replace(GENERIC_PREFIXED_SECRET_RE, SECRET_REDACTION_PLACEHOLDER).replace(GENERIC_SECRET_ASSIGNMENT_RE, SECRET_REDACTION_PLACEHOLDER).replace(HIGH_ENTROPY_ASSIGNMENT_RE, (match) => {
1402
+ return serializedRedacted.replace(PRIVATE_KEY_RE, SECRET_REDACTION_PLACEHOLDER).replace(BEARER_TOKEN_RE, `Bearer ${SECRET_REDACTION_PLACEHOLDER}`).replace(BASIC_CREDENTIAL_RE, `Basic ${SECRET_REDACTION_PLACEHOLDER}`).replace(JWT_RE, SECRET_REDACTION_PLACEHOLDER).replace(COMMON_SECRET_RE, SECRET_REDACTION_PLACEHOLDER).replace(GENERIC_PREFIXED_SECRET_RE, SECRET_REDACTION_PLACEHOLDER).replace(GENERIC_SECRET_ASSIGNMENT_RE, SECRET_REDACTION_PLACEHOLDER).replace(HIGH_ENTROPY_ASSIGNMENT_RE, (match) => {
1390
1403
  const separator = match.includes("=") ? "=" : ":";
1391
1404
  const [key] = match.split(separator, 1);
1392
1405
  return `${key.trim()}${separator}${SECRET_REDACTION_PLACEHOLDER}`;
@@ -1421,9 +1434,12 @@ function createSecretRedactionContext(initialValues = []) {
1421
1434
  function redact(value) {
1422
1435
  if (typeof value === "string") return redactString(value);
1423
1436
  if (Array.isArray(value)) return value.map((entry) => redact(entry));
1424
- if (isRecord(value)) {
1437
+ if (value && typeof value === "object") {
1425
1438
  return Object.fromEntries(
1426
- Object.entries(value).map(([key, entry]) => [key, redact(entry)])
1439
+ Object.entries(value).map(([key, entry]) => [
1440
+ key,
1441
+ SENSITIVE_FIELD_NAME_RE.test(key) ? SECRET_REDACTION_PLACEHOLDER : redact(entry)
1442
+ ])
1427
1443
  );
1428
1444
  }
1429
1445
  return value;
@@ -1447,7 +1463,7 @@ var ledgerIngressRedactor = createSecretRedactionContext();
1447
1463
 
1448
1464
  // ../shared_libs/play-runtime/run-ledger.ts
1449
1465
  var LOG_TAIL_LIMIT = 100;
1450
- function isRecord2(value) {
1466
+ function isRecord(value) {
1451
1467
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
1452
1468
  }
1453
1469
  function finiteNumber(value) {
@@ -1540,21 +1556,21 @@ function createEmptyPlayRunLedgerSnapshot(input2) {
1540
1556
  };
1541
1557
  }
1542
1558
  function normalizePlayRunLedgerSnapshot(value, fallback) {
1543
- if (!isRecord2(value)) {
1559
+ if (!isRecord(value)) {
1544
1560
  return createEmptyPlayRunLedgerSnapshot(fallback);
1545
1561
  }
1546
1562
  const orderedStepIds = Array.isArray(value.orderedStepIds) ? value.orderedStepIds.filter(
1547
1563
  (entry) => typeof entry === "string" && Boolean(entry.trim())
1548
1564
  ) : [];
1549
- const rawSteps = isRecord2(value.stepsById) ? value.stepsById : {};
1565
+ const rawSteps = isRecord(value.stepsById) ? value.stepsById : {};
1550
1566
  const stepsById = {};
1551
1567
  for (const [stepId, rawStep] of Object.entries(rawSteps)) {
1552
- if (!stepId.trim() || !isRecord2(rawStep)) continue;
1568
+ if (!stepId.trim() || !isRecord(rawStep)) continue;
1553
1569
  const rawStatus = normalizeStepStatus(rawStep.status);
1554
1570
  if (!rawStatus) continue;
1555
1571
  const completedAt = finiteNumber(rawStep.completedAt);
1556
1572
  const status = rawStatus === "running" && completedAt !== null ? "completed" : rawStatus;
1557
- const rawProgress = isRecord2(rawStep.progress) ? rawStep.progress : null;
1573
+ const rawProgress = isRecord(rawStep.progress) ? rawStep.progress : null;
1558
1574
  stepsById[stepId] = {
1559
1575
  stepId,
1560
1576
  label: optionalString(rawStep.label),
@@ -1569,10 +1585,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
1569
1585
  progress: rawProgress ? normalizeStepProgress(rawProgress) : null
1570
1586
  };
1571
1587
  }
1572
- const rawDatasets = isRecord2(value.datasetsById) ? value.datasetsById : {};
1588
+ const rawDatasets = isRecord(value.datasetsById) ? value.datasetsById : {};
1573
1589
  const datasetsById = {};
1574
1590
  for (const [datasetId, rawDataset] of Object.entries(rawDatasets)) {
1575
- if (!datasetId.trim() || !isRecord2(rawDataset)) continue;
1591
+ if (!datasetId.trim() || !isRecord(rawDataset)) continue;
1576
1592
  const phase = rawDataset.phase === "available" || rawDataset.phase === "failed" ? rawDataset.phase : "registered";
1577
1593
  datasetsById[datasetId] = {
1578
1594
  datasetId,
@@ -1703,18 +1719,18 @@ function normalizePlayRunLiveStatus(value) {
1703
1719
  function isTerminalPlayRunLiveStatus(status) {
1704
1720
  return isTerminalPlayRunLifecycleStatus(status);
1705
1721
  }
1706
- function isRecord3(value) {
1722
+ function isRecord2(value) {
1707
1723
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
1708
1724
  }
1709
1725
  function finiteNumber2(value) {
1710
1726
  return typeof value === "number" && Number.isFinite(value) ? value : null;
1711
1727
  }
1712
1728
  function extractTerminalRunLogTail(result) {
1713
- if (!isRecord3(result) || !isRecord3(result._metadata)) {
1729
+ if (!isRecord2(result) || !isRecord2(result._metadata)) {
1714
1730
  return null;
1715
1731
  }
1716
1732
  const runLogTail = result._metadata.runLogTail;
1717
- if (!isRecord3(runLogTail) || !Array.isArray(runLogTail.tail)) {
1733
+ if (!isRecord2(runLogTail) || !Array.isArray(runLogTail.tail)) {
1718
1734
  return null;
1719
1735
  }
1720
1736
  const logTail = runLogTail.tail.filter(
@@ -2451,7 +2467,7 @@ function resolveToolExecuteTimeoutMs(toolId) {
2451
2467
  }
2452
2468
  var RUNS_FAILED_LOG_LIMIT = 20;
2453
2469
  var RUN_LOGS_PAGE_LIMIT = 1e3;
2454
- function isRecord4(value) {
2470
+ function isRecord3(value) {
2455
2471
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
2456
2472
  }
2457
2473
  function isPrebuiltPlayDescription(play) {
@@ -2608,7 +2624,7 @@ function updatePlayLiveStatusState(state, event) {
2608
2624
  }
2609
2625
  const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
2610
2626
  const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
2611
- const progressPayload = isRecord4(payload.progress) ? payload.progress : {};
2627
+ const progressPayload = isRecord3(payload.progress) ? payload.progress : {};
2612
2628
  if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
2613
2629
  const payloadLogs = readStringArray(payload.logs);
2614
2630
  const progressLogs = readStringArray(progressPayload.logs);
@@ -2723,9 +2739,9 @@ var DeeplineClient = class {
2723
2739
  return fields.length > 0 ? { fields } : schema;
2724
2740
  }
2725
2741
  schemaMetadata(schema, key) {
2726
- if (!isRecord4(schema)) return null;
2742
+ if (!isRecord3(schema)) return null;
2727
2743
  const value = schema[key];
2728
- return isRecord4(value) ? value : null;
2744
+ return isRecord3(value) ? value : null;
2729
2745
  }
2730
2746
  playRunCommand(play, options) {
2731
2747
  const target = play.reference || play.name;
@@ -2774,7 +2790,7 @@ var DeeplineClient = class {
2774
2790
  aliases,
2775
2791
  inputSchema: options?.compact ? this.compactSchema(play.inputSchema) : play.inputSchema ?? null,
2776
2792
  outputSchema: options?.compact ? this.compactSchema(play.outputSchema) : play.outputSchema ?? null,
2777
- staticPipeline: isRecord4(play.staticPipeline) ? play.staticPipeline : isRecord4(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord4(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
2793
+ staticPipeline: isRecord3(play.staticPipeline) ? play.staticPipeline : isRecord3(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord3(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
2778
2794
  ...csvInput ? { csvInput } : {},
2779
2795
  ...rowOutputSchema ? { rowOutputSchema } : {},
2780
2796
  runCommand: runCommand2,
@@ -7373,14 +7389,14 @@ function sanitizeCsvProjectionInfo(input2) {
7373
7389
  const rows = input2.rows.map(stripCsvProjectionFields);
7374
7390
  return { rows, columns };
7375
7391
  }
7376
- function isRecord5(value) {
7392
+ function isRecord4(value) {
7377
7393
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
7378
7394
  }
7379
7395
  function isSerializedDataset(value) {
7380
- return isRecord5(value) && value.kind === "dataset" && typeof value.count === "number" && (Array.isArray(value.preview) || typeof value.tableNamespace === "string");
7396
+ return isRecord4(value) && value.kind === "dataset" && typeof value.count === "number" && (Array.isArray(value.preview) || typeof value.tableNamespace === "string");
7381
7397
  }
7382
7398
  function isPackagedDatasetOutput(value) {
7383
- return isRecord5(value) && value.kind === "dataset" && isRecord5(value.preview) && Array.isArray(value.preview.rows);
7399
+ return isRecord4(value) && value.kind === "dataset" && isRecord4(value.preview) && Array.isArray(value.preview.rows);
7384
7400
  }
7385
7401
  function pathParts(path) {
7386
7402
  return path.split(".").map((part) => part.trim()).filter(Boolean);
@@ -7388,7 +7404,7 @@ function pathParts(path) {
7388
7404
  function valueAtPath(root, path) {
7389
7405
  let cursor = root;
7390
7406
  for (const part of pathParts(path)) {
7391
- if (!isRecord5(cursor)) {
7407
+ if (!isRecord4(cursor)) {
7392
7408
  return void 0;
7393
7409
  }
7394
7410
  cursor = cursor[part];
@@ -7396,17 +7412,17 @@ function valueAtPath(root, path) {
7396
7412
  return cursor;
7397
7413
  }
7398
7414
  function totalRowsForDataset(result, datasetPath) {
7399
- const metadata = isRecord5(result._metadata) ? result._metadata : null;
7415
+ const metadata = isRecord4(result._metadata) ? result._metadata : null;
7400
7416
  const parentPath = datasetPath.split(".").slice(0, -1).join(".");
7401
7417
  const parent = parentPath ? valueAtPath({ result }, parentPath) : result;
7402
- return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (isRecord5(parent) ? parent.totalRows ?? parent.rowCount ?? parent.count : void 0) ?? result.totalRows ?? result.rowCount ?? result.count;
7418
+ return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (isRecord4(parent) ? parent.totalRows ?? parent.rowCount ?? parent.count : void 0) ?? result.totalRows ?? result.rowCount ?? result.count;
7403
7419
  }
7404
7420
  function rowArray(value) {
7405
7421
  if (!Array.isArray(value)) {
7406
7422
  return null;
7407
7423
  }
7408
7424
  const rows = value.filter(
7409
- (row) => isRecord5(row)
7425
+ (row) => isRecord4(row)
7410
7426
  );
7411
7427
  return rows.length === value.length ? rows : null;
7412
7428
  }
@@ -7430,7 +7446,7 @@ function inferColumns(rows) {
7430
7446
  return columns;
7431
7447
  }
7432
7448
  function columnsFromDatasetSummary(summary) {
7433
- if (!isRecord5(summary) || !isRecord5(summary.columnStats)) {
7449
+ if (!isRecord4(summary) || !isRecord4(summary.columnStats)) {
7434
7450
  return [];
7435
7451
  }
7436
7452
  return Object.keys(summary.columnStats).filter((column) => column);
@@ -7520,7 +7536,7 @@ function collectDatasetCandidates(input2) {
7520
7536
  });
7521
7537
  return;
7522
7538
  }
7523
- if (!isRecord5(input2.value)) {
7539
+ if (!isRecord4(input2.value)) {
7524
7540
  return;
7525
7541
  }
7526
7542
  for (const [key, child] of Object.entries(input2.value)) {
@@ -7537,12 +7553,12 @@ function collectDatasetCandidates(input2) {
7537
7553
  }
7538
7554
  }
7539
7555
  function collectCanonicalRowsInfos(statusOrResult) {
7540
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
7541
- const result = isRecord5(root?.result) ? root.result : root;
7556
+ const root = isRecord4(statusOrResult) ? statusOrResult : null;
7557
+ const result = isRecord4(root?.result) ? root.result : root;
7542
7558
  if (!result) {
7543
7559
  return [];
7544
7560
  }
7545
- const metadata = isRecord5(result._metadata) ? result._metadata : null;
7561
+ const metadata = isRecord4(result._metadata) ? result._metadata : null;
7546
7562
  const totalFromMetadata = metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count;
7547
7563
  const candidates = [
7548
7564
  {
@@ -7566,8 +7582,8 @@ function collectCanonicalRowsInfos(statusOrResult) {
7566
7582
  total: totalFromMetadata ?? result.totalRows ?? result.rowCount ?? result.count
7567
7583
  }
7568
7584
  ];
7569
- if (isRecord5(result.output)) {
7570
- const outputMetadata = isRecord5(result.output._metadata) ? result.output._metadata : null;
7585
+ if (isRecord4(result.output)) {
7586
+ const outputMetadata = isRecord4(result.output._metadata) ? result.output._metadata : null;
7571
7587
  const outputTotalFromMetadata = outputMetadata?.totalRows ?? outputMetadata?.rowCount ?? outputMetadata?.count;
7572
7588
  candidates.push(
7573
7589
  {
@@ -7594,14 +7610,14 @@ function collectCanonicalRowsInfos(statusOrResult) {
7594
7610
  }
7595
7611
  if (Array.isArray(result.steps)) {
7596
7612
  result.steps.forEach((step, index) => {
7597
- if (!isRecord5(step) || !isRecord5(step.output)) {
7613
+ if (!isRecord4(step) || !isRecord4(step.output)) {
7598
7614
  return;
7599
7615
  }
7600
7616
  const source = typeof step.output.path === "string" ? step.output.path : typeof step.id === "string" ? `steps.${step.id}.output` : `steps.${index}.output`;
7601
7617
  candidates.push({
7602
7618
  source,
7603
7619
  value: step.output,
7604
- total: step.output.rowCount ?? (isRecord5(step.output.preview) ? step.output.preview.totalRows : void 0) ?? (isRecord5(step.progress) ? step.progress.total : void 0)
7620
+ total: step.output.rowCount ?? (isRecord4(step.output.preview) ? step.output.preview.totalRows : void 0) ?? (isRecord4(step.progress) ? step.progress.total : void 0)
7605
7621
  });
7606
7622
  });
7607
7623
  }
@@ -7629,15 +7645,15 @@ function collectCanonicalRowsInfos(statusOrResult) {
7629
7645
  return infos;
7630
7646
  }
7631
7647
  function collectPackagedDatasetCandidates(statusOrResult) {
7632
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
7648
+ const root = isRecord4(statusOrResult) ? statusOrResult : null;
7633
7649
  if (!root) {
7634
7650
  return [];
7635
7651
  }
7636
- const pkg = isRecord5(root.package) ? root.package : root;
7652
+ const pkg = isRecord4(root.package) ? root.package : root;
7637
7653
  const datasets = Array.isArray(pkg.datasets) ? pkg.datasets : [];
7638
7654
  const candidates = [];
7639
7655
  for (const output2 of datasets) {
7640
- if (!isRecord5(output2) || !isPackagedDatasetOutput(output2)) {
7656
+ if (!isRecord4(output2) || !isPackagedDatasetOutput(output2)) {
7641
7657
  continue;
7642
7658
  }
7643
7659
  const source = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
@@ -7647,14 +7663,14 @@ function collectPackagedDatasetCandidates(statusOrResult) {
7647
7663
  candidates.push({
7648
7664
  source,
7649
7665
  value: output2,
7650
- total: output2.rowCount ?? (isRecord5(output2.preview) ? output2.preview.totalRows : void 0)
7666
+ total: output2.rowCount ?? (isRecord4(output2.preview) ? output2.preview.totalRows : void 0)
7651
7667
  });
7652
7668
  }
7653
7669
  return candidates;
7654
7670
  }
7655
7671
  function collectSerializedDatasetRowsInfos(statusOrResult) {
7656
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
7657
- const result = isRecord5(root?.result) ? root.result : root;
7672
+ const root = isRecord4(statusOrResult) ? statusOrResult : null;
7673
+ const result = isRecord4(root?.result) ? root.result : root;
7658
7674
  const candidates = [];
7659
7675
  if (result) {
7660
7676
  collectDatasetCandidates({
@@ -7662,7 +7678,7 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
7662
7678
  path: "result",
7663
7679
  output: candidates
7664
7680
  });
7665
- if (isRecord5(result.output)) {
7681
+ if (isRecord4(result.output)) {
7666
7682
  collectDatasetCandidates({
7667
7683
  value: result.output,
7668
7684
  path: "result",
@@ -7734,13 +7750,13 @@ function summarizeSampleValue(value, depth = 0) {
7734
7750
  if (typeof parsed === "number" || typeof parsed === "boolean") return parsed;
7735
7751
  if (depth >= 3) {
7736
7752
  if (Array.isArray(parsed)) return [];
7737
- if (isRecord5(parsed)) return {};
7753
+ if (isRecord4(parsed)) return {};
7738
7754
  return compactScalar(parsed);
7739
7755
  }
7740
7756
  if (Array.isArray(parsed)) {
7741
7757
  return parsed.slice(0, 3).map((item) => summarizeSampleValue(item, depth + 1));
7742
7758
  }
7743
- if (isRecord5(parsed)) {
7759
+ if (isRecord4(parsed)) {
7744
7760
  const out = {};
7745
7761
  for (const [key, nested] of Object.entries(parsed)) {
7746
7762
  if (["__dl", "meta", "metadata"].includes(key)) {
@@ -7771,7 +7787,7 @@ function compactCell(value) {
7771
7787
  }
7772
7788
  return `[${parsed.length} items]`;
7773
7789
  }
7774
- if (isRecord5(parsed)) {
7790
+ if (isRecord4(parsed)) {
7775
7791
  for (const key of ["matched_result", "output"]) {
7776
7792
  if (parsed[key] !== null && parsed[key] !== void 0 && parsed[key] !== "") {
7777
7793
  return compactCell(parsed[key]);
@@ -8810,17 +8826,17 @@ function parsePositiveInteger2(value, flagName) {
8810
8826
  }
8811
8827
  return parsed;
8812
8828
  }
8813
- function isRecord6(value) {
8829
+ function isRecord5(value) {
8814
8830
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
8815
8831
  }
8816
8832
  function stringValue(value) {
8817
8833
  return typeof value === "string" ? value.trim() : "";
8818
8834
  }
8819
8835
  function extractionEntries(value) {
8820
- if (Array.isArray(value)) return value.filter(isRecord6);
8821
- if (!isRecord6(value)) return [];
8836
+ if (Array.isArray(value)) return value.filter(isRecord5);
8837
+ if (!isRecord5(value)) return [];
8822
8838
  return Object.entries(value).map(
8823
- ([name, entry]) => isRecord6(entry) ? { name, ...entry } : { name }
8839
+ ([name, entry]) => isRecord5(entry) ? { name, ...entry } : { name }
8824
8840
  );
8825
8841
  }
8826
8842
  var PlayBootstrapError = class extends Error {
@@ -9382,7 +9398,7 @@ function readCsvSampleRows(sample) {
9382
9398
  relax_column_count: true,
9383
9399
  trim: true
9384
9400
  });
9385
- return Array.isArray(parsedRows) ? parsedRows.filter(isRecord6) : [];
9401
+ return Array.isArray(parsedRows) ? parsedRows.filter(isRecord5) : [];
9386
9402
  }
9387
9403
  function readSourceCsvColumnSpecs(csvPath) {
9388
9404
  const sample = readCsvSample(csvPath);
@@ -9415,16 +9431,16 @@ function packagedCsvPathForPlay(csvPath) {
9415
9431
  return portablePath.startsWith(".") ? portablePath : `./${portablePath}`;
9416
9432
  }
9417
9433
  function getterNamesFromTool(tool, kind) {
9418
- const usageGuidance = isRecord6(tool?.usageGuidance) ? tool.usageGuidance : {};
9419
- const resultGuidance = isRecord6(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord6(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
9434
+ const usageGuidance = isRecord5(tool?.usageGuidance) ? tool.usageGuidance : {};
9435
+ const resultGuidance = isRecord5(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord5(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
9420
9436
  const key = kind === "list" ? "extractedLists" : "extractedValues";
9421
9437
  const snakeKey = kind === "list" ? "extracted_lists" : "extracted_values";
9422
9438
  return extractionEntries(resultGuidance[key] ?? resultGuidance[snakeKey]).map((entry) => stringValue(entry.name)).filter(Boolean);
9423
9439
  }
9424
9440
  function targetGettersFromTool(tool) {
9425
- const record = isRecord6(tool) ? tool : {};
9441
+ const record = isRecord5(tool) ? tool : {};
9426
9442
  const raw = record.targetGetters ?? record.target_getters;
9427
- if (!isRecord6(raw)) return {};
9443
+ if (!isRecord5(raw)) return {};
9428
9444
  const entries = [];
9429
9445
  for (const [target, value] of Object.entries(raw)) {
9430
9446
  const paths = Array.isArray(value) ? value.map((path) => typeof path === "string" ? path.trim() : "").filter(Boolean) : [];
@@ -9445,10 +9461,10 @@ function listRowCandidateKeysFromTool(tool) {
9445
9461
  return [...keys].sort();
9446
9462
  }
9447
9463
  function inputPropertyNames(schema) {
9448
- if (!isRecord6(schema)) return [];
9449
- if (isRecord6(schema.properties)) return Object.keys(schema.properties);
9464
+ if (!isRecord5(schema)) return [];
9465
+ if (isRecord5(schema.properties)) return Object.keys(schema.properties);
9450
9466
  if (Array.isArray(schema.fields)) {
9451
- return schema.fields.filter(isRecord6).map((field) => stringValue(field.name)).filter(Boolean);
9467
+ return schema.fields.filter(isRecord5).map((field) => stringValue(field.name)).filter(Boolean);
9452
9468
  }
9453
9469
  return [];
9454
9470
  }
@@ -9462,7 +9478,7 @@ function schemaFieldDetails(schema) {
9462
9478
  return { required, optional };
9463
9479
  }
9464
9480
  function jsonSchemaTypeExpression(schema) {
9465
- if (!isRecord6(schema)) return "unknown";
9481
+ if (!isRecord5(schema)) return "unknown";
9466
9482
  const type = schema.type;
9467
9483
  if (Array.isArray(type)) {
9468
9484
  return type.map((entry) => jsonSchemaTypeExpression({ ...schema, type: entry })).join(" | ");
@@ -9492,7 +9508,7 @@ function jsonSchemaTypeExpression(schema) {
9492
9508
  }
9493
9509
  }
9494
9510
  function objectPropertySchema(schema, property) {
9495
- return isRecord6(schema) && isRecord6(schema.properties) ? schema.properties[property] : null;
9511
+ return isRecord5(schema) && isRecord5(schema.properties) ? schema.properties[property] : null;
9496
9512
  }
9497
9513
  function playOutputHasField(schema, field) {
9498
9514
  return objectPropertySchema(schema, field) != null;
@@ -9668,14 +9684,14 @@ ${indent2.slice(2)}}`;
9668
9684
  }
9669
9685
  function requiredPlayInputFields(play) {
9670
9686
  const schema = play?.inputSchema;
9671
- if (!isRecord6(schema)) return [];
9687
+ if (!isRecord5(schema)) return [];
9672
9688
  if (Array.isArray(schema.required)) {
9673
9689
  return schema.required.filter(
9674
9690
  (value) => typeof value === "string"
9675
9691
  );
9676
9692
  }
9677
9693
  if (Array.isArray(schema.fields)) {
9678
- return schema.fields.filter(isRecord6).filter(
9694
+ return schema.fields.filter(isRecord5).filter(
9679
9695
  (field) => field.required === true && typeof field.name === "string"
9680
9696
  ).map((field) => String(field.name));
9681
9697
  }
@@ -9856,7 +9872,7 @@ function validateBootstrapRoutes(input2) {
9856
9872
  }
9857
9873
  }
9858
9874
  function staticPipelineSubsteps(pipeline) {
9859
- if (!isRecord6(pipeline)) return [];
9875
+ if (!isRecord5(pipeline)) return [];
9860
9876
  return [
9861
9877
  ...extractionEntries(pipeline.stages),
9862
9878
  ...extractionEntries(pipeline.substeps)
@@ -9864,7 +9880,7 @@ function staticPipelineSubsteps(pipeline) {
9864
9880
  }
9865
9881
  function playUsesMapBackedRuntime(play) {
9866
9882
  const pipeline = play?.staticPipeline;
9867
- if (!isRecord6(pipeline)) return false;
9883
+ if (!isRecord5(pipeline)) return false;
9868
9884
  if (stringValue(pipeline.tableNamespace)) return true;
9869
9885
  return staticPipelineSubsteps(pipeline).some((substep) => {
9870
9886
  if (stringValue(substep.type) === "map") return true;
@@ -9873,7 +9889,7 @@ function playUsesMapBackedRuntime(play) {
9873
9889
  aliases: [],
9874
9890
  runCommand: "",
9875
9891
  examples: [],
9876
- staticPipeline: isRecord6(substep.pipeline) ? substep.pipeline : null
9892
+ staticPipeline: isRecord5(substep.pipeline) ? substep.pipeline : null
9877
9893
  });
9878
9894
  });
9879
9895
  }
@@ -12678,8 +12694,12 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
12678
12694
  }
12679
12695
  const eventRunId = getRunIdFromLiveEvent(event);
12680
12696
  if (typeof eventRunId === "string" && eventRunId && eventRunId !== "pending") {
12697
+ const runStartedNow = !lastKnownWorkflowId;
12681
12698
  lastKnownWorkflowId = eventRunId;
12682
12699
  firstRunIdMs ??= Date.now() - startedAt;
12700
+ if (runStartedNow) {
12701
+ input2.onRunStarted?.(eventRunId);
12702
+ }
12683
12703
  }
12684
12704
  const workflowId = lastKnownWorkflowId || "pending";
12685
12705
  if (workflowId !== "pending" && !emittedDashboardUrl) {
@@ -14293,7 +14313,7 @@ function extractPlayValidationErrors(value) {
14293
14313
  if (value instanceof DeeplineError) {
14294
14314
  return extractPlayValidationErrors(value.details);
14295
14315
  }
14296
- if (!isRecord7(value)) {
14316
+ if (!isRecord6(value)) {
14297
14317
  return [];
14298
14318
  }
14299
14319
  const directErrors = stringArrayField(value, "errors");
@@ -14728,7 +14748,7 @@ function shouldUseLocalOnlyPlayCheck() {
14728
14748
  const value = process.env.DEEPLINE_PLAY_CHECK_LOCAL_ONLY?.trim().toLowerCase();
14729
14749
  return value === "1" || value === "true" || value === "yes" || value === "on";
14730
14750
  }
14731
- function isRecord7(value) {
14751
+ function isRecord6(value) {
14732
14752
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
14733
14753
  }
14734
14754
  function stringValue2(value) {
@@ -14738,14 +14758,14 @@ function asArray(value) {
14738
14758
  return Array.isArray(value) ? value : [];
14739
14759
  }
14740
14760
  function extractionEntries2(value) {
14741
- if (Array.isArray(value)) return value.filter(isRecord7);
14742
- if (!isRecord7(value)) return [];
14761
+ if (Array.isArray(value)) return value.filter(isRecord6);
14762
+ if (!isRecord6(value)) return [];
14743
14763
  return Object.entries(value).map(
14744
- ([name, entry]) => isRecord7(entry) ? { name, ...entry } : { name }
14764
+ ([name, entry]) => isRecord6(entry) ? { name, ...entry } : { name }
14745
14765
  );
14746
14766
  }
14747
14767
  function firstRawPath(entry) {
14748
- const details = isRecord7(entry.details) ? entry.details : {};
14768
+ const details = isRecord6(entry.details) ? entry.details : {};
14749
14769
  const paths = [
14750
14770
  ...asArray(details.rawToolOutputPaths),
14751
14771
  ...asArray(details.raw_tool_output_paths),
@@ -14763,12 +14783,12 @@ function checkHintRawPath(value) {
14763
14783
  function collectStaticPipelineToolIds(staticPipeline) {
14764
14784
  const seen = /* @__PURE__ */ new Set();
14765
14785
  const visitPipeline = (pipeline) => {
14766
- if (!isRecord7(pipeline)) return;
14786
+ if (!isRecord6(pipeline)) return;
14767
14787
  for (const step of [
14768
14788
  ...asArray(pipeline.stages),
14769
14789
  ...asArray(pipeline.substeps)
14770
14790
  ]) {
14771
- if (!isRecord7(step)) continue;
14791
+ if (!isRecord6(step)) continue;
14772
14792
  if (step.type === "tool") {
14773
14793
  const toolId = stringValue2(step.toolId) || stringValue2(step.tool);
14774
14794
  if (toolId) seen.add(toolId);
@@ -14782,9 +14802,9 @@ function collectStaticPipelineToolIds(staticPipeline) {
14782
14802
  return [...seen].sort();
14783
14803
  }
14784
14804
  function toolGetterHintFromMetadata(toolId, tool) {
14785
- const usageGuidance = isRecord7(tool.usageGuidance) ? tool.usageGuidance : {};
14786
- const resultGuidance = isRecord7(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord7(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
14787
- const toolResponse = isRecord7(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord7(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
14805
+ const usageGuidance = isRecord6(tool.usageGuidance) ? tool.usageGuidance : {};
14806
+ const resultGuidance = isRecord6(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord6(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
14807
+ const toolResponse = isRecord6(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord6(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
14788
14808
  const lists = extractionEntries2(
14789
14809
  resultGuidance.extractedLists ?? resultGuidance.extracted_lists
14790
14810
  ).map((entry) => ({
@@ -15227,7 +15247,8 @@ async function handleFileBackedRun(options, hooks) {
15227
15247
  emitLogs: options.emitLogs,
15228
15248
  waitTimeoutMs: options.waitTimeoutMs,
15229
15249
  noOpen: options.noOpen,
15230
- progress
15250
+ progress,
15251
+ onRunStarted: hooks?.onRunStarted
15231
15252
  }).catch(async (error) => {
15232
15253
  throw await normalizePlayStartError(client2, error, playName);
15233
15254
  })
@@ -15393,7 +15414,8 @@ async function handleNamedRun(options, hooks) {
15393
15414
  emitLogs: options.emitLogs,
15394
15415
  waitTimeoutMs: options.waitTimeoutMs,
15395
15416
  noOpen: options.noOpen,
15396
- progress
15417
+ progress,
15418
+ onRunStarted: hooks?.onRunStarted
15397
15419
  }).catch(async (error) => {
15398
15420
  throw await normalizePlayStartError(client2, error, playName, {
15399
15421
  suggestMissingPlay: true
@@ -19085,7 +19107,7 @@ function isMarkedTestAiInferenceCommand(command) {
19085
19107
  if (normalizeEnrichPlayRef(command.tool) !== "run_javascript") {
19086
19108
  return false;
19087
19109
  }
19088
- return isRecord8(command.payload) && command.payload[ENRICH_TEST_AI_INFERENCE_PAYLOAD_MARKER] === true;
19110
+ return isRecord7(command.payload) && command.payload[ENRICH_TEST_AI_INFERENCE_PAYLOAD_MARKER] === true;
19089
19111
  }
19090
19112
  function enrichDebugEnabled(env = process.env) {
19091
19113
  const raw = String(env.DEEPLINE_DEBUG_ENRICH ?? "").trim().toLowerCase();
@@ -19349,7 +19371,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
19349
19371
  if (Array.isArray(value)) {
19350
19372
  return value.map(rewrite);
19351
19373
  }
19352
- if (!isRecord8(value)) {
19374
+ if (!isRecord7(value)) {
19353
19375
  return value;
19354
19376
  }
19355
19377
  const next = Object.fromEntries(
@@ -19358,7 +19380,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
19358
19380
  key === "rerunCommand" && typeof entry === "string" ? enrichCommand : rewrite(entry)
19359
19381
  ])
19360
19382
  );
19361
- if (isRecord8(next.next) && typeof next.next.run === "string") {
19383
+ if (isRecord7(next.next) && typeof next.next.run === "string") {
19362
19384
  next.next = { ...next.next, run: enrichCommand };
19363
19385
  }
19364
19386
  return next;
@@ -19829,7 +19851,7 @@ async function resolveWatchedGeneratedPlayStatus(input2) {
19829
19851
  }
19830
19852
  return input2.client.runs.get(runId, { full: true });
19831
19853
  }
19832
- function isRecord8(value) {
19854
+ function isRecord7(value) {
19833
19855
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
19834
19856
  }
19835
19857
  async function captureStdout(run, options = {}) {
@@ -19891,6 +19913,7 @@ async function runGeneratedEnrichPlay(client2, runArgs, options = {}) {
19891
19913
  let terminalStatus2 = null;
19892
19914
  const captured2 = await captureStdout(
19893
19915
  () => handlePlayRun(runArgs, {
19916
+ onRunStarted: options.onRunStarted,
19894
19917
  onTerminalStatus: (status) => {
19895
19918
  terminalStatus2 = status;
19896
19919
  }
@@ -19912,6 +19935,7 @@ async function runGeneratedEnrichPlay(client2, runArgs, options = {}) {
19912
19935
  let terminalStatus = null;
19913
19936
  const captured = await captureStdout(
19914
19937
  () => handlePlayRun(runArgs, {
19938
+ onRunStarted: options.onRunStarted,
19915
19939
  onTerminalStatus: (status) => {
19916
19940
  terminalStatus = status;
19917
19941
  }
@@ -19920,6 +19944,17 @@ async function runGeneratedEnrichPlay(client2, runArgs, options = {}) {
19920
19944
  );
19921
19945
  return { ...captured, terminalStatus };
19922
19946
  }
19947
+ function writeEnrichInterruptionHint(input2) {
19948
+ const output2 = input2.outputPath ? ` --out ${input2.outputPath}` : "";
19949
+ process.stderr.write(
19950
+ [
19951
+ `Enrich client interrupted by ${input2.signal}; the run is continuing in the background.`,
19952
+ `Run id: ${input2.runId}`,
19953
+ `Inspect: deepline runs get ${input2.runId} --full --json`,
19954
+ `Export: deepline runs export ${input2.runId} --dataset result.rows${output2}`
19955
+ ].join("\n") + "\n"
19956
+ );
19957
+ }
19923
19958
  async function writeOutputCsv(outputPath, status, options) {
19924
19959
  let rowsInfo = extractCanonicalRowsInfo(status);
19925
19960
  if (!rowsInfo) {
@@ -20068,13 +20103,13 @@ function readFirstEnrichDatasetActions(value) {
20068
20103
  return null;
20069
20104
  }
20070
20105
  const record = candidate;
20071
- const actions = isRecord8(record.actions) ? record.actions : null;
20072
- const query = isRecord8(actions?.query) ? actions.query : null;
20106
+ const actions = isRecord7(record.actions) ? record.actions : null;
20107
+ const query = isRecord7(actions?.query) ? actions.query : null;
20073
20108
  if (query?.kind === "deepline_db_query") {
20074
20109
  return {
20075
20110
  dataset: record,
20076
20111
  query,
20077
- ...isRecord8(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
20112
+ ...isRecord7(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
20078
20113
  };
20079
20114
  }
20080
20115
  if (options.allowLegacy && record.kind === "dataset" && typeof record.queryDatasetCommand === "string" && record.queryDatasetCommand.trim()) {
@@ -20127,7 +20162,7 @@ function enrichCustomerDbJson(input2) {
20127
20162
  const dataset = actions.dataset;
20128
20163
  const sql = actionStringField(query, "sql") ?? parseSqlFromDbQueryCommand(actions.queryDatasetCommand);
20129
20164
  const datasetPath = actionStringField(query, "datasetPath") ?? actionStringField(dataset, "path") ?? actionStringField(dataset, "tableNamespace");
20130
- const api = isRecord8(query.api) ? query.api : null;
20165
+ const api = isRecord7(query.api) ? query.api : null;
20131
20166
  const apiPath = actionStringField(api ?? {}, "path") ?? "/api/v2/db/query";
20132
20167
  const apiMethod = actionStringField(api ?? {}, "method") ?? "POST";
20133
20168
  if (!datasetPath) {
@@ -20196,11 +20231,11 @@ function sqlStringLiteral(value) {
20196
20231
  return `'${value.replace(/'/g, "''")}'`;
20197
20232
  }
20198
20233
  function failureAliasFromCellMeta(cellMeta) {
20199
- if (!isRecord8(cellMeta)) {
20234
+ if (!isRecord7(cellMeta)) {
20200
20235
  return null;
20201
20236
  }
20202
20237
  for (const [alias, meta] of Object.entries(cellMeta)) {
20203
- if (!isRecord8(meta)) {
20238
+ if (!isRecord7(meta)) {
20204
20239
  continue;
20205
20240
  }
20206
20241
  const failure = failureCellFromMeta(meta, {});
@@ -20693,7 +20728,7 @@ function exportableSheetRow2(row, sourceRowStart = 0) {
20693
20728
  return fallback;
20694
20729
  }
20695
20730
  function failureCellFromMeta(meta, fallback) {
20696
- if (!isRecord8(meta)) {
20731
+ if (!isRecord7(meta)) {
20697
20732
  return null;
20698
20733
  }
20699
20734
  const status = typeof meta.status === "string" ? meta.status.trim().toLowerCase() : "";
@@ -20713,7 +20748,7 @@ function failureCellFromMeta(meta, fallback) {
20713
20748
  };
20714
20749
  }
20715
20750
  function applyFailureCellMeta(row, cellMeta, fallback) {
20716
- if (!isRecord8(cellMeta)) {
20751
+ if (!isRecord7(cellMeta)) {
20717
20752
  return;
20718
20753
  }
20719
20754
  for (const [field, meta] of Object.entries(cellMeta)) {
@@ -20941,7 +20976,7 @@ function stableRowSnapshot(value) {
20941
20976
  }
20942
20977
  function cellFailureError(value) {
20943
20978
  const parsed = parseMaybeJsonObject(value);
20944
- if (!isRecord8(parsed)) {
20979
+ if (!isRecord7(parsed)) {
20945
20980
  const text = typeof parsed === "string" ? parsed.trim() : "";
20946
20981
  if (/^(?:[A-Za-z0-9_:-]+:\s*)?(?:Error|TypeError|ReferenceError|SyntaxError|RangeError):\s+/.test(
20947
20982
  text
@@ -20949,12 +20984,12 @@ function cellFailureError(value) {
20949
20984
  return { message: text };
20950
20985
  }
20951
20986
  }
20952
- if (!isRecord8(parsed)) {
20987
+ if (!isRecord7(parsed)) {
20953
20988
  return null;
20954
20989
  }
20955
20990
  const status = typeof parsed.status === "string" ? parsed.status.trim().toLowerCase() : "";
20956
20991
  const directError = typeof parsed.error === "string" ? parsed.error.trim() : typeof parsed.last_error === "string" ? parsed.last_error.trim() : "";
20957
- const result = isRecord8(parsed.result) ? parsed.result : null;
20992
+ const result = isRecord7(parsed.result) ? parsed.result : null;
20958
20993
  const resultError = typeof result?.error === "string" ? result.error.trim() : typeof result?.message === "string" ? result.message.trim() : "";
20959
20994
  if (!directError && !resultError && status !== "error" && status !== "failed") {
20960
20995
  return null;
@@ -21024,7 +21059,7 @@ function assignFlattenedFailurePath(target, field, value) {
21024
21059
  let cursor = target;
21025
21060
  for (const part of normalized.slice(0, -1)) {
21026
21061
  const existing = cursor[part];
21027
- if (!isRecord8(existing)) {
21062
+ if (!isRecord7(existing)) {
21028
21063
  const next = {};
21029
21064
  cursor[part] = next;
21030
21065
  cursor = next;
@@ -21188,10 +21223,10 @@ function waterfallExecutionSignal(status, spec) {
21188
21223
  let everyChildStatOnlyConditionSkipped = true;
21189
21224
  const childAliasesWithStats = /* @__PURE__ */ new Set();
21190
21225
  for (const childAlias of childAliases) {
21191
- for (const stat2 of summaries.map((summary) => summary[childAlias]).filter(isRecord8)) {
21226
+ for (const stat2 of summaries.map((summary) => summary[childAlias]).filter(isRecord7)) {
21192
21227
  sawChildStats = true;
21193
21228
  childAliasesWithStats.add(childAlias);
21194
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
21229
+ const execution = isRecord7(stat2.execution) ? stat2.execution : null;
21195
21230
  const executedSummary = parseExecutionSummary(
21196
21231
  execution?.["completed:executed"]
21197
21232
  );
@@ -21221,7 +21256,7 @@ function waterfallExecutionSignal(status, spec) {
21221
21256
  }
21222
21257
  function emptyWaterfallStatsEvidence(status, spec) {
21223
21258
  const summaries = collectColumnStats(status);
21224
- const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord8);
21259
+ const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord7);
21225
21260
  for (const stat2 of parentStats) {
21226
21261
  const nonEmpty = parseExecutionSummary(stat2.non_empty);
21227
21262
  if (nonEmpty?.total && nonEmpty.count === 0) {
@@ -21235,7 +21270,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
21235
21270
  let selectedRows = 0;
21236
21271
  let sawStatsForEveryChild = true;
21237
21272
  for (const childAlias of childAliases) {
21238
- const stat2 = summaries.map((summary) => summary[childAlias]).find(isRecord8);
21273
+ const stat2 = summaries.map((summary) => summary[childAlias]).find(isRecord7);
21239
21274
  if (!stat2) {
21240
21275
  sawStatsForEveryChild = false;
21241
21276
  break;
@@ -21244,7 +21279,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
21244
21279
  if ((nonEmpty?.count ?? 0) > 0) {
21245
21280
  return null;
21246
21281
  }
21247
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
21282
+ const execution = isRecord7(stat2.execution) ? stat2.execution : null;
21248
21283
  const executed = parseExecutionSummary(execution?.["completed:executed"]);
21249
21284
  const reused = parseExecutionSummary(execution?.["completed:reused"]);
21250
21285
  const skipped = parseExecutionSummary(execution?.["skipped:condition"]);
@@ -21286,11 +21321,11 @@ function collectStatusFailureJobs(input2) {
21286
21321
  const jobs = [];
21287
21322
  aliases.forEach((spec, aliasIndex) => {
21288
21323
  const { alias } = spec;
21289
- const stat2 = summaries.map((summary) => summary[alias]).find(isRecord8);
21324
+ const stat2 = summaries.map((summary) => summary[alias]).find(isRecord7);
21290
21325
  if (!stat2) {
21291
21326
  return;
21292
21327
  }
21293
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
21328
+ const execution = isRecord7(stat2.execution) ? stat2.execution : null;
21294
21329
  const failedCount = Math.min(
21295
21330
  selectedRows,
21296
21331
  Math.max(
@@ -21397,10 +21432,10 @@ function collectColumnStats(status) {
21397
21432
  value.forEach(visit);
21398
21433
  return;
21399
21434
  }
21400
- if (!isRecord8(value)) {
21435
+ if (!isRecord7(value)) {
21401
21436
  return;
21402
21437
  }
21403
- if (isRecord8(value.columnStats)) {
21438
+ if (isRecord7(value.columnStats)) {
21404
21439
  summaries.push(value.columnStats);
21405
21440
  }
21406
21441
  Object.values(value).forEach(visit);
@@ -21412,12 +21447,12 @@ function firstAliasExecutionCounts(input2) {
21412
21447
  const aliases = collectConfigScalarAliasOrder(input2.config);
21413
21448
  const summaries = collectColumnStats(input2.status);
21414
21449
  for (const alias of aliases) {
21415
- const stat2 = summaries.map((summary) => summary[alias]).find(isRecord8);
21450
+ const stat2 = summaries.map((summary) => summary[alias]).find(isRecord7);
21416
21451
  if (!stat2) continue;
21417
21452
  if (input2.forceAliases.has(normalizeAlias2(alias))) {
21418
21453
  return { executed: input2.selectedRows, reused: 0 };
21419
21454
  }
21420
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
21455
+ const execution = isRecord7(stat2.execution) ? stat2.execution : null;
21421
21456
  if (!execution) continue;
21422
21457
  return {
21423
21458
  executed: parseExecutionCount(execution["completed:executed"]),
@@ -21444,14 +21479,14 @@ function rewriteEnrichJsonStatus(input2) {
21444
21479
  if (Array.isArray(value)) {
21445
21480
  return value.map(rewrite);
21446
21481
  }
21447
- if (!isRecord8(value)) {
21482
+ if (!isRecord7(value)) {
21448
21483
  return value;
21449
21484
  }
21450
21485
  const next = {};
21451
21486
  for (const [key, entry] of Object.entries(value)) {
21452
21487
  next[key] = rewrite(entry);
21453
21488
  }
21454
- if (isRecord8(next.progress)) {
21489
+ if (isRecord7(next.progress)) {
21455
21490
  next.progress = {
21456
21491
  ...next.progress,
21457
21492
  ...selectedRows > 0 ? { total: selectedRows } : {},
@@ -21460,8 +21495,8 @@ function rewriteEnrichJsonStatus(input2) {
21460
21495
  ...failedRows > 0 ? { failed: failedRows, pending: 0 } : {}
21461
21496
  };
21462
21497
  }
21463
- if (isRecord8(next.summary)) {
21464
- const rowCounts = isRecord8(next.summary.rowCounts) ? next.summary.rowCounts : null;
21498
+ if (isRecord7(next.summary)) {
21499
+ const rowCounts = isRecord7(next.summary.rowCounts) ? next.summary.rowCounts : null;
21465
21500
  if (failedRows > 0) {
21466
21501
  next.summary = {
21467
21502
  ...next.summary,
@@ -21474,11 +21509,11 @@ function rewriteEnrichJsonStatus(input2) {
21474
21509
  };
21475
21510
  }
21476
21511
  }
21477
- if (isRecord8(next.columnStats) && selectedRows > 0) {
21512
+ if (isRecord7(next.columnStats) && selectedRows > 0) {
21478
21513
  const columnStats = { ...next.columnStats };
21479
21514
  for (const alias of forcedAliases) {
21480
- const stat2 = isRecord8(columnStats[alias]) ? columnStats[alias] : null;
21481
- const execution = isRecord8(stat2?.execution) ? stat2.execution : null;
21515
+ const stat2 = isRecord7(columnStats[alias]) ? columnStats[alias] : null;
21516
+ const execution = isRecord7(stat2?.execution) ? stat2.execution : null;
21482
21517
  if (!stat2 || !execution) continue;
21483
21518
  columnStats[alias] = {
21484
21519
  ...stat2,
@@ -21497,14 +21532,14 @@ function rewriteEnrichJsonStatus(input2) {
21497
21532
  return next;
21498
21533
  };
21499
21534
  const rewritten = rewrite(input2.status);
21500
- if (failedRows === 0 || !isRecord8(rewritten)) {
21535
+ if (failedRows === 0 || !isRecord7(rewritten)) {
21501
21536
  return rewritten;
21502
21537
  }
21503
21538
  const partialStatus = selectedRows > 0 && failedRows < selectedRows ? "partial_success" : "failed";
21504
21539
  return {
21505
21540
  ...rewritten,
21506
21541
  ...rewritten.status === "completed" || rewritten.status === "failed" ? { status: partialStatus } : {},
21507
- ...isRecord8(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
21542
+ ...isRecord7(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
21508
21543
  };
21509
21544
  }
21510
21545
  function summarizeFailedJobError(value) {
@@ -22110,7 +22145,7 @@ function materializeCsvCellValue(value) {
22110
22145
  return value;
22111
22146
  }
22112
22147
  function compactArrayEnvelopeCompleteValue(value) {
22113
- if (!isRecord8(value) || value.kind !== "array") {
22148
+ if (!isRecord7(value) || value.kind !== "array") {
22114
22149
  return null;
22115
22150
  }
22116
22151
  if (!Array.isArray(value.preview)) {
@@ -22124,7 +22159,7 @@ function compactArrayEnvelopeCompleteValue(value) {
22124
22159
  }
22125
22160
  function disambiguateCompactAiInferencePayload(value) {
22126
22161
  const parsed = parseMaybeJsonObject(value);
22127
- if (!isRecord8(parsed) || !cellFailureError(parsed)) {
22162
+ if (!isRecord7(parsed) || !cellFailureError(parsed)) {
22128
22163
  return value;
22129
22164
  }
22130
22165
  return {
@@ -22133,14 +22168,14 @@ function disambiguateCompactAiInferencePayload(value) {
22133
22168
  };
22134
22169
  }
22135
22170
  function compactAiInferenceCellForCsv(value) {
22136
- if (!isRecord8(value)) {
22171
+ if (!isRecord7(value)) {
22137
22172
  return value;
22138
22173
  }
22139
22174
  const extractedJson = value.extracted_json;
22140
22175
  if (extractedJson !== null && extractedJson !== void 0) {
22141
22176
  return disambiguateCompactAiInferencePayload(extractedJson);
22142
22177
  }
22143
- const result = isRecord8(value.result) ? value.result : null;
22178
+ const result = isRecord7(value.result) ? value.result : null;
22144
22179
  const object = result?.object;
22145
22180
  if (object !== null && object !== void 0) {
22146
22181
  return disambiguateCompactAiInferencePayload(object);
@@ -22157,12 +22192,12 @@ function compactAiInferenceCellForCsv(value) {
22157
22192
  }
22158
22193
  function materializeEnrichAliasCellForCsv(row, alias, options) {
22159
22194
  const direct = row[alias];
22160
- if (isRecord8(direct)) {
22195
+ if (isRecord7(direct)) {
22161
22196
  const completeArray = compactArrayEnvelopeCompleteValue(direct);
22162
22197
  if (completeArray) {
22163
22198
  return materializeCsvCellValue(completeArray);
22164
22199
  }
22165
- if (options?.compactAiCell && direct.status === "completed" && (isRecord8(direct.result) || Object.prototype.hasOwnProperty.call(direct, "extracted_json") || typeof direct.output === "string")) {
22200
+ if (options?.compactAiCell && direct.status === "completed" && (isRecord7(direct.result) || Object.prototype.hasOwnProperty.call(direct, "extracted_json") || typeof direct.output === "string")) {
22166
22201
  return materializeCsvCellValue(compactAiInferenceCellForCsv(direct));
22167
22202
  }
22168
22203
  if (Object.prototype.hasOwnProperty.call(direct, "matched_result") || Object.prototype.hasOwnProperty.call(direct, "matchedResult") || Object.prototype.hasOwnProperty.call(direct, "result")) {
@@ -22303,11 +22338,11 @@ function normalizeEnrichRowsForCsvExport(rows, config, options) {
22303
22338
  }
22304
22339
  function legacyMetadataFromRow(row) {
22305
22340
  const direct = parseLegacyMetadataCell(row._metadata);
22306
- if (direct && isRecord8(direct.columns)) {
22341
+ if (direct && isRecord7(direct.columns)) {
22307
22342
  return direct;
22308
22343
  }
22309
22344
  const relocated = parseLegacyMetadataCell(row.metadata);
22310
- if (relocated && isRecord8(relocated.columns)) {
22345
+ if (relocated && isRecord7(relocated.columns)) {
22311
22346
  return relocated;
22312
22347
  }
22313
22348
  const flattenedColumns = parseLegacyMetadataCell(row["metadata.columns"]);
@@ -22324,7 +22359,7 @@ function legacyMetadataFromRow(row) {
22324
22359
  }
22325
22360
  function parseLegacyMetadataCell(value) {
22326
22361
  const parsed = parseMaybeJsonObject(value);
22327
- if (isRecord8(parsed)) {
22362
+ if (isRecord7(parsed)) {
22328
22363
  return parsed;
22329
22364
  }
22330
22365
  if (typeof value !== "string") {
@@ -22341,12 +22376,12 @@ function parseLegacyMetadataCell(value) {
22341
22376
  for (const candidate of candidates) {
22342
22377
  try {
22343
22378
  const decoded = JSON.parse(candidate);
22344
- if (isRecord8(decoded)) {
22379
+ if (isRecord7(decoded)) {
22345
22380
  return decoded;
22346
22381
  }
22347
22382
  if (typeof decoded === "string") {
22348
22383
  const nested = JSON.parse(decoded);
22349
- if (isRecord8(nested)) {
22384
+ if (isRecord7(nested)) {
22350
22385
  return nested;
22351
22386
  }
22352
22387
  }
@@ -22356,8 +22391,8 @@ function parseLegacyMetadataCell(value) {
22356
22391
  return null;
22357
22392
  }
22358
22393
  function mergeLegacyMetadataRecords(base, enriched) {
22359
- const baseColumns = isRecord8(base.columns) ? base.columns : null;
22360
- const enrichedColumns = isRecord8(enriched.columns) ? enriched.columns : null;
22394
+ const baseColumns = isRecord7(base.columns) ? base.columns : null;
22395
+ const enrichedColumns = isRecord7(enriched.columns) ? enriched.columns : null;
22361
22396
  const merged = {
22362
22397
  ...base,
22363
22398
  ...enriched
@@ -22509,6 +22544,7 @@ function registerEnrichCommand(program) {
22509
22544
  }
22510
22545
  const rows = parseRows(options.rows, options.all);
22511
22546
  let outputPath = options.inPlace ? inputCsv : options.output;
22547
+ const requestedOutputPath = options.inPlace ? (0, import_node_path12.resolve)(inputCsv) : options.output ? (0, import_node_path12.resolve)(options.output) : void 0;
22512
22548
  const sourceCsvPath = !options.inPlace && outputPath && await regularFileExists(outputPath) ? outputPath : inputCsv;
22513
22549
  const forceAliases = resolveForceAliases(config, options);
22514
22550
  for (const alias of collectFailedInputAliases(
@@ -22550,6 +22586,19 @@ function registerEnrichCommand(program) {
22550
22586
  const inPlaceCommitOutputPath = options.inPlace ? (await (0, import_promises3.lstat)(inputCsv)).isSymbolicLink() ? await (0, import_promises3.realpath)(inputCsv) : inPlaceFinalOutputPath : null;
22551
22587
  const failureReportOutputPath = options.inPlace ? inPlaceFinalOutputPath : null;
22552
22588
  const enrichIssueFollowUpOutputPath = options.inPlace && inPlaceFinalOutputPath ? sidecarEnrichRowsExportPath(inPlaceFinalOutputPath) : null;
22589
+ let activeRunId2 = null;
22590
+ const interruptEnrich = (signal) => {
22591
+ if (activeRunId2) {
22592
+ writeEnrichInterruptionHint({
22593
+ signal,
22594
+ runId: activeRunId2,
22595
+ outputPath: requestedOutputPath
22596
+ });
22597
+ }
22598
+ process.exit(signal === "SIGINT" ? 130 : 143);
22599
+ };
22600
+ const onSigint = () => interruptEnrich("SIGINT");
22601
+ const onSigterm = () => interruptEnrich("SIGTERM");
22553
22602
  const prepareInPlaceOutput = async () => {
22554
22603
  if (!options.inPlace) {
22555
22604
  return;
@@ -22588,6 +22637,8 @@ function registerEnrichCommand(program) {
22588
22637
  };
22589
22638
  };
22590
22639
  try {
22640
+ process.once("SIGINT", onSigint);
22641
+ process.once("SIGTERM", onSigterm);
22591
22642
  await (0, import_promises3.writeFile)(tempPlay, playSource, "utf8");
22592
22643
  if (options.inPlace) {
22593
22644
  await prepareInPlaceOutput();
@@ -22625,7 +22676,10 @@ function registerEnrichCommand(program) {
22625
22676
  runArgs.push("--tail-timeout-ms", String(timeoutSeconds * 1e3));
22626
22677
  }
22627
22678
  const captured2 = await runGeneratedEnrichPlay(client2, runArgs, {
22628
- passthroughStdout: input2.passthroughStdout
22679
+ passthroughStdout: input2.passthroughStdout,
22680
+ onRunStarted: (runId) => {
22681
+ activeRunId2 = runId;
22682
+ }
22629
22683
  });
22630
22684
  const generatedPlayStatus = input2.json ? parseJsonOutput(captured2.stdout) : captured2.terminalStatus ?? await resolveWatchedGeneratedPlayStatus({
22631
22685
  client: client2,
@@ -22773,6 +22827,8 @@ function registerEnrichCommand(program) {
22773
22827
  await completeTelemetry({ status: "failed", failedJobs: 1 });
22774
22828
  throw error;
22775
22829
  } finally {
22830
+ process.removeListener("SIGINT", onSigint);
22831
+ process.removeListener("SIGTERM", onSigterm);
22776
22832
  if (inPlaceTempDir) {
22777
22833
  await (0, import_promises3.rm)(inPlaceTempDir, { recursive: true, force: true });
22778
22834
  } else if (inPlaceTempOutputPath) {
@@ -26585,7 +26641,7 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
26585
26641
  }
26586
26642
  function extractionContractEntries(entries) {
26587
26643
  return entries.flatMap((entry) => {
26588
- if (!isRecord9(entry)) return [];
26644
+ if (!isRecord8(entry)) return [];
26589
26645
  const name = stringField2(entry, "name");
26590
26646
  const expression = stringField2(entry, "expression");
26591
26647
  return name && expression ? [{ name, expression }] : [];
@@ -26593,8 +26649,8 @@ function extractionContractEntries(entries) {
26593
26649
  }
26594
26650
  function printCompactToolContract(tool, requestedToolId) {
26595
26651
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
26596
- const cost = isRecord9(contract.cost) ? contract.cost : {};
26597
- const getters = isRecord9(contract.getters) ? contract.getters : {};
26652
+ const cost = isRecord8(contract.cost) ? contract.cost : {};
26653
+ const getters = isRecord8(contract.getters) ? contract.getters : {};
26598
26654
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
26599
26655
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
26600
26656
  const inputFields = Array.isArray(contract.inputFields) ? contract.inputFields : [];
@@ -26611,7 +26667,7 @@ function printCompactToolContract(tool, requestedToolId) {
26611
26667
  console.log("");
26612
26668
  console.log("Inputs:");
26613
26669
  for (const field of inputFields) {
26614
- if (!isRecord9(field)) continue;
26670
+ if (!isRecord8(field)) continue;
26615
26671
  const name = stringField2(field, "name");
26616
26672
  if (!name) continue;
26617
26673
  const required = field.required ? "*" : "";
@@ -26624,7 +26680,7 @@ function printCompactToolContract(tool, requestedToolId) {
26624
26680
  }
26625
26681
  console.log("");
26626
26682
  printToolExamplesOnly(tool, requestedToolId, { includeSamples: false });
26627
- const starterScript = isRecord9(contract.starterScript) ? contract.starterScript : {};
26683
+ const starterScript = isRecord8(contract.starterScript) ? contract.starterScript : {};
26628
26684
  const starterPath = stringField2(starterScript, "path");
26629
26685
  if (starterPath) {
26630
26686
  console.log("");
@@ -26638,14 +26694,14 @@ function printCompactToolContract(tool, requestedToolId) {
26638
26694
  console.log("Getters:");
26639
26695
  if (listGetters.length) console.log("Lists:");
26640
26696
  for (const entry of listGetters) {
26641
- if (isRecord9(entry))
26697
+ if (isRecord8(entry))
26642
26698
  console.log(
26643
26699
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
26644
26700
  );
26645
26701
  }
26646
26702
  if (valueGetters.length) console.log("Values:");
26647
26703
  for (const entry of valueGetters) {
26648
- if (isRecord9(entry))
26704
+ if (isRecord8(entry))
26649
26705
  console.log(
26650
26706
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
26651
26707
  );
@@ -26658,7 +26714,7 @@ function printCompactToolContract(tool, requestedToolId) {
26658
26714
  }
26659
26715
  function printToolPricingOnly(tool, requestedToolId, options = {}) {
26660
26716
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
26661
- const cost = isRecord9(contract.cost) ? contract.cost : {};
26717
+ const cost = isRecord8(contract.cost) ? contract.cost : {};
26662
26718
  const pricingModel = stringField2(cost, "pricingModel") || "unknown";
26663
26719
  const billingMode = stringField2(cost, "billingMode") || "unknown";
26664
26720
  const unit = pricingModel === "per_page" ? "page" : pricingModel === "per_result" ? "result" : pricingModel === "fixed" ? "call" : pricingModel.replace(/^per_/, "") || "unit";
@@ -26678,7 +26734,7 @@ function printToolSchemaOnly(tool, requestedToolId) {
26678
26734
  }
26679
26735
  console.log("Inputs:");
26680
26736
  for (const field of inputFields) {
26681
- if (!isRecord9(field)) continue;
26737
+ if (!isRecord8(field)) continue;
26682
26738
  const name = stringField2(field, "name");
26683
26739
  if (!name) continue;
26684
26740
  const required = field.required ? "*" : "";
@@ -26708,10 +26764,10 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
26708
26764
  ` input: ${JSON.stringify(sampleInput || {}, null, 2).replace(/\n/g, "\n ")},`
26709
26765
  );
26710
26766
  console.log("});");
26711
- const getters = isRecord9(contract.getters) ? contract.getters : {};
26767
+ const getters = isRecord8(contract.getters) ? contract.getters : {};
26712
26768
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
26713
26769
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
26714
- const firstGetter = [...valueGetters, ...listGetters].find(isRecord9);
26770
+ const firstGetter = [...valueGetters, ...listGetters].find(isRecord8);
26715
26771
  if (firstGetter) {
26716
26772
  const name = stringField2(firstGetter, "name") || "value";
26717
26773
  const expression = stringField2(firstGetter, "expression");
@@ -26747,7 +26803,7 @@ function printPlayLikeToolUsage(tool, requestedToolId) {
26747
26803
  }
26748
26804
  function printToolGettersOnly(tool, requestedToolId) {
26749
26805
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
26750
- const getters = isRecord9(contract.getters) ? contract.getters : {};
26806
+ const getters = isRecord8(contract.getters) ? contract.getters : {};
26751
26807
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
26752
26808
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
26753
26809
  console.log(`Getters: ${contract.toolId}`);
@@ -26760,7 +26816,7 @@ function printToolGettersOnly(tool, requestedToolId) {
26760
26816
  if (listGetters.length) {
26761
26817
  console.log("Lists:");
26762
26818
  for (const entry of listGetters) {
26763
- if (isRecord9(entry))
26819
+ if (isRecord8(entry))
26764
26820
  console.log(
26765
26821
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
26766
26822
  );
@@ -26769,7 +26825,7 @@ function printToolGettersOnly(tool, requestedToolId) {
26769
26825
  if (valueGetters.length) {
26770
26826
  console.log("Values:");
26771
26827
  for (const entry of valueGetters) {
26772
- if (isRecord9(entry))
26828
+ if (isRecord8(entry))
26773
26829
  console.log(
26774
26830
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
26775
26831
  );
@@ -26795,7 +26851,7 @@ function sampleValueForField(field) {
26795
26851
  function samplePayloadForInputFields(fields) {
26796
26852
  return Object.fromEntries(
26797
26853
  fields.slice(0, 4).flatMap((field) => {
26798
- if (!isRecord9(field)) return [];
26854
+ if (!isRecord8(field)) return [];
26799
26855
  const name = stringField2(field, "name");
26800
26856
  if (!name) return [];
26801
26857
  return [[name, sampleValueForField(field)]];
@@ -26913,12 +26969,12 @@ function formatListedToolCost(tool) {
26913
26969
  }
26914
26970
  function toolInputFieldsForDisplay(inputSchema) {
26915
26971
  if (Array.isArray(inputSchema.fields))
26916
- return inputSchema.fields.filter(isRecord9);
26917
- const jsonSchema = isRecord9(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
26918
- const properties = isRecord9(jsonSchema.properties) ? jsonSchema.properties : {};
26972
+ return inputSchema.fields.filter(isRecord8);
26973
+ const jsonSchema = isRecord8(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
26974
+ const properties = isRecord8(jsonSchema.properties) ? jsonSchema.properties : {};
26919
26975
  const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
26920
26976
  return Object.entries(properties).map(([name, value]) => {
26921
- const property = isRecord9(value) ? value : {};
26977
+ const property = isRecord8(value) ? value : {};
26922
26978
  return {
26923
26979
  name,
26924
26980
  type: typeof property.type === "string" ? property.type : "unknown",
@@ -26947,15 +27003,15 @@ function printJsonPreview(label, payload) {
26947
27003
  }
26948
27004
  function samplePayload(samples, key) {
26949
27005
  const entry = samples[key];
26950
- if (!isRecord9(entry)) return void 0;
27006
+ if (!isRecord8(entry)) return void 0;
26951
27007
  return Object.prototype.hasOwnProperty.call(entry, "payload") ? entry.payload : entry;
26952
27008
  }
26953
27009
  function commandEnvelopeFromRawResponse(rawResponse) {
26954
- return isRecord9(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
27010
+ return isRecord8(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
26955
27011
  }
26956
27012
  function listExtractorPathsFromUsageGuidance(tool) {
26957
27013
  const toolExecutionResult = tool.usageGuidance?.toolExecutionResult;
26958
- const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord9(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
27014
+ const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord8(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
26959
27015
  return extractedLists.flatMap((entry) => {
26960
27016
  const paths = entry.details?.candidatePaths ?? entry.details?.rawToolOutputPaths;
26961
27017
  if (!Array.isArray(paths)) return [];
@@ -26971,7 +27027,7 @@ function formatDecimal(value) {
26971
27027
  function formatUsd(value) {
26972
27028
  return `$${formatDecimal(value)}`;
26973
27029
  }
26974
- function isRecord9(value) {
27030
+ function isRecord8(value) {
26975
27031
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
26976
27032
  }
26977
27033
  function stringField2(source, ...keys) {
@@ -26998,7 +27054,7 @@ function arrayField2(source, ...keys) {
26998
27054
  function recordField2(source, ...keys) {
26999
27055
  for (const key of keys) {
27000
27056
  const value = source[key];
27001
- if (isRecord9(value)) return value;
27057
+ if (isRecord8(value)) return value;
27002
27058
  }
27003
27059
  return {};
27004
27060
  }
@@ -27064,7 +27120,7 @@ function parseJsonObjectArgument(raw, flagName) {
27064
27120
  }
27065
27121
  throw invalidJsonError(flagName, message);
27066
27122
  }
27067
- if (!isRecord9(parsed)) {
27123
+ if (!isRecord8(parsed)) {
27068
27124
  throw invalidJsonError(flagName, "expected an object.");
27069
27125
  }
27070
27126
  return parsed;
@@ -27210,7 +27266,7 @@ function buildToolExecuteBaseEnvelope(input2) {
27210
27266
  kind: summaryEntries.length > 0 ? "object" : "raw",
27211
27267
  summary: input2.summary
27212
27268
  };
27213
- const envelopeHasCanonicalOutput = isRecord9(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
27269
+ const envelopeHasCanonicalOutput = isRecord8(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
27214
27270
  const envelopeHasDeclaredOutput = Object.prototype.hasOwnProperty.call(
27215
27271
  envelope,
27216
27272
  "output"
@@ -27429,7 +27485,7 @@ async function executeTool(args) {
27429
27485
  {
27430
27486
  ...baseEnvelope,
27431
27487
  local: {
27432
- ...isRecord9(baseEnvelope.local) ? baseEnvelope.local : {},
27488
+ ...isRecord8(baseEnvelope.local) ? baseEnvelope.local : {},
27433
27489
  payload_file: jsonPath
27434
27490
  }
27435
27491
  },