deepline 0.3.228 → 0.3.230

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  2. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  3. package/dist/bundling-sources/shared_libs/play-data-plane/contracts.ts +12 -0
  4. package/dist/bundling-sources/shared_libs/play-data-plane/index.ts +1 -0
  5. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-column-storage.ts +252 -0
  6. package/dist/bundling-sources/shared_libs/play-data-plane/sheet-contract.ts +29 -8
  7. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +19 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +297 -69
  9. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +5 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +38 -2
  11. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +8 -3
  12. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +9 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +39 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +293 -4
  15. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +29 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +56 -11
  17. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +1 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +4 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +4 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +380 -183
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +187 -14
  22. package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +52 -2
  23. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +5 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +30 -2
  25. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +118 -6
  26. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +135 -21
  27. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +1 -0
  28. package/dist/bundling-sources/shared_libs/plays/dataset.ts +16 -2
  29. package/dist/bundling-sources/shared_libs/plays/execution-pipeline.ts +72 -0
  30. package/dist/bundling-sources/shared_libs/plays/launch/prepare.ts +1 -3
  31. package/dist/bundling-sources/shared_libs/plays/sheet-filter.ts +9 -13
  32. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +28 -31
  33. package/dist/cli/index.js +102 -2
  34. package/dist/cli/index.mjs +102 -2
  35. package/dist/{compiler-manifest-Dpd2hEet.d.mts → compiler-manifest-n8ZtPv2h.d.mts} +31 -21
  36. package/dist/{compiler-manifest-Dpd2hEet.d.ts → compiler-manifest-n8ZtPv2h.d.ts} +31 -21
  37. package/dist/index.d.mts +2 -2
  38. package/dist/index.d.ts +2 -2
  39. package/dist/index.js +98 -2
  40. package/dist/index.mjs +98 -2
  41. package/dist/install-integrity.json +4 -2
  42. package/dist/plays/bundle-play-file.d.mts +2 -2
  43. package/dist/plays/bundle-play-file.d.ts +2 -2
  44. package/dist/release.d.mts +1 -1
  45. package/dist/release.d.ts +1 -1
  46. package/dist/release.js +1 -1
  47. package/dist/release.mjs +1 -1
  48. package/package.json +1 -1
@@ -1,5 +1,15 @@
1
1
  import { normalizeTableNamespace } from './row-identity';
2
2
  import { sqlSafePlayColumnName } from '../play-data-plane/column-names';
3
+ import type {
4
+ PlaySheetColumnSource,
5
+ PlaySheetColumnContract,
6
+ PlaySheetContract,
7
+ } from '../play-data-plane/contracts';
8
+ export type {
9
+ PlaySheetColumnSource,
10
+ PlaySheetColumnContract,
11
+ PlaySheetContract,
12
+ } from '../play-data-plane/contracts';
3
13
  import type { PlayDocflow } from './docflow';
4
14
 
5
15
  export { sqlSafePlayColumnName };
@@ -144,32 +154,6 @@ export function deriveStaticPipelineEntryInputFields(
144
154
  : dedupeStaticFieldNames(pipeline.inputFields ?? []);
145
155
  }
146
156
 
147
- export type PlaySheetColumnSource =
148
- | 'input'
149
- | 'datasetColumn'
150
- | 'waterfallStep'
151
- | 'childPlayColumn';
152
-
153
- export interface PlaySheetColumnContract {
154
- id: string;
155
- sqlName: string;
156
- source: PlaySheetColumnSource;
157
- field?: string;
158
- parentField?: string;
159
- playId?: string;
160
- waterfallId?: string;
161
- outputField?: string;
162
- outputSqlName?: string;
163
- stepId?: string;
164
- toolId?: string;
165
- isRowKey?: boolean;
166
- }
167
-
168
- export interface PlaySheetContract {
169
- tableNamespace: string;
170
- columns: PlaySheetColumnContract[];
171
- }
172
-
173
157
  export type PlayStaticColumnProducerKind =
174
158
  | 'tool'
175
159
  | 'waterfall'
@@ -339,13 +323,15 @@ function truncateStaticControlFlowBranchesForStorage(
339
323
  maxEmbeddedPlayCallPipelineDepth: number;
340
324
  maxStoredSubstepDepth: number;
341
325
  storedSubstepDepth: number;
326
+ preserveAdditiveMetadata: boolean;
342
327
  },
