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.
@@ -610,10 +610,10 @@ var SDK_RELEASE = {
610
610
  // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
611
611
  // 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
612
612
  // automatically without blocking their current command.
613
- version: "0.1.222",
613
+ version: "0.1.224",
614
614
  apiContract: "2026-06-dataset-handle-results-hard-cutover",
615
615
  supportPolicy: {
616
- latest: "0.1.222",
616
+ latest: "0.1.224",
617
617
  minimumSupported: "0.1.53",
618
618
  deprecatedBelow: "0.1.219",
619
619
  commandMinimumSupported: [
@@ -1349,29 +1349,42 @@ function normalizePlayRunLedgerTerminalSource(value) {
1349
1349
  // ../shared_libs/play-runtime/secret-redaction.ts
1350
1350
  var SECRET_REDACTION_PLACEHOLDER = "[REDACTED_SECRET]";
1351
1351
  var BEARER_TOKEN_RE = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}\b/g;
1352
- var JWT_RE = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g;
1352
+ var BASIC_CREDENTIAL_RE = /\bBasic\s+[A-Za-z0-9+/]{4,}={0,2}\b/g;
1353
+ var JWT_RE = /\b[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{1,}\.[A-Za-z0-9_-]{8,}\b/g;
1353
1354
  var PRIVATE_KEY_RE = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g;
1354
- 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;
1355
+ var SENSITIVE_FIELD_NAME = "authorization|cookie|password|(?:client[_-]?)?secret|(?:access|refresh)[_-]?token|(?:x[_-]?)?api[_-]?key|private[_-]?key|token|credentials";
1356
+ var COMMON_SECRET_RE = /\b(?:[prs]k_(?:live|test)_|(?:pat|ghp|github_pat)_|xox[baprs]-)[A-Za-z0-9_./+=:-]{12,}\b/gi;
1355
1357
  var GENERIC_PREFIXED_SECRET_RE = /\b(?:key|token|secret|api[_-]?key)_[A-Za-z0-9_./+=:-]{12,}\b/gi;
1356
- var URL_SECRET_VALUE_RE = /\b(?:sk|pk|rk|pat|ghp|github_pat|xox)[A-Za-z0-9_./+=:-]{12,}\b/i;
1358
+ var URL_SECRET_VALUE_RE = /\b(?:[spr]k|pat|ghp|github_pat|xox)[A-Za-z0-9_./+=:-]{12,}\b/i;
1357
1359
  var GENERIC_SECRET_ASSIGNMENT_RE = /\b(?:api[_-]?key|token|secret|password)\b\s*[:=]\s*["']?[^"',\s]{12,}["']?/gi;
1358
- var HIGH_ENTROPY_ASSIGNMENT_RE = /\b(?:api[_-]?key|token|secret|password|authorization|access[_-]?token|refresh[_-]?token)\b\s*[:=]\s*["']?[^"',\s]{16,}["']?/gi;
1360
+ var HIGH_ENTROPY_ASSIGNMENT_RE = /\b(?:api[_-]?key|token|secret|password|authorization|(?:access|refresh)[_-]?token)\b\s*[:=]\s*["']?[^"',\s]{16,}["']?/gi;
1359
1361
  var SENSITIVE_URL_PARAM_RE = /[?#&](?:\w*(?:key|token)|secret|password|authorization|credential|signature|sig)(?:=|$)/i;
1362
+ var SENSITIVE_FIELD_NAME_RE = new RegExp(
1363
+ `(^|[._-])(?:${SENSITIVE_FIELD_NAME})$`,
1364
+ "i"
1365
+ );
1366
+ var SERIALIZED_SECRET_FIELD_RE = new RegExp(
1367
+ `"(${SENSITIVE_FIELD_NAME})"\\s*:\\s*(?:"[^"\\\\]*"|\\{[^{}]*\\})`,
1368
+ "gi"
1369
+ );
1360
1370
  function escapeRegExp(value) {
1361
1371
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1362
1372
  }
1363
- function isRecord(value) {
1364
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1365
- }
1366
1373
  function redactSecretLikeString(value) {
1367
- const trimmed = value.trim();
1374
+ const serializedRedacted = value.replace(
1375
+ SERIALIZED_SECRET_FIELD_RE,
1376
+ `"$1":"${SECRET_REDACTION_PLACEHOLDER}"`
1377
+ );
1378
+ const trimmed = serializedRedacted.trim();
1368
1379
  if (/^https?:\/\/\S+$/i.test(trimmed)) {
1369
1380
  if (/^https?:\/\/[^/?#@]+@/i.test(trimmed) || SENSITIVE_URL_PARAM_RE.test(trimmed)) {
1370
1381
  return SECRET_REDACTION_PLACEHOLDER;
1371
1382
  }
1372
- if (!URL_SECRET_VALUE_RE.test(value)) return value;
1383
+ if (!URL_SECRET_VALUE_RE.test(serializedRedacted)) {
1384
+ return serializedRedacted;
1385
+ }
1373
1386
  }
1374
- 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) => {
1387
+ 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) => {
1375
1388
  const separator = match.includes("=") ? "=" : ":";
1376
1389
  const [key] = match.split(separator, 1);
1377
1390
  return `${key.trim()}${separator}${SECRET_REDACTION_PLACEHOLDER}`;
@@ -1406,9 +1419,12 @@ function createSecretRedactionContext(initialValues = []) {
1406
1419
  function redact(value) {
1407
1420
  if (typeof value === "string") return redactString(value);
1408
1421
  if (Array.isArray(value)) return value.map((entry) => redact(entry));
1409
- if (isRecord(value)) {
1422
+ if (value && typeof value === "object") {
1410
1423
  return Object.fromEntries(
1411
- Object.entries(value).map(([key, entry]) => [key, redact(entry)])
1424
+ Object.entries(value).map(([key, entry]) => [
1425
+ key,
1426
+ SENSITIVE_FIELD_NAME_RE.test(key) ? SECRET_REDACTION_PLACEHOLDER : redact(entry)
1427
+ ])
1412
1428
  );
1413
1429
  }
1414
1430
  return value;
@@ -1432,7 +1448,7 @@ var ledgerIngressRedactor = createSecretRedactionContext();
1432
1448
 
1433
1449
  // ../shared_libs/play-runtime/run-ledger.ts
1434
1450
  var LOG_TAIL_LIMIT = 100;
1435
- function isRecord2(value) {
1451
+ function isRecord(value) {
1436
1452
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
1437
1453
  }
1438
1454
  function finiteNumber(value) {
@@ -1525,21 +1541,21 @@ function createEmptyPlayRunLedgerSnapshot(input2) {
1525
1541
  };
1526
1542
  }
1527
1543
  function normalizePlayRunLedgerSnapshot(value, fallback) {
1528
- if (!isRecord2(value)) {
1544
+ if (!isRecord(value)) {
1529
1545
  return createEmptyPlayRunLedgerSnapshot(fallback);
1530
1546
  }
1531
1547
  const orderedStepIds = Array.isArray(value.orderedStepIds) ? value.orderedStepIds.filter(
1532
1548
  (entry) => typeof entry === "string" && Boolean(entry.trim())
1533
1549
  ) : [];
1534
- const rawSteps = isRecord2(value.stepsById) ? value.stepsById : {};
1550
+ const rawSteps = isRecord(value.stepsById) ? value.stepsById : {};
1535
1551
  const stepsById = {};
1536
1552
  for (const [stepId, rawStep] of Object.entries(rawSteps)) {
1537
- if (!stepId.trim() || !isRecord2(rawStep)) continue;
1553
+ if (!stepId.trim() || !isRecord(rawStep)) continue;
1538
1554
  const rawStatus = normalizeStepStatus(rawStep.status);
1539
1555
  if (!rawStatus) continue;
1540
1556
  const completedAt = finiteNumber(rawStep.completedAt);
1541
1557
  const status = rawStatus === "running" && completedAt !== null ? "completed" : rawStatus;
1542
- const rawProgress = isRecord2(rawStep.progress) ? rawStep.progress : null;
1558
+ const rawProgress = isRecord(rawStep.progress) ? rawStep.progress : null;
1543
1559
  stepsById[stepId] = {
1544
1560
  stepId,
1545
1561
  label: optionalString(rawStep.label),
@@ -1554,10 +1570,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
1554
1570
  progress: rawProgress ? normalizeStepProgress(rawProgress) : null
1555
1571
  };
1556
1572
  }
1557
- const rawDatasets = isRecord2(value.datasetsById) ? value.datasetsById : {};
1573
+ const rawDatasets = isRecord(value.datasetsById) ? value.datasetsById : {};
1558
1574
  const datasetsById = {};
1559
1575
  for (const [datasetId, rawDataset] of Object.entries(rawDatasets)) {
1560
- if (!datasetId.trim() || !isRecord2(rawDataset)) continue;
1576
+ if (!datasetId.trim() || !isRecord(rawDataset)) continue;
1561
1577
  const phase = rawDataset.phase === "available" || rawDataset.phase === "failed" ? rawDataset.phase : "registered";
1562
1578
  datasetsById[datasetId] = {
1563
1579
  datasetId,
@@ -1688,18 +1704,18 @@ function normalizePlayRunLiveStatus(value) {
1688
1704
  function isTerminalPlayRunLiveStatus(status) {
1689
1705
  return isTerminalPlayRunLifecycleStatus(status);
1690
1706
  }
1691
- function isRecord3(value) {
1707
+ function isRecord2(value) {
1692
1708
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
1693
1709
  }
1694
1710
  function finiteNumber2(value) {
1695
1711
  return typeof value === "number" && Number.isFinite(value) ? value : null;
1696
1712
  }
1697
1713
  function extractTerminalRunLogTail(result) {
1698
- if (!isRecord3(result) || !isRecord3(result._metadata)) {
1714
+ if (!isRecord2(result) || !isRecord2(result._metadata)) {
1699
1715
  return null;
1700
1716
  }
1701
1717
  const runLogTail = result._metadata.runLogTail;
1702
- if (!isRecord3(runLogTail) || !Array.isArray(runLogTail.tail)) {
1718
+ if (!isRecord2(runLogTail) || !Array.isArray(runLogTail.tail)) {
1703
1719
  return null;
1704
1720
  }
1705
1721
  const logTail = runLogTail.tail.filter(
@@ -2436,7 +2452,7 @@ function resolveToolExecuteTimeoutMs(toolId) {
2436
2452
  }
2437
2453
  var RUNS_FAILED_LOG_LIMIT = 20;
2438
2454
  var RUN_LOGS_PAGE_LIMIT = 1e3;
2439
- function isRecord4(value) {
2455
+ function isRecord3(value) {
2440
2456
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
2441
2457
  }
2442
2458
  function isPrebuiltPlayDescription(play) {
@@ -2593,7 +2609,7 @@ function updatePlayLiveStatusState(state, event) {
2593
2609
  }
2594
2610
  const runId = typeof payload.runId === "string" && payload.runId ? payload.runId : isPlayRunPackage(payload) ? payload.run.id : state.runId;
2595
2611
  const status = normalizeLiveStatus(payload.status) ?? (isPlayRunPackage(payload) ? normalizeLiveStatus(payload.run.status) : null) ?? state.status;
2596
- const progressPayload = isRecord4(payload.progress) ? payload.progress : {};
2612
+ const progressPayload = isRecord3(payload.progress) ? payload.progress : {};
2597
2613
  if (event.type === "play.run.final_status" && state.logs.length === 0 && state.lastLogSeq === 0) {
2598
2614
  const payloadLogs = readStringArray(payload.logs);
2599
2615
  const progressLogs = readStringArray(progressPayload.logs);
@@ -2708,9 +2724,9 @@ var DeeplineClient = class {
2708
2724
  return fields.length > 0 ? { fields } : schema;
2709
2725
  }
2710
2726
  schemaMetadata(schema, key) {
2711
- if (!isRecord4(schema)) return null;
2727
+ if (!isRecord3(schema)) return null;
2712
2728
  const value = schema[key];
2713
- return isRecord4(value) ? value : null;
2729
+ return isRecord3(value) ? value : null;
2714
2730
  }
2715
2731
  playRunCommand(play, options) {
2716
2732
  const target = play.reference || play.name;
@@ -2759,7 +2775,7 @@ var DeeplineClient = class {
2759
2775
  aliases,
2760
2776
  inputSchema: options?.compact ? this.compactSchema(play.inputSchema) : play.inputSchema ?? null,
2761
2777
  outputSchema: options?.compact ? this.compactSchema(play.outputSchema) : play.outputSchema ?? null,
2762
- staticPipeline: isRecord4(play.staticPipeline) ? play.staticPipeline : isRecord4(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord4(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
2778
+ staticPipeline: isRecord3(play.staticPipeline) ? play.staticPipeline : isRecord3(play.currentRevision?.staticPipeline) ? play.currentRevision.staticPipeline : isRecord3(play.liveRevision?.staticPipeline) ? play.liveRevision.staticPipeline : null,
2763
2779
  ...csvInput ? { csvInput } : {},
2764
2780
  ...rowOutputSchema ? { rowOutputSchema } : {},
2765
2781
  runCommand: runCommand2,
@@ -7378,14 +7394,14 @@ function sanitizeCsvProjectionInfo(input2) {
7378
7394
  const rows = input2.rows.map(stripCsvProjectionFields);
7379
7395
  return { rows, columns };
7380
7396
  }
7381
- function isRecord5(value) {
7397
+ function isRecord4(value) {
7382
7398
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
7383
7399
  }
7384
7400
  function isSerializedDataset(value) {
7385
- return isRecord5(value) && value.kind === "dataset" && typeof value.count === "number" && (Array.isArray(value.preview) || typeof value.tableNamespace === "string");
7401
+ return isRecord4(value) && value.kind === "dataset" && typeof value.count === "number" && (Array.isArray(value.preview) || typeof value.tableNamespace === "string");
7386
7402
  }
7387
7403
  function isPackagedDatasetOutput(value) {
7388
- return isRecord5(value) && value.kind === "dataset" && isRecord5(value.preview) && Array.isArray(value.preview.rows);
7404
+ return isRecord4(value) && value.kind === "dataset" && isRecord4(value.preview) && Array.isArray(value.preview.rows);
7389
7405
  }
7390
7406
  function pathParts(path) {
7391
7407
  return path.split(".").map((part) => part.trim()).filter(Boolean);
@@ -7393,7 +7409,7 @@ function pathParts(path) {
7393
7409
  function valueAtPath(root, path) {
7394
7410
  let cursor = root;
7395
7411
  for (const part of pathParts(path)) {
7396
- if (!isRecord5(cursor)) {
7412
+ if (!isRecord4(cursor)) {
7397
7413
  return void 0;
7398
7414
  }
7399
7415
  cursor = cursor[part];
@@ -7401,17 +7417,17 @@ function valueAtPath(root, path) {
7401
7417
  return cursor;
7402
7418
  }
7403
7419
  function totalRowsForDataset(result, datasetPath) {
7404
- const metadata = isRecord5(result._metadata) ? result._metadata : null;
7420
+ const metadata = isRecord4(result._metadata) ? result._metadata : null;
7405
7421
  const parentPath = datasetPath.split(".").slice(0, -1).join(".");
7406
7422
  const parent = parentPath ? valueAtPath({ result }, parentPath) : result;
7407
- return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (isRecord5(parent) ? parent.totalRows ?? parent.rowCount ?? parent.count : void 0) ?? result.totalRows ?? result.rowCount ?? result.count;
7423
+ return metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count ?? (isRecord4(parent) ? parent.totalRows ?? parent.rowCount ?? parent.count : void 0) ?? result.totalRows ?? result.rowCount ?? result.count;
7408
7424
  }
7409
7425
  function rowArray(value) {
7410
7426
  if (!Array.isArray(value)) {
7411
7427
  return null;
7412
7428
  }
7413
7429
  const rows = value.filter(
7414
- (row) => isRecord5(row)
7430
+ (row) => isRecord4(row)
7415
7431
  );
7416
7432
  return rows.length === value.length ? rows : null;
7417
7433
  }
@@ -7435,7 +7451,7 @@ function inferColumns(rows) {
7435
7451
  return columns;
7436
7452
  }
7437
7453
  function columnsFromDatasetSummary(summary) {
7438
- if (!isRecord5(summary) || !isRecord5(summary.columnStats)) {
7454
+ if (!isRecord4(summary) || !isRecord4(summary.columnStats)) {
7439
7455
  return [];
7440
7456
  }
7441
7457
  return Object.keys(summary.columnStats).filter((column) => column);
@@ -7525,7 +7541,7 @@ function collectDatasetCandidates(input2) {
7525
7541
  });
7526
7542
  return;
7527
7543
  }
7528
- if (!isRecord5(input2.value)) {
7544
+ if (!isRecord4(input2.value)) {
7529
7545
  return;
7530
7546
  }
7531
7547
  for (const [key, child] of Object.entries(input2.value)) {
@@ -7542,12 +7558,12 @@ function collectDatasetCandidates(input2) {
7542
7558
  }
7543
7559
  }
7544
7560
  function collectCanonicalRowsInfos(statusOrResult) {
7545
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
7546
- const result = isRecord5(root?.result) ? root.result : root;
7561
+ const root = isRecord4(statusOrResult) ? statusOrResult : null;
7562
+ const result = isRecord4(root?.result) ? root.result : root;
7547
7563
  if (!result) {
7548
7564
  return [];
7549
7565
  }
7550
- const metadata = isRecord5(result._metadata) ? result._metadata : null;
7566
+ const metadata = isRecord4(result._metadata) ? result._metadata : null;
7551
7567
  const totalFromMetadata = metadata?.totalRows ?? metadata?.rowCount ?? metadata?.count;
7552
7568
  const candidates = [
7553
7569
  {
@@ -7571,8 +7587,8 @@ function collectCanonicalRowsInfos(statusOrResult) {
7571
7587
  total: totalFromMetadata ?? result.totalRows ?? result.rowCount ?? result.count
7572
7588
  }
7573
7589
  ];
7574
- if (isRecord5(result.output)) {
7575
- const outputMetadata = isRecord5(result.output._metadata) ? result.output._metadata : null;
7590
+ if (isRecord4(result.output)) {
7591
+ const outputMetadata = isRecord4(result.output._metadata) ? result.output._metadata : null;
7576
7592
  const outputTotalFromMetadata = outputMetadata?.totalRows ?? outputMetadata?.rowCount ?? outputMetadata?.count;
7577
7593
  candidates.push(
7578
7594
  {
@@ -7599,14 +7615,14 @@ function collectCanonicalRowsInfos(statusOrResult) {
7599
7615
  }
7600
7616
  if (Array.isArray(result.steps)) {
7601
7617
  result.steps.forEach((step, index) => {
7602
- if (!isRecord5(step) || !isRecord5(step.output)) {
7618
+ if (!isRecord4(step) || !isRecord4(step.output)) {
7603
7619
  return;
7604
7620
  }
7605
7621
  const source = typeof step.output.path === "string" ? step.output.path : typeof step.id === "string" ? `steps.${step.id}.output` : `steps.${index}.output`;
7606
7622
  candidates.push({
7607
7623
  source,
7608
7624
  value: step.output,
7609
- total: step.output.rowCount ?? (isRecord5(step.output.preview) ? step.output.preview.totalRows : void 0) ?? (isRecord5(step.progress) ? step.progress.total : void 0)
7625
+ total: step.output.rowCount ?? (isRecord4(step.output.preview) ? step.output.preview.totalRows : void 0) ?? (isRecord4(step.progress) ? step.progress.total : void 0)
7610
7626
  });
7611
7627
  });
7612
7628
  }
@@ -7634,15 +7650,15 @@ function collectCanonicalRowsInfos(statusOrResult) {
7634
7650
  return infos;
7635
7651
  }
7636
7652
  function collectPackagedDatasetCandidates(statusOrResult) {
7637
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
7653
+ const root = isRecord4(statusOrResult) ? statusOrResult : null;
7638
7654
  if (!root) {
7639
7655
  return [];
7640
7656
  }
7641
- const pkg = isRecord5(root.package) ? root.package : root;
7657
+ const pkg = isRecord4(root.package) ? root.package : root;
7642
7658
  const datasets = Array.isArray(pkg.datasets) ? pkg.datasets : [];
7643
7659
  const candidates = [];
7644
7660
  for (const output2 of datasets) {
7645
- if (!isRecord5(output2) || !isPackagedDatasetOutput(output2)) {
7661
+ if (!isRecord4(output2) || !isPackagedDatasetOutput(output2)) {
7646
7662
  continue;
7647
7663
  }
7648
7664
  const source = typeof output2.path === "string" && output2.path.trim() ? output2.path.trim() : null;
@@ -7652,14 +7668,14 @@ function collectPackagedDatasetCandidates(statusOrResult) {
7652
7668
  candidates.push({
7653
7669
  source,
7654
7670
  value: output2,
7655
- total: output2.rowCount ?? (isRecord5(output2.preview) ? output2.preview.totalRows : void 0)
7671
+ total: output2.rowCount ?? (isRecord4(output2.preview) ? output2.preview.totalRows : void 0)
7656
7672
  });
7657
7673
  }
7658
7674
  return candidates;
7659
7675
  }
7660
7676
  function collectSerializedDatasetRowsInfos(statusOrResult) {
7661
- const root = isRecord5(statusOrResult) ? statusOrResult : null;
7662
- const result = isRecord5(root?.result) ? root.result : root;
7677
+ const root = isRecord4(statusOrResult) ? statusOrResult : null;
7678
+ const result = isRecord4(root?.result) ? root.result : root;
7663
7679
  const candidates = [];
7664
7680
  if (result) {
7665
7681
  collectDatasetCandidates({
@@ -7667,7 +7683,7 @@ function collectSerializedDatasetRowsInfos(statusOrResult) {
7667
7683
  path: "result",
7668
7684
  output: candidates
7669
7685
  });
7670
- if (isRecord5(result.output)) {
7686
+ if (isRecord4(result.output)) {
7671
7687
  collectDatasetCandidates({
7672
7688
  value: result.output,
7673
7689
  path: "result",
@@ -7739,13 +7755,13 @@ function summarizeSampleValue(value, depth = 0) {
7739
7755
  if (typeof parsed === "number" || typeof parsed === "boolean") return parsed;
7740
7756
  if (depth >= 3) {
7741
7757
  if (Array.isArray(parsed)) return [];
7742
- if (isRecord5(parsed)) return {};
7758
+ if (isRecord4(parsed)) return {};
7743
7759
  return compactScalar(parsed);
7744
7760
  }
7745
7761
  if (Array.isArray(parsed)) {
7746
7762
  return parsed.slice(0, 3).map((item) => summarizeSampleValue(item, depth + 1));
7747
7763
  }
7748
- if (isRecord5(parsed)) {
7764
+ if (isRecord4(parsed)) {
7749
7765
  const out = {};
7750
7766
  for (const [key, nested] of Object.entries(parsed)) {
7751
7767
  if (["__dl", "meta", "metadata"].includes(key)) {
@@ -7776,7 +7792,7 @@ function compactCell(value) {
7776
7792
  }
7777
7793
  return `[${parsed.length} items]`;
7778
7794
  }
7779
- if (isRecord5(parsed)) {
7795
+ if (isRecord4(parsed)) {
7780
7796
  for (const key of ["matched_result", "output"]) {
7781
7797
  if (parsed[key] !== null && parsed[key] !== void 0 && parsed[key] !== "") {
7782
7798
  return compactCell(parsed[key]);
@@ -8839,17 +8855,17 @@ function parsePositiveInteger2(value, flagName) {
8839
8855
  }
8840
8856
  return parsed;
8841
8857
  }
8842
- function isRecord6(value) {
8858
+ function isRecord5(value) {
8843
8859
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
8844
8860
  }
8845
8861
  function stringValue(value) {
8846
8862
  return typeof value === "string" ? value.trim() : "";
8847
8863
  }
8848
8864
  function extractionEntries(value) {
8849
- if (Array.isArray(value)) return value.filter(isRecord6);
8850
- if (!isRecord6(value)) return [];
8865
+ if (Array.isArray(value)) return value.filter(isRecord5);
8866
+ if (!isRecord5(value)) return [];
8851
8867
  return Object.entries(value).map(
8852
- ([name, entry]) => isRecord6(entry) ? { name, ...entry } : { name }
8868
+ ([name, entry]) => isRecord5(entry) ? { name, ...entry } : { name }
8853
8869
  );
8854
8870
  }
8855
8871
  var PlayBootstrapError = class extends Error {
@@ -9411,7 +9427,7 @@ function readCsvSampleRows(sample) {
9411
9427
  relax_column_count: true,
9412
9428
  trim: true
9413
9429
  });
9414
- return Array.isArray(parsedRows) ? parsedRows.filter(isRecord6) : [];
9430
+ return Array.isArray(parsedRows) ? parsedRows.filter(isRecord5) : [];
9415
9431
  }
9416
9432
  function readSourceCsvColumnSpecs(csvPath) {
9417
9433
  const sample = readCsvSample(csvPath);
@@ -9444,16 +9460,16 @@ function packagedCsvPathForPlay(csvPath) {
9444
9460
  return portablePath.startsWith(".") ? portablePath : `./${portablePath}`;
9445
9461
  }
9446
9462
  function getterNamesFromTool(tool, kind) {
9447
- const usageGuidance = isRecord6(tool?.usageGuidance) ? tool.usageGuidance : {};
9448
- const resultGuidance = isRecord6(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord6(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
9463
+ const usageGuidance = isRecord5(tool?.usageGuidance) ? tool.usageGuidance : {};
9464
+ const resultGuidance = isRecord5(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord5(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
9449
9465
  const key = kind === "list" ? "extractedLists" : "extractedValues";
9450
9466
  const snakeKey = kind === "list" ? "extracted_lists" : "extracted_values";
9451
9467
  return extractionEntries(resultGuidance[key] ?? resultGuidance[snakeKey]).map((entry) => stringValue(entry.name)).filter(Boolean);
9452
9468
  }
9453
9469
  function targetGettersFromTool(tool) {
9454
- const record = isRecord6(tool) ? tool : {};
9470
+ const record = isRecord5(tool) ? tool : {};
9455
9471
  const raw = record.targetGetters ?? record.target_getters;
9456
- if (!isRecord6(raw)) return {};
9472
+ if (!isRecord5(raw)) return {};
9457
9473
  const entries = [];
9458
9474
  for (const [target, value] of Object.entries(raw)) {
9459
9475
  const paths = Array.isArray(value) ? value.map((path) => typeof path === "string" ? path.trim() : "").filter(Boolean) : [];
@@ -9474,10 +9490,10 @@ function listRowCandidateKeysFromTool(tool) {
9474
9490
  return [...keys].sort();
9475
9491
  }
9476
9492
  function inputPropertyNames(schema) {
9477
- if (!isRecord6(schema)) return [];
9478
- if (isRecord6(schema.properties)) return Object.keys(schema.properties);
9493
+ if (!isRecord5(schema)) return [];
9494
+ if (isRecord5(schema.properties)) return Object.keys(schema.properties);
9479
9495
  if (Array.isArray(schema.fields)) {
9480
- return schema.fields.filter(isRecord6).map((field) => stringValue(field.name)).filter(Boolean);
9496
+ return schema.fields.filter(isRecord5).map((field) => stringValue(field.name)).filter(Boolean);
9481
9497
  }
9482
9498
  return [];
9483
9499
  }
@@ -9491,7 +9507,7 @@ function schemaFieldDetails(schema) {
9491
9507
  return { required, optional };
9492
9508
  }
9493
9509
  function jsonSchemaTypeExpression(schema) {
9494
- if (!isRecord6(schema)) return "unknown";
9510
+ if (!isRecord5(schema)) return "unknown";
9495
9511
  const type = schema.type;
9496
9512
  if (Array.isArray(type)) {
9497
9513
  return type.map((entry) => jsonSchemaTypeExpression({ ...schema, type: entry })).join(" | ");
@@ -9521,7 +9537,7 @@ function jsonSchemaTypeExpression(schema) {
9521
9537
  }
9522
9538
  }
9523
9539
  function objectPropertySchema(schema, property) {
9524
- return isRecord6(schema) && isRecord6(schema.properties) ? schema.properties[property] : null;
9540
+ return isRecord5(schema) && isRecord5(schema.properties) ? schema.properties[property] : null;
9525
9541
  }
9526
9542
  function playOutputHasField(schema, field) {
9527
9543
  return objectPropertySchema(schema, field) != null;
@@ -9697,14 +9713,14 @@ ${indent2.slice(2)}}`;
9697
9713
  }
9698
9714
  function requiredPlayInputFields(play) {
9699
9715
  const schema = play?.inputSchema;
9700
- if (!isRecord6(schema)) return [];
9716
+ if (!isRecord5(schema)) return [];
9701
9717
  if (Array.isArray(schema.required)) {
9702
9718
  return schema.required.filter(
9703
9719
  (value) => typeof value === "string"
9704
9720
  );
9705
9721
  }
9706
9722
  if (Array.isArray(schema.fields)) {
9707
- return schema.fields.filter(isRecord6).filter(
9723
+ return schema.fields.filter(isRecord5).filter(
9708
9724
  (field) => field.required === true && typeof field.name === "string"
9709
9725
  ).map((field) => String(field.name));
9710
9726
  }
@@ -9885,7 +9901,7 @@ function validateBootstrapRoutes(input2) {
9885
9901
  }
9886
9902
  }
9887
9903
  function staticPipelineSubsteps(pipeline) {
9888
- if (!isRecord6(pipeline)) return [];
9904
+ if (!isRecord5(pipeline)) return [];
9889
9905
  return [
9890
9906
  ...extractionEntries(pipeline.stages),
9891
9907
  ...extractionEntries(pipeline.substeps)
@@ -9893,7 +9909,7 @@ function staticPipelineSubsteps(pipeline) {
9893
9909
  }
9894
9910
  function playUsesMapBackedRuntime(play) {
9895
9911
  const pipeline = play?.staticPipeline;
9896
- if (!isRecord6(pipeline)) return false;
9912
+ if (!isRecord5(pipeline)) return false;
9897
9913
  if (stringValue(pipeline.tableNamespace)) return true;
9898
9914
  return staticPipelineSubsteps(pipeline).some((substep) => {
9899
9915
  if (stringValue(substep.type) === "map") return true;
@@ -9902,7 +9918,7 @@ function playUsesMapBackedRuntime(play) {
9902
9918
  aliases: [],
9903
9919
  runCommand: "",
9904
9920
  examples: [],
9905
- staticPipeline: isRecord6(substep.pipeline) ? substep.pipeline : null
9921
+ staticPipeline: isRecord5(substep.pipeline) ? substep.pipeline : null
9906
9922
  });
9907
9923
  });
9908
9924
  }
@@ -12707,8 +12723,12 @@ async function startAndWaitForPlayCompletionByStreamOnce(input2) {
12707
12723
  }
12708
12724
  const eventRunId = getRunIdFromLiveEvent(event);
12709
12725
  if (typeof eventRunId === "string" && eventRunId && eventRunId !== "pending") {
12726
+ const runStartedNow = !lastKnownWorkflowId;
12710
12727
  lastKnownWorkflowId = eventRunId;
12711
12728
  firstRunIdMs ??= Date.now() - startedAt;
12729
+ if (runStartedNow) {
12730
+ input2.onRunStarted?.(eventRunId);
12731
+ }
12712
12732
  }
12713
12733
  const workflowId = lastKnownWorkflowId || "pending";
12714
12734
  if (workflowId !== "pending" && !emittedDashboardUrl) {
@@ -14322,7 +14342,7 @@ function extractPlayValidationErrors(value) {
14322
14342
  if (value instanceof DeeplineError) {
14323
14343
  return extractPlayValidationErrors(value.details);
14324
14344
  }
14325
- if (!isRecord7(value)) {
14345
+ if (!isRecord6(value)) {
14326
14346
  return [];
14327
14347
  }
14328
14348
  const directErrors = stringArrayField(value, "errors");
@@ -14757,7 +14777,7 @@ function shouldUseLocalOnlyPlayCheck() {
14757
14777
  const value = process.env.DEEPLINE_PLAY_CHECK_LOCAL_ONLY?.trim().toLowerCase();
14758
14778
  return value === "1" || value === "true" || value === "yes" || value === "on";
14759
14779
  }
14760
- function isRecord7(value) {
14780
+ function isRecord6(value) {
14761
14781
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
14762
14782
  }
14763
14783
  function stringValue2(value) {
@@ -14767,14 +14787,14 @@ function asArray(value) {
14767
14787
  return Array.isArray(value) ? value : [];
14768
14788
  }
14769
14789
  function extractionEntries2(value) {
14770
- if (Array.isArray(value)) return value.filter(isRecord7);
14771
- if (!isRecord7(value)) return [];
14790
+ if (Array.isArray(value)) return value.filter(isRecord6);
14791
+ if (!isRecord6(value)) return [];
14772
14792
  return Object.entries(value).map(
14773
- ([name, entry]) => isRecord7(entry) ? { name, ...entry } : { name }
14793
+ ([name, entry]) => isRecord6(entry) ? { name, ...entry } : { name }
14774
14794
  );
14775
14795
  }
14776
14796
  function firstRawPath(entry) {
14777
- const details = isRecord7(entry.details) ? entry.details : {};
14797
+ const details = isRecord6(entry.details) ? entry.details : {};
14778
14798
  const paths = [
14779
14799
  ...asArray(details.rawToolOutputPaths),
14780
14800
  ...asArray(details.raw_tool_output_paths),
@@ -14792,12 +14812,12 @@ function checkHintRawPath(value) {
14792
14812
  function collectStaticPipelineToolIds(staticPipeline) {
14793
14813
  const seen = /* @__PURE__ */ new Set();
14794
14814
  const visitPipeline = (pipeline) => {
14795
- if (!isRecord7(pipeline)) return;
14815
+ if (!isRecord6(pipeline)) return;
14796
14816
  for (const step of [
14797
14817
  ...asArray(pipeline.stages),
14798
14818
  ...asArray(pipeline.substeps)
14799
14819
  ]) {
14800
- if (!isRecord7(step)) continue;
14820
+ if (!isRecord6(step)) continue;
14801
14821
  if (step.type === "tool") {
14802
14822
  const toolId = stringValue2(step.toolId) || stringValue2(step.tool);
14803
14823
  if (toolId) seen.add(toolId);
@@ -14811,9 +14831,9 @@ function collectStaticPipelineToolIds(staticPipeline) {
14811
14831
  return [...seen].sort();
14812
14832
  }
14813
14833
  function toolGetterHintFromMetadata(toolId, tool) {
14814
- const usageGuidance = isRecord7(tool.usageGuidance) ? tool.usageGuidance : {};
14815
- const resultGuidance = isRecord7(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord7(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
14816
- const toolResponse = isRecord7(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord7(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
14834
+ const usageGuidance = isRecord6(tool.usageGuidance) ? tool.usageGuidance : {};
14835
+ const resultGuidance = isRecord6(usageGuidance.toolExecutionResult) ? usageGuidance.toolExecutionResult : isRecord6(usageGuidance.tool_execution_result) ? usageGuidance.tool_execution_result : {};
14836
+ const toolResponse = isRecord6(resultGuidance.toolResponse) ? resultGuidance.toolResponse : isRecord6(resultGuidance.tool_response) ? resultGuidance.tool_response : {};
14817
14837
  const lists = extractionEntries2(
14818
14838
  resultGuidance.extractedLists ?? resultGuidance.extracted_lists
14819
14839
  ).map((entry) => ({
@@ -15256,7 +15276,8 @@ async function handleFileBackedRun(options, hooks) {
15256
15276
  emitLogs: options.emitLogs,
15257
15277
  waitTimeoutMs: options.waitTimeoutMs,
15258
15278
  noOpen: options.noOpen,
15259
- progress
15279
+ progress,
15280
+ onRunStarted: hooks?.onRunStarted
15260
15281
  }).catch(async (error) => {
15261
15282
  throw await normalizePlayStartError(client2, error, playName);
15262
15283
  })
@@ -15422,7 +15443,8 @@ async function handleNamedRun(options, hooks) {
15422
15443
  emitLogs: options.emitLogs,
15423
15444
  waitTimeoutMs: options.waitTimeoutMs,
15424
15445
  noOpen: options.noOpen,
15425
- progress
15446
+ progress,
15447
+ onRunStarted: hooks?.onRunStarted
15426
15448
  }).catch(async (error) => {
15427
15449
  throw await normalizePlayStartError(client2, error, playName, {
15428
15450
  suggestMissingPlay: true
@@ -19114,7 +19136,7 @@ function isMarkedTestAiInferenceCommand(command) {
19114
19136
  if (normalizeEnrichPlayRef(command.tool) !== "run_javascript") {
19115
19137
  return false;
19116
19138
  }
19117
- return isRecord8(command.payload) && command.payload[ENRICH_TEST_AI_INFERENCE_PAYLOAD_MARKER] === true;
19139
+ return isRecord7(command.payload) && command.payload[ENRICH_TEST_AI_INFERENCE_PAYLOAD_MARKER] === true;
19118
19140
  }
19119
19141
  function enrichDebugEnabled(env = process.env) {
19120
19142
  const raw = String(env.DEEPLINE_DEBUG_ENRICH ?? "").trim().toLowerCase();
@@ -19378,7 +19400,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
19378
19400
  if (Array.isArray(value)) {
19379
19401
  return value.map(rewrite);
19380
19402
  }
19381
- if (!isRecord8(value)) {
19403
+ if (!isRecord7(value)) {
19382
19404
  return value;
19383
19405
  }
19384
19406
  const next = Object.fromEntries(
@@ -19387,7 +19409,7 @@ function rewriteGeneratedPlayRerunForEnrich(status, enrichCommand) {
19387
19409
  key === "rerunCommand" && typeof entry === "string" ? enrichCommand : rewrite(entry)
19388
19410
  ])
19389
19411
  );
19390
- if (isRecord8(next.next) && typeof next.next.run === "string") {
19412
+ if (isRecord7(next.next) && typeof next.next.run === "string") {
19391
19413
  next.next = { ...next.next, run: enrichCommand };
19392
19414
  }
19393
19415
  return next;
@@ -19858,7 +19880,7 @@ async function resolveWatchedGeneratedPlayStatus(input2) {
19858
19880
  }
19859
19881
  return input2.client.runs.get(runId, { full: true });
19860
19882
  }
19861
- function isRecord8(value) {
19883
+ function isRecord7(value) {
19862
19884
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
19863
19885
  }
19864
19886
  async function captureStdout(run, options = {}) {
@@ -19920,6 +19942,7 @@ async function runGeneratedEnrichPlay(client2, runArgs, options = {}) {
19920
19942
  let terminalStatus2 = null;
19921
19943
  const captured2 = await captureStdout(
19922
19944
  () => handlePlayRun(runArgs, {
19945
+ onRunStarted: options.onRunStarted,
19923
19946
  onTerminalStatus: (status) => {
19924
19947
  terminalStatus2 = status;
19925
19948
  }
@@ -19941,6 +19964,7 @@ async function runGeneratedEnrichPlay(client2, runArgs, options = {}) {
19941
19964
  let terminalStatus = null;
19942
19965
  const captured = await captureStdout(
19943
19966
  () => handlePlayRun(runArgs, {
19967
+ onRunStarted: options.onRunStarted,
19944
19968
  onTerminalStatus: (status) => {
19945
19969
  terminalStatus = status;
19946
19970
  }
@@ -19949,6 +19973,17 @@ async function runGeneratedEnrichPlay(client2, runArgs, options = {}) {
19949
19973
  );
19950
19974
  return { ...captured, terminalStatus };
19951
19975
  }
19976
+ function writeEnrichInterruptionHint(input2) {
19977
+ const output2 = input2.outputPath ? ` --out ${input2.outputPath}` : "";
19978
+ process.stderr.write(
19979
+ [
19980
+ `Enrich client interrupted by ${input2.signal}; the run is continuing in the background.`,
19981
+ `Run id: ${input2.runId}`,
19982
+ `Inspect: deepline runs get ${input2.runId} --full --json`,
19983
+ `Export: deepline runs export ${input2.runId} --dataset result.rows${output2}`
19984
+ ].join("\n") + "\n"
19985
+ );
19986
+ }
19952
19987
  async function writeOutputCsv(outputPath, status, options) {
19953
19988
  let rowsInfo = extractCanonicalRowsInfo(status);
19954
19989
  if (!rowsInfo) {
@@ -20097,13 +20132,13 @@ function readFirstEnrichDatasetActions(value) {
20097
20132
  return null;
20098
20133
  }
20099
20134
  const record = candidate;
20100
- const actions = isRecord8(record.actions) ? record.actions : null;
20101
- const query = isRecord8(actions?.query) ? actions.query : null;
20135
+ const actions = isRecord7(record.actions) ? record.actions : null;
20136
+ const query = isRecord7(actions?.query) ? actions.query : null;
20102
20137
  if (query?.kind === "deepline_db_query") {
20103
20138
  return {
20104
20139
  dataset: record,
20105
20140
  query,
20106
- ...isRecord8(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
20141
+ ...isRecord7(actions?.exportCsv) ? { exportCsv: actions.exportCsv } : {}
20107
20142
  };
20108
20143
  }
20109
20144
  if (options.allowLegacy && record.kind === "dataset" && typeof record.queryDatasetCommand === "string" && record.queryDatasetCommand.trim()) {
@@ -20156,7 +20191,7 @@ function enrichCustomerDbJson(input2) {
20156
20191
  const dataset = actions.dataset;
20157
20192
  const sql = actionStringField(query, "sql") ?? parseSqlFromDbQueryCommand(actions.queryDatasetCommand);
20158
20193
  const datasetPath = actionStringField(query, "datasetPath") ?? actionStringField(dataset, "path") ?? actionStringField(dataset, "tableNamespace");
20159
- const api = isRecord8(query.api) ? query.api : null;
20194
+ const api = isRecord7(query.api) ? query.api : null;
20160
20195
  const apiPath = actionStringField(api ?? {}, "path") ?? "/api/v2/db/query";
20161
20196
  const apiMethod = actionStringField(api ?? {}, "method") ?? "POST";
20162
20197
  if (!datasetPath) {
@@ -20225,11 +20260,11 @@ function sqlStringLiteral(value) {
20225
20260
  return `'${value.replace(/'/g, "''")}'`;
20226
20261
  }
20227
20262
  function failureAliasFromCellMeta(cellMeta) {
20228
- if (!isRecord8(cellMeta)) {
20263
+ if (!isRecord7(cellMeta)) {
20229
20264
  return null;
20230
20265
  }
20231
20266
  for (const [alias, meta] of Object.entries(cellMeta)) {
20232
- if (!isRecord8(meta)) {
20267
+ if (!isRecord7(meta)) {
20233
20268
  continue;
20234
20269
  }
20235
20270
  const failure = failureCellFromMeta(meta, {});
@@ -20722,7 +20757,7 @@ function exportableSheetRow2(row, sourceRowStart = 0) {
20722
20757
  return fallback;
20723
20758
  }
20724
20759
  function failureCellFromMeta(meta, fallback) {
20725
- if (!isRecord8(meta)) {
20760
+ if (!isRecord7(meta)) {
20726
20761
  return null;
20727
20762
  }
20728
20763
  const status = typeof meta.status === "string" ? meta.status.trim().toLowerCase() : "";
@@ -20742,7 +20777,7 @@ function failureCellFromMeta(meta, fallback) {
20742
20777
  };
20743
20778
  }
20744
20779
  function applyFailureCellMeta(row, cellMeta, fallback) {
20745
- if (!isRecord8(cellMeta)) {
20780
+ if (!isRecord7(cellMeta)) {
20746
20781
  return;
20747
20782
  }
20748
20783
  for (const [field, meta] of Object.entries(cellMeta)) {
@@ -20970,7 +21005,7 @@ function stableRowSnapshot(value) {
20970
21005
  }
20971
21006
  function cellFailureError(value) {
20972
21007
  const parsed = parseMaybeJsonObject(value);
20973
- if (!isRecord8(parsed)) {
21008
+ if (!isRecord7(parsed)) {
20974
21009
  const text = typeof parsed === "string" ? parsed.trim() : "";
20975
21010
  if (/^(?:[A-Za-z0-9_:-]+:\s*)?(?:Error|TypeError|ReferenceError|SyntaxError|RangeError):\s+/.test(
20976
21011
  text
@@ -20978,12 +21013,12 @@ function cellFailureError(value) {
20978
21013
  return { message: text };
20979
21014
  }
20980
21015
  }
20981
- if (!isRecord8(parsed)) {
21016
+ if (!isRecord7(parsed)) {
20982
21017
  return null;
20983
21018
  }
20984
21019
  const status = typeof parsed.status === "string" ? parsed.status.trim().toLowerCase() : "";
20985
21020
  const directError = typeof parsed.error === "string" ? parsed.error.trim() : typeof parsed.last_error === "string" ? parsed.last_error.trim() : "";
20986
- const result = isRecord8(parsed.result) ? parsed.result : null;
21021
+ const result = isRecord7(parsed.result) ? parsed.result : null;
20987
21022
  const resultError = typeof result?.error === "string" ? result.error.trim() : typeof result?.message === "string" ? result.message.trim() : "";
20988
21023
  if (!directError && !resultError && status !== "error" && status !== "failed") {
20989
21024
  return null;
@@ -21053,7 +21088,7 @@ function assignFlattenedFailurePath(target, field, value) {
21053
21088
  let cursor = target;
21054
21089
  for (const part of normalized.slice(0, -1)) {
21055
21090
  const existing = cursor[part];
21056
- if (!isRecord8(existing)) {
21091
+ if (!isRecord7(existing)) {
21057
21092
  const next = {};
21058
21093
  cursor[part] = next;
21059
21094
  cursor = next;
@@ -21217,10 +21252,10 @@ function waterfallExecutionSignal(status, spec) {
21217
21252
  let everyChildStatOnlyConditionSkipped = true;
21218
21253
  const childAliasesWithStats = /* @__PURE__ */ new Set();
21219
21254
  for (const childAlias of childAliases) {
21220
- for (const stat2 of summaries.map((summary) => summary[childAlias]).filter(isRecord8)) {
21255
+ for (const stat2 of summaries.map((summary) => summary[childAlias]).filter(isRecord7)) {
21221
21256
  sawChildStats = true;
21222
21257
  childAliasesWithStats.add(childAlias);
21223
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
21258
+ const execution = isRecord7(stat2.execution) ? stat2.execution : null;
21224
21259
  const executedSummary = parseExecutionSummary(
21225
21260
  execution?.["completed:executed"]
21226
21261
  );
@@ -21250,7 +21285,7 @@ function waterfallExecutionSignal(status, spec) {
21250
21285
  }
21251
21286
  function emptyWaterfallStatsEvidence(status, spec) {
21252
21287
  const summaries = collectColumnStats(status);
21253
- const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord8);
21288
+ const parentStats = summaries.map((summary) => summary[spec.alias]).filter(isRecord7);
21254
21289
  for (const stat2 of parentStats) {
21255
21290
  const nonEmpty = parseExecutionSummary(stat2.non_empty);
21256
21291
  if (nonEmpty?.total && nonEmpty.count === 0) {
@@ -21264,7 +21299,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
21264
21299
  let selectedRows = 0;
21265
21300
  let sawStatsForEveryChild = true;
21266
21301
  for (const childAlias of childAliases) {
21267
- const stat2 = summaries.map((summary) => summary[childAlias]).find(isRecord8);
21302
+ const stat2 = summaries.map((summary) => summary[childAlias]).find(isRecord7);
21268
21303
  if (!stat2) {
21269
21304
  sawStatsForEveryChild = false;
21270
21305
  break;
@@ -21273,7 +21308,7 @@ function emptyWaterfallStatsEvidence(status, spec) {
21273
21308
  if ((nonEmpty?.count ?? 0) > 0) {
21274
21309
  return null;
21275
21310
  }
21276
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
21311
+ const execution = isRecord7(stat2.execution) ? stat2.execution : null;
21277
21312
  const executed = parseExecutionSummary(execution?.["completed:executed"]);
21278
21313
  const reused = parseExecutionSummary(execution?.["completed:reused"]);
21279
21314
  const skipped = parseExecutionSummary(execution?.["skipped:condition"]);
@@ -21315,11 +21350,11 @@ function collectStatusFailureJobs(input2) {
21315
21350
  const jobs = [];
21316
21351
  aliases.forEach((spec, aliasIndex) => {
21317
21352
  const { alias } = spec;
21318
- const stat2 = summaries.map((summary) => summary[alias]).find(isRecord8);
21353
+ const stat2 = summaries.map((summary) => summary[alias]).find(isRecord7);
21319
21354
  if (!stat2) {
21320
21355
  return;
21321
21356
  }
21322
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
21357
+ const execution = isRecord7(stat2.execution) ? stat2.execution : null;
21323
21358
  const failedCount = Math.min(
21324
21359
  selectedRows,
21325
21360
  Math.max(
@@ -21426,10 +21461,10 @@ function collectColumnStats(status) {
21426
21461
  value.forEach(visit);
21427
21462
  return;
21428
21463
  }
21429
- if (!isRecord8(value)) {
21464
+ if (!isRecord7(value)) {
21430
21465
  return;
21431
21466
  }
21432
- if (isRecord8(value.columnStats)) {
21467
+ if (isRecord7(value.columnStats)) {
21433
21468
  summaries.push(value.columnStats);
21434
21469
  }
21435
21470
  Object.values(value).forEach(visit);
@@ -21441,12 +21476,12 @@ function firstAliasExecutionCounts(input2) {
21441
21476
  const aliases = collectConfigScalarAliasOrder(input2.config);
21442
21477
  const summaries = collectColumnStats(input2.status);
21443
21478
  for (const alias of aliases) {
21444
- const stat2 = summaries.map((summary) => summary[alias]).find(isRecord8);
21479
+ const stat2 = summaries.map((summary) => summary[alias]).find(isRecord7);
21445
21480
  if (!stat2) continue;
21446
21481
  if (input2.forceAliases.has(normalizeAlias2(alias))) {
21447
21482
  return { executed: input2.selectedRows, reused: 0 };
21448
21483
  }
21449
- const execution = isRecord8(stat2.execution) ? stat2.execution : null;
21484
+ const execution = isRecord7(stat2.execution) ? stat2.execution : null;
21450
21485
  if (!execution) continue;
21451
21486
  return {
21452
21487
  executed: parseExecutionCount(execution["completed:executed"]),
@@ -21473,14 +21508,14 @@ function rewriteEnrichJsonStatus(input2) {
21473
21508
  if (Array.isArray(value)) {
21474
21509
  return value.map(rewrite);
21475
21510
  }
21476
- if (!isRecord8(value)) {
21511
+ if (!isRecord7(value)) {
21477
21512
  return value;
21478
21513
  }
21479
21514
  const next = {};
21480
21515
  for (const [key, entry] of Object.entries(value)) {
21481
21516
  next[key] = rewrite(entry);
21482
21517
  }
21483
- if (isRecord8(next.progress)) {
21518
+ if (isRecord7(next.progress)) {
21484
21519
  next.progress = {
21485
21520
  ...next.progress,
21486
21521
  ...selectedRows > 0 ? { total: selectedRows } : {},
@@ -21489,8 +21524,8 @@ function rewriteEnrichJsonStatus(input2) {
21489
21524
  ...failedRows > 0 ? { failed: failedRows, pending: 0 } : {}
21490
21525
  };
21491
21526
  }
21492
- if (isRecord8(next.summary)) {
21493
- const rowCounts = isRecord8(next.summary.rowCounts) ? next.summary.rowCounts : null;
21527
+ if (isRecord7(next.summary)) {
21528
+ const rowCounts = isRecord7(next.summary.rowCounts) ? next.summary.rowCounts : null;
21494
21529
  if (failedRows > 0) {
21495
21530
  next.summary = {
21496
21531
  ...next.summary,
@@ -21503,11 +21538,11 @@ function rewriteEnrichJsonStatus(input2) {
21503
21538
  };
21504
21539
  }
21505
21540
  }
21506
- if (isRecord8(next.columnStats) && selectedRows > 0) {
21541
+ if (isRecord7(next.columnStats) && selectedRows > 0) {
21507
21542
  const columnStats = { ...next.columnStats };
21508
21543
  for (const alias of forcedAliases) {
21509
- const stat2 = isRecord8(columnStats[alias]) ? columnStats[alias] : null;
21510
- const execution = isRecord8(stat2?.execution) ? stat2.execution : null;
21544
+ const stat2 = isRecord7(columnStats[alias]) ? columnStats[alias] : null;
21545
+ const execution = isRecord7(stat2?.execution) ? stat2.execution : null;
21511
21546
  if (!stat2 || !execution) continue;
21512
21547
  columnStats[alias] = {
21513
21548
  ...stat2,
@@ -21526,14 +21561,14 @@ function rewriteEnrichJsonStatus(input2) {
21526
21561
  return next;
21527
21562
  };
21528
21563
  const rewritten = rewrite(input2.status);
21529
- if (failedRows === 0 || !isRecord8(rewritten)) {
21564
+ if (failedRows === 0 || !isRecord7(rewritten)) {
21530
21565
  return rewritten;
21531
21566
  }
21532
21567
  const partialStatus = selectedRows > 0 && failedRows < selectedRows ? "partial_success" : "failed";
21533
21568
  return {
21534
21569
  ...rewritten,
21535
21570
  ...rewritten.status === "completed" || rewritten.status === "failed" ? { status: partialStatus } : {},
21536
- ...isRecord8(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
21571
+ ...isRecord7(rewritten.run) && (rewritten.run.status === "completed" || rewritten.run.status === "failed") ? { run: { ...rewritten.run, status: partialStatus } } : {}
21537
21572
  };
21538
21573
  }
21539
21574
  function summarizeFailedJobError(value) {
@@ -22139,7 +22174,7 @@ function materializeCsvCellValue(value) {
22139
22174
  return value;
22140
22175
  }
22141
22176
  function compactArrayEnvelopeCompleteValue(value) {
22142
- if (!isRecord8(value) || value.kind !== "array") {
22177
+ if (!isRecord7(value) || value.kind !== "array") {
22143
22178
  return null;
22144
22179
  }
22145
22180
  if (!Array.isArray(value.preview)) {
@@ -22153,7 +22188,7 @@ function compactArrayEnvelopeCompleteValue(value) {
22153
22188
  }
22154
22189
  function disambiguateCompactAiInferencePayload(value) {
22155
22190
  const parsed = parseMaybeJsonObject(value);
22156
- if (!isRecord8(parsed) || !cellFailureError(parsed)) {
22191
+ if (!isRecord7(parsed) || !cellFailureError(parsed)) {
22157
22192
  return value;
22158
22193
  }
22159
22194
  return {
@@ -22162,14 +22197,14 @@ function disambiguateCompactAiInferencePayload(value) {
22162
22197
  };
22163
22198
  }
22164
22199
  function compactAiInferenceCellForCsv(value) {
22165
- if (!isRecord8(value)) {
22200
+ if (!isRecord7(value)) {
22166
22201
  return value;
22167
22202
  }
22168
22203
  const extractedJson = value.extracted_json;
22169
22204
  if (extractedJson !== null && extractedJson !== void 0) {
22170
22205
  return disambiguateCompactAiInferencePayload(extractedJson);
22171
22206
  }
22172
- const result = isRecord8(value.result) ? value.result : null;
22207
+ const result = isRecord7(value.result) ? value.result : null;
22173
22208
  const object = result?.object;
22174
22209
  if (object !== null && object !== void 0) {
22175
22210
  return disambiguateCompactAiInferencePayload(object);
@@ -22186,12 +22221,12 @@ function compactAiInferenceCellForCsv(value) {
22186
22221
  }
22187
22222
  function materializeEnrichAliasCellForCsv(row, alias, options) {
22188
22223
  const direct = row[alias];
22189
- if (isRecord8(direct)) {
22224
+ if (isRecord7(direct)) {
22190
22225
  const completeArray = compactArrayEnvelopeCompleteValue(direct);
22191
22226
  if (completeArray) {
22192
22227
  return materializeCsvCellValue(completeArray);
22193
22228
  }
22194
- if (options?.compactAiCell && direct.status === "completed" && (isRecord8(direct.result) || Object.prototype.hasOwnProperty.call(direct, "extracted_json") || typeof direct.output === "string")) {
22229
+ if (options?.compactAiCell && direct.status === "completed" && (isRecord7(direct.result) || Object.prototype.hasOwnProperty.call(direct, "extracted_json") || typeof direct.output === "string")) {
22195
22230
  return materializeCsvCellValue(compactAiInferenceCellForCsv(direct));
22196
22231
  }
22197
22232
  if (Object.prototype.hasOwnProperty.call(direct, "matched_result") || Object.prototype.hasOwnProperty.call(direct, "matchedResult") || Object.prototype.hasOwnProperty.call(direct, "result")) {
@@ -22332,11 +22367,11 @@ function normalizeEnrichRowsForCsvExport(rows, config, options) {
22332
22367
  }
22333
22368
  function legacyMetadataFromRow(row) {
22334
22369
  const direct = parseLegacyMetadataCell(row._metadata);
22335
- if (direct && isRecord8(direct.columns)) {
22370
+ if (direct && isRecord7(direct.columns)) {
22336
22371
  return direct;
22337
22372
  }
22338
22373
  const relocated = parseLegacyMetadataCell(row.metadata);
22339
- if (relocated && isRecord8(relocated.columns)) {
22374
+ if (relocated && isRecord7(relocated.columns)) {
22340
22375
  return relocated;
22341
22376
  }
22342
22377
  const flattenedColumns = parseLegacyMetadataCell(row["metadata.columns"]);
@@ -22353,7 +22388,7 @@ function legacyMetadataFromRow(row) {
22353
22388
  }
22354
22389
  function parseLegacyMetadataCell(value) {
22355
22390
  const parsed = parseMaybeJsonObject(value);
22356
- if (isRecord8(parsed)) {
22391
+ if (isRecord7(parsed)) {
22357
22392
  return parsed;
22358
22393
  }
22359
22394
  if (typeof value !== "string") {
@@ -22370,12 +22405,12 @@ function parseLegacyMetadataCell(value) {
22370
22405
  for (const candidate of candidates) {
22371
22406
  try {
22372
22407
  const decoded = JSON.parse(candidate);
22373
- if (isRecord8(decoded)) {
22408
+ if (isRecord7(decoded)) {
22374
22409
  return decoded;
22375
22410
  }
22376
22411
  if (typeof decoded === "string") {
22377
22412
  const nested = JSON.parse(decoded);
22378
- if (isRecord8(nested)) {
22413
+ if (isRecord7(nested)) {
22379
22414
  return nested;
22380
22415
  }
22381
22416
  }
@@ -22385,8 +22420,8 @@ function parseLegacyMetadataCell(value) {
22385
22420
  return null;
22386
22421
  }
22387
22422
  function mergeLegacyMetadataRecords(base, enriched) {
22388
- const baseColumns = isRecord8(base.columns) ? base.columns : null;
22389
- const enrichedColumns = isRecord8(enriched.columns) ? enriched.columns : null;
22423
+ const baseColumns = isRecord7(base.columns) ? base.columns : null;
22424
+ const enrichedColumns = isRecord7(enriched.columns) ? enriched.columns : null;
22390
22425
  const merged = {
22391
22426
  ...base,
22392
22427
  ...enriched
@@ -22538,6 +22573,7 @@ function registerEnrichCommand(program) {
22538
22573
  }
22539
22574
  const rows = parseRows(options.rows, options.all);
22540
22575
  let outputPath = options.inPlace ? inputCsv : options.output;
22576
+ const requestedOutputPath = options.inPlace ? resolve9(inputCsv) : options.output ? resolve9(options.output) : void 0;
22541
22577
  const sourceCsvPath = !options.inPlace && outputPath && await regularFileExists(outputPath) ? outputPath : inputCsv;
22542
22578
  const forceAliases = resolveForceAliases(config, options);
22543
22579
  for (const alias of collectFailedInputAliases(
@@ -22579,6 +22615,19 @@ function registerEnrichCommand(program) {
22579
22615
  const inPlaceCommitOutputPath = options.inPlace ? (await lstat(inputCsv)).isSymbolicLink() ? await realpath(inputCsv) : inPlaceFinalOutputPath : null;
22580
22616
  const failureReportOutputPath = options.inPlace ? inPlaceFinalOutputPath : null;
22581
22617
  const enrichIssueFollowUpOutputPath = options.inPlace && inPlaceFinalOutputPath ? sidecarEnrichRowsExportPath(inPlaceFinalOutputPath) : null;
22618
+ let activeRunId2 = null;
22619
+ const interruptEnrich = (signal) => {
22620
+ if (activeRunId2) {
22621
+ writeEnrichInterruptionHint({
22622
+ signal,
22623
+ runId: activeRunId2,
22624
+ outputPath: requestedOutputPath
22625
+ });
22626
+ }
22627
+ process.exit(signal === "SIGINT" ? 130 : 143);
22628
+ };
22629
+ const onSigint = () => interruptEnrich("SIGINT");
22630
+ const onSigterm = () => interruptEnrich("SIGTERM");
22582
22631
  const prepareInPlaceOutput = async () => {
22583
22632
  if (!options.inPlace) {
22584
22633
  return;
@@ -22617,6 +22666,8 @@ function registerEnrichCommand(program) {
22617
22666
  };
22618
22667
  };
22619
22668
  try {
22669
+ process.once("SIGINT", onSigint);
22670
+ process.once("SIGTERM", onSigterm);
22620
22671
  await writeFile3(tempPlay, playSource, "utf8");
22621
22672
  if (options.inPlace) {
22622
22673
  await prepareInPlaceOutput();
@@ -22654,7 +22705,10 @@ function registerEnrichCommand(program) {
22654
22705
  runArgs.push("--tail-timeout-ms", String(timeoutSeconds * 1e3));
22655
22706
  }
22656
22707
  const captured2 = await runGeneratedEnrichPlay(client2, runArgs, {
22657
- passthroughStdout: input2.passthroughStdout
22708
+ passthroughStdout: input2.passthroughStdout,
22709
+ onRunStarted: (runId) => {
22710
+ activeRunId2 = runId;
22711
+ }
22658
22712
  });
22659
22713
  const generatedPlayStatus = input2.json ? parseJsonOutput(captured2.stdout) : captured2.terminalStatus ?? await resolveWatchedGeneratedPlayStatus({
22660
22714
  client: client2,
@@ -22802,6 +22856,8 @@ function registerEnrichCommand(program) {
22802
22856
  await completeTelemetry({ status: "failed", failedJobs: 1 });
22803
22857
  throw error;
22804
22858
  } finally {
22859
+ process.removeListener("SIGINT", onSigint);
22860
+ process.removeListener("SIGTERM", onSigterm);
22805
22861
  if (inPlaceTempDir) {
22806
22862
  await rm(inPlaceTempDir, { recursive: true, force: true });
22807
22863
  } else if (inPlaceTempOutputPath) {
@@ -26633,7 +26689,7 @@ function toolContractJsonForDescribe(tool, requestedToolId) {
26633
26689
  }
26634
26690
  function extractionContractEntries(entries) {
26635
26691
  return entries.flatMap((entry) => {
26636
- if (!isRecord9(entry)) return [];
26692
+ if (!isRecord8(entry)) return [];
26637
26693
  const name = stringField2(entry, "name");
26638
26694
  const expression = stringField2(entry, "expression");
26639
26695
  return name && expression ? [{ name, expression }] : [];
@@ -26641,8 +26697,8 @@ function extractionContractEntries(entries) {
26641
26697
  }
26642
26698
  function printCompactToolContract(tool, requestedToolId) {
26643
26699
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
26644
- const cost = isRecord9(contract.cost) ? contract.cost : {};
26645
- const getters = isRecord9(contract.getters) ? contract.getters : {};
26700
+ const cost = isRecord8(contract.cost) ? contract.cost : {};
26701
+ const getters = isRecord8(contract.getters) ? contract.getters : {};
26646
26702
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
26647
26703
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
26648
26704
  const inputFields = Array.isArray(contract.inputFields) ? contract.inputFields : [];
@@ -26659,7 +26715,7 @@ function printCompactToolContract(tool, requestedToolId) {
26659
26715
  console.log("");
26660
26716
  console.log("Inputs:");
26661
26717
  for (const field of inputFields) {
26662
- if (!isRecord9(field)) continue;
26718
+ if (!isRecord8(field)) continue;
26663
26719
  const name = stringField2(field, "name");
26664
26720
  if (!name) continue;
26665
26721
  const required = field.required ? "*" : "";
@@ -26672,7 +26728,7 @@ function printCompactToolContract(tool, requestedToolId) {
26672
26728
  }
26673
26729
  console.log("");
26674
26730
  printToolExamplesOnly(tool, requestedToolId, { includeSamples: false });
26675
- const starterScript = isRecord9(contract.starterScript) ? contract.starterScript : {};
26731
+ const starterScript = isRecord8(contract.starterScript) ? contract.starterScript : {};
26676
26732
  const starterPath = stringField2(starterScript, "path");
26677
26733
  if (starterPath) {
26678
26734
  console.log("");
@@ -26686,14 +26742,14 @@ function printCompactToolContract(tool, requestedToolId) {
26686
26742
  console.log("Getters:");
26687
26743
  if (listGetters.length) console.log("Lists:");
26688
26744
  for (const entry of listGetters) {
26689
- if (isRecord9(entry))
26745
+ if (isRecord8(entry))
26690
26746
  console.log(
26691
26747
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
26692
26748
  );
26693
26749
  }
26694
26750
  if (valueGetters.length) console.log("Values:");
26695
26751
  for (const entry of valueGetters) {
26696
- if (isRecord9(entry))
26752
+ if (isRecord8(entry))
26697
26753
  console.log(
26698
26754
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
26699
26755
  );
@@ -26706,7 +26762,7 @@ function printCompactToolContract(tool, requestedToolId) {
26706
26762
  }
26707
26763
  function printToolPricingOnly(tool, requestedToolId, options = {}) {
26708
26764
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
26709
- const cost = isRecord9(contract.cost) ? contract.cost : {};
26765
+ const cost = isRecord8(contract.cost) ? contract.cost : {};
26710
26766
  const pricingModel = stringField2(cost, "pricingModel") || "unknown";
26711
26767
  const billingMode = stringField2(cost, "billingMode") || "unknown";
26712
26768
  const unit = pricingModel === "per_page" ? "page" : pricingModel === "per_result" ? "result" : pricingModel === "fixed" ? "call" : pricingModel.replace(/^per_/, "") || "unit";
@@ -26726,7 +26782,7 @@ function printToolSchemaOnly(tool, requestedToolId) {
26726
26782
  }
26727
26783
  console.log("Inputs:");
26728
26784
  for (const field of inputFields) {
26729
- if (!isRecord9(field)) continue;
26785
+ if (!isRecord8(field)) continue;
26730
26786
  const name = stringField2(field, "name");
26731
26787
  if (!name) continue;
26732
26788
  const required = field.required ? "*" : "";
@@ -26756,10 +26812,10 @@ function printToolExamplesOnly(tool, requestedToolId, options = {}) {
26756
26812
  ` input: ${JSON.stringify(sampleInput || {}, null, 2).replace(/\n/g, "\n ")},`
26757
26813
  );
26758
26814
  console.log("});");
26759
- const getters = isRecord9(contract.getters) ? contract.getters : {};
26815
+ const getters = isRecord8(contract.getters) ? contract.getters : {};
26760
26816
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
26761
26817
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
26762
- const firstGetter = [...valueGetters, ...listGetters].find(isRecord9);
26818
+ const firstGetter = [...valueGetters, ...listGetters].find(isRecord8);
26763
26819
  if (firstGetter) {
26764
26820
  const name = stringField2(firstGetter, "name") || "value";
26765
26821
  const expression = stringField2(firstGetter, "expression");
@@ -26795,7 +26851,7 @@ function printPlayLikeToolUsage(tool, requestedToolId) {
26795
26851
  }
26796
26852
  function printToolGettersOnly(tool, requestedToolId) {
26797
26853
  const contract = toolContractJsonForDescribe(tool, requestedToolId);
26798
- const getters = isRecord9(contract.getters) ? contract.getters : {};
26854
+ const getters = isRecord8(contract.getters) ? contract.getters : {};
26799
26855
  const listGetters = Array.isArray(getters.extractedLists) ? getters.extractedLists : [];
26800
26856
  const valueGetters = Array.isArray(getters.extractedValues) ? getters.extractedValues : [];
26801
26857
  console.log(`Getters: ${contract.toolId}`);
@@ -26808,7 +26864,7 @@ function printToolGettersOnly(tool, requestedToolId) {
26808
26864
  if (listGetters.length) {
26809
26865
  console.log("Lists:");
26810
26866
  for (const entry of listGetters) {
26811
- if (isRecord9(entry))
26867
+ if (isRecord8(entry))
26812
26868
  console.log(
26813
26869
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
26814
26870
  );
@@ -26817,7 +26873,7 @@ function printToolGettersOnly(tool, requestedToolId) {
26817
26873
  if (valueGetters.length) {
26818
26874
  console.log("Values:");
26819
26875
  for (const entry of valueGetters) {
26820
- if (isRecord9(entry))
26876
+ if (isRecord8(entry))
26821
26877
  console.log(
26822
26878
  `- ${stringField2(entry, "name")}: ${playResultExpression(entry)}`
26823
26879
  );
@@ -26843,7 +26899,7 @@ function sampleValueForField(field) {
26843
26899
  function samplePayloadForInputFields(fields) {
26844
26900
  return Object.fromEntries(
26845
26901
  fields.slice(0, 4).flatMap((field) => {
26846
- if (!isRecord9(field)) return [];
26902
+ if (!isRecord8(field)) return [];
26847
26903
  const name = stringField2(field, "name");
26848
26904
  if (!name) return [];
26849
26905
  return [[name, sampleValueForField(field)]];
@@ -26961,12 +27017,12 @@ function formatListedToolCost(tool) {
26961
27017
  }
26962
27018
  function toolInputFieldsForDisplay(inputSchema) {
26963
27019
  if (Array.isArray(inputSchema.fields))
26964
- return inputSchema.fields.filter(isRecord9);
26965
- const jsonSchema = isRecord9(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
26966
- const properties = isRecord9(jsonSchema.properties) ? jsonSchema.properties : {};
27020
+ return inputSchema.fields.filter(isRecord8);
27021
+ const jsonSchema = isRecord8(inputSchema.jsonSchema) ? inputSchema.jsonSchema : inputSchema;
27022
+ const properties = isRecord8(jsonSchema.properties) ? jsonSchema.properties : {};
26967
27023
  const required = Array.isArray(jsonSchema.required) ? new Set(jsonSchema.required.map(String)) : /* @__PURE__ */ new Set();
26968
27024
  return Object.entries(properties).map(([name, value]) => {
26969
- const property = isRecord9(value) ? value : {};
27025
+ const property = isRecord8(value) ? value : {};
26970
27026
  return {
26971
27027
  name,
26972
27028
  type: typeof property.type === "string" ? property.type : "unknown",
@@ -26995,15 +27051,15 @@ function printJsonPreview(label, payload) {
26995
27051
  }
26996
27052
  function samplePayload(samples, key) {
26997
27053
  const entry = samples[key];
26998
- if (!isRecord9(entry)) return void 0;
27054
+ if (!isRecord8(entry)) return void 0;
26999
27055
  return Object.prototype.hasOwnProperty.call(entry, "payload") ? entry.payload : entry;
27000
27056
  }
27001
27057
  function commandEnvelopeFromRawResponse(rawResponse) {
27002
- return isRecord9(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
27058
+ return isRecord8(rawResponse) ? { ...rawResponse } : { status: "completed", result: rawResponse };
27003
27059
  }
27004
27060
  function listExtractorPathsFromUsageGuidance(tool) {
27005
27061
  const toolExecutionResult = tool.usageGuidance?.toolExecutionResult;
27006
- const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord9(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
27062
+ const extractedLists = Array.isArray(toolExecutionResult?.extractedLists) ? toolExecutionResult.extractedLists : isRecord8(toolExecutionResult?.extractedLists) ? Object.values(toolExecutionResult.extractedLists) : [];
27007
27063
  return extractedLists.flatMap((entry) => {
27008
27064
  const paths = entry.details?.candidatePaths ?? entry.details?.rawToolOutputPaths;
27009
27065
  if (!Array.isArray(paths)) return [];
@@ -27019,7 +27075,7 @@ function formatDecimal(value) {
27019
27075
  function formatUsd(value) {
27020
27076
  return `$${formatDecimal(value)}`;
27021
27077
  }
27022
- function isRecord9(value) {
27078
+ function isRecord8(value) {
27023
27079
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
27024
27080
  }
27025
27081
  function stringField2(source, ...keys) {
@@ -27046,7 +27102,7 @@ function arrayField2(source, ...keys) {
27046
27102
  function recordField2(source, ...keys) {
27047
27103
  for (const key of keys) {
27048
27104
  const value = source[key];
27049
- if (isRecord9(value)) return value;
27105
+ if (isRecord8(value)) return value;
27050
27106
  }
27051
27107
  return {};
27052
27108
  }
@@ -27112,7 +27168,7 @@ function parseJsonObjectArgument(raw, flagName) {
27112
27168
  }
27113
27169
  throw invalidJsonError(flagName, message);
27114
27170
  }
27115
- if (!isRecord9(parsed)) {
27171
+ if (!isRecord8(parsed)) {
27116
27172
  throw invalidJsonError(flagName, "expected an object.");
27117
27173
  }
27118
27174
  return parsed;
@@ -27258,7 +27314,7 @@ function buildToolExecuteBaseEnvelope(input2) {
27258
27314
  kind: summaryEntries.length > 0 ? "object" : "raw",
27259
27315
  summary: input2.summary
27260
27316
  };
27261
- const envelopeHasCanonicalOutput = isRecord9(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
27317
+ const envelopeHasCanonicalOutput = isRecord8(envelope.toolResponse) && Object.prototype.hasOwnProperty.call(envelope.toolResponse, "raw");
27262
27318
  const envelopeHasDeclaredOutput = Object.prototype.hasOwnProperty.call(
27263
27319
  envelope,
27264
27320
  "output"
@@ -27477,7 +27533,7 @@ async function executeTool(args) {
27477
27533
  {
27478
27534
  ...baseEnvelope,
27479
27535
  local: {
27480
- ...isRecord9(baseEnvelope.local) ? baseEnvelope.local : {},
27536
+ ...isRecord8(baseEnvelope.local) ? baseEnvelope.local : {},
27481
27537
  payload_file: jsonPath
27482
27538
  }
27483
27539
  },