deepline 0.3.294 → 0.3.296

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 (138) hide show
  1. package/dist/bundling-sources/sdk/src/compat.ts +35 -7
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +108 -35
  4. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-api-origin.ts +25 -0
  5. package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +14 -1
  6. package/dist/cli/auth-JCGIDVDF.mjs +31 -0
  7. package/dist/cli/auth-QDWV3TXX.js +31 -0
  8. package/dist/cli/billing-OQBSIXRG.mjs +1749 -0
  9. package/dist/cli/billing-YBK3J4WP.js +1749 -0
  10. package/dist/cli/chunk-2C3AVPTY.js +5688 -0
  11. package/dist/cli/chunk-2MZ5EQZE.mjs +499 -0
  12. package/dist/cli/chunk-3KC45UVF.js +150 -0
  13. package/dist/cli/chunk-3XX5TEA4.js +15 -0
  14. package/dist/cli/chunk-4MBOJQPL.mjs +0 -0
  15. package/dist/cli/chunk-4Y6CG4GE.js +2240 -0
  16. package/dist/cli/chunk-4ZB3CJRD.js +1269 -0
  17. package/dist/cli/chunk-5JLQPVNX.js +3056 -0
  18. package/dist/cli/chunk-6A3TJUWC.js +76 -0
  19. package/dist/cli/chunk-6HPEDBSJ.js +1995 -0
  20. package/dist/cli/chunk-7D6QG5KF.js +890 -0
  21. package/dist/cli/chunk-7P5AA3SN.js +344 -0
  22. package/dist/cli/chunk-7UAO5MWV.mjs +190 -0
  23. package/dist/cli/chunk-A7427JJH.js +190 -0
  24. package/dist/cli/chunk-AQRTLPHZ.js +735 -0
  25. package/dist/cli/chunk-AYHLUHE5.js +52 -0
  26. package/dist/cli/chunk-BZ77OTRF.mjs +923 -0
  27. package/dist/cli/chunk-CBVIJSHF.mjs +560 -0
  28. package/dist/cli/chunk-COGTRVWW.js +30 -0
  29. package/dist/cli/chunk-DLIRSHV6.mjs +28 -0
  30. package/dist/cli/chunk-DYWHXO7O.mjs +34 -0
  31. package/dist/cli/chunk-EDWJY6T4.mjs +3056 -0
  32. package/dist/cli/chunk-EXMLR72R.mjs +0 -0
  33. package/dist/cli/chunk-G46HHFNB.mjs +1269 -0
  34. package/dist/cli/chunk-GAMFK2ZP.mjs +148 -0
  35. package/dist/cli/chunk-GLKUGBTP.mjs +2240 -0
  36. package/dist/cli/chunk-GONRLVV3.js +3440 -0
  37. package/dist/cli/chunk-GVUJJJ5G.mjs +76 -0
  38. package/dist/cli/chunk-H7HIDGZ7.mjs +150 -0
  39. package/dist/cli/chunk-HUZXWOSK.mjs +503 -0
  40. package/dist/cli/chunk-I5YZLGMG.js +1 -0
  41. package/dist/cli/chunk-ITOFSXIU.mjs +15 -0
  42. package/dist/cli/chunk-J2D3VDOU.mjs +5688 -0
  43. package/dist/cli/chunk-J5NA2TTX.js +503 -0
  44. package/dist/cli/chunk-JCS5TPNY.mjs +3440 -0
  45. package/dist/cli/chunk-JNNOCMQY.js +47 -0
  46. package/dist/cli/chunk-KRD6H754.mjs +30 -0
  47. package/dist/cli/chunk-L4HBNHFW.js +34 -0
  48. package/dist/cli/chunk-LA46MMTL.js +560 -0
  49. package/dist/cli/chunk-LIKFCE7Z.js +190 -0
  50. package/dist/cli/chunk-MIMASXO4.mjs +389 -0
  51. package/dist/cli/chunk-NPPJX3BL.mjs +1995 -0
  52. package/dist/cli/chunk-NTEZFZLE.mjs +890 -0
  53. package/dist/cli/chunk-NXDRDJ4K.js +389 -0
  54. package/dist/cli/chunk-NXGCO4JB.mjs +344 -0
  55. package/dist/cli/chunk-OG64RBAC.js +6 -0
  56. package/dist/cli/chunk-OWJZUE3Y.mjs +103 -0
  57. package/dist/cli/chunk-QSIO4TX2.mjs +190 -0
  58. package/dist/cli/chunk-RCUE5C5C.mjs +735 -0
  59. package/dist/cli/chunk-SDK3ZA2C.js +103 -0
  60. package/dist/cli/chunk-SFLARO4Y.mjs +47 -0
  61. package/dist/cli/chunk-TAC3JIFE.mjs +354 -0
  62. package/dist/cli/chunk-UC6GHEL4.js +499 -0
  63. package/dist/cli/chunk-UFS752TU.mjs +52 -0
  64. package/dist/cli/chunk-UNEMDKXN.js +1 -0
  65. package/dist/cli/chunk-WB6Z2Q44.mjs +1622 -0
  66. package/dist/cli/chunk-WJYPBHTE.js +148 -0
  67. package/dist/cli/chunk-WOHBA5PV.js +354 -0
  68. package/dist/cli/chunk-WZYKRD7T.mjs +6 -0
  69. package/dist/cli/chunk-XNYIZMNQ.js +28 -0
  70. package/dist/cli/chunk-ZDO3TO3M.js +1622 -0
  71. package/dist/cli/chunk-ZDOC4HFL.js +923 -0
  72. package/dist/cli/client-CZDA4JKO.mjs +20 -0
  73. package/dist/cli/client-IZGIN2ZA.js +20 -0
  74. package/dist/cli/csv-6KOMZA2H.mjs +585 -0
  75. package/dist/cli/csv-UTEQY3NA.js +585 -0
  76. package/dist/cli/db-D5EP6TKO.mjs +486 -0
  77. package/dist/cli/db-SIBLPIKC.js +486 -0
  78. package/dist/cli/executions-2PHT57IO.js +28 -0
  79. package/dist/cli/executions-DFWM2YYY.mjs +28 -0
  80. package/dist/cli/feedback-GZW37JMI.mjs +107 -0
  81. package/dist/cli/feedback-IQVWIJZ4.js +107 -0
  82. package/dist/cli/getting-started.js +18 -76
  83. package/dist/cli/getting-started.mjs +10 -37
  84. package/dist/cli/git-563GYLMA.js +23 -0
  85. package/dist/cli/git-B72Y4FFQ.mjs +23 -0
  86. package/dist/cli/index.js +291 -54294
  87. package/dist/cli/index.mjs +209 -54352
  88. package/dist/cli/legacy-noops-37F5MX2P.mjs +157 -0
  89. package/dist/cli/legacy-noops-IFGVDCOM.js +157 -0
  90. package/dist/cli/monitors-42H6LOVT.mjs +3251 -0
  91. package/dist/cli/monitors-GQCHXBXZ.js +3251 -0
  92. package/dist/cli/org-4GCPBTGR.js +849 -0
  93. package/dist/cli/org-JYZA3ZRJ.mjs +849 -0
  94. package/dist/cli/play-46ZJ4FMI.js +18439 -0
  95. package/dist/cli/play-Q2XV3FZZ.mjs +18439 -0
  96. package/dist/cli/providers-CTKQP45X.mjs +95 -0
  97. package/dist/cli/providers-PCNF5E3K.js +95 -0
  98. package/dist/cli/proxy-env-EBANZHPV.js +161 -0
  99. package/dist/cli/proxy-env-M4ZHXHRL.mjs +161 -0
  100. package/dist/cli/quickstart-FTHWRVWN.js +69 -0
  101. package/dist/cli/quickstart-X7EVVWRG.mjs +69 -0
  102. package/dist/cli/search-73YPOFDO.mjs +18 -0
  103. package/dist/cli/search-XA5UVC3G.js +18 -0
  104. package/dist/cli/secrets-OUMPT4FX.mjs +400 -0
  105. package/dist/cli/secrets-UOEVR73Q.js +400 -0
  106. package/dist/cli/sessions-CMKXCN5Y.js +15 -0
  107. package/dist/cli/sessions-ZIFGDZE7.mjs +15 -0
  108. package/dist/cli/settings-OO5R3G52.mjs +846 -0
  109. package/dist/cli/settings-ULZT2NIC.js +846 -0
  110. package/dist/cli/setup-6GZH52OZ.mjs +1257 -0
  111. package/dist/cli/setup-DHGERXPZ.js +1257 -0
  112. package/dist/cli/skills-Q7NUCS2W.js +28 -0
  113. package/dist/cli/skills-T3EY2656.mjs +28 -0
  114. package/dist/cli/tools-BIMOAOTX.mjs +2955 -0
  115. package/dist/cli/tools-ODXVCKO7.js +2955 -0
  116. package/dist/cli/update-UMB3ULBR.js +28 -0
  117. package/dist/cli/update-X4HX7Z3M.mjs +28 -0
  118. package/dist/cli/workflow-EAUFVPIP.mjs +1936 -0
  119. package/dist/cli/workflow-IVLCPFTG.js +1936 -0
  120. package/dist/helpers.js +6 -32
  121. package/dist/helpers.mjs +2 -0
  122. package/dist/index.js +1972 -12825
  123. package/dist/index.mjs +1910 -12672
  124. package/dist/install-integrity.json +110 -0
  125. package/dist/monitor-fleet-contract.js +31 -730
  126. package/dist/monitor-fleet-contract.mjs +18 -667
  127. package/dist/monitor-input-contract.js +10 -390
  128. package/dist/monitor-input-contract.mjs +7 -348
  129. package/dist/plays/bundle-play-file.mjs +13 -5178
  130. package/dist/plays/csv-data-input.js +5 -3132
  131. package/dist/plays/csv-data-input.mjs +5 -3105
  132. package/dist/plays/run-request.js +56 -664
  133. package/dist/plays/run-request.mjs +30 -588
  134. package/dist/release.d.mts +1 -1
  135. package/dist/release.d.ts +1 -1
  136. package/dist/release.js +5 -212
  137. package/dist/release.mjs +5 -185
  138. package/package.json +1 -1