343
328
  ): PlayStaticControlFlowBranch[] | undefined {
344
329
  if (!branches) return undefined;
345
330
  return branches.map((branch) =>
346
331
  omitUndefinedProperties({
347
- label: branch.label,
348
- condition: branch.condition,
332
+ ...(input.preserveAdditiveMetadata
333
+ ? branch
334
+ : { label: branch.label, condition: branch.condition }),
349
335
  steps: truncateStaticSubstepsForStorage(
350
336
  branch.steps,
351
337
  nextStoredSubstepInput(input),
@@ -359,6 +345,7 @@ function nextStoredSubstepInput(input: {
359
345
  maxEmbeddedPlayCallPipelineDepth: number;
360
346
  maxStoredSubstepDepth: number;
361
347
  storedSubstepDepth: number;
348
+ preserveAdditiveMetadata: boolean;
362
349
  }) {
363
350
  return {
364
351
  ...input,
@@ -392,6 +379,7 @@ function truncateStaticSubstepsForStorage(
392
379
  maxEmbeddedPlayCallPipelineDepth: number;
393
380
  maxStoredSubstepDepth: number;
394
381
  storedSubstepDepth: number;
382
+ preserveAdditiveMetadata: boolean;
395
383
  },
396
384
  ): PlayStaticSubstep[] {
397
385
  return (substeps ?? []).map((substep) => {
@@ -431,6 +419,7 @@ function truncateStaticSubstepsForStorage(
431
419
  input.embeddedPlayCallPipelineDepth + 1,
432
420
  maxStoredSubstepDepth: input.maxStoredSubstepDepth,
433
421
  storedSubstepDepth: input.storedSubstepDepth + 1,
422
+ preserveAdditiveMetadata: input.preserveAdditiveMetadata,
434
423
  })
435
424
  : nestedPipeline;
436
425
  }
@@ -479,9 +468,9 @@ function truncateStaticSubstepsForStorage(
479
468
  ...base,
480
469
  steps: base.steps?.map((step) =>
481
470
  omitUndefinedProperties({
482
- id: step.id,
483
- kind: step.kind,
484
- toolId: step.toolId,
471
+ ...(input.preserveAdditiveMetadata
472
+ ? step
473
+ : { id: step.id, kind: step.kind, toolId: step.toolId }),
485
474
  }),
486
475
  ),
487
476
  });
@@ -551,6 +540,7 @@ function truncateStaticSubstepsForStorage(
551
540
  embeddedPlayCallPipelineDepth: input.embeddedPlayCallPipelineDepth + 1,
552
541
  maxStoredSubstepDepth: input.maxStoredSubstepDepth,
553
542
  storedSubstepDepth: input.storedSubstepDepth + 1,
543
+ preserveAdditiveMetadata: input.preserveAdditiveMetadata,
554
544
  }),
555
545
  });
556
546
  });
@@ -563,6 +553,8 @@ export function truncateStaticPipelineForStorage(
563
553
  embeddedPlayCallPipelineDepth?: number;
564
554
  maxStoredSubstepDepth?: number;
565
555
  storedSubstepDepth?: number;
556
+ /** Keep retained additive metadata only in the full runtime contract. */
557
+ preserveAdditiveMetadata?: boolean;
566
558
  } = {},
567
559
  ): PlayStaticPipeline | null | undefined {
568
560
  if (!pipeline) {
@@ -576,6 +568,7 @@ export function truncateStaticPipelineForStorage(
576
568
  const maxStoredSubstepDepth =
577
569
  options.maxStoredSubstepDepth ?? DEFAULT_MAX_STORED_SUBSTEP_DEPTH;
578
570
  const storedSubstepDepth = options.storedSubstepDepth ?? 0;
571
+ const preserveAdditiveMetadata = options.preserveAdditiveMetadata ?? false;
579
572
 
580
573
  return stripUndefinedDeep(
581
574
  omitUndefinedProperties({
@@ -593,12 +586,14 @@ export function truncateStaticPipelineForStorage(
593
586
  maxEmbeddedPlayCallPipelineDepth,
594
587
  maxStoredSubstepDepth,
595
588
  storedSubstepDepth,
589
+ preserveAdditiveMetadata,
596
590
  }),
597
591
  substeps: truncateStaticSubstepsForStorage(pipeline.substeps, {
598
592
  embeddedPlayCallPipelineDepth,
599
593
  maxEmbeddedPlayCallPipelineDepth,
600
594
  maxStoredSubstepDepth,
601
595
  storedSubstepDepth,
596
+ preserveAdditiveMetadata,
602
597
  }),
603
598
  sheetContract: cloneStorageSafeSheetContract(pipeline.sheetContract),
604
599
  sheetContractErrors: pipeline.sheetContractErrors
@@ -615,6 +610,8 @@ export function truncateStaticPipelineForRuntimeContract(
615
610
  // Runtime admission must preserve every dataset contract. The caller's
616
611
  // serialized artifact-size budget is the bound; a UI depth cap is not.
617
612
  maxStoredSubstepDepth: Number.POSITIVE_INFINITY,
613
+ maxEmbeddedPlayCallPipelineDepth: Number.POSITIVE_INFINITY,
614
+ preserveAdditiveMetadata: true,
618
615
  });
619
616
  }
620
617
 
package/dist/cli/index.js CHANGED
@@ -3051,7 +3051,7 @@ var SDK_RELEASE = {
3051
3051
  // getters keep their established compatibility behavior.
3052
3052
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3053
3053
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3054
- version: "0.3.228",
3054
+ version: "0.3.230",
3055
3055
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
3056
3056
  packageCapabilities: {
3057
3057
  updatePreferences: 1
@@ -5384,12 +5384,84 @@ function normalizeDatasetBornFrom(value) {
5384
5384
 
5385
5385
  // ../play-runtime/run-ledger.ts
5386
5386
  var LOG_TAIL_LIMIT = 100;
5387
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
5388
+ "completed",
5389
+ "failed",
5390
+ "cancelled",
5391
+ "terminated",
5392
+ "timed_out"
5393
+ ]);
5387
5394
  function isRecord5(value) {
5388
5395
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
5389
5396
  }
5390
5397
  function finiteNumber(value) {
5391
5398
  return typeof value === "number" && Number.isFinite(value) ? value : null;
5392
5399
  }
5400
+ function nonnegativeSafeInteger(value) {
5401
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
5402
+ }
5403
+ function isWorkCounterSegmentId(value) {
5404
+ return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
5405
+ value
5406
+ );
5407
+ }
5408
+ function normalizePlayRunLedgerTerminalWorkCounterSegment(value) {
5409
+ if (!isRecord5(value)) return void 0;
5410
+ if (!nonnegativeSafeInteger(value.attempt) || !nonnegativeSafeInteger(value.invocationSeq) || value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId)) {
5411
+ return void 0;
5412
+ }
5413
+ return {
5414
+ attempt: value.attempt,
5415
+ invocationSeq: value.invocationSeq,
5416
+ segmentId: value.segmentId
5417
+ };
5418
+ }
5419
+ function hasConfirmedPlayRunLedgerWorkCounters(snapshot) {
5420
+ const counters = snapshot.workCounters;
5421
+ const terminal = snapshot.terminalWorkCounterSegment;
5422
+ return Boolean(
5423
+ isTerminalPlayRunLedgerStatus(snapshot.status) && (snapshot.terminalSource === "worker" || snapshot.terminalSource === "system") && counters?.final && counters.completeThroughAttempt && counters.consistent && terminal && counters.attempt === terminal.attempt && counters.invocationSeq === terminal.invocationSeq && counters.segmentId === terminal.segmentId && Number.isSafeInteger(
5424
+ counters.completedLogicalCalls + counters.logicalCalls
5425
+ ) && Number.isSafeInteger(
5426
+ counters.completedProviderRequests + counters.providerRequests
5427
+ ) && Number.isSafeInteger(
5428
+ counters.completedProvider429s + counters.provider429s
5429
+ )
5430
+ );
5431
+ }
5432
+ function normalizeWorkCounters(value) {
5433
+ if (!isRecord5(value)) return void 0;
5434
+ for (const field of [
5435
+ "attempt",
5436
+ "invocationSeq",
5437
+ "logicalCalls",
5438
+ "providerRequests",
5439
+ "provider429s",
5440
+ "completedLogicalCalls",
5441
+ "completedProviderRequests",
5442
+ "completedProvider429s"
5443
+ ]) {
5444
+ if (!nonnegativeSafeInteger(value[field])) return void 0;
5445
+ }
5446
+ if (value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId) || typeof value.final !== "boolean" || typeof value.completeThroughAttempt !== "boolean" || typeof value.consistent !== "boolean") {
5447
+ return void 0;
5448
+ }
5449
+ return {
5450
+ ...value,
5451
+ attempt: value.attempt,
5452
+ invocationSeq: value.invocationSeq,
5453
+ segmentId: value.segmentId,
5454
+ logicalCalls: value.logicalCalls,
5455
+ providerRequests: value.providerRequests,
5456
+ provider429s: value.provider429s,
5457
+ final: value.final,
5458
+ completedLogicalCalls: value.completedLogicalCalls,
5459
+ completedProviderRequests: value.completedProviderRequests,
5460
+ completedProvider429s: value.completedProvider429s,
5461
+ completeThroughAttempt: value.completeThroughAttempt,
5462
+ consistent: value.consistent
5463
+ };
5464
+ }
5393
5465
  function optionalFiniteNumber(value) {
5394
5466
  const normalized = finiteNumber(value);
5395
5467
  return normalized === null ? void 0 : normalized;
@@ -5431,6 +5503,9 @@ function normalizePlayRunLedgerStatus(value) {
5431
5503
  return "unknown";
5432
5504
  }
5433
5505
  }
5506
+ function isTerminalPlayRunLedgerStatus(status) {
5507
+ return TERMINAL_STATUSES.has(status);
5508
+ }
5434
5509
  function summarizeRunRowOutcomes(snapshot) {
5435
5510
  let completedRows = 0;
5436
5511
  let failedRows = 0;
@@ -5565,6 +5640,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
5565
5640
  const error = Object.prototype.hasOwnProperty.call(value, "error") ? optionalNullableString(value.error) ?? null : fallback.error ?? null;
5566
5641
  const rawTail = Array.isArray(value.logTail) ? value.logTail : value.logs;
5567
5642
  const logTail = Array.isArray(rawTail) ? rawTail.filter((line) => typeof line === "string") : [];
5643
+ const workCounters = normalizeWorkCounters(value.workCounters);
5644
+ const terminalWorkCounterSegment = normalizePlayRunLedgerTerminalWorkCounterSegment(
5645
+ value.terminalWorkCounterSegment
5646
+ );
5568
5647
  return {
5569
5648
  runId: optionalString(value.runId) ?? fallback.runId,
5570
5649
  playName: optionalNullableString(value.playName) ?? fallback.playName ?? null,
@@ -5587,6 +5666,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
5587
5666
  (activityId) => typeof activityId === "string" && Boolean(activitiesById[activityId])
5588
5667
  ),
5589
5668
  activitiesById,
5669
+ ...workCounters ? { workCounters } : {},
5670
+ ...terminalWorkCounterSegment ? { terminalWorkCounterSegment } : {},
5590
5671
  logTail: logTail.slice(-LOG_TAIL_LIMIT),
5591
5672
  // Snapshots persisted before totalLogCount existed only know the retained
5592
5673
  // tail, so the best lower bound for the cumulative count is the tail size.
@@ -5894,6 +5975,13 @@ function buildSnapshotFromLedger(snapshot) {
5894
5975
  const liveStatus = normalizePlayRunLiveStatus(snapshot.status);
5895
5976
  const terminalRowOutcomes = isTerminalPlayRunLiveStatus(liveStatus) ? summarizeRunRowOutcomes(snapshot) : null;
5896
5977
  const rowOutcomes = terminalRowOutcomes && (Object.keys(snapshot.stepsById).length > 0 || terminalRowOutcomes.totalRows > 0 || (terminalRowOutcomes.supersededRows ?? 0) > 0) ? terminalRowOutcomes : null;
5978
+ const workCounters = snapshot.workCounters;
5979
+ const calls = workCounters ? {
5980
+ logicalCalls: workCounters.completedLogicalCalls + workCounters.logicalCalls,
5981
+ providerRequests: workCounters.completedProviderRequests + workCounters.providerRequests,
5982
+ provider429s: workCounters.completedProvider429s + workCounters.provider429s,
5983
+ confirmed: isTerminalPlayRunLiveStatus(liveStatus) && hasConfirmedPlayRunLedgerWorkCounters(snapshot)
5984
+ } : null;
5897
5985
  return {
5898
5986
  runId: snapshot.runId,
5899
5987
  status: liveStatus,
@@ -5918,7 +6006,10 @@ function buildSnapshotFromLedger(snapshot) {
5918
6006
  activeActivity: snapshot.activeActivityId ? snapshot.activitiesById[snapshot.activeActivityId] ?? null : null,
5919
6007
  nodeStates,
5920
6008
  activeNodeId: snapshot.activeStepId ?? null,
5921
- ...rowOutcomes ? { rowOutcomes } : {}
6009
+ ...rowOutcomes ? { rowOutcomes } : {},
6010
+ ...calls && Object.values(calls).every(
6011
+ (value) => typeof value === "boolean" || Number.isSafeInteger(value)
6012
+ ) ? { calls } : {}
5922
6013
  };
5923
6014
  }
5924
6015
  function buildPlayRunStatusSnapshot(input2) {
@@ -25044,6 +25135,15 @@ function getProgressLinesFromLiveEvent(event) {
25044
25135
  `progress ${formatProgressLabel(record3.nodeId ?? progress.artifactTableNamespace)}: ${counts}${messageSuffix}`
25045
25136
  );
25046
25137
  }
25138
+ const calls = readRecord(payload.calls);
25139
+ const callCounts = calls ? [calls.logicalCalls, calls.providerRequests, calls.provider429s] : [];
25140
+ if (callCounts.length === 3 && callCounts.every(
25141
+ (count) => typeof count === "number" && Number.isSafeInteger(count) && count >= 0
25142
+ )) {
25143
+ lines.push(
25144
+ `progress calls: ${formatInteger(callCounts[0])} logical, ${formatInteger(callCounts[1])} provider requests, ${formatInteger(callCounts[2])} provider 429s${calls?.confirmed === true ? "" : " (observed)"}`
25145
+ );
25146
+ }
25047
25147
  const rowOutcomes = readRowOutcomeSummary({
25048
25148
  rowOutcomes: payload.rowOutcomes
25049
25149
  });
@@ -3046,7 +3046,7 @@ var SDK_RELEASE = {
3046
3046
  // getters keep their established compatibility behavior.
3047
3047
  // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
3048
3048
  // 0.3.90 is the first deliberately versioned SDK release for API v3.
3049
- version: "0.3.228",
3049
+ version: "0.3.230",
3050
3050
  updateSummary: "Play grep now returns concise results with the matched fields and terms. Automatic CLI updates are enabled by default; use `deepline settings autoupdate off` to opt out, `deepline settings autoupdate on` to re-enable updates, or `deepline settings autoupdate pin <version>` to hold an exact release.",
3051
3051
  packageCapabilities: {
3052
3052
  updatePreferences: 1
@@ -5379,12 +5379,84 @@ function normalizeDatasetBornFrom(value) {
5379
5379
 
5380
5380
  // ../play-runtime/run-ledger.ts
5381
5381
  var LOG_TAIL_LIMIT = 100;
5382
+ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
5383
+ "completed",
5384
+ "failed",
5385
+ "cancelled",
5386
+ "terminated",
5387
+ "timed_out"
5388
+ ]);
5382
5389
  function isRecord5(value) {
5383
5390
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
5384
5391
  }
5385
5392
  function finiteNumber(value) {
5386
5393
  return typeof value === "number" && Number.isFinite(value) ? value : null;
5387
5394
  }
5395
+ function nonnegativeSafeInteger(value) {
5396
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
5397
+ }
5398
+ function isWorkCounterSegmentId(value) {
5399
+ return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(
5400
+ value
5401
+ );
5402
+ }
5403
+ function normalizePlayRunLedgerTerminalWorkCounterSegment(value) {
5404
+ if (!isRecord5(value)) return void 0;
5405
+ if (!nonnegativeSafeInteger(value.attempt) || !nonnegativeSafeInteger(value.invocationSeq) || value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId)) {
5406
+ return void 0;
5407
+ }
5408
+ return {
5409
+ attempt: value.attempt,
5410
+ invocationSeq: value.invocationSeq,
5411
+ segmentId: value.segmentId
5412
+ };
5413
+ }
5414
+ function hasConfirmedPlayRunLedgerWorkCounters(snapshot) {
5415
+ const counters = snapshot.workCounters;
5416
+ const terminal = snapshot.terminalWorkCounterSegment;
5417
+ return Boolean(
5418
+ isTerminalPlayRunLedgerStatus(snapshot.status) && (snapshot.terminalSource === "worker" || snapshot.terminalSource === "system") && counters?.final && counters.completeThroughAttempt && counters.consistent && terminal && counters.attempt === terminal.attempt && counters.invocationSeq === terminal.invocationSeq && counters.segmentId === terminal.segmentId && Number.isSafeInteger(
5419
+ counters.completedLogicalCalls + counters.logicalCalls
5420
+ ) && Number.isSafeInteger(
5421
+ counters.completedProviderRequests + counters.providerRequests
5422
+ ) && Number.isSafeInteger(
5423
+ counters.completedProvider429s + counters.provider429s
5424
+ )
5425
+ );
5426
+ }
5427
+ function normalizeWorkCounters(value) {
5428
+ if (!isRecord5(value)) return void 0;
5429
+ for (const field of [
5430
+ "attempt",
5431
+ "invocationSeq",
5432
+ "logicalCalls",
5433
+ "providerRequests",
5434
+ "provider429s",
5435
+ "completedLogicalCalls",
5436
+ "completedProviderRequests",
5437
+ "completedProvider429s"
5438
+ ]) {
5439
+ if (!nonnegativeSafeInteger(value[field])) return void 0;
5440
+ }
5441
+ if (value.invocationSeq === 0 || !isWorkCounterSegmentId(value.segmentId) || typeof value.final !== "boolean" || typeof value.completeThroughAttempt !== "boolean" || typeof value.consistent !== "boolean") {
5442
+ return void 0;
5443
+ }
5444
+ return {
5445
+ ...value,
5446
+ attempt: value.attempt,
5447
+ invocationSeq: value.invocationSeq,
5448
+ segmentId: value.segmentId,
5449
+ logicalCalls: value.logicalCalls,
5450
+ providerRequests: value.providerRequests,
5451
+ provider429s: value.provider429s,
5452
+ final: value.final,
5453
+ completedLogicalCalls: value.completedLogicalCalls,
5454
+ completedProviderRequests: value.completedProviderRequests,
5455
+ completedProvider429s: value.completedProvider429s,
5456
+ completeThroughAttempt: value.completeThroughAttempt,
5457
+ consistent: value.consistent
5458
+ };
5459
+ }
5388
5460
  function optionalFiniteNumber(value) {
5389
5461
  const normalized = finiteNumber(value);
5390
5462
  return normalized === null ? void 0 : normalized;
@@ -5426,6 +5498,9 @@ function normalizePlayRunLedgerStatus(value) {
5426
5498
  return "unknown";
5427
5499
  }
5428
5500
  }
5501
+ function isTerminalPlayRunLedgerStatus(status) {
5502
+ return TERMINAL_STATUSES.has(status);
5503
+ }
5429
5504
  function summarizeRunRowOutcomes(snapshot) {
5430
5505
  let completedRows = 0;
5431
5506
  let failedRows = 0;
@@ -5560,6 +5635,10 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
5560
5635
  const error = Object.prototype.hasOwnProperty.call(value, "error") ? optionalNullableString(value.error) ?? null : fallback.error ?? null;
5561
5636
  const rawTail = Array.isArray(value.logTail) ? value.logTail : value.logs;
5562
5637
  const logTail = Array.isArray(rawTail) ? rawTail.filter((line) => typeof line === "string") : [];
5638
+ const workCounters = normalizeWorkCounters(value.workCounters);
5639
+ const terminalWorkCounterSegment = normalizePlayRunLedgerTerminalWorkCounterSegment(
5640
+ value.terminalWorkCounterSegment
5641
+ );
5563
5642
  return {
5564
5643
  runId: optionalString(value.runId) ?? fallback.runId,
5565
5644
  playName: optionalNullableString(value.playName) ?? fallback.playName ?? null,
@@ -5582,6 +5661,8 @@ function normalizePlayRunLedgerSnapshot(value, fallback) {
5582
5661
  (activityId) => typeof activityId === "string" && Boolean(activitiesById[activityId])
5583
5662
  ),
5584
5663
  activitiesById,
5664
+ ...workCounters ? { workCounters } : {},
5665
+ ...terminalWorkCounterSegment ? { terminalWorkCounterSegment } : {},
5585
5666
  logTail: logTail.slice(-LOG_TAIL_LIMIT),
5586
5667
  // Snapshots persisted before totalLogCount existed only know the retained
5587
5668
  // tail, so the best lower bound for the cumulative count is the tail size.
@@ -5889,6 +5970,13 @@ function buildSnapshotFromLedger(snapshot) {
5889
5970
  const liveStatus = normalizePlayRunLiveStatus(snapshot.status);
5890
5971
  const terminalRowOutcomes = isTerminalPlayRunLiveStatus(liveStatus) ? summarizeRunRowOutcomes(snapshot) : null;
5891
5972
  const rowOutcomes = terminalRowOutcomes && (Object.keys(snapshot.stepsById).length > 0 || terminalRowOutcomes.totalRows > 0 || (terminalRowOutcomes.supersededRows ?? 0) > 0) ? terminalRowOutcomes : null;
5973
+ const workCounters = snapshot.workCounters;
5974
+ const calls = workCounters ? {
5975
+ logicalCalls: workCounters.completedLogicalCalls + workCounters.logicalCalls,
5976
+ providerRequests: workCounters.completedProviderRequests + workCounters.providerRequests,
5977
+ provider429s: workCounters.completedProvider429s + workCounters.provider429s,
5978
+ confirmed: isTerminalPlayRunLiveStatus(liveStatus) && hasConfirmedPlayRunLedgerWorkCounters(snapshot)
5979
+ } : null;
5892
5980
  return {
5893
5981
  runId: snapshot.runId,
5894
5982
  status: liveStatus,
@@ -5913,7 +6001,10 @@ function buildSnapshotFromLedger(snapshot) {
5913
6001
  activeActivity: snapshot.activeActivityId ? snapshot.activitiesById[snapshot.activeActivityId] ?? null : null,
5914
6002
  nodeStates,
5915
6003
  activeNodeId: snapshot.activeStepId ?? null,
5916
- ...rowOutcomes ? { rowOutcomes } : {}
6004
+ ...rowOutcomes ? { rowOutcomes } : {},
6005
+ ...calls && Object.values(calls).every(
6006
+ (value) => typeof value === "boolean" || Number.isSafeInteger(value)
6007
+ ) ? { calls } : {}
5917
6008
  };
5918
6009
  }
5919
6010
  function buildPlayRunStatusSnapshot(input2) {
@@ -25117,6 +25208,15 @@ function getProgressLinesFromLiveEvent(event) {
25117
25208
  `progress ${formatProgressLabel(record3.nodeId ?? progress.artifactTableNamespace)}: ${counts}${messageSuffix}`
25118
25209
  );
25119
25210
  }
25211
+ const calls = readRecord(payload.calls);
25212
+ const callCounts = calls ? [calls.logicalCalls, calls.providerRequests, calls.provider429s] : [];
25213
+ if (callCounts.length === 3 && callCounts.every(
25214
+ (count) => typeof count === "number" && Number.isSafeInteger(count) && count >= 0
25215
+ )) {
25216
+ lines.push(
25217
+ `progress calls: ${formatInteger(callCounts[0])} logical, ${formatInteger(callCounts[1])} provider requests, ${formatInteger(callCounts[2])} provider 429s${calls?.confirmed === true ? "" : " (observed)"}`
25218
+ );
25219
+ }
25120
25220
  const rowOutcomes = readRowOutcomeSummary({
25121
25221
  rowOutcomes: payload.rowOutcomes
25122
25222
  });
@@ -220,6 +220,33 @@ interface PlayR2FileRef {
220
220
  }
221
221
  type PlayExecutionFileRef = PlayR2FileRef;
222
222
 
223
+ /** Source evidence is advisory; stored values determine lossless SQL encoding. */
224
+ interface PlayDatasetColumnTypeEvidence {
225
+ postgresTypeId: number;
226
+ valueType: 'boolean' | 'number' | 'string' | 'json';
227
+ }
228
+ type PlayDatasetColumnTypes = Record<string, PlayDatasetColumnTypeEvidence>;
229
+ type PlaySheetColumnSource = 'input' | 'datasetColumn' | 'waterfallStep' | 'childPlayColumn';
230
+ interface PlaySheetColumnContract {
231
+ id: string;
232
+ sqlName: string;
233
+ source: PlaySheetColumnSource;
234
+ field?: string;
235
+ parentField?: string;
236
+ playId?: string;
237
+ waterfallId?: string;
238
+ outputField?: string;
239
+ outputSqlName?: string;
240
+ stepId?: string;
241
+ toolId?: string;
242
+ isRowKey?: boolean;
243
+ typeEvidence?: PlayDatasetColumnTypeEvidence;
244
+ }
245
+ interface PlaySheetContract {
246
+ tableNamespace: string;
247
+ columns: PlaySheetColumnContract[];
248
+ }
249
+
223
250
  declare const PLAY_DATASET_BRAND: unique symbol;
224
251
  type PlayDatasetKind = 'csv' | 'map';
225
252
  type PlayDatasetBacking = {
@@ -265,8 +292,7 @@ type PlayDatasetTransformOptions = {
265
292
  * `materialize(limit)` or async iteration only when the dataset is intentionally
266
293
  * small and bounded. `PlayDataset` intentionally does not expose `.rows`,
267
294
  * `.toArray()`, `.length`, numeric indexing, spread, or synchronous iteration;
268
- * those hide the runtime cost of loading persisted rows into memory or make
269
- * behavior depend on whether rows happen to be resident.
295
+ * these hide loading costs or make behavior depend on row residency.
270
296
  *
271
297
  * @sdkReference runtime 190
272
298
  */
@@ -282,6 +308,8 @@ interface PlayDataset<T> extends AsyncIterable<T> {
282
308
  readonly sourceLabel?: string | null;
283
309
  /** Runtime table name. */
284
310
  readonly tableNamespace?: string | null;
311
+ /** Advisory source types; transformed fields must infer from their values. */
312
+ readonly columnTypes?: PlayDatasetColumnTypes;
285
313
  /** Row count. */
286
314
  count(): Promise<number>;
287
315
  /** Preview rows. */
@@ -309,6 +337,7 @@ interface PlayDataset<T> extends AsyncIterable<T> {
309
337
  sourceLabel?: string | null;
310
338
  tableNamespace?: string | null;
311
339
  columns?: string[];
340
+ columnTypes?: PlayDatasetColumnTypes;
312
341
  _metadata?: {
313
342
  workProgress?: PlayDatasetWorkProgressSummary;
314
343
  };
@@ -2983,25 +3012,6 @@ interface PlayStaticPipeline {
2983
3012
  sheetContract?: PlaySheetContract | null;
2984
3013
  sheetContractErrors?: string[];
2985
3014
  }
2986
- type PlaySheetColumnSource = 'input' | 'datasetColumn' | 'waterfallStep' | 'childPlayColumn';
2987
- interface PlaySheetColumnContract {
2988
- id: string;
2989
- sqlName: string;
2990
- source: PlaySheetColumnSource;
2991
- field?: string;
2992
- parentField?: string;
2993
- playId?: string;
2994
- waterfallId?: string;
2995
- outputField?: string;
2996
- outputSqlName?: string;
2997
- stepId?: string;
2998
- toolId?: string;
2999
- isRowKey?: boolean;
3000
- }
3001
- interface PlaySheetContract {
3002
- tableNamespace: string;
3003
- columns: PlaySheetColumnContract[];
3004
- }
3005
3015
  type PlayStaticColumnProducerKind = 'tool' | 'waterfall' | 'stepProgram' | 'playCall' | 'controlFlow' | 'transform';
3006
3016
  interface PlayStaticColumnProducer {
3007
3017
  id: string;
@@ -220,6 +220,33 @@ interface PlayR2FileRef {
220
220
  }
221
221
  type PlayExecutionFileRef = PlayR2FileRef;
222
222
 
223
+ /** Source evidence is advisory; stored values determine lossless SQL encoding. */
224
+ interface PlayDatasetColumnTypeEvidence {
225
+ postgresTypeId: number;
226
+ valueType: 'boolean' | 'number' | 'string' | 'json';
227
+ }
228
+ type PlayDatasetColumnTypes = Record<string, PlayDatasetColumnTypeEvidence>;
229
+ type PlaySheetColumnSource = 'input' | 'datasetColumn' | 'waterfallStep' | 'childPlayColumn';
230
+ interface PlaySheetColumnContract {
231
+ id: string;
232
+ sqlName: string;
233
+ source: PlaySheetColumnSource;
234
+ field?: string;
235
+ parentField?: string;
236
+ playId?: string;
237
+ waterfallId?: string;
238
+ outputField?: string;
239
+ outputSqlName?: string;
240
+ stepId?: string;
241
+ toolId?: string;
242
+ isRowKey?: boolean;
243
+ typeEvidence?: PlayDatasetColumnTypeEvidence;
244
+ }
245
+ interface PlaySheetContract {
246
+ tableNamespace: string;
247
+ columns: PlaySheetColumnContract[];
248
+ }
249
+
223
250
  declare const PLAY_DATASET_BRAND: unique symbol;
224
251
  type PlayDatasetKind = 'csv' | 'map';
225
252
  type PlayDatasetBacking = {
@@ -265,8 +292,7 @@ type PlayDatasetTransformOptions = {
265
292
  * `materialize(limit)` or async iteration only when the dataset is intentionally
266
293
  * small and bounded. `PlayDataset` intentionally does not expose `.rows`,
267
294
  * `.toArray()`, `.length`, numeric indexing, spread, or synchronous iteration;
268
- * those hide the runtime cost of loading persisted rows into memory or make
269
- * behavior depend on whether rows happen to be resident.
295
+ * these hide loading costs or make behavior depend on row residency.
270
296
  *
271
297
  * @sdkReference runtime 190
272
298
  */
@@ -282,6 +308,8 @@ interface PlayDataset<T> extends AsyncIterable<T> {
282
308
  readonly sourceLabel?: string | null;
283
309
  /** Runtime table name. */
284
310
  readonly tableNamespace?: string | null;
311
+ /** Advisory source types; transformed fields must infer from their values. */
312
+ readonly columnTypes?: PlayDatasetColumnTypes;
285
313
  /** Row count. */
286
314
  count(): Promise<number>;
287
315
  /** Preview rows. */
@@ -309,6 +337,7 @@ interface PlayDataset<T> extends AsyncIterable<T> {
309
337
  sourceLabel?: string | null;
310
338
  tableNamespace?: string | null;
311
339
  columns?: string[];
340
+ columnTypes?: PlayDatasetColumnTypes;
312
341
  _metadata?: {
313
342
  workProgress?: PlayDatasetWorkProgressSummary;
314
343
  };
@@ -2983,25 +3012,6 @@ interface PlayStaticPipeline {
2983
3012
  sheetContract?: PlaySheetContract | null;
2984
3013
  sheetContractErrors?: string[];
2985
3014
  }
2986
- type PlaySheetColumnSource = 'input' | 'datasetColumn' | 'waterfallStep' | 'childPlayColumn';
2987
- interface PlaySheetColumnContract {
2988
- id: string;
2989
- sqlName: string;
2990
- source: PlaySheetColumnSource;
2991
- field?: string;
2992
- parentField?: string;
2993
- playId?: string;
2994
- waterfallId?: string;
2995
- outputField?: string;
2996
- outputSqlName?: string;
2997
- stepId?: string;
2998
- toolId?: string;
2999
- isRowKey?: boolean;
3000
- }
3001
- interface PlaySheetContract {
3002
- tableNamespace: string;
3003
- columns: PlaySheetColumnContract[];
3004
- }
3005
3015
  type PlayStaticColumnProducerKind = 'tool' | 'waterfall' | 'stepProgram' | 'playCall' | 'controlFlow' | 'transform';
3006
3016
  interface PlayStaticColumnProducer {
3007
3017
  id: string;
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference path="./text-imports.d.ts" />
2
2
  import { z } from 'zod';
3
- import { c as PlayCompilerManifest, T as ToolResultBilling, A as AsyncPlayRunRef$1, i as PlayAuthoringColumnMap, j as PlayAuthoringColumnResolver, k as PlayAuthoringRuntimeContext, l as PlayAuthoringConditionalStepResolver, m as PlayAuthoringCsvInput, n as PlayAuthoringCsvOptions, o as PlayAuthoringDatasetBuilder, p as PlayAuthoringDatasetColumnDefinition, q as PlayAuthoringDatasetColumnRunInput, r as ToolExecuteResult, s as PlayAuthoringReferenceLike, t as PlayReturnObject$1, u as PlayAuthoringDefineConfig, v as PlayAuthoringDefinedPlay, w as PlayAuthoringFetchOptions, x as PlayAuthoringFileInput, y as PlayAuthoringAsyncCallOptions, z as PlayAuthoringBindings, B as PlayAuthoringCallExecution, C as PlayAuthoringCallOptions, D as PlayAuthoringFetchResponse, E as PlayAuthoringInputContract, F as PlayRunId$1, G as PlayAuthoringStepProgramStep, H as PlayAuthoringRuntimeStepOptions, I as PlaySqlListenerDeclaration, J as PlaySqlListenerEvent, K as PlaySqlListenerOperation, L as PlaySqlQuery, M as PlayAuthoringStepOptions, N as PlayAuthoringStepProgram, O as PlayAuthoringStepProgramResolver, Q as PlayAuthoringStepResolver, R as PlayToolExecutionRequest, S as PlayAuthoringStepProgramOptions, U as DeeplineError, V as ToolExecutionError, W as ToolExecutionErrorOptions } from './compiler-manifest-Dpd2hEet.mjs';
4
- export { X as CtxFetchHttpError, Y as DEEPLINE_EXTRACTOR_TARGETS, Z as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, _ as DeeplineEmailStatusGetterValue, $ as DeeplineExtractorTarget, a0 as DeeplineGetterValue, a1 as DeeplineGetterValueMap, a2 as JOB_CHANGE_STATUS_VALUES, a3 as JobChangeStatus, a4 as PHONE_STATUS_VALUES, a5 as PhoneStatus, a6 as PlayDataset, a7 as PlayDatasetInput, a8 as PreviousCell, a9 as ProviderTransientError, aa as ProviderTransientErrorCategory, ab as ProviderUnavailableError, ac as ProviderUnavailableReason, ad as ToolExecutionErrorCategory, ae as ToolExecutionErrorOrigin, af as ToolExecutionFailureV1, ag as ToolExecutionNetworkKind, ah as ToolExecutionNetworkScope, ai as ToolExecutionPublicDetails, aj as getProviderUnavailableReason, ak as isDeeplineExtractorTarget, al as isProviderUnavailable, am as isProviderWaterfallUnavailableError } from './compiler-manifest-Dpd2hEet.mjs';
3
+ import { c as PlayCompilerManifest, T as ToolResultBilling, A as AsyncPlayRunRef$1, i as PlayAuthoringColumnMap, j as PlayAuthoringColumnResolver, k as PlayAuthoringRuntimeContext, l as PlayAuthoringConditionalStepResolver, m as PlayAuthoringCsvInput, n as PlayAuthoringCsvOptions, o as PlayAuthoringDatasetBuilder, p as PlayAuthoringDatasetColumnDefinition, q as PlayAuthoringDatasetColumnRunInput, r as ToolExecuteResult, s as PlayAuthoringReferenceLike, t as PlayReturnObject$1, u as PlayAuthoringDefineConfig, v as PlayAuthoringDefinedPlay, w as PlayAuthoringFetchOptions, x as PlayAuthoringFileInput, y as PlayAuthoringAsyncCallOptions, z as PlayAuthoringBindings, B as PlayAuthoringCallExecution, C as PlayAuthoringCallOptions, D as PlayAuthoringFetchResponse, E as PlayAuthoringInputContract, F as PlayRunId$1, G as PlayAuthoringStepProgramStep, H as PlayAuthoringRuntimeStepOptions, I as PlaySqlListenerDeclaration, J as PlaySqlListenerEvent, K as PlaySqlListenerOperation, L as PlaySqlQuery, M as PlayAuthoringStepOptions, N as PlayAuthoringStepProgram, O as PlayAuthoringStepProgramResolver, Q as PlayAuthoringStepResolver, R as PlayToolExecutionRequest, S as PlayAuthoringStepProgramOptions, U as DeeplineError, V as ToolExecutionError, W as ToolExecutionErrorOptions } from './compiler-manifest-n8ZtPv2h.mjs';
4
+ export { X as CtxFetchHttpError, Y as DEEPLINE_EXTRACTOR_TARGETS, Z as DEEPLINE_EXTRACTOR_TARGET_DEFINITIONS, _ as DeeplineEmailStatusGetterValue, $ as DeeplineExtractorTarget, a0 as DeeplineGetterValue, a1 as DeeplineGetterValueMap, a2 as JOB_CHANGE_STATUS_VALUES, a3 as JobChangeStatus, a4 as PHONE_STATUS_VALUES, a5 as PhoneStatus, a6 as PlayDataset, a7 as PlayDatasetInput, a8 as PreviousCell, a9 as ProviderTransientError, aa as ProviderTransientErrorCategory, ab as ProviderUnavailableError, ac as ProviderUnavailableReason, ad as ToolExecutionErrorCategory, ae as ToolExecutionErrorOrigin, af as ToolExecutionFailureV1, ag as ToolExecutionNetworkKind, ah as ToolExecutionNetworkScope, ai as ToolExecutionPublicDetails, aj as getProviderUnavailableReason, ak as isDeeplineExtractorTarget, al as isProviderUnavailable, am as isProviderWaterfallUnavailableError } from './compiler-manifest-n8ZtPv2h.mjs';
5
5
  import { MonitorFleetDefinition } from './monitor-fleet-contract.mjs';
6
6
  export { AdmittedMonitorFleetAuthoringContract, MONITOR_FLEET_AUTHORING_CONTRACT_CHANGELOG, MONITOR_FLEET_AUTHORING_CONTRACT_EDITION, MONITOR_FLEET_DOCUMENTATION, MONITOR_FLEET_FRONTIER_MAX_ROWS, MONITOR_FLEET_MAX_MEMBERS, MonitorFleetAuthoringContractEdition, MonitorFleetAuthoringContractResult, MonitorFleetColumn, MonitorFleetContractIssue, MonitorFleetExpression, MonitorFleetTemplate, admitMonitorFleetAuthoringContract, defineMonitorFleet, fleetColumn, fleetKey, lintMonitorFleetInput, validateMonitorFleetDefinition } from './monitor-fleet-contract.mjs';
7
7
  export { BatchMonitorInput, MonitorInputIssue, MonitorSpec as MonitorInputSpec, lintMonitorBatchInput, lintMonitorSpecTemplate, renderMonitorSpecTemplate } from './monitor-input-contract.mjs';