deepline 0.3.294 → 0.3.295

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 (136) 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/tool-http-errors.ts +14 -1
  4. package/dist/cli/auth-EDTRERZP.mjs +31 -0
  5. package/dist/cli/auth-TDHKB277.js +31 -0
  6. package/dist/cli/billing-ELIDPILY.js +1749 -0
  7. package/dist/cli/billing-EXGXJVAU.mjs +1749 -0
  8. package/dist/cli/chunk-2S5Y3TZP.js +5688 -0
  9. package/dist/cli/chunk-3KC45UVF.js +150 -0
  10. package/dist/cli/chunk-3XX5TEA4.js +15 -0
  11. package/dist/cli/chunk-4MBOJQPL.mjs +0 -0
  12. package/dist/cli/chunk-4NEFYBF7.js +2240 -0
  13. package/dist/cli/chunk-5JLQPVNX.js +3056 -0
  14. package/dist/cli/chunk-5KDKFHZI.js +1269 -0
  15. package/dist/cli/chunk-6A3TJUWC.js +76 -0
  16. package/dist/cli/chunk-6O5YZOVN.mjs +890 -0
  17. package/dist/cli/chunk-7P5AA3SN.js +344 -0
  18. package/dist/cli/chunk-AYHLUHE5.js +52 -0
  19. package/dist/cli/chunk-CBVIJSHF.mjs +560 -0
  20. package/dist/cli/chunk-CFVVCN4A.js +735 -0
  21. package/dist/cli/chunk-COGTRVWW.js +30 -0
  22. package/dist/cli/chunk-D4AZUZO4.js +190 -0
  23. package/dist/cli/chunk-DLIRSHV6.mjs +28 -0
  24. package/dist/cli/chunk-EACVZI6N.mjs +1995 -0
  25. package/dist/cli/chunk-EDWJY6T4.mjs +3056 -0
  26. package/dist/cli/chunk-EXMLR72R.mjs +0 -0
  27. package/dist/cli/chunk-F35VOIQL.js +890 -0
  28. package/dist/cli/chunk-GAMFK2ZP.mjs +148 -0
  29. package/dist/cli/chunk-GHRQQPW2.mjs +2240 -0
  30. package/dist/cli/chunk-GONRLVV3.js +3440 -0
  31. package/dist/cli/chunk-GVUJJJ5G.mjs +76 -0
  32. package/dist/cli/chunk-H7HIDGZ7.mjs +150 -0
  33. package/dist/cli/chunk-HUZXWOSK.mjs +503 -0
  34. package/dist/cli/chunk-I5YZLGMG.js +1 -0
  35. package/dist/cli/chunk-ITOFSXIU.mjs +15 -0
  36. package/dist/cli/chunk-J5NA2TTX.js +503 -0
  37. package/dist/cli/chunk-JCS5TPNY.mjs +3440 -0
  38. package/dist/cli/chunk-JNNOCMQY.js +47 -0
  39. package/dist/cli/chunk-KRD6H754.mjs +30 -0
  40. package/dist/cli/chunk-LA46MMTL.js +560 -0
  41. package/dist/cli/chunk-LDWT7RJK.mjs +190 -0
  42. package/dist/cli/chunk-M2V26OR5.js +499 -0
  43. package/dist/cli/chunk-MIMASXO4.mjs +389 -0
  44. package/dist/cli/chunk-MROPCKW2.mjs +190 -0
  45. package/dist/cli/chunk-NXDRDJ4K.js +389 -0
  46. package/dist/cli/chunk-NXGCO4JB.mjs +344 -0
  47. package/dist/cli/chunk-OG64RBAC.js +6 -0
  48. package/dist/cli/chunk-OQYEC4GL.mjs +34 -0
  49. package/dist/cli/chunk-OWJZUE3Y.mjs +103 -0
  50. package/dist/cli/chunk-SDK3ZA2C.js +103 -0
  51. package/dist/cli/chunk-SFLARO4Y.mjs +47 -0
  52. package/dist/cli/chunk-SVIIIYIQ.js +923 -0
  53. package/dist/cli/chunk-TAC3JIFE.mjs +354 -0
  54. package/dist/cli/chunk-U3PI7HBM.js +34 -0
  55. package/dist/cli/chunk-UFS752TU.mjs +52 -0
  56. package/dist/cli/chunk-UI37DQE7.mjs +499 -0
  57. package/dist/cli/chunk-UNEMDKXN.js +1 -0
  58. package/dist/cli/chunk-WB6Z2Q44.mjs +1622 -0
  59. package/dist/cli/chunk-WJYPBHTE.js +148 -0
  60. package/dist/cli/chunk-WOHBA5PV.js +354 -0
  61. package/dist/cli/chunk-WQICC2B3.js +190 -0
  62. package/dist/cli/chunk-WZYKRD7T.mjs +6 -0
  63. package/dist/cli/chunk-XL2FO6CW.mjs +5688 -0
  64. package/dist/cli/chunk-XNYIZMNQ.js +28 -0
  65. package/dist/cli/chunk-XRK2TZT5.js +1995 -0
  66. package/dist/cli/chunk-YJYPL5OK.mjs +1269 -0
  67. package/dist/cli/chunk-YWNDYCXR.mjs +735 -0
  68. package/dist/cli/chunk-YWWAF7KZ.mjs +923 -0
  69. package/dist/cli/chunk-ZDO3TO3M.js +1622 -0
  70. package/dist/cli/client-4JVOYVC5.js +20 -0
  71. package/dist/cli/client-EEN2IJN2.mjs +20 -0
  72. package/dist/cli/csv-BOHBEP2I.mjs +585 -0
  73. package/dist/cli/csv-S5NYRUEX.js +585 -0
  74. package/dist/cli/db-CLODWCOB.mjs +486 -0
  75. package/dist/cli/db-F6PKFOOV.js +486 -0
  76. package/dist/cli/executions-5TQAKLJU.js +28 -0
  77. package/dist/cli/executions-MAKW6QOY.mjs +28 -0
  78. package/dist/cli/feedback-GV4QJFEN.js +107 -0
  79. package/dist/cli/feedback-XY24TW7H.mjs +107 -0
  80. package/dist/cli/getting-started.js +18 -76
  81. package/dist/cli/getting-started.mjs +10 -37
  82. package/dist/cli/git-6S2C22T5.js +23 -0
  83. package/dist/cli/git-OZLBD5HH.mjs +23 -0
  84. package/dist/cli/index.js +291 -54294
  85. package/dist/cli/index.mjs +209 -54352
  86. package/dist/cli/legacy-noops-LLCGDPQE.js +157 -0
  87. package/dist/cli/legacy-noops-TYH3TW2D.mjs +157 -0
  88. package/dist/cli/monitors-CABMB4DW.js +3251 -0
  89. package/dist/cli/monitors-TTD55HMK.mjs +3251 -0
  90. package/dist/cli/org-MSF3RG76.js +849 -0
  91. package/dist/cli/org-SFJ77MWY.mjs +849 -0
  92. package/dist/cli/play-NXHJSCKL.mjs +18439 -0
  93. package/dist/cli/play-OKSFNNO4.js +18439 -0
  94. package/dist/cli/providers-QC2ERERL.js +95 -0
  95. package/dist/cli/providers-TIIAZEUA.mjs +95 -0
  96. package/dist/cli/proxy-env-EBANZHPV.js +161 -0
  97. package/dist/cli/proxy-env-M4ZHXHRL.mjs +161 -0
  98. package/dist/cli/quickstart-ICANHLMI.js +69 -0
  99. package/dist/cli/quickstart-KWUOP3FI.mjs +69 -0
  100. package/dist/cli/search-U5H2FDOO.mjs +18 -0
  101. package/dist/cli/search-XQRQOLWS.js +18 -0
  102. package/dist/cli/secrets-3J6YTWFA.mjs +400 -0
  103. package/dist/cli/secrets-YNMNZNOM.js +400 -0
  104. package/dist/cli/sessions-CLEES4L6.mjs +15 -0
  105. package/dist/cli/sessions-J6VR47FG.js +15 -0
  106. package/dist/cli/settings-EEKZMTY4.js +846 -0
  107. package/dist/cli/settings-UVLOQZRH.mjs +846 -0
  108. package/dist/cli/setup-DLMDXPGJ.mjs +1257 -0
  109. package/dist/cli/setup-HC4Q7QM4.js +1257 -0
  110. package/dist/cli/skills-33PHFBSB.mjs +28 -0
  111. package/dist/cli/skills-LFRY3KPX.js +28 -0
  112. package/dist/cli/tools-3COEPKML.mjs +2955 -0
  113. package/dist/cli/tools-QXEVCN45.js +2955 -0
  114. package/dist/cli/update-LSAC4FF5.mjs +28 -0
  115. package/dist/cli/update-NXHSPYXA.js +28 -0
  116. package/dist/cli/workflow-7S44OECF.mjs +1936 -0
  117. package/dist/cli/workflow-QPZWYSZE.js +1936 -0
  118. package/dist/helpers.js +6 -32
  119. package/dist/helpers.mjs +2 -0
  120. package/dist/index.js +1972 -12825
  121. package/dist/index.mjs +1910 -12672
  122. package/dist/install-integrity.json +110 -0
  123. package/dist/monitor-fleet-contract.js +31 -730
  124. package/dist/monitor-fleet-contract.mjs +18 -667
  125. package/dist/monitor-input-contract.js +10 -390
  126. package/dist/monitor-input-contract.mjs +7 -348
  127. package/dist/plays/bundle-play-file.mjs +13 -5178
  128. package/dist/plays/csv-data-input.js +5 -3132
  129. package/dist/plays/csv-data-input.mjs +5 -3105
  130. package/dist/plays/run-request.js +56 -664
  131. package/dist/plays/run-request.mjs +30 -588
  132. package/dist/release.d.mts +1 -1
  133. package/dist/release.d.ts +1 -1
  134. package/dist/release.js +5 -212
  135. package/dist/release.mjs +5 -185
  136. package/package.json +1 -1
@@ -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
+ };
@@ -0,0 +1,190 @@
1
+ import {
2
+ DeeplineClient
3
+ } from "./chunk-XL2FO6CW.mjs";
4
+ import {
5
+ printCommandEnvelope
6
+ } from "./chunk-6O5YZOVN.mjs";
7
+ import {
8
+ resolveConfig,
9
+ sdkCliStateDirPath
10
+ } from "./chunk-EACVZI6N.mjs";
11
+
12
+ // src/cli/search-ref.ts
13
+ import { mkdirSync, readFileSync, writeFileSync } from "fs";
14
+ import { dirname, join } from "path";
15
+ var SEARCH_REF_TTL_MS = 15 * 6e4;
16
+ function lastSearchPath() {
17
+ return join(sdkCliStateDirPath(resolveConfig().baseUrl), "last-search.json");
18
+ }
19
+ function rememberSearchRef(searchRef) {
20
+ try {
21
+ mkdirSync(dirname(lastSearchPath()), { recursive: true });
22
+ writeFileSync(
23
+ lastSearchPath(),
24
+ JSON.stringify({ searchRef, at: Date.now() }),
25
+ { mode: 384 }
26
+ );
27
+ } catch {
28
+ }
29
+ }
30
+ function recentSearchRef() {
31
+ try {
32
+ const saved = JSON.parse(readFileSync(lastSearchPath(), "utf8"));
33
+ return typeof saved.searchRef === "string" && typeof saved.at === "number" && Date.now() - saved.at < SEARCH_REF_TTL_MS ? saved.searchRef : void 0;
34
+ } catch {
35
+ return void 0;
36
+ }
37
+ }
38
+
39
+ // src/cli/commands/search.ts
40
+ var SEARCH_TYPES = [
41
+ "tools",
42
+ "plays",
43
+ "monitors",
44
+ "prebuilts",
45
+ "custom"
46
+ ];
47
+ var USAGE = "Usage: deepline search [query] [--type <types>] [--categories <categories>] [--search_terms <terms>] [--json]";
48
+ function parseTypes(flag, raw) {
49
+ const names = (raw ?? "").split(",").map((name) => name.trim().toLowerCase()).filter(Boolean);
50
+ const unknown = names.filter(
51
+ (name) => !SEARCH_TYPES.includes(name)
52
+ );
53
+ if (unknown.length > 0) {
54
+ throw new Error(
55
+ `Unknown ${flag} ${unknown.join(", ")}. Use any of: ${SEARCH_TYPES.join(", ")}.`
56
+ );
57
+ }
58
+ return names;
59
+ }
60
+ function optionalInteger(raw) {
61
+ return raw === void 0 ? void 0 : Number.parseInt(raw, 10);
62
+ }
63
+ function appendCsv(value, previous) {
64
+ return previous ? `${previous},${value}` : value;
65
+ }
66
+ function addSearchOptions(command) {
67
+ return command.option(
68
+ "--categories <categories>",
69
+ "Comma-separated tool categories; may be used without a query"
70
+ ).option(
71
+ "--search_terms <terms>",
72
+ "Comma-separated structured search terms; may be used without a query"
73
+ ).option("--search-terms <terms>", "Alias for --search_terms").option(
74
+ "--task <sentence>",
75
+ "What you are trying to accomplish: input you have -> result you need"
76
+ ).option("--limit <count>", "Maximum ranked results to return (1-50)").option("--offset <count>", "Zero-based ranked result offset").option("--search-mode <mode>", "Ranked search mode: v1 or v2").option("--include-search-debug", "Include ranked search debug metadata").option("--json", "Emit JSON output instead of the readable default");
77
+ }
78
+ async function runSearch(queryInput, options, types, exclude = []) {
79
+ const query = queryInput?.trim() ?? "";
80
+ const searchTerms = options.searchTerms ?? options.search_terms;
81
+ if (!query && !options.categories?.trim() && !searchTerms?.trim()) {
82
+ console.error(USAGE);
83
+ return 1;
84
+ }
85
+ const { search_ref: searchRef, ...result } = await new DeeplineClient().search({
86
+ query,
87
+ types,
88
+ exclude,
89
+ categories: options.categories,
90
+ searchTerms,
91
+ task: options.task,
92
+ limit: optionalInteger(options.limit),
93
+ offset: optionalInteger(options.offset),
94
+ searchMode: options.searchMode === "v1" || options.searchMode === "v2" ? options.searchMode : void 0,
95
+ includeSearchDebug: Boolean(options.includeSearchDebug)
96
+ });
97
+ if (searchRef) rememberSearchRef(searchRef);
98
+ printCommandEnvelope(result, {
99
+ json: options.json === true
100
+ });
101
+ return 0;
102
+ }
103
+ function registerDeprecatedSearchCommand(parent, typesFor) {
104
+ const name = `deepline ${parent.name()} search`;
105
+ addSearchOptions(
106
+ parent.command("search [query]").description(`Deprecated. Use deepline search --type <types>.`).addHelpText(
107
+ "after",
108
+ `
109
+ Notes:
110
+ Deprecated alias for the unified search. It runs deepline search with the
111
+ matching --type and returns the same results envelope.
112
+
113
+ Examples:
114
+ deepline search email --type ${typesFor({}).join(",")}
115
+ `
116
+ ).option("--all", "Include plays your workspace created").option("--compact", "Accepted for compatibility; results are compact")
117
+ ).action(async (query, options) => {
118
+ const types = typesFor(options);
119
+ console.error(
120
+ `${name} is deprecated. Use: deepline search${query ? ` ${JSON.stringify(query)}` : ""} --type ${types.join(",")}`
121
+ );
122
+ process.exitCode = await runSearch(query, options, types);
123
+ });
124
+ }
125
+ function registerSearchCommand(program) {
126
+ addSearchOptions(
127
+ program.command("search [query]").description(
128
+ "Search tools, monitors, and plays together, ranked by intent."
129
+ ).addHelpText(
130
+ "after",
131
+ `
132
+ Notes:
133
+ One ranked search across everything Deepline can run, deploy, or explain.
134
+ Every result carries a kind: tool, monitor_type, prebuilt_play, custom_play
135
+ (a play your workspace created), or doc. Narrow with --type, a
136
+ comma-separated list of:
137
+ tools atomic provider operations (deepline tools execute)
138
+ monitors monitor types you can deploy
139
+ prebuilts Deepline-maintained plays
140
+ custom plays your workspace created
141
+ plays prebuilts and custom together
142
+ --exclude takes the same names and leaves those kinds out instead.
143
+ Ranking uses a third-party AI relevance model. For plays your workspace
144
+ created it is sent only the play name and description, never play code.
145
+ Both flags may be repeated: --type tools --type prebuilts.
146
+ Provide a query, or omit it only when --categories and/or --search_terms is
147
+ supplied. Use --limit and --offset to page (limit 1-50, offset zero-based);
148
+ JSON includes next_offset. Pass --task with one sentence on what you are
149
+ trying to accomplish: the input you have and the result you need. It
150
+ materially improves ranking, especially for short queries.
151
+ Search prints a readable result list by default, piped or not, and that is
152
+ the recommended form. Pass --json only when a program parses the result.
153
+
154
+ Examples:
155
+ deepline search "find work email"
156
+ deepline search "find work email" --type tools --limit 10
157
+ deepline search "company to contacts" --type plays
158
+ deepline search "enrich a company" --exclude monitors,custom
159
+ deepline search linkedin --task "I have 200 LinkedIn profile URLs and need each person's current title and company"
160
+ deepline search --type tools --categories company_search --search_terms "investors,funding"
161
+ `
162
+ ).option(
163
+ "--type <types>",
164
+ `Kinds to search, comma-separated or repeated: ${SEARCH_TYPES.join(", ")}`,
165
+ appendCsv
166
+ ).option(
167
+ "--exclude <types>",
168
+ "Kinds to leave out, comma-separated or repeated; the opposite of --type",
169
+ appendCsv
170
+ )
171
+ ).action(async (query, options) => {
172
+ let types;
173
+ let exclude;
174
+ try {
175
+ types = parseTypes("--type", options.type);
176
+ exclude = parseTypes("--exclude", options.exclude);
177
+ } catch (error) {
178
+ console.error(error instanceof Error ? error.message : String(error));
179
+ process.exitCode = 1;
180
+ return;
181
+ }
182
+ process.exitCode = await runSearch(query, options, types, exclude);
183
+ });
184
+ }
185
+
186
+ export {
187
+ recentSearchRef,
188
+ registerDeprecatedSearchCommand,
189
+ registerSearchCommand
190
+ };