@@ -0,0 +1,190 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkOG64RBACjs = require('./chunk-OG64RBAC.js');
4
+
5
+ // src/release.ts
6
+ var SDK_RELEASE = {
7
+ // 0.1.94 is claimed by PR #1527 — this watch-render fix ships as 0.1.95.
8
+ // 0.1.98 ships the duplicate-browser-tab fix (default-browser detection).
9
+ // 0.1.99 ships prebuilt job-change source-column preservation and validation fixes.
10
+ // 0.1.101 ships retryable play artifact publish failures and CI retry hardening.
11
+ // 0.1.102 ships the job-change ledger fixes: recovered-dataset export on
12
+ // failed runs, persisted/succeeded/failed row counts, strict local CSV
13
+ // preflight (existence, data rows, quotes, duplicate headers), HTML error
14
+ // scrubbing, and word-boundary watch truncation.
15
+ // 0.1.103 ships the refined SDK CLI command surface.
16
+ // 0.1.104 shipped the retired Postgres scheduler suspension/billing parity and runtime worker hardening.
17
+ // 0.1.105 ships the billing catalog surface: billing plans, subscribe,
18
+ // subscription status/cancel, invoices, and the client.billing namespace.
19
+ // 0.1.106 ships play cell provenance metadata and v2 preview retry hardening.
20
+ // 0.1.107 ships the v2 quickstart command, the deepline-plays-quickstart
21
+ // skill on the sdk sync surface, and the people-search-to-email prebuilt.
22
+ // 0.1.108 ships explicit dataset column/tool recompute policy and removes
23
+ // the SDK enrich generator's one-second stale policy.
24
+ // 0.1.110 ships authored V2 prebuilts and required top-level play descriptions.
25
+ // 0.1.111 ships dataset-native tool list getters and result row datasets.
26
+ // 0.1.154 removes the short-lived generated enrich StepOptions recompute
27
+ // fields shipped in 0.1.153.
28
+ // 0.1.175 ships loud `deepline enrich` empty-waterfall reporting.
29
+ // 0.1.230 propagates enrich extractor failures as failed rows rather than
30
+ // silently materializing them as unmatched results.
31
+ // 0.1.220 deprecates SDK CLI versions below 0.1.219 and updates them
32
+ // automatically without blocking their current command.
33
+ // 0.1.241 hard-cuts published and launched plays to immutable cjs_node20
34
+ // artifacts. Older clients can submit esm_workers artifacts that the Absurd
35
+ // runtime intentionally no longer compiles at publish or launch time.
36
+ // 0.1.242 removes the retired Workers/ESM compiler, generated bundles, and
37
+ // deploy-time artifact migration. Play authoring now has one CJS contract.
38
+ // 0.1.252 hard-cuts the customer Monitor catalog to the two launched
39
+ // Deepline-native radars. Older clients must update before discovering,
40
+ // checking, or deploying an unlaunched monitor integration.
41
+ // 0.1.253 makes play-page browser opening opt-in and retires --no-open.
42
+ // 0.1.254 removes the internal operations tree from the published SDK CLI.
43
+ // Operators use the checkout-local deepline-admin binary instead.
44
+ // 0.2.0 makes Dataset Handles uniformly async-only after 0.1.320 briefly
45
+ // exposed storage-dependent synchronous access. This deliberate minor
46
+ // release keeps lazy paging semantics independent of row residency.
47
+ // 0.3.0 introduces raw-v2: complete scrubbed provider responses are
48
+ // available at toolResponse.rawV2 while toolResponse.raw and all declared
49
+ // getters keep their established compatibility behavior.
50
+ // 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
51
+ // 0.3.90 is the first deliberately versioned SDK release for API v3.
52
+ version: "0.3.296",
53
+ 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.",
54
+ packageCapabilities: {
55
+ updatePreferences: 1
56
+ },
57
+ contracts: {
58
+ api: {
59
+ name: "sdk-http-api",
60
+ // Concise Play grep has the current wire id. Older ids follow the
61
+ // standard API support window.
62
+ currentMajor: 3,
63
+ supportedMajors: [3, 2],
64
+ // Older ids remain subject to the API support window.
65
+ legacyWireIds: [
66
+ "2026-09-play-grep-concise-results",
67
+ "2026-07-admin-cli-local-cutover",
68
+ "2026-07-native-monitor-launch-hard-cutover"
69
+ ]
70
+ },
71
+ playArtifact: {
72
+ name: "play-artifact-runtime",
73
+ currentVersion: _chunkOG64RBACjs.CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION,
74
+ supportedVersions: [1, _chunkOG64RBACjs.CURRENT_PLAY_ARTIFACT_CONTRACT_VERSION]
75
+ },
76
+ release: {
77
+ name: "production-sdk-release",
78
+ publishFrom: "latest-successful-production-deployment",
79
+ coalesce: "latest-healthy"
80
+ }
81
+ },
82
+ supportPolicy: {
83
+ minimumSupported: "0.1.53",
84
+ deprecatedBelow: "0.3.1",
85
+ commandIntroducedIn: [
86
+ {
87
+ command: "search",
88
+ introducedIn: "0.3.91",
89
+ reason: "deepline search was added in SDK CLI 0.3.91 as the one search across tools, monitors, and plays. On an older version run deepline tools search or deepline plays search, or update."
90
+ },
91
+ {
92
+ command: "notifications",
93
+ introducedIn: "0.2.40",
94
+ reason: "deepline notifications was added in SDK CLI 0.2.40. Older versions have no way to configure a Play failure alert, so a cron Play that dies reports to nobody."
95
+ }
96
+ ],
97
+ commandMinimumSupported: [
98
+ {
99
+ command: "enrich",
100
+ // Compatibility window through 2026-08-22 (owner: Chirag): versions
101
+ // 0.1.238-0.1.252 differ only in local browser-opening behavior and
102
+ // already contain the enrich data-correctness fixes below.
103
+ minimumSupported: "0.1.238",
104
+ reason: 'Older SDK CLI enrich generated stale play source; SDK CLI enrich 0.1.153 generated removed StepOptions fields in play source; SDK CLI enrich before 0.1.175 could silently succeed on the empty-waterfall bug when a requested waterfall returned no values for selected rows; SDK CLI enrich before 0.1.230 could convert extractor failures into successful unmatched results; SDK CLI enrich before 0.1.238 could drop a nested provider email match during generic pick("email") extraction and materialize it as NO_MATCH.'
105
+ },
106
+ {
107
+ command: "plays",
108
+ minimumSupported: "0.1.241",
109
+ reason: "Older SDK CLI versions predate dataset-native Play results and can emit the retired esm_workers artifact contract. Update before checking, publishing, or running plays."
110
+ },
111
+ {
112
+ command: "plays run",
113
+ minimumSupported: "0.1.253",
114
+ reason: "Older SDK CLI versions predate dataset-native Play results and can emit the retired esm_workers artifact contract; versions before 0.1.253 open the play page by default and accept the removed --no-open flag."
115
+ },
116
+ {
117
+ command: "run",
118
+ displayCommand: "plays run",
119
+ minimumSupported: "0.1.253",
120
+ reason: "Older SDK CLI versions predate dataset-native Play results and can emit the retired esm_workers artifact contract; versions before 0.1.253 open the play page by default and accept the removed --no-open flag."
121
+ },
122
+ {
123
+ command: "plays check",
124
+ minimumSupported: "0.1.241",
125
+ reason: "Older SDK CLI versions predate dataset-native Play authoring and validate against the retired esm_workers artifact contract."
126
+ },
127
+ {
128
+ command: "check",
129
+ displayCommand: "plays check",
130
+ minimumSupported: "0.1.241",
131
+ reason: "Older SDK CLI versions predate dataset-native Play authoring and validate against the retired esm_workers artifact contract."
132
+ },
133
+ {
134
+ command: "plays publish",
135
+ minimumSupported: "0.1.241",
136
+ reason: "Older SDK CLI versions predate dataset-native Play artifacts and can publish the retired esm_workers artifact contract."
137
+ },
138
+ {
139
+ command: "publish",
140
+ displayCommand: "plays publish",
141
+ minimumSupported: "0.1.241",
142
+ reason: "Older SDK CLI versions predate dataset-native Play artifacts and can publish the retired esm_workers artifact contract."
143
+ },
144
+ {
145
+ command: "plays set-live",
146
+ minimumSupported: "0.1.241",
147
+ reason: "Older SDK CLI versions predate dataset-native Play artifacts and can publish the retired esm_workers artifact contract."
148
+ },
149
+ {
150
+ command: "set-live",
151
+ displayCommand: "plays set-live",
152
+ minimumSupported: "0.1.241",
153
+ reason: "Older SDK CLI versions predate dataset-native Play artifacts and can publish the retired esm_workers artifact contract."
154
+ },
155
+ {
156
+ command: "runs",
157
+ minimumSupported: "0.1.111",
158
+ reason: "Run result rows now render as dataset handles with explicit export commands."
159
+ },
160
+ {
161
+ command: "runs get",
162
+ minimumSupported: "0.1.111",
163
+ reason: "Run result rows now render as dataset handles with explicit export commands."
164
+ },
165
+ {
166
+ command: "get",
167
+ displayCommand: "runs get",
168
+ minimumSupported: "0.1.111",
169
+ reason: "Run result rows now render as dataset handles with explicit export commands."
170
+ },
171
+ {
172
+ command: "runs export",
173
+ minimumSupported: "0.1.111",
174
+ reason: "Run result row datasets now use the dataset-handle export contract."
175
+ },
176
+ {
177
+ command: "export",
178
+ displayCommand: "runs export",
179
+ minimumSupported: "0.1.111",
180
+ reason: "Run result row datasets now use the dataset-handle export contract."
181
+ }
182
+ ],
183
+ directToolsCompatibilityVersions: ["0.1.171"],
184
+ autoUpdatePatchLag: 2
185
+ }
186
+ };
187
+
188
+
189
+
190
+ exports.SDK_RELEASE = SDK_RELEASE;
@@ -0,0 +1,389 @@
1
+ // src/tool-output.ts
2
+ import {
3
+ closeSync,
4
+ mkdirSync,
5
+ openSync,
6
+ writeFileSync,
7
+ writeSync
8
+ } from "fs";
9
+ import { homedir } from "os";
10
+ import { dirname, join } from "path";
11
+ function isPlainObject(value) {
12
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
13
+ }
14
+ function getByDottedPath(root, dottedPath) {
15
+ let current = root;
16
+ for (const segment of String(dottedPath || "").split(".").filter(Boolean)) {
17
+ if (!isPlainObject(current) || !(segment in current)) {
18
+ return null;
19
+ }
20
+ current = current[segment];
21
+ }
22
+ return current;
23
+ }
24
+ function normalizeRows(value) {
25
+ if (!Array.isArray(value)) return null;
26
+ return value.map((entry) => {
27
+ if (isPlainObject(entry)) return entry;
28
+ return { value: entry };
29
+ });
30
+ }
31
+ function columnsForRows(rows) {
32
+ const seen = /* @__PURE__ */ new Set();
33
+ const columns = [];
34
+ for (const row of rows) {
35
+ for (const key of Object.keys(row)) {
36
+ if (!seen.has(key)) {
37
+ seen.add(key);
38
+ columns.push(key);
39
+ }
40
+ }
41
+ }
42
+ return columns;
43
+ }
44
+ function candidateRoots(payload) {
45
+ const roots = [
46
+ { path: null, value: payload }
47
+ ];
48
+ if (isPlainObject(payload) && isPlainObject(payload.toolResponse)) {
49
+ roots.push({ path: "toolResponse", value: payload.toolResponse });
50
+ if (Object.prototype.hasOwnProperty.call(payload.toolResponse, "raw")) {
51
+ roots.push({
52
+ path: "toolResponse.raw",
53
+ value: payload.toolResponse.raw
54
+ });
55
+ }
56
+ }
57
+ if (isPlainObject(payload) && isPlainObject(payload.output)) {
58
+ roots.push({ path: "output", value: payload.output });
59
+ if (Object.prototype.hasOwnProperty.call(payload.output, "body")) {
60
+ roots.push({ path: "output.body", value: payload.output.body });
61
+ }
62
+ }
63
+ if (isPlainObject(payload) && isPlainObject(payload.result)) {
64
+ roots.push({ path: "result", value: payload.result });
65
+ if (isPlainObject(payload.result.data)) {
66
+ roots.push({ path: "result.data", value: payload.result.data });
67
+ }
68
+ }
69
+ return roots;
70
+ }
71
+ function findBestArrayCandidate(value, pathPrefix = "", depth = 0) {
72
+ if (depth > 5) return null;
73
+ const directRows = normalizeRows(value);
74
+ const hasObjectRow = directRows?.some(
75
+ (row) => Object.keys(row).some((key) => key !== "value")
76
+ ) ?? false;
77
+ let best = directRows && directRows.length > 0 && hasObjectRow ? { path: pathPrefix, rows: directRows } : null;
78
+ if (!isPlainObject(value)) {
79
+ return best;
80
+ }
81
+ for (const [key, child] of Object.entries(value)) {
82
+ const childPath = pathPrefix ? `${pathPrefix}.${key}` : key;
83
+ const candidate = findBestArrayCandidate(child, childPath, depth + 1);
84
+ if (!candidate) continue;
85
+ if (!best || candidate.rows.length > best.rows.length) {
86
+ best = candidate;
87
+ }
88
+ }
89
+ return best;
90
+ }
91
+ function tryConvertToList(payload, options) {
92
+ const listExtractorPaths = Array.isArray(options?.listExtractorPaths) ? options?.listExtractorPaths.filter(
93
+ (entry) => typeof entry === "string" && entry.trim().length > 0
94
+ ) : [];
95
+ if (listExtractorPaths.length > 0) {
96
+ let emptyMatch = null;
97
+ for (const root of candidateRoots(payload)) {
98
+ for (const extractorPath of listExtractorPaths) {
99
+ const resolved = getByDottedPath(root.value, extractorPath);
100
+ const rows = normalizeRows(resolved);
101
+ if (!rows) {
102
+ continue;
103
+ }
104
+ const sourcePath = root.path ? `${root.path}.${extractorPath}` : extractorPath;
105
+ if (rows.length > 0) {
106
+ return { rows, strategy: "configured_paths", sourcePath };
107
+ }
108
+ emptyMatch ??= { rows, strategy: "configured_paths", sourcePath };
109
+ }
110
+ }
111
+ if (emptyMatch) {
112
+ return emptyMatch;
113
+ }
114
+ }
115
+ for (const root of candidateRoots(payload)) {
116
+ const candidate = findBestArrayCandidate(root.value, root.path ?? "");
117
+ if (!candidate || candidate.rows.length === 0) continue;
118
+ return {
119
+ rows: candidate.rows,
120
+ strategy: "auto_detected",
121
+ sourcePath: candidate.path || root.path
122
+ };
123
+ }
124
+ return null;
125
+ }
126
+ function projectRowOutput(conversion) {
127
+ return {
128
+ rows: conversion.rows,
129
+ rowCount: conversion.rows.length,
130
+ columns: columnsForRows(conversion.rows),
131
+ previewRows: conversion.rows.slice(0, 5),
132
+ strategy: conversion.strategy,
133
+ sourcePath: conversion.sourcePath
134
+ };
135
+ }
136
+ function ensureOutputDir() {
137
+ const outputDir = join(homedir(), ".local", "share", "deepline", "data");
138
+ mkdirSync(outputDir, { recursive: true });
139
+ return outputDir;
140
+ }
141
+ function writeJsonOutputFile(payload, stem) {
142
+ const outputDir = ensureOutputDir();
143
+ const outputPath = join(outputDir, `${stem}_${Date.now()}.json`);
144
+ writeFileSync(outputPath, JSON.stringify(payload, null, 2), "utf-8");
145
+ return outputPath;
146
+ }
147
+ function writeCsvOutputFile(rows, stem, options) {
148
+ const outputPath = options?.outPath ? options.outPath : join(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
149
+ mkdirSync(dirname(outputPath), { recursive: true });
150
+ const columns = columnsForRows(rows);
151
+ const escapeCell = (value) => {
152
+ const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
153
+ if (/[",\n]/.test(normalized)) {
154
+ return `"${normalized.replace(/"/g, '""')}"`;
155
+ }
156
+ return normalized;
157
+ };
158
+ const fd = openSync(outputPath, "w");
159
+ try {
160
+ writeSync(fd, `${columns.map(escapeCell).join(",")}
161
+ `);
162
+ for (const row of rows) {
163
+ writeSync(
164
+ fd,
165
+ `${columns.map((column) => escapeCell(row[column])).join(",")}
166
+ `
167
+ );
168
+ }
169
+ } finally {
170
+ closeSync(fd);
171
+ }
172
+ const previewRows = rows.slice(0, 5);
173
+ const previewColumns = columns.slice(0, 5);
174
+ const preview = [
175
+ previewColumns.join(","),
176
+ ...previewRows.map(
177
+ (row) => previewColumns.map((column) => escapeCell(row[column])).join(",")
178
+ )
179
+ ].join("\n");
180
+ return {
181
+ path: outputPath,
182
+ rowCount: rows.length,
183
+ columns,
184
+ preview
185
+ };
186
+ }
187
+ function extractSummaryFields(payload) {
188
+ const candidates = candidateRoots(payload);
189
+ for (const candidate of candidates) {
190
+ if (!isPlainObject(candidate.value)) continue;
191
+ const summaryEntries = Object.entries(candidate.value).filter(
192
+ ([, value]) => {
193
+ return value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
194
+ }
195
+ );
196
+ if (summaryEntries.length === 0) continue;
197
+ return Object.fromEntries(summaryEntries);
198
+ }
199
+ return {};
200
+ }
201
+
202
+ // ../plays/row-identity.ts
203
+ var POSTGRES_IDENTIFIER_MAX_LENGTH = 63;
204
+ var MAP_KEY_NAMESPACE_MAX_LENGTH = POSTGRES_IDENTIFIER_MAX_LENGTH;
205
+ var SHA256_INITIAL_HASH = [
206
+ 1779033703,
207
+ 3144134277,
208
+ 1013904242,
209
+ 2773480762,
210
+ 1359893119,
211
+ 2600822924,
212
+ 528734635,
213
+ 1541459225
214
+ ];
215
+ var SHA256_ROUND_CONSTANTS = [
216
+ 1116352408,
217
+ 1899447441,
218
+ 3049323471,
219
+ 3921009573,
220
+ 961987163,
221
+ 1508970993,
222
+ 2453635748,
223
+ 2870763221,
224
+ 3624381080,
225
+ 310598401,
226
+ 607225278,
227
+ 1426881987,
228
+ 1925078388,
229
+ 2162078206,
230
+ 2614888103,
231
+ 3248222580,
232
+ 3835390401,
233
+ 4022224774,
234
+ 264347078,
235
+ 604807628,
236
+ 770255983,
237
+ 1249150122,
238
+ 1555081692,
239
+ 1996064986,
240
+ 2554220882,
241
+ 2821834349,
242
+ 2952996808,
243
+ 3210313671,
244
+ 3336571891,
245
+ 3584528711,
246
+ 113926993,
247
+ 338241895,
248
+ 666307205,
249
+ 773529912,
250
+ 1294757372,
251
+ 1396182291,
252
+ 1695183700,
253
+ 1986661051,
254
+ 2177026350,
255
+ 2456956037,
256
+ 2730485921,
257
+ 2820302411,
258
+ 3259730800,
259
+ 3345764771,
260
+ 3516065817,
261
+ 3600352804,
262
+ 4094571909,
263
+ 275423344,
264
+ 430227734,
265
+ 506948616,
266
+ 659060556,
267
+ 883997877,
268
+ 958139571,
269
+ 1322822218,
270
+ 1537002063,
271
+ 1747873779,
272
+ 1955562222,
273
+ 2024104815,
274
+ 2227730452,
275
+ 2361852424,
276
+ 2428436474,
277
+ 2756734187,
278
+ 3204031479,
279
+ 3329325298
280
+ ];
281
+ function stableValue(value) {
282
+ if (Array.isArray(value)) {
283
+ return value.map((entry) => stableValue(entry));
284
+ }
285
+ if (value && typeof value === "object") {
286
+ return Object.fromEntries(
287
+ Object.entries(value).filter(([, entry]) => entry !== void 0).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, stableValue(entry)])
288
+ );
289
+ }
290
+ return value;
291
+ }
292
+ function stableStringify(value) {
293
+ return JSON.stringify(stableValue(value));
294
+ }
295
+ function rightRotate32(value, bits) {
296
+ return value >>> bits | value << 32 - bits;
297
+ }
298
+ function sha256Hex(input) {
299
+ const bytes = Array.from(new TextEncoder().encode(input));
300
+ const bitLength = bytes.length * 8;
301
+ bytes.push(128);
302
+ while (bytes.length % 64 !== 56) {
303
+ bytes.push(0);
304
+ }
305
+ const highBits = Math.floor(bitLength / 4294967296);
306
+ const lowBits = bitLength >>> 0;
307
+ bytes.push(
308
+ highBits >>> 24 & 255,
309
+ highBits >>> 16 & 255,
310
+ highBits >>> 8 & 255,
311
+ highBits & 255,
312
+ lowBits >>> 24 & 255,
313
+ lowBits >>> 16 & 255,
314
+ lowBits >>> 8 & 255,
315
+ lowBits & 255
316
+ );
317
+ const hash = [...SHA256_INITIAL_HASH];
318
+ const words = new Array(64).fill(0);
319
+ for (let offset = 0; offset < bytes.length; offset += 64) {
320
+ for (let index = 0; index < 16; index += 1) {
321
+ const wordOffset = offset + index * 4;
322
+ words[index] = (bytes[wordOffset] ?? 0) << 24 | (bytes[wordOffset + 1] ?? 0) << 16 | (bytes[wordOffset + 2] ?? 0) << 8 | (bytes[wordOffset + 3] ?? 0);
323
+ }
324
+ for (let index = 16; index < 64; index += 1) {
325
+ const s0 = rightRotate32(words[index - 15], 7) ^ rightRotate32(words[index - 15], 18) ^ words[index - 15] >>> 3;
326
+ const s1 = rightRotate32(words[index - 2], 17) ^ rightRotate32(words[index - 2], 19) ^ words[index - 2] >>> 10;
327
+ words[index] = words[index - 16] + s0 + words[index - 7] + s1 >>> 0;
328
+ }
329
+ let [a, b, c, d, e, f, g, h] = hash;
330
+ for (let index = 0; index < 64; index += 1) {
331
+ const s1 = rightRotate32(e, 6) ^ rightRotate32(e, 11) ^ rightRotate32(e, 25);
332
+ const ch = e & f ^ ~e & g;
333
+ const temp1 = h + s1 + ch + SHA256_ROUND_CONSTANTS[index] + words[index] >>> 0;
334
+ const s0 = rightRotate32(a, 2) ^ rightRotate32(a, 13) ^ rightRotate32(a, 22);
335
+ const maj = a & b ^ a & c ^ b & c;
336
+ const temp2 = s0 + maj >>> 0;
337
+ h = g;
338
+ g = f;
339
+ f = e;
340
+ e = d + temp1 >>> 0;
341
+ d = c;
342
+ c = b;
343
+ b = a;
344
+ a = temp1 + temp2 >>> 0;
345
+ }
346
+ hash[0] = hash[0] + a >>> 0;
347
+ hash[1] = hash[1] + b >>> 0;
348
+ hash[2] = hash[2] + c >>> 0;
349
+ hash[3] = hash[3] + d >>> 0;
350
+ hash[4] = hash[4] + e >>> 0;
351
+ hash[5] = hash[5] + f >>> 0;
352
+ hash[6] = hash[6] + g >>> 0;
353
+ hash[7] = hash[7] + h >>> 0;
354
+ }
355
+ return hash.map((word) => word.toString(16).padStart(8, "0")).join("");
356
+ }
357
+ function sanitizeIdentifierPart(value) {
358
+ return value.trim().replace(/[^a-z0-9]+/gi, "_").replace(/_+/g, "_").replace(/^_+|_+$/g, "").toLowerCase();
359
+ }
360
+ function validateIdentifierPart(rawValue, label, maxLength) {
361
+ const sanitized = sanitizeIdentifierPart(rawValue);
362
+ if (!sanitized) {
363
+ throw new Error(`${label} must contain a letter or number.`);
364
+ }
365
+ if (sanitized.length > maxLength) {
366
+ throw new Error(
367
+ `${label} is too long after normalization (${sanitized.length}/${maxLength}): "${sanitized}".`
368
+ );
369
+ }
370
+ return sanitized;
371
+ }
372
+ function normalizeTableNamespace(value) {
373
+ return validateIdentifierPart(
374
+ value,
375
+ "ctx.dataset() key",
376
+ MAP_KEY_NAMESPACE_MAX_LENGTH
377
+ );
378
+ }
379
+
380
+ export {
381
+ stableStringify,
382
+ sha256Hex,
383
+ normalizeTableNamespace,
384
+ tryConvertToList,
385
+ projectRowOutput,
386
+ writeJsonOutputFile,
387
+ writeCsvOutputFile,
388
+ extractSummaryFields
389
+ };