deepline 0.3.285 → 0.3.287

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 (45) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +48 -26
  2. package/dist/bundling-sources/sdk/src/index.ts +4 -0
  3. package/dist/bundling-sources/sdk/src/release.ts +7 -1
  4. package/dist/bundling-sources/sdk/src/types.ts +36 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/cell-provenance.ts +16 -0
  6. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +21 -0
  7. package/dist/bundling-sources/shared_libs/play-runtime/live-state-contract.ts +2 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +18 -0
  9. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +16 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +38 -3
  11. package/dist/bundling-sources/shared_libs/play-runtime/run-observation.ts +12 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +3 -0
  13. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +43 -1
  14. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +28 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +88 -1
  16. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +243 -90
  17. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +53 -25
  18. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +40 -7
  19. package/dist/bundling-sources/shared_libs/play-runtime/step-progress.ts +83 -1
  20. package/dist/bundling-sources/shared_libs/play-runtime/test-async-batching.ts +4 -1
  21. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +68 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/worker-api-types.ts +2 -0
  23. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +10 -1
  24. package/dist/bundling-sources/shared_libs/plays/enrich-compat-adapter.ts +2 -0
  25. package/dist/cli/index.js +30615 -34474
  26. package/dist/cli/index.mjs +30310 -34181
  27. package/dist/{client-T2jVnZrq.d.ts → client-FR_u0dxT.d.ts} +40 -4
  28. package/dist/{client-Cl-zj2oS.d.mts → client-phK1Ixcl.d.mts} +40 -4
  29. package/dist/{compiler-manifest-B1zo3igW.d.mts → compiler-manifest-9SQtUuKb.d.mts} +1 -1
  30. package/dist/{compiler-manifest-B1zo3igW.d.ts → compiler-manifest-9SQtUuKb.d.ts} +1 -1
  31. package/dist/index.d.mts +4 -4
  32. package/dist/index.d.ts +4 -4
  33. package/dist/index.js +57 -28
  34. package/dist/index.mjs +57 -28
  35. package/dist/install-integrity.json +4 -4
  36. package/dist/plays/bundle-play-file.d.mts +2 -2
  37. package/dist/plays/bundle-play-file.d.ts +2 -2
  38. package/dist/plays/bundle-play-file.mjs +8 -1
  39. package/dist/plays/run-request.d.mts +2 -2
  40. package/dist/plays/run-request.d.ts +2 -2
  41. package/dist/release.d.mts +5 -1
  42. package/dist/release.d.ts +5 -1
  43. package/dist/release.js +6 -1
  44. package/dist/release.mjs +6 -1
  45. package/package.json +1 -1
@@ -43,7 +43,12 @@ import {
43
43
  type PlayStaticPipeline,
44
44
  type PlayStaticSubstep,
45
45
  } from '../../plays/static-pipeline';
46
- import { getStaticSubstepNodeId } from '../step-progress';
46
+ import {
47
+ getStaticSubstepNodeId,
48
+ projectDocflowConditionCounts,
49
+ } from '../step-progress';
50
+ import type { PlayConditionCounts } from '../cell-provenance';
51
+ import { readRuntimeSheetRowOutcomeCounts } from '../runtime-api';
47
52
  import { runtimeApiBaseUrlFromLaunch } from './runtime-api-origin';
48
53
 
49
54
  // Patterns mirrored from runner events — they parse
@@ -232,6 +237,7 @@ export type PostgresSchedulerProgressReporter = {
232
237
  completed: number;
233
238
  failed: number;
234
239
  total: number;
240
+ conditions?: Record<string, PlayConditionCounts>;
235
241
  }>,
236
242
  ): void;
237
243
  /**
@@ -737,6 +743,9 @@ export function createPostgresSchedulerProgressReporter(input: {
737
743
  ? { completedAt: current.completedAt }
738
744
  : {}),
739
745
  ...(current.nodeIo !== undefined ? { nodeIo: current.nodeIo } : {}),
746
+ ...(current.conditionCounts !== undefined
747
+ ? { conditionCounts: current.conditionCounts }
748
+ : {}),
740
749
  ...(patch.completed !== undefined
741
750
  ? { completed: patch.completed }
742
751
  : {}),
@@ -783,6 +792,9 @@ export function createPostgresSchedulerProgressReporter(input: {
783
792
  ? { completedAt: patch.completedAt }
784
793
  : {}),
785
794
  ...(patch.nodeIo !== undefined ? { nodeIo: patch.nodeIo } : {}),
795
+ ...(patch.conditionCounts !== undefined
796
+ ? { conditionCounts: patch.conditionCounts }
797
+ : {}),
786
798
  updatedAt: Date.now(),
787
799
  },
788
800
  };
@@ -1474,6 +1486,7 @@ export function createPostgresSchedulerProgressReporter(input: {
1474
1486
  completed: number;
1475
1487
  failed: number;
1476
1488
  total: number;
1489
+ conditions?: Record<string, PlayConditionCounts>;
1477
1490
  }> = [];
1478
1491
 
1479
1492
  const applyTerminalSheetOutcomes = (
@@ -1482,6 +1495,7 @@ export function createPostgresSchedulerProgressReporter(input: {
1482
1495
  completed: number;
1483
1496
  failed: number;
1484
1497
  total: number;
1498
+ conditions?: Record<string, PlayConditionCounts>;
1485
1499
  }>,
1486
1500
  ): void => {
1487
1501
  terminalSheetOutcomes = outcomes;
@@ -1491,6 +1505,13 @@ export function createPostgresSchedulerProgressReporter(input: {
1491
1505
  // the two disagree; also the only terminal source when frames are missing
1492
1506
  // (detached push runs) and liveNodeProgress is empty (zero-event runs).
1493
1507
  const reconcileTerminalMapProgressFromSheetOutcomes = (): void => {
1508
+ const conditionCounts = projectDocflowConditionCounts(
1509
+ staticPipelineFromContractSnapshot(launch.contractSnapshot),
1510
+ terminalSheetOutcomes,
1511
+ );
1512
+ for (const [nodeId, counts] of Object.entries(conditionCounts)) {
1513
+ setNodeProgress(nodeId, { conditionCounts: counts });
1514
+ }
1494
1515
  for (const outcome of terminalSheetOutcomes) {
1495
1516
  const tableNamespace = outcome.tableNamespace.trim();
1496
1517
  if (!tableNamespace) continue;
@@ -1650,6 +1671,7 @@ export function buildFailedTerminalSettledProgressEvents(input: {
1650
1671
  tableNamespace: string;
1651
1672
  completed: number;
1652
1673
  failed: number;
1674
+ conditions?: Record<string, PlayConditionCounts>;
1653
1675
  }>;
1654
1676
  occurredAt: number;
1655
1677
  }): PlayRunLedgerEvent[] {
@@ -1680,6 +1702,21 @@ export function buildFailedTerminalSettledProgressEvents(input: {
1680
1702
  },
1681
1703
  });
1682
1704
  }
1705
+ for (const [stepId, conditionCounts] of Object.entries(
1706
+ projectDocflowConditionCounts(
1707
+ staticPipelineFromContractSnapshot(input.launch.contractSnapshot),
1708
+ input.outcomes,
1709
+ ),
1710
+ )) {
1711
+ events.push({
1712
+ type: 'step.progress',
1713
+ runId: input.launch.runId,
1714
+ source: 'worker',
1715
+ occurredAt: input.occurredAt,
1716
+ stepId,
1717
+ progress: { conditionCounts },
1718
+ });
1719
+ }
1683
1720
  return events;
1684
1721
  }
1685
1722
 
@@ -1724,6 +1761,56 @@ export async function collectGatewayRunnerTerminalProgressLedgerEvents(input: {
1724
1761
  captured.update = update;
1725
1762
  },
1726
1763
  });
1764
+ // The gateway can win terminal before the worker reconciles the sheet.
1765
+ // Carry predicate summaries in that same durable terminal outbox prefix.
1766
+ const pipeline = staticPipelineFromContractSnapshot(
1767
+ input.launch.contractSnapshot,
1768
+ );
1769
+ if (
1770
+ pipeline?.docflow?.nodes.some(
1771
+ (node) => node.kind === 'decision' && !node.sketch,
1772
+ )
1773
+ ) {
1774
+ const outcomes = [];
1775
+ const namespaces = new Set(
1776
+ (input.launch.preloadedDbSessions ?? [])
1777
+ .filter((session) => session.logicalTable === 'sheet_rows')
1778
+ .map((session) => session.tableNamespace),
1779
+ );
1780
+ for (const tableNamespace of namespaces) {
1781
+ try {
1782
+ outcomes.push({
1783
+ tableNamespace,
1784
+ ...(await readRuntimeSheetRowOutcomeCounts(
1785
+ {
1786
+ baseUrl: input.launch.baseUrl,
1787
+ executorToken: input.launch.executorToken,
1788
+ orgId: input.launch.orgId,
1789
+ playName: input.launch.playName,
1790
+ runId: input.launch.runId,
1791
+ dbSessionStrategy: 'preloaded',
1792
+ preloadedDbSessions:
1793
+ input.launch.preloadedDbSessions ?? undefined,
1794
+ postgresSessionUnwrapKey:
1795
+ input.launch.preloadedDbSessionUnwrapKey ??
1796
+ input.launch.executorToken,
1797
+ },
1798
+ { tableNamespace, includeConditions: true },
1799
+ )),
1800
+ });
1801
+ } catch (error) {
1802
+ console.warn(
1803
+ '[postgres-scheduler.terminal_condition_reconcile_failed]',
1804
+ {
1805
+ runId: input.launch.runId,
1806
+ tableNamespace,
1807
+ error: error instanceof Error ? error.message : String(error),
1808
+ },
1809
+ );
1810
+ }
1811
+ }
1812
+ reporter.applyTerminalSheetOutcomes(outcomes);
1813
+ }
1727
1814
  for (const event of input.events) reporter.onRunnerEvent(event);
1728
1815
  await reporter.finalize(input.result, {
1729
1816
  status: 'running',