deepline 0.3.392 → 0.3.394

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 (153) hide show
  1. package/dist/bundling-sources/sdk/src/client.ts +156 -24
  2. package/dist/bundling-sources/sdk/src/compat.ts +9 -0
  3. package/dist/bundling-sources/sdk/src/http.ts +5 -1
  4. package/dist/bundling-sources/sdk/src/index.ts +5 -0
  5. package/dist/bundling-sources/sdk/src/plays/run-request.ts +182 -6
  6. package/dist/bundling-sources/sdk/src/release.ts +4 -1
  7. package/dist/bundling-sources/sdk/src/types.ts +13 -0
  8. package/dist/bundling-sources/shared_libs/integration-contracts/request-warnings.ts +64 -0
  9. package/dist/bundling-sources/shared_libs/play-data-plane/runtime-sheet-storage-contract.ts +315 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/async-operation.ts +41 -8
  11. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +895 -54
  12. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +41 -4
  13. package/dist/bundling-sources/shared_libs/play-runtime/durable-call-policy.ts +28 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/durable-invocation-fence.ts +36 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +251 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/map-execution-frame.ts +11 -3
  17. package/dist/bundling-sources/shared_libs/play-runtime/play-runs/projection/gateway-adapter.ts +1 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +30 -1
  19. package/dist/bundling-sources/shared_libs/play-runtime/run-identity.ts +26 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +168 -10
  21. package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +252 -10
  22. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +92 -58
  23. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +7 -1
  24. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +30 -7
  25. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1161 -316
  26. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +28 -15
  27. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +24 -3
  28. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +32 -0
  29. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +103 -23
  30. package/dist/bundling-sources/shared_libs/plays/core.ts +1 -1
  31. package/dist/bundling-sources/shared_libs/plays/dataset.ts +172 -79
  32. package/dist/bundling-sources/shared_libs/plays/static-pipeline.ts +173 -1
  33. package/dist/bundling-sources/shared_libs/plays/tool-result-types.ts +18 -0
  34. package/dist/cli/auth-IHKISLJQ.js +39 -0
  35. package/dist/cli/{auth-6JSA2ZCW.mjs → auth-OSXDAVCF.mjs} +4 -4
  36. package/dist/cli/{billing-Q5BLQHIU.js → billing-EKLYOXUY.js} +101 -74
  37. package/dist/cli/{billing-MRRO643H.mjs → billing-ZNNKX3UR.mjs} +32 -5
  38. package/dist/cli/{chunk-4SFPVW7A.js → chunk-2MDDA7A4.js} +26 -26
  39. package/dist/cli/{chunk-JOFPQGXW.js → chunk-354JCXA2.js} +50 -50
  40. package/dist/cli/{chunk-7E66A24V.mjs → chunk-3HU47EGZ.mjs} +71 -9
  41. package/dist/cli/{chunk-DSWSEHRX.mjs → chunk-3HWALOL2.mjs} +1 -1
  42. package/dist/cli/{chunk-T7OKJ2T6.js → chunk-4P27AXEA.js} +73 -63
  43. package/dist/cli/{chunk-24VEN5PQ.mjs → chunk-5BB2RGAX.mjs} +190 -18
  44. package/dist/cli/{chunk-JSLPHFP7.js → chunk-6YAUMG27.js} +3 -2
  45. package/dist/cli/{chunk-MU6M3URX.mjs → chunk-BP33SIZF.mjs} +1 -1
  46. package/dist/cli/{chunk-WMS5U6YB.js → chunk-CS6RAIVY.js} +20 -19
  47. package/dist/cli/{chunk-CVLM3WMJ.js → chunk-E23BQ5SC.js} +242 -183
  48. package/dist/cli/{chunk-2GAHHSLB.mjs → chunk-FJGW5GXU.mjs} +3 -2
  49. package/dist/cli/{chunk-YN6YA7ZZ.mjs → chunk-JHIJIHFB.mjs} +79 -20
  50. package/dist/cli/{chunk-Q6EOHNRH.mjs → chunk-JI2B4RZP.mjs} +119 -6
  51. package/dist/cli/{chunk-5O4B6AUN.js → chunk-KB4SDX5S.js} +71 -9
  52. package/dist/cli/{chunk-RV6ALZIX.js → chunk-KGNTKMRG.js} +32 -7
  53. package/dist/cli/{chunk-6DBOU7UH.js → chunk-KI635JN4.js} +176 -87
  54. package/dist/cli/{chunk-2FQG2HU4.js → chunk-KIUMEOM5.js} +8 -8
  55. package/dist/cli/{chunk-Y6VOGHF2.mjs → chunk-KZZC33PY.mjs} +0 -181
  56. package/dist/cli/{chunk-2Q3GEFL4.mjs → chunk-M57J2SK4.mjs} +2 -2
  57. package/dist/cli/{chunk-R3O2CZ4H.mjs → chunk-MFB2VKBO.mjs} +2 -2
  58. package/dist/cli/{chunk-QGKPTBRR.js → chunk-MH73HMPV.js} +3 -3
  59. package/dist/cli/{chunk-BB3FNYFY.js → chunk-MLPU5SMZ.js} +2 -2
  60. package/dist/cli/{chunk-2G7DXFHI.mjs → chunk-NR3DFKNF.mjs} +27 -2
  61. package/dist/cli/{chunk-EY7RFC6A.js → chunk-QIQBYKLB.js} +15 -15
  62. package/dist/cli/{chunk-RIV2GS5E.js → chunk-RBJYWRCF.js} +638 -466
  63. package/dist/cli/{chunk-3VN4FTE3.js → chunk-RDXFGPJU.js} +1 -182
  64. package/dist/cli/{chunk-YAZCDBXX.mjs → chunk-TJI2EN6K.mjs} +3 -2
  65. package/dist/cli/chunk-UBKA33KY.mjs +310 -0
  66. package/dist/cli/{chunk-PAIMOGCM.js → chunk-UHNDVD3P.js} +125 -12
  67. package/dist/cli/{chunk-4TCT77UF.js → chunk-URWF7NGQ.js} +6 -1
  68. package/dist/cli/{chunk-2QLML6G4.mjs → chunk-UXFSWG3Q.mjs} +4 -4
  69. package/dist/cli/{chunk-UCKJQG25.js → chunk-VK6FYZLP.js} +8 -8
  70. package/dist/cli/{chunk-ZTACINO5.mjs → chunk-X63FDZJZ.mjs} +13 -3
  71. package/dist/cli/chunk-XDVT3GOM.js +310 -0
  72. package/dist/cli/{chunk-A3APGZFP.mjs → chunk-XRQ2AQL7.mjs} +2 -2
  73. package/dist/cli/{chunk-3FV4GBRK.mjs → chunk-XXUDVEXK.mjs} +97 -8
  74. package/dist/cli/{chunk-PQSA443V.mjs → chunk-ZI2ZNDJK.mjs} +6 -1
  75. package/dist/cli/{chunk-HGYBEAQP.mjs → chunk-ZYBGA4AR.mjs} +3 -3
  76. package/dist/cli/command-docs.js +2 -2
  77. package/dist/cli/command-docs.mjs +1 -1
  78. package/dist/cli/{csv-E4QGUIGI.mjs → csv-5AXRB35H.mjs} +3 -3
  79. package/dist/cli/{csv-26U5T24Z.js → csv-LU7O75WE.js} +12 -12
  80. package/dist/cli/{db-JTRJIAQW.mjs → db-7XP5UWEW.mjs} +6 -5
  81. package/dist/cli/{db-QHBFLMVL.js → db-F7YTFKVM.js} +31 -30
  82. package/dist/cli/{describe-FDV2V74F.js → describe-FRH32RDV.js} +24 -23
  83. package/dist/cli/{describe-E3DE3ZK3.mjs → describe-K4ES5LIL.mjs} +17 -16
  84. package/dist/cli/{executions-B3GTNPRE.mjs → executions-IEHEHJUO.mjs} +6 -5
  85. package/dist/cli/{executions-VZYOGVQY.js → executions-RZV5XPT2.js} +8 -7
  86. package/dist/cli/{feedback-CR55FJA2.js → feedback-3P65QTX3.js} +7 -7
  87. package/dist/cli/{feedback-4CEBR3OV.mjs → feedback-FPUVZBAN.mjs} +3 -3
  88. package/dist/cli/{git-NM2PHHZ4.mjs → git-GLVVP7TY.mjs} +4 -4
  89. package/dist/cli/git-MFFAWVVX.js +23 -0
  90. package/dist/cli/index.js +100 -96
  91. package/dist/cli/index.mjs +47 -43
  92. package/dist/cli/{legacy-noops-A7MSW5ND.mjs → legacy-noops-3MOI6NBM.mjs} +4 -4
  93. package/dist/cli/{legacy-noops-ZUA4YFIH.js → legacy-noops-XKSGZR7Q.js} +7 -7
  94. package/dist/cli/{monitors-NVPRQYP3.mjs → monitors-FTBGNEFG.mjs} +6 -5
  95. package/dist/cli/{monitors-ZE3TLZ4H.js → monitors-NZ2DYNST.js} +87 -86
  96. package/dist/cli/{org-U7A6DV5D.js → org-MCKDQXIV.js} +66 -65
  97. package/dist/cli/{org-KUBILNQV.mjs → org-V2J5RBCN.mjs} +6 -5
  98. package/dist/cli/{play-HRDXQ4QE.mjs → play-AJFGME3B.mjs} +11 -10
  99. package/dist/cli/play-WLSN2EO2.js +158 -0
  100. package/dist/cli/{providers-VD6YTVQZ.js → providers-2JEZ2264.js} +9 -8
  101. package/dist/cli/{providers-OHIWI453.mjs → providers-I6RQJZFZ.mjs} +6 -5
  102. package/dist/cli/{quickstart-UBV2FONF.mjs → quickstart-BIDQDMO4.mjs} +3 -3
  103. package/dist/cli/{quickstart-ETTCWPA4.js → quickstart-GJ2RPDU3.js} +5 -5
  104. package/dist/cli/run-identity-G257GQED.js +25 -0
  105. package/dist/cli/run-identity-MRNCEGV2.mjs +25 -0
  106. package/dist/cli/search-5VN4YD4I.js +27 -0
  107. package/dist/cli/{search-F44IZRT7.mjs → search-ELRXFWG5.mjs} +7 -6
  108. package/dist/cli/{secrets-CAEMRORF.js → secrets-53IT6VXD.js} +15 -14
  109. package/dist/cli/{secrets-R6XOJZKU.mjs → secrets-SQXGZXIC.mjs} +6 -5
  110. package/dist/cli/{sessions-RLN6UQS3.mjs → sessions-2X5QF7SL.mjs} +4 -4
  111. package/dist/cli/{sessions-6GC7OFTT.js → sessions-CAV5M77Y.js} +5 -5
  112. package/dist/cli/{settings-DPNVUAV2.js → settings-532WNAZO.js} +76 -75
  113. package/dist/cli/{settings-KIPAMRPP.mjs → settings-7P67VGCJ.mjs} +9 -8
  114. package/dist/cli/{setup-DTL3L5SG.js → setup-6L2VSUWJ.js} +41 -41
  115. package/dist/cli/{setup-TU2F7PU5.mjs → setup-QGGBV2LE.mjs} +6 -6
  116. package/dist/cli/{skills-UV5MYJ46.mjs → skills-3FE62WBG.mjs} +4 -4
  117. package/dist/cli/skills-S6NPZAN7.js +28 -0
  118. package/dist/cli/tools-647RLXQS.js +41 -0
  119. package/dist/cli/{tools-QRRNDCQ7.mjs → tools-DMR25DEF.mjs} +10 -9
  120. package/dist/cli/{update-4426TF35.mjs → update-6RZMHJZP.mjs} +6 -6
  121. package/dist/cli/update-WVTSC3EM.js +28 -0
  122. package/dist/cli/{workflow-N4U5VLZ3.mjs → workflow-L2DQRE6R.mjs} +7 -6
  123. package/dist/cli/{workflow-HNLOVISB.js → workflow-TX4F2PIX.js} +17 -16
  124. package/dist/{client-e6Qh5ZIg.d.mts → client-BktIPdIj.d.mts} +153 -4
  125. package/dist/{client-Uxuy-xQ2.d.ts → client-C3O1Ipf3.d.ts} +153 -4
  126. package/dist/{compiler-manifest-CY2v8ab0.d.ts → compiler-manifest-DLxUY5kI.d.mts} +124 -10
  127. package/dist/{compiler-manifest-CY2v8ab0.d.mts → compiler-manifest-DLxUY5kI.d.ts} +124 -10
  128. package/dist/{index-BZ6uzZJl.d.ts → index-B_GM9E3q.d.ts} +1 -1
  129. package/dist/{index-B9fBZH1g.d.mts → index-SCb0NvDb.d.mts} +1 -1
  130. package/dist/index.d.mts +5 -5
  131. package/dist/index.d.ts +5 -5
  132. package/dist/index.js +120 -29
  133. package/dist/index.mjs +111 -20
  134. package/dist/install-integrity.json +94 -88
  135. package/dist/plays/bundle-play-file.d.mts +3 -3
  136. package/dist/plays/bundle-play-file.d.ts +3 -3
  137. package/dist/plays/bundle-play-file.mjs +2 -2
  138. package/dist/plays/run-request.d.mts +2 -2
  139. package/dist/plays/run-request.d.ts +2 -2
  140. package/dist/plays/run-request.js +5 -2
  141. package/dist/plays/run-request.mjs +4 -1
  142. package/dist/release.d.mts +4 -1
  143. package/dist/release.d.ts +4 -1
  144. package/dist/release.js +2 -2
  145. package/dist/release.mjs +1 -1
  146. package/package.json +1 -1
  147. package/dist/cli/auth-67TAELQL.js +0 -39
  148. package/dist/cli/git-I5JTK6YU.js +0 -23
  149. package/dist/cli/play-A2V7YDU7.js +0 -157
  150. package/dist/cli/search-WWXMBVPH.js +0 -26
  151. package/dist/cli/skills-SWOSEZLB.js +0 -28
  152. package/dist/cli/tools-IL2YCDQ6.js +0 -40
  153. package/dist/cli/update-BERDPEYR.js +0 -28
@@ -4,6 +4,118 @@ import type { PlayDatasetColumnTypes } from '../play-data-plane/contracts';
4
4
  const PLAY_DATASET_BRAND = Symbol.for('deepline.play.dataset');
5
5
  const NODE_INSPECT_CUSTOM = Symbol.for('nodejs.util.inspect.custom');
6
6
  const residentRowsByDataset = new WeakMap<object, readonly unknown[]>();
7
+ // Source ordinals are execution provenance, never customer columns. Weak
8
+ // references keep streaming sources bounded and transforms preserve ordinals.
9
+ type PlayDatasetSourceRowIdentity = Readonly<{
10
+ datasetId: string;
11
+ rowIndex: number;
12
+ }>;
13
+ const sourceRowIdentityByRow = new WeakMap<
14
+ object,
15
+ PlayDatasetSourceRowIdentity
16
+ >();
17
+ const sourceRowIdentitiesByRows = new WeakMap<
18
+ readonly unknown[],
19
+ readonly (PlayDatasetSourceRowIdentity | undefined)[]
20
+ >();
21
+ type PlayDatasetSourceOccurrence<T> = {
22
+ row: T;
23
+ sourceIdentity?: PlayDatasetSourceRowIdentity;
24
+ };
25
+ const sourceOccurrencesByDataset = new WeakMap<
26
+ object,
27
+ () => AsyncIterable<PlayDatasetSourceOccurrence<unknown>>
28
+ >();
29
+
30
+ export function setPlayDatasetSourceRowIdentity<T>(
31
+ row: T,
32
+ identity: Readonly<{ datasetId: string; rowIndex: number }>,
33
+ ): T {
34
+ if (row && typeof row === 'object') sourceRowIdentityByRow.set(row, identity);
35
+ return row;
36
+ }
37
+
38
+ export function getPlayDatasetSourceRowIdentity(
39
+ row: unknown,
40
+ ): Readonly<{ datasetId: string; rowIndex: number }> | undefined {
41
+ return row && typeof row === 'object'
42
+ ? sourceRowIdentityByRow.get(row)
43
+ : undefined;
44
+ }
45
+
46
+ /** Container provenance distinguishes occurrences even when a mapper returns a shared typed value. */
47
+ export function getPlayDatasetSourceRowIdentityAt(
48
+ rows: readonly unknown[],
49
+ index: number,
50
+ ): PlayDatasetSourceRowIdentity | undefined {
51
+ const identities = sourceRowIdentitiesByRows.get(rows);
52
+ return identities
53
+ ? identities[index]
54
+ : getPlayDatasetSourceRowIdentity(rows[index]);
55
+ }
56
+
57
+ export function copyPlayDatasetSourceRowIdentity<T>(
58
+ source: unknown,
59
+ target: T,
60
+ ): T {
61
+ const identity = getPlayDatasetSourceRowIdentity(source);
62
+ return identity ? setPlayDatasetSourceRowIdentity(target, identity) : target;
63
+ }
64
+
65
+ /** A mapper may return the same object for several physical source records. */
66
+ function copySourceOccurrenceToMappedValue<T>(
67
+ identity: PlayDatasetSourceRowIdentity | undefined,
68
+ mapped: T,
69
+ ): T {
70
+ if (!identity || !mapped || typeof mapped !== 'object') return mapped;
71
+ const prototype = Object.getPrototypeOf(mapped);
72
+ // Plain row values can carry provenance on a distinct execution object.
73
+ // Typed values retain their mapper result and internal slots; their distinct
74
+ // occurrences travel in the iterator/container sidecar instead.
75
+ const occurrence = (
76
+ Array.isArray(mapped)
77
+ ? Object.defineProperties([], Object.getOwnPropertyDescriptors(mapped))
78
+ : prototype === Object.prototype || prototype === null
79
+ ? Object.create(prototype, Object.getOwnPropertyDescriptors(mapped))
80
+ : mapped
81
+ ) as T;
82
+ return setPlayDatasetSourceRowIdentity(occurrence, identity);
83
+ }
84
+
85
+ async function* iterateSourceOccurrences<T>(
86
+ input: PlayDatasetInput<T>,
87
+ ): AsyncIterable<PlayDatasetSourceOccurrence<T>> {
88
+ if (isPlayDataset(input)) {
89
+ const occurrences = sourceOccurrencesByDataset.get(input);
90
+ if (occurrences) {
91
+ yield* occurrences() as AsyncIterable<PlayDatasetSourceOccurrence<T>>;
92
+ return;
93
+ }
94
+ for await (const row of input)
95
+ yield { row, sourceIdentity: getPlayDatasetSourceRowIdentity(row) };
96
+ return;
97
+ }
98
+ if (Array.isArray(input)) {
99
+ for (let index = 0; index < input.length; index += 1) {
100
+ yield {
101
+ row: input[index]!,
102
+ sourceIdentity: getPlayDatasetSourceRowIdentityAt(input, index),
103
+ };
104
+ }
105
+ return;
106
+ }
107
+ if (
108
+ input != null &&
109
+ typeof input === 'object' &&
110
+ Symbol.asyncIterator in input
111
+ ) {
112
+ for await (const row of input as AsyncIterable<T>)
113
+ yield { row, sourceIdentity: getPlayDatasetSourceRowIdentity(row) };
114
+ return;
115
+ }
116
+ for (const row of input as Iterable<T>)
117
+ yield { row, sourceIdentity: getPlayDatasetSourceRowIdentity(row) };
118
+ }
7
119
  const DEFAULT_MATERIALIZE_LIMIT = 10_000;
8
120
  export const PLAY_DATASET_EXECUTION_PAGE_ROWS = 1_000;
9
121
  export const PLAY_DATASET_EXECUTION_PAGE_BYTES = 64 * 1024 * 1024;
@@ -32,6 +144,14 @@ export type PlayDatasetWorkProgressSummary = {
32
144
  pending: number;
33
145
  failed: number;
34
146
  degraded?: boolean;
147
+ /** Fixed-shape source/output accounting; does not redefine legacy totals. */
148
+ cardinality?: {
149
+ sourceRows: number;
150
+ uniqueInputRows: number;
151
+ duplicateOccurrences: number;
152
+ outputRows: number;
153
+ rowIdentity: 'source_row' | 'key';
154
+ };
35
155
  duplicates?: {
36
156
  exact?: number;
37
157
  semantic?: number;
@@ -658,7 +778,9 @@ function createTransformedPlayDataset<T, U>(
658
778
  options?.sourceLabel ??
659
779
  `${source.sourceLabel ?? source.tableNamespace ?? source.datasetId}.${transform.kind}`;
660
780
 
661
- const iterate = async function* (): AsyncIterable<U> {
781
+ const iterateOccurrences = async function* (): AsyncIterable<
782
+ PlayDatasetSourceOccurrence<U>
783
+ > {
662
784
  if (transform.kind === 'slice') {
663
785
  const bounds = normalizeSliceBounds({
664
786
  start: transform.start,
@@ -666,10 +788,10 @@ function createTransformedPlayDataset<T, U>(
666
788
  count: await source.count(),
667
789
  });
668
790
  let index = 0;
669
- for await (const row of source) {
791
+ for await (const occurrence of iterateSourceOccurrences(source)) {
670
792
  if (index >= bounds.end) break;
671
793
  if (index >= bounds.start) {
672
- yield row as unknown as U;
794
+ yield occurrence as unknown as PlayDatasetSourceOccurrence<U>;
673
795
  }
674
796
  index += 1;
675
797
  }
@@ -678,27 +800,42 @@ function createTransformedPlayDataset<T, U>(
678
800
 
679
801
  let inputIndex = 0;
680
802
  let outputIndex = 0;
681
- for await (const row of source) {
803
+ for await (const { row, sourceIdentity } of iterateSourceOccurrences(
804
+ source,
805
+ )) {
682
806
  if (transform.kind === 'filter') {
683
807
  if (await transform.predicate(row, inputIndex)) {
684
- yield row as unknown as U;
808
+ yield { row: row as unknown as U, sourceIdentity };
685
809
  outputIndex += 1;
686
810
  }
687
811
  } else {
688
- yield await transform.mapper(row, outputIndex);
812
+ yield {
813
+ row: copySourceOccurrenceToMappedValue(
814
+ sourceIdentity,
815
+ await transform.mapper(row, outputIndex),
816
+ ),
817
+ sourceIdentity,
818
+ };
689
819
  outputIndex += 1;
690
820
  }
691
821
  inputIndex += 1;
692
822
  }
693
823
  };
694
824
 
825
+ const iterate = async function* (): AsyncIterable<U> {
826
+ for await (const { row } of iterateOccurrences()) yield row;
827
+ };
828
+
695
829
  const collect = async (limit?: number): Promise<U[]> => {
696
830
  const rows: U[] = [];
831
+ const identities: (PlayDatasetSourceRowIdentity | undefined)[] = [];
832
+ sourceRowIdentitiesByRows.set(rows, identities);
697
833
  const boundedLimit =
698
834
  limit === undefined ? undefined : Math.max(0, Math.floor(limit));
699
835
  if (boundedLimit === 0) return rows;
700
- for await (const row of iterate()) {
836
+ for await (const { row, sourceIdentity } of iterateOccurrences()) {
701
837
  rows.push(row);
838
+ identities.push(sourceIdentity);
702
839
  if (boundedLimit !== undefined && rows.length >= boundedLimit) break;
703
840
  }
704
841
  return rows;
@@ -722,7 +859,7 @@ function createTransformedPlayDataset<T, U>(
722
859
  return total;
723
860
  };
724
861
 
725
- return createDeferredPlayDataset({
862
+ const dataset = createDeferredPlayDataset({
726
863
  datasetKind: source.datasetKind,
727
864
  datasetId: transformDatasetId({
728
865
  source: source as PlayDataset<unknown>,
@@ -747,6 +884,13 @@ function createTransformedPlayDataset<T, U>(
747
884
  }) as AsyncIterable<U>,
748
885
  },
749
886
  });
887
+ sourceOccurrencesByDataset.set(
888
+ dataset,
889
+ iterateOccurrences as () => AsyncIterable<
890
+ PlayDatasetSourceOccurrence<unknown>
891
+ >,
892
+ );
893
+ return dataset;
750
894
  }
751
895
 
752
896
  export function createDeferredPlayDataset<T>(input: {
@@ -922,10 +1066,15 @@ export async function* iteratePlayDatasetInputPages<T>(
922
1066
  : DATASET_UTF8_ENCODER.encode(serialized).byteLength;
923
1067
  });
924
1068
  let page: T[] = [];
1069
+ let pageIdentities: (PlayDatasetSourceRowIdentity | undefined)[] = [];
1070
+ sourceRowIdentitiesByRows.set(page, pageIdentities);
925
1071
  let pageBytes = 0;
926
1072
  let offset = 0;
927
1073
  let index = 0;
928
- const pushRow = (row: T): Array<{ rows: T[]; offset: number }> => {
1074
+ const pushRow = (
1075
+ row: T,
1076
+ sourceIdentity: PlayDatasetSourceRowIdentity | undefined,
1077
+ ): Array<{ rows: T[]; offset: number }> => {
929
1078
  options?.onRow?.(row, index);
930
1079
  index += 1;
931
1080
  const rowBytes = Math.max(0, Math.ceil(estimateRowBytes(row)));
@@ -934,14 +1083,19 @@ export async function* iteratePlayDatasetInputPages<T>(
934
1083
  ready.push({ rows: page, offset });
935
1084
  offset += page.length;
936
1085
  page = [];
1086
+ pageIdentities = [];
1087
+ sourceRowIdentitiesByRows.set(page, pageIdentities);
937
1088
  pageBytes = 0;
938
1089
  }
939
1090
  page.push(row);
1091
+ pageIdentities.push(sourceIdentity);
940
1092
  pageBytes += rowBytes;
941
1093
  if (page.length >= pageSize || pageBytes >= maxPageBytes) {
942
1094
  ready.push({ rows: page, offset });
943
1095
  offset += page.length;
944
1096
  page = [];
1097
+ pageIdentities = [];
1098
+ sourceRowIdentitiesByRows.set(page, pageIdentities);
945
1099
  pageBytes = 0;
946
1100
  }
947
1101
  return ready;
@@ -952,48 +1106,15 @@ export async function* iteratePlayDatasetInputPages<T>(
952
1106
  const finalPage = page;
953
1107
  const finalOffset = offset;
954
1108
  page = [];
1109
+ pageIdentities = [];
1110
+ sourceRowIdentitiesByRows.set(page, pageIdentities);
955
1111
  pageBytes = 0;
956
1112
  offset += finalPage.length;
957
1113
  return { rows: finalPage, offset: finalOffset };
958
1114
  };
959
1115
 
960
- const emitRow = async function* (row: T) {
961
- for (const ready of pushRow(row)) yield ready;
962
- };
963
-
964
- if (isPlayDataset(input)) {
965
- for await (const row of input) {
966
- yield* emitRow(row);
967
- }
968
- const finalPage = flush();
969
- if (finalPage) yield finalPage;
970
- return;
971
- }
972
-
973
- if (Array.isArray(input)) {
974
- for (const row of input) {
975
- yield* emitRow(row);
976
- }
977
- const finalPage = flush();
978
- if (finalPage) yield finalPage;
979
- return;
980
- }
981
-
982
- if (
983
- input != null &&
984
- typeof input === 'object' &&
985
- Symbol.asyncIterator in input
986
- ) {
987
- for await (const row of input as AsyncIterable<T>) {
988
- yield* emitRow(row);
989
- }
990
- const finalPage = flush();
991
- if (finalPage) yield finalPage;
992
- return;
993
- }
994
-
995
- for (const row of input as Iterable<T>) {
996
- yield* emitRow(row);
1116
+ for await (const { row, sourceIdentity } of iterateSourceOccurrences(input)) {
1117
+ for (const ready of pushRow(row, sourceIdentity)) yield ready;
997
1118
  }
998
1119
  const finalPage = flush();
999
1120
  if (finalPage) yield finalPage;
@@ -1003,41 +1124,13 @@ export async function materializePlayDatasetInput<T>(
1003
1124
  input: PlayDatasetInput<T>,
1004
1125
  options?: MaterializePlayDatasetInputOptions<T>,
1005
1126
  ): Promise<T[]> {
1006
- const pushRow = (rows: T[], row: T): void => {
1127
+ const rows: T[] = [];
1128
+ const identities: (PlayDatasetSourceRowIdentity | undefined)[] = [];
1129
+ sourceRowIdentitiesByRows.set(rows, identities);
1130
+ for await (const { row, sourceIdentity } of iterateSourceOccurrences(input)) {
1007
1131
  options?.onRow?.(row, rows.length);
1008
1132
  rows.push(row);
1009
- };
1010
-
1011
- if (isPlayDataset(input)) {
1012
- const rows: T[] = [];
1013
- for await (const row of input) {
1014
- pushRow(rows, row);
1015
- }
1016
- return rows;
1017
- }
1018
-
1019
- if (Array.isArray(input)) {
1020
- const rows: T[] = [];
1021
- for (const row of input) {
1022
- pushRow(rows, row);
1023
- }
1024
- return rows;
1025
- }
1026
-
1027
- const rows: T[] = [];
1028
- if (
1029
- input != null &&
1030
- typeof input === 'object' &&
1031
- Symbol.asyncIterator in input
1032
- ) {
1033
- for await (const row of input as AsyncIterable<T>) {
1034
- pushRow(rows, row);
1035
- }
1036
- return rows;
1037
- }
1038
-
1039
- for (const row of input as Iterable<T>) {
1040
- pushRow(rows, row);
1133
+ identities.push(sourceIdentity);
1041
1134
  }
1042
1135
  return rows;
1043
1136
  }
@@ -98,6 +98,7 @@ export interface StoredStaticPipelineV2Branch {
98
98
  index: number;
99
99
  label: string;
100
100
  condition?: string;
101
+ inputRequirement?: PlayStaticInputCondition;
101
102
  }
102
103
 
103
104
  function dedupeStaticFieldNames(
@@ -336,7 +337,11 @@ function truncateStaticControlFlowBranchesForStorage(
336
337
  omitUndefinedProperties({
337
338
  ...(input.preserveAdditiveMetadata
338
339
  ? branch
339
- : { label: branch.label, condition: branch.condition }),
340
+ : {
341
+ label: branch.label,
342
+ condition: branch.condition,
343
+ inputRequirement: branch.inputRequirement,
344
+ }),
340
345
  steps: truncateStaticSubstepsForStorage(
341
346
  branch.steps,
342
347
  nextStoredSubstepInput(input),
@@ -882,6 +887,9 @@ export function createStoredStaticPipelineV2(
882
887
  typeof branchRecord.condition === 'string'
883
888
  ? branchRecord.condition
884
889
  : undefined,
890
+ inputRequirement: parsePlayStaticInputCondition(
891
+ branchRecord.inputRequirement,
892
+ ),
885
893
  }),
886
894
  );
887
895
  if (Array.isArray(branchRecord.steps)) {
@@ -1043,6 +1051,9 @@ export function hydrateStoredStaticPipelineV2(
1043
1051
  label: branch.label,
1044
1052
  condition:
1045
1053
  typeof branch.condition === 'string' ? branch.condition : undefined,
1054
+ inputRequirement: parsePlayStaticInputCondition(
1055
+ branch.inputRequirement,
1056
+ ),
1046
1057
  steps: [] as PlayStaticSubstep[],
1047
1058
  }),
1048
1059
  );
@@ -1233,10 +1244,14 @@ export interface PlayStaticSourceRange {
1233
1244
  }
1234
1245
 
1235
1246
  type PlayStaticSubstepMetadata = {
1247
+ /** A source helper received execution context but its work could not be resolved. */
1248
+ unresolvedProviderWork?: boolean;
1236
1249
  /** This call is syntactically inside Promise.all/allSettled/race/any. */
1237
1250
  concurrent?: boolean;
1238
1251
  conditional?: boolean;
1239
1252
  disabled?: boolean;
1253
+ /** Source-bound input-only gate; absent means reachability is unknown. */
1254
+ inputRequirement?: PlayStaticInputCondition;
1240
1255
  /**
1241
1256
  * Where this substep was REACHED FROM, when the extractor resolved it by
1242
1257
  * following a call into another function — the range of the call expression
@@ -1267,10 +1282,167 @@ export type PlayStaticControlFlowBranch = {
1267
1282
  label: string;
1268
1283
  /** The arm's condition source text, when it has one (omitted for `else`). */
1269
1284
  condition?: string;
1285
+ inputRequirement?: PlayStaticInputCondition;
1270
1286
  /** Static work in this arm. Empty for log/throw/return-only arms. */
1271
1287
  steps: PlayStaticSubstep[];
1272
1288
  };
1273
1289
 
1290
+ /** Declarative subset of input conditions; never evaluates authored JavaScript. */
1291
+ export type PlayStaticInputValue =
1292
+ | { kind: 'input'; path: string[] }
1293
+ | { kind: 'literal'; value: string | number | boolean | null };
1294
+ export type PlayStaticInputCondition =
1295
+ | { kind: 'truthy'; value: PlayStaticInputValue }
1296
+ | { kind: 'not'; condition: PlayStaticInputCondition }
1297
+ | {
1298
+ kind: 'and' | 'or';
1299
+ left: PlayStaticInputCondition;
1300
+ right: PlayStaticInputCondition;
1301
+ }
1302
+ | { kind: 'equals'; left: PlayStaticInputValue; right: PlayStaticInputValue }
1303
+ | {
1304
+ kind: 'includes';
1305
+ value: PlayStaticInputValue;
1306
+ item: PlayStaticInputValue;
1307
+ };
1308
+
1309
+ function parsePlayStaticInputCondition(
1310
+ value: unknown,
1311
+ ): PlayStaticInputCondition | undefined {
1312
+ if (value === undefined) return undefined;
1313
+ const active = new WeakSet<object>();
1314
+ const operand = (value: unknown): PlayStaticInputValue => {
1315
+ const record = asStaticRecord(value);
1316
+ if (
1317
+ record?.kind === 'input' &&
1318
+ Array.isArray(record.path) &&
1319
+ record.path.every((key) => typeof key === 'string')
1320
+ )
1321
+ return { ...record, kind: 'input', path: record.path };
1322
+ if (record?.kind === 'literal') {
1323
+ const literal = record.value;
1324
+ if (literal === null) return { ...record, kind: 'literal', value: null };
1325
+ if (
1326
+ typeof literal === 'string' ||
1327
+ typeof literal === 'boolean' ||
1328
+ (typeof literal === 'number' && Number.isFinite(literal))
1329
+ )
1330
+ return { ...record, kind: 'literal', value: literal };
1331
+ }
1332
+ return invalidStoredStaticPipelineV2('invalid input requirement value');
1333
+ };
1334
+ const condition = (value: unknown): PlayStaticInputCondition => {
1335
+ const record = asStaticRecord(value);
1336
+ if (!record || active.has(record))
1337
+ return invalidStoredStaticPipelineV2(
1338
+ 'invalid input requirement condition',
1339
+ );
1340
+ active.add(record);
1341
+ try {
1342
+ switch (record.kind) {
1343
+ case 'truthy':
1344
+ return { ...record, kind: 'truthy', value: operand(record.value) };
1345
+ case 'not':
1346
+ return {
1347
+ ...record,
1348
+ kind: 'not',
1349
+ condition: condition(record.condition),
1350
+ };
1351
+ case 'and':
1352
+ case 'or':
1353
+ return {
1354
+ ...record,
1355
+ kind: record.kind,
1356
+ left: condition(record.left),
1357
+ right: condition(record.right),
1358
+ };
1359
+ case 'equals':
1360
+ return {
1361
+ ...record,
1362
+ kind: 'equals',
1363
+ left: operand(record.left),
1364
+ right: operand(record.right),
1365
+ };
1366
+ case 'includes':
1367
+ return {
1368
+ ...record,
1369
+ kind: 'includes',
1370
+ value: operand(record.value),
1371
+ item: operand(record.item),
1372
+ };
1373
+ default:
1374
+ return invalidStoredStaticPipelineV2(
1375
+ 'invalid input requirement condition',
1376
+ );
1377
+ }
1378
+ } finally {
1379
+ active.delete(record);
1380
+ }
1381
+ };
1382
+ return condition(value);
1383
+ }
1384
+
1385
+ export function evaluatePlayStaticInputCondition(
1386
+ condition: PlayStaticInputCondition,
1387
+ input: Record<string, unknown>,
1388
+ ): boolean | null {
1389
+ const read = (value: PlayStaticInputValue): unknown => {
1390
+ if (value.kind === 'literal') return value.value;
1391
+ let current: unknown = input;
1392
+ for (const key of value.path) {
1393
+ if (
1394
+ !current ||
1395
+ typeof current !== 'object' ||
1396
+ !Object.hasOwn(current, key)
1397
+ )
1398
+ return undefined;
1399
+ current = (current as Record<string, unknown>)[key];
1400
+ }
1401
+ return current;
1402
+ };
1403
+ const evaluate = (value: PlayStaticInputCondition): boolean | null => {
1404
+ switch (value.kind) {
1405
+ case 'truthy':
1406
+ return Boolean(read(value.value));
1407
+ case 'not': {
1408
+ const result = evaluate(value.condition);
1409
+ return result === null ? null : !result;
1410
+ }
1411
+ case 'equals':
1412
+ return read(value.left) === read(value.right);
1413
+ case 'includes': {
1414
+ const collection = read(value.value);
1415
+ const item = read(value.item);
1416
+ if (Array.isArray(collection)) return collection.includes(item);
1417
+ if (typeof collection === 'string' && typeof item === 'string')
1418
+ return collection.includes(item);
1419
+ return null;
1420
+ }
1421
+ case 'and': {
1422
+ const left = evaluate(value.left);
1423
+ const right = evaluate(value.right);
1424
+ return left === false || right === false
1425
+ ? false
1426
+ : left === true && right === true
1427
+ ? true
1428
+ : null;
1429
+ }
1430
+ case 'or': {
1431
+ const left = evaluate(value.left);
1432
+ const right = evaluate(value.right);
1433
+ return left === true || right === true
1434
+ ? true
1435
+ : left === false && right === false
1436
+ ? false
1437
+ : null;
1438
+ }
1439
+ default:
1440
+ return null;
1441
+ }
1442
+ };
1443
+ return evaluate(condition);
1444
+ }
1445
+
1274
1446
  export type PlayStaticSubstep = PlayStaticSubstepMetadata &
1275
1447
  (
1276
1448
  | {
@@ -40,6 +40,24 @@ export type ToolResultExecutionMetadata = {
40
40
  /** Canonical saved result identity; receiptKey may name a transport alias. */
41
41
  resultReceiptKey?: string;
42
42
  attachedToReceiptKey?: string;
43
+ /** Freshness and operation recovery are independent of provider idempotency. */
44
+ freshness?: CallFreshnessMetadata;
45
+ /** Time the live result completed, retained unchanged through recovery. */
46
+ completedAt?: number;
47
+ };
48
+
49
+ export type CallFreshnessMetadata = {
50
+ requestedStaleAfterSeconds: number | null;
51
+ effectiveStaleAfterSeconds: number | null;
52
+ source:
53
+ | 'executed'
54
+ | 'operation_recovery'
55
+ | 'reusable_result'
56
+ | 'live_observation';
57
+ resultAgeMs: number;
58
+ completedAt: number;
59
+ operationReceiptKey?: string;
60
+ unavailableReason?: string;
43
61
  };
44
62
 
45
63
  export type ToolResultTargetMetadata = {
@@ -0,0 +1,39 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ var _chunk354JCXA2js = require('./chunk-354JCXA2.js');
17
+ require('./chunk-KGNTKMRG.js');
18
+ require('./chunk-CS6RAIVY.js');
19
+ require('./chunk-XNYIZMNQ.js');
20
+ require('./chunk-7P5AA3SN.js');
21
+ require('./chunk-6YAUMG27.js');
22
+ require('./chunk-OG64RBAC.js');
23
+ require('./chunk-COGTRVWW.js');
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ exports.EXIT_WORKSPACE_MISMATCH = _chunk354JCXA2js.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunk354JCXA2js.authStatusLine; exports.clearPendingClaim = _chunk354JCXA2js.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunk354JCXA2js.clearSatisfiedPendingClaim; exports.handleRegister = _chunk354JCXA2js.handleRegister; exports.handleStatus = _chunk354JCXA2js.handleStatus; exports.handleWait = _chunk354JCXA2js.handleWait; exports.httpJson = _chunk354JCXA2js.httpJson; exports.readPendingAuthClaim = _chunk354JCXA2js.readPendingAuthClaim; exports.readStatusBanner = _chunk354JCXA2js.readStatusBanner; exports.registerAuthCommands = _chunk354JCXA2js.registerAuthCommands; exports.reportSetupCompleted = _chunk354JCXA2js.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunk354JCXA2js.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunk354JCXA2js.statusBannerLine;
@@ -13,12 +13,12 @@ import {
13
13
  reportSetupCompleted,
14
14
  resolvePendingAuthClaimForResume,
15
15
  statusBannerLine
16
- } from "./chunk-R3O2CZ4H.mjs";
17
- import "./chunk-2G7DXFHI.mjs";
18
- import "./chunk-2GAHHSLB.mjs";
16
+ } from "./chunk-MFB2VKBO.mjs";
17
+ import "./chunk-NR3DFKNF.mjs";
18
+ import "./chunk-FJGW5GXU.mjs";
19
19
  import "./chunk-DLIRSHV6.mjs";
20
20
  import "./chunk-NXGCO4JB.mjs";
21
- import "./chunk-YAZCDBXX.mjs";
21
+ import "./chunk-TJI2EN6K.mjs";
22
22
  import "./chunk-WZYKRD7T.mjs";
23
23
  import "./chunk-KRD6H754.mjs";
24
24
  export {