deepline 0.3.396 → 0.3.397
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.
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-behavior.ts +2 -2
- package/dist/cli/{auth-3LTD62VL.mjs → auth-AZJFXGKP.mjs} +5 -4
- package/dist/cli/auth-CZJQU7B5.js +40 -0
- package/dist/cli/{billing-PA5OXEM5.js → billing-MQV5AGDJ.js} +76 -75
- package/dist/cli/{billing-DP7ZAJBO.mjs → billing-MZAAUHGH.mjs} +5 -4
- package/dist/cli/{chunk-VE3U3SQC.mjs → chunk-2LDADJNO.mjs} +7 -107
- package/dist/cli/{chunk-772W2SAU.js → chunk-3VP34TAU.js} +8 -8
- package/dist/cli/{chunk-QHGPA362.mjs → chunk-4D745XZO.mjs} +6 -108
- package/dist/cli/chunk-7DRPTGCK.js +930 -0
- package/dist/cli/{chunk-NSOTASOP.js → chunk-BQR6UN3C.js} +1 -83
- package/dist/cli/{chunk-RTO5QZWT.js → chunk-DQ65ZVHN.js} +6 -6
- package/dist/cli/{chunk-3T4MCB5R.mjs → chunk-F3BUFYKE.mjs} +89 -969
- package/dist/cli/chunk-FIVKWNMT.mjs +210 -0
- package/dist/cli/{describe-6O2ENKTP.mjs → chunk-HFYQBC2D.mjs} +22 -160
- package/dist/cli/chunk-HGFFYVXN.js +210 -0
- package/dist/cli/{chunk-5WNJF2T3.mjs → chunk-IHG7UAHD.mjs} +1 -83
- package/dist/cli/{chunk-GNN4MY5X.js → chunk-IZ74ABSX.js} +1 -1
- package/dist/cli/{chunk-MR6XCBQJ.mjs → chunk-J7ABTQQ7.mjs} +4 -2
- package/dist/cli/{chunk-2VOLOWYZ.js → chunk-K33MXVXQ.js} +293 -1173
- package/dist/cli/chunk-LJ5747UC.mjs +107 -0
- package/dist/cli/{chunk-NHB5YUCS.mjs → chunk-MRXMMERY.mjs} +1 -1
- package/dist/cli/{chunk-TLQ3FZOC.mjs → chunk-MV7QRALK.mjs} +3 -3
- package/dist/cli/{chunk-AUYXWELC.mjs → chunk-MYPH2LUU.mjs} +2 -2
- package/dist/cli/{chunk-LWERJUKN.js → chunk-NA4T3B62.js} +7 -215
- package/dist/cli/{chunk-23GAA3YO.mjs → chunk-NOX2TCBP.mjs} +1 -1
- package/dist/cli/chunk-OSDXE27V.mjs +88 -0
- package/dist/cli/{chunk-KAEZNPUM.js → chunk-PSGEDGLT.js} +13 -115
- package/dist/cli/chunk-Q2E4E4FJ.js +112 -0
- package/dist/cli/{describe-EFWNECHI.js → chunk-RFG3MRAC.js} +37 -175
- package/dist/cli/{chunk-XKZXO7D3.mjs → chunk-RNSWDKBM.mjs} +1 -1
- package/dist/cli/{chunk-V7UP2F4U.js → chunk-RYW4HPSM.js} +21 -121
- package/dist/cli/{chunk-7Z66NHUC.js → chunk-SO7RUVTY.js} +26 -26
- package/dist/cli/{chunk-H5KLUGY7.mjs → chunk-TXZVVBQZ.mjs} +1 -209
- package/dist/cli/{chunk-WQJJNIMQ.js → chunk-UVXBVUZQ.js} +11 -9
- package/dist/cli/{chunk-AVHLATII.js → chunk-VTF4RRWJ.js} +50 -50
- package/dist/cli/{chunk-LOGGNW4H.mjs → chunk-W3HMGKMI.mjs} +2 -2
- package/dist/cli/{chunk-JCN4DHF7.mjs → chunk-WM2QEHZL.mjs} +2 -2
- package/dist/cli/chunk-YHPYUZZX.mjs +112 -0
- package/dist/cli/chunk-YHZUZO3U.mjs +930 -0
- package/dist/cli/{chunk-ME6XRFLY.js → chunk-YLRME7MK.js} +15 -15
- package/dist/cli/{chunk-DC6LTULT.js → chunk-YSVORIEW.js} +2 -2
- package/dist/cli/{chunk-I4T4XAA2.mjs → chunk-YUDKBQUD.mjs} +4 -4
- package/dist/cli/chunk-ZAAKSJAS.js +88 -0
- package/dist/cli/{chunk-RMTASUAK.js → chunk-ZHUMDMOS.js} +65 -65
- package/dist/cli/chunk-ZM2YPJQJ.js +107 -0
- package/dist/cli/{csv-TF576S77.js → csv-AQBQ5O3I.js} +13 -12
- package/dist/cli/{csv-RLRR74RQ.mjs → csv-MB7PJMYQ.mjs} +4 -3
- package/dist/cli/{db-FDBJUTFO.js → db-JPUYC5RB.js} +30 -29
- package/dist/cli/{db-XORGNBIC.mjs → db-L5IEI2AU.mjs} +5 -4
- package/dist/cli/describe-6WT74AOR.js +164 -0
- package/dist/cli/describe-S6BFANVI.mjs +164 -0
- package/dist/cli/describe-core.d.mts +100 -0
- package/dist/cli/describe-core.d.ts +100 -0
- package/dist/cli/describe-core.js +18 -0
- package/dist/cli/describe-core.mjs +18 -0
- package/dist/cli/{executions-SFYAXPF4.js → executions-6TMQTFP4.js} +7 -6
- package/dist/cli/{executions-YPP7WR77.mjs → executions-L7I2ZW4Z.mjs} +5 -4
- package/dist/cli/{feedback-RBGA5ARU.mjs → feedback-DSJ63HK6.mjs} +4 -3
- package/dist/cli/{feedback-5UZFYMGB.js → feedback-XF7CQGMD.js} +8 -7
- package/dist/cli/{git-IRSAJEK2.mjs → git-C3ENM67D.mjs} +5 -4
- package/dist/cli/git-HYDZK2QR.js +24 -0
- package/dist/cli/index.js +93 -91
- package/dist/cli/index.mjs +35 -33
- package/dist/cli/{legacy-noops-CVAOQY2F.js → legacy-noops-B2NHWIVD.js} +8 -7
- package/dist/cli/{legacy-noops-NA7N6ZOU.mjs → legacy-noops-VFG2K6HK.mjs} +5 -4
- package/dist/cli/{monitors-4OMRXCXP.js → monitors-ORFWOVZB.js} +86 -85
- package/dist/cli/{monitors-ILZ2XHYG.mjs → monitors-TCEDBDGY.mjs} +5 -4
- package/dist/cli/{org-QDDXAE3J.mjs → org-45KREIKZ.mjs} +5 -4
- package/dist/cli/{org-YGNJDD2X.js → org-T74CJESN.js} +65 -64
- package/dist/cli/{play-VT6OHB2D.mjs → play-MU7MYBIM.mjs} +19 -15
- package/dist/cli/{play-L535H26U.js → play-XHK2LPON.js} +251 -247
- package/dist/cli/{providers-GPZ6PQAL.js → providers-4MGQKYFD.js} +8 -7
- package/dist/cli/{providers-KG4W5MPK.mjs → providers-VYCXIJT5.mjs} +5 -4
- package/dist/cli/{quickstart-UI27S5LO.js → quickstart-47G3VEOT.js} +6 -5
- package/dist/cli/{quickstart-2JDGTXIG.mjs → quickstart-H724EFM2.mjs} +4 -3
- package/dist/cli/search-3356ENLD.js +30 -0
- package/dist/cli/{search-PW3RAUX7.mjs → search-VQHXEFQ4.mjs} +7 -5
- package/dist/cli/{secrets-WFAXOUZE.js → secrets-ALLKCU35.js} +14 -13
- package/dist/cli/{secrets-HNOMK5A2.mjs → secrets-CPBNGA44.mjs} +5 -4
- package/dist/cli/{sessions-XLX3E5UO.mjs → sessions-7RSQB7IX.mjs} +5 -4
- package/dist/cli/sessions-FKGAY7WQ.js +16 -0
- package/dist/cli/{settings-YNZ4YKCH.mjs → settings-UYSGV4IC.mjs} +8 -7
- package/dist/cli/{settings-GADAG2UK.js → settings-Y5BI42P7.js} +75 -74
- package/dist/cli/{setup-PSEHIUXO.mjs → setup-L3ZBBTS4.mjs} +7 -6
- package/dist/cli/{setup-R5YO7GT6.js → setup-VXQPEU3E.js} +42 -41
- package/dist/cli/skills-DUZQTDTE.js +29 -0
- package/dist/cli/{skills-LTQBP6CZ.mjs → skills-QHVDLSFE.mjs} +5 -4
- package/dist/cli/{tools-UAXDWU63.mjs → tools-LSCEK4K2.mjs} +13 -8
- package/dist/cli/tools-YWU5QOQ5.js +39 -0
- package/dist/cli/update-5LYQAI55.js +29 -0
- package/dist/cli/{update-SMNIBIMS.mjs → update-CU22OTBM.mjs} +7 -6
- package/dist/cli/{workflow-AOQVZHMD.js → workflow-ERFLTRNX.js} +16 -15
- package/dist/cli/{workflow-IKGMBGF6.mjs → workflow-KQARK5BZ.mjs} +6 -5
- package/dist/{client-DiGl8ska.d.mts → client-D0j-_aaa.d.mts} +1 -1
- package/dist/{client-Bgis7F6-.d.ts → client-DflfVyj6.d.ts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +14 -10
- package/dist/index.mjs +19 -15
- package/dist/install-integrity.json +92 -76
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/package.json +6 -1
- package/dist/cli/auth-562JPKOM.js +0 -39
- package/dist/cli/git-5LDY5ZID.js +0 -23
- package/dist/cli/search-MGWROZ33.js +0 -28
- package/dist/cli/sessions-366KROUA.js +0 -15
- package/dist/cli/skills-JF2LPEGM.js +0 -28
- package/dist/cli/tools-CP2PEFRN.js +0 -34
- package/dist/cli/update-HZHZOU6C.js +0 -28
|
@@ -0,0 +1,210 @@
|
|
|
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
|
+
const roots = candidateRoots(payload);
|
|
116
|
+
const v2Raw = roots.find((root) => root.path === "toolResponse.raw");
|
|
117
|
+
for (const root of v2Raw ? [v2Raw] : roots) {
|
|
118
|
+
const candidate = findBestArrayCandidate(root.value, root.path ?? "");
|
|
119
|
+
if (!candidate || candidate.rows.length === 0) continue;
|
|
120
|
+
return {
|
|
121
|
+
rows: candidate.rows,
|
|
122
|
+
strategy: "auto_detected",
|
|
123
|
+
sourcePath: candidate.path || root.path
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
function projectRowOutput(conversion) {
|
|
129
|
+
return {
|
|
130
|
+
rows: conversion.rows,
|
|
131
|
+
rowCount: conversion.rows.length,
|
|
132
|
+
columns: columnsForRows(conversion.rows),
|
|
133
|
+
previewRows: conversion.rows.slice(0, 5),
|
|
134
|
+
strategy: conversion.strategy,
|
|
135
|
+
sourcePath: conversion.sourcePath
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function ensureOutputDir() {
|
|
139
|
+
const outputDir = join(homedir(), ".local", "share", "deepline", "data");
|
|
140
|
+
mkdirSync(outputDir, { recursive: true });
|
|
141
|
+
return outputDir;
|
|
142
|
+
}
|
|
143
|
+
function writeJsonOutputFile(payload, stem) {
|
|
144
|
+
const outputDir = ensureOutputDir();
|
|
145
|
+
const outputPath = join(outputDir, `${stem}_${Date.now()}.json`);
|
|
146
|
+
writeFileSync(outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
147
|
+
return outputPath;
|
|
148
|
+
}
|
|
149
|
+
function writeCsvOutputFile(rows, stem, options) {
|
|
150
|
+
const outputPath = options?.outPath ? options.outPath : join(ensureOutputDir(), `${stem}_${Date.now()}.csv`);
|
|
151
|
+
mkdirSync(dirname(outputPath), { recursive: true });
|
|
152
|
+
const columns = columnsForRows(rows);
|
|
153
|
+
const escapeCell = (value) => {
|
|
154
|
+
const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
|
|
155
|
+
if (/[",\n]/.test(normalized)) {
|
|
156
|
+
return `"${normalized.replace(/"/g, '""')}"`;
|
|
157
|
+
}
|
|
158
|
+
return normalized;
|
|
159
|
+
};
|
|
160
|
+
const fd = openSync(outputPath, "w");
|
|
161
|
+
try {
|
|
162
|
+
writeSync(fd, `${columns.map(escapeCell).join(",")}
|
|
163
|
+
`);
|
|
164
|
+
for (const row of rows) {
|
|
165
|
+
writeSync(
|
|
166
|
+
fd,
|
|
167
|
+
`${columns.map((column) => escapeCell(row[column])).join(",")}
|
|
168
|
+
`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
} finally {
|
|
172
|
+
closeSync(fd);
|
|
173
|
+
}
|
|
174
|
+
const previewRows = rows.slice(0, 5);
|
|
175
|
+
const previewColumns = columns.slice(0, 5);
|
|
176
|
+
const preview = [
|
|
177
|
+
previewColumns.join(","),
|
|
178
|
+
...previewRows.map(
|
|
179
|
+
(row) => previewColumns.map((column) => escapeCell(row[column])).join(",")
|
|
180
|
+
)
|
|
181
|
+
].join("\n");
|
|
182
|
+
return {
|
|
183
|
+
path: outputPath,
|
|
184
|
+
rowCount: rows.length,
|
|
185
|
+
columns,
|
|
186
|
+
preview
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function extractSummaryFields(payload) {
|
|
190
|
+
const candidates = candidateRoots(payload);
|
|
191
|
+
for (const candidate of candidates) {
|
|
192
|
+
if (!isPlainObject(candidate.value)) continue;
|
|
193
|
+
const summaryEntries = Object.entries(candidate.value).filter(
|
|
194
|
+
([, value]) => {
|
|
195
|
+
return value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
if (summaryEntries.length === 0) continue;
|
|
199
|
+
return Object.fromEntries(summaryEntries);
|
|
200
|
+
}
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export {
|
|
205
|
+
tryConvertToList,
|
|
206
|
+
projectRowOutput,
|
|
207
|
+
writeJsonOutputFile,
|
|
208
|
+
writeCsvOutputFile,
|
|
209
|
+
extractSummaryFields
|
|
210
|
+
};
|
|
@@ -2,12 +2,9 @@ import {
|
|
|
2
2
|
describedTool,
|
|
3
3
|
formatModelDescription,
|
|
4
4
|
publicToolSchemas,
|
|
5
|
-
seedToolListScript,
|
|
6
5
|
toolMetadataJsonForDescribe
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YHZUZO3U.mjs";
|
|
8
7
|
import {
|
|
9
|
-
SCHEMA_LINE_LIMIT,
|
|
10
|
-
addDescribeOptions,
|
|
11
8
|
buildPlayDashboardUrl,
|
|
12
9
|
byokLines,
|
|
13
10
|
describedJson,
|
|
@@ -16,34 +13,10 @@ import {
|
|
|
16
13
|
examples,
|
|
17
14
|
schemaLines,
|
|
18
15
|
topLevelField
|
|
19
|
-
} from "./chunk-
|
|
20
|
-
import "./chunk-OVDNJAJN.mjs";
|
|
21
|
-
import "./chunk-QHGPA362.mjs";
|
|
22
|
-
import "./chunk-H5KLUGY7.mjs";
|
|
23
|
-
import "./chunk-3HU47EGZ.mjs";
|
|
24
|
-
import {
|
|
25
|
-
DeeplineClient
|
|
26
|
-
} from "./chunk-MR6XCBQJ.mjs";
|
|
27
|
-
import "./chunk-6IKARAYD.mjs";
|
|
28
|
-
import "./chunk-JI2B4RZP.mjs";
|
|
29
|
-
import "./chunk-EIMG75BT.mjs";
|
|
30
|
-
import "./chunk-UBKA33KY.mjs";
|
|
31
|
-
import "./chunk-WXLOW623.mjs";
|
|
32
|
-
import {
|
|
33
|
-
printCommandEnvelope
|
|
34
|
-
} from "./chunk-XKZXO7D3.mjs";
|
|
35
|
-
import "./chunk-VE3U3SQC.mjs";
|
|
36
|
-
import "./chunk-DLIRSHV6.mjs";
|
|
16
|
+
} from "./chunk-IHG7UAHD.mjs";
|
|
37
17
|
import {
|
|
38
18
|
DeeplineError
|
|
39
19
|
} from "./chunk-NXGCO4JB.mjs";
|
|
40
|
-
import "./chunk-NHB5YUCS.mjs";
|
|
41
|
-
import "./chunk-WZYKRD7T.mjs";
|
|
42
|
-
import "./chunk-KRD6H754.mjs";
|
|
43
|
-
|
|
44
|
-
// src/cli/commands/describe.ts
|
|
45
|
-
import { writeFileSync } from "fs";
|
|
46
|
-
import { resolve } from "path";
|
|
47
20
|
|
|
48
21
|
// src/cli/tool-features.ts
|
|
49
22
|
var VIEWS = {
|
|
@@ -115,6 +88,24 @@ var FILTER_OF = {
|
|
|
115
88
|
prebuilt_play: "prebuilts",
|
|
116
89
|
custom_play: "custom"
|
|
117
90
|
};
|
|
91
|
+
async function found(lookup) {
|
|
92
|
+
try {
|
|
93
|
+
return await lookup;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof DeeplineError && (error.statusCode === 404 || error.code === "PLAY_NOT_FOUND" || error.code === "NOT_FOUND")) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function describeLookupsFor(client) {
|
|
102
|
+
return {
|
|
103
|
+
play: (reference) => found(client.describePlay(reference)),
|
|
104
|
+
tool: (name) => found(client.getTool(name)),
|
|
105
|
+
describeModel: (model) => client.describeModel(model),
|
|
106
|
+
baseUrl: client.baseUrl
|
|
107
|
+
};
|
|
108
|
+
}
|
|
118
109
|
async function describeName(name, options, lookups) {
|
|
119
110
|
const maintainedOnly = options.prebuilt === true || options.tool === true;
|
|
120
111
|
const wants = (filter) => (!options.kinds || options.kinds.includes(filter)) && !(maintainedOnly && filter === "custom");
|
|
@@ -289,136 +280,7 @@ async function describeName(name, options, lookups) {
|
|
|
289
280
|
return { status: "described", envelope, lines: view.lines };
|
|
290
281
|
}
|
|
291
282
|
|
|
292
|
-
// src/cli/commands/describe.ts
|
|
293
|
-
async function found(lookup) {
|
|
294
|
-
try {
|
|
295
|
-
return await lookup;
|
|
296
|
-
} catch (error) {
|
|
297
|
-
if (error instanceof DeeplineError && (error.statusCode === 404 || error.code === "PLAY_NOT_FOUND" || error.code === "NOT_FOUND")) {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
throw error;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
async function describeAnything(name, options, onMissing) {
|
|
304
|
-
const client = new DeeplineClient();
|
|
305
|
-
const outcome = await describeName(name, options, {
|
|
306
|
-
play: (reference) => found(client.describePlay(reference)),
|
|
307
|
-
tool: async (toolName) => options.fetchedTool ?? await found(client.getTool(toolName)),
|
|
308
|
-
describeModel: (model) => client.describeModel(model),
|
|
309
|
-
baseUrl: client.baseUrl,
|
|
310
|
-
seedStarterScript: seedToolListScript
|
|
311
|
-
});
|
|
312
|
-
if (outcome.status === "missing") {
|
|
313
|
-
if (onMissing) return onMissing();
|
|
314
|
-
console.error(
|
|
315
|
-
`Nothing named "${name}". Search for it: deepline search ${JSON.stringify(name.replace(/[-_./]+/g, " "))}`
|
|
316
|
-
);
|
|
317
|
-
return 2;
|
|
318
|
-
}
|
|
319
|
-
if (outcome.status === "refused") {
|
|
320
|
-
console.error(outcome.message);
|
|
321
|
-
return outcome.exitCode;
|
|
322
|
-
}
|
|
323
|
-
return deliver(outcome.envelope, outcome.lines, {
|
|
324
|
-
json: options.json === true,
|
|
325
|
-
out: options.out
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
function deliver(envelope, lines, { json, out }) {
|
|
329
|
-
const text = `${lines.join("\n")}
|
|
330
|
-
`;
|
|
331
|
-
if (out) {
|
|
332
|
-
const path = resolve(out);
|
|
333
|
-
const content = json ? `${JSON.stringify(envelope, null, 2)}
|
|
334
|
-
` : text;
|
|
335
|
-
writeFileSync(path, content);
|
|
336
|
-
const bytes = Buffer.byteLength(content);
|
|
337
|
-
printCommandEnvelope(
|
|
338
|
-
{ path, bytes },
|
|
339
|
-
{ json, text: `Wrote ${path} (${bytes} bytes)
|
|
340
|
-
` }
|
|
341
|
-
);
|
|
342
|
-
return 0;
|
|
343
|
-
}
|
|
344
|
-
printCommandEnvelope(envelope, { json, text });
|
|
345
|
-
return 0;
|
|
346
|
-
}
|
|
347
|
-
function registerDescribeCommand(program) {
|
|
348
|
-
addDescribeOptions(program.command("describe <name>")).option("--web-url", "Print only a play's play page URL").description(
|
|
349
|
-
"Describe anything search returns: a tool, monitor type, or play."
|
|
350
|
-
).addHelpText(
|
|
351
|
-
"after",
|
|
352
|
-
`
|
|
353
|
-
What you can describe:
|
|
354
|
-
Any id deepline search returns: a tool id, a monitor type id, or a play name
|
|
355
|
-
or reference. You do not say which kind it is; tool ids, monitor type ids
|
|
356
|
-
and prebuilt play names never overlap.
|
|
357
|
-
|
|
358
|
-
When a name is taken twice:
|
|
359
|
-
A play your workspace created is shown instead of a Deepline tool, monitor
|
|
360
|
-
type or prebuilt play with the same name, and the output says so.
|
|
361
|
-
Pass --prebuilt (or --tool) to see the Deepline one.
|
|
362
|
-
|
|
363
|
-
What it prints:
|
|
364
|
-
The same sections for every kind: what it is, cost, inputs, outputs, then
|
|
365
|
-
an example of running it from the CLI and from inside a play.
|
|
366
|
-
|
|
367
|
-
Examples in the output:
|
|
368
|
-
(default) required inputs filled in, first output read
|
|
369
|
-
--verbose every input filled in, every output read; also shows
|
|
370
|
-
secondary fields
|
|
371
|
-
--cli-example only the CLI example, with how inputs and outputs work
|
|
372
|
-
--play-example only the in-play example, with how inputs and outputs work
|
|
373
|
-
--no-example no examples
|
|
374
|
-
|
|
375
|
-
Features:
|
|
376
|
-
A tool lists its features: parts with their own description, such as the
|
|
377
|
-
model an AI tool runs. --feature <name> describes one at its default value,
|
|
378
|
-
--feature <name>=<value> at another, e.g. --feature model=openai/gpt-5.6-luna.
|
|
379
|
-
|
|
380
|
-
Schema size and format:
|
|
381
|
-
Secondary fields (diagnostics, attempt logs, echoes of input) are left out
|
|
382
|
-
by default; the output names them, and --verbose shows them.
|
|
383
|
-
--fields email,miss_reason shows only the fields you name, plus every
|
|
384
|
-
required input, and names the rest. Use it when you know what you need.
|
|
385
|
-
A schema over ${SCHEMA_LINE_LIMIT} lines is folded: deeper objects show only their field
|
|
386
|
-
names. A shape used more than once is printed once under Types.
|
|
387
|
-
--full-schema the normal output, with the schema not folded
|
|
388
|
-
--schema-only only the schema, not folded, and nothing else
|
|
389
|
-
--json the same facts as JSON: fields keyed by name, with what
|
|
390
|
-
each means and, for a tool, where it is in the result;
|
|
391
|
-
secondary fields are named in "hidden"
|
|
392
|
-
--json --full-schema the whole catalog record, as tools describe and
|
|
393
|
-
plays describe print it
|
|
394
|
-
--schema-only --json
|
|
395
|
-
only the input and output JSON Schemas; use this for a
|
|
396
|
-
program, or for a schema too large to read
|
|
397
|
-
--out <path> save any of the above to a file instead of printing it
|
|
398
|
-
|
|
399
|
-
Play page:
|
|
400
|
-
For a play, the output ends with its play page URL (JSON: dashboardUrl).
|
|
401
|
-
--web-url print only that URL; with --json, {"dashboardUrl": ...}.
|
|
402
|
-
Fails for a tool or monitor type, which have no play page.
|
|
403
|
-
|
|
404
|
-
Older commands:
|
|
405
|
-
deepline tools describe and deepline plays describe are this command limited
|
|
406
|
-
to one kind. Their own flags still work: --pricing-only, --examples-only,
|
|
407
|
-
--model and --estimate-payload on tools; --json <fields> on plays.
|
|
408
|
-
|
|
409
|
-
Examples:
|
|
410
|
-
deepline describe hunter_email_verifier
|
|
411
|
-
deepline describe person-linkedin-to-email
|
|
412
|
-
deepline describe my-play --prebuilt
|
|
413
|
-
deepline describe ai_ark_people_search --full-schema
|
|
414
|
-
deepline describe prebuilt/person-to-email-batch --web-url
|
|
415
|
-
deepline describe ai_ark_people_search --schema-only --out schema.json
|
|
416
|
-
`
|
|
417
|
-
).action(async (name, options) => {
|
|
418
|
-
process.exitCode = await describeAnything(name, options);
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
283
|
export {
|
|
422
|
-
|
|
423
|
-
|
|
284
|
+
describeLookupsFor,
|
|
285
|
+
describeName
|
|
424
286
|
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/tool-output.ts
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _fs = require('fs');
|
|
9
|
+
var _os = require('os');
|
|
10
|
+
var _path = require('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 = _nullishCoalesce(_optionalChain([directRows, 'optionalAccess', _ => _.some, 'call', _2 => _2(
|
|
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(_optionalChain([options, 'optionalAccess', _3 => _3.listExtractorPaths])) ? _optionalChain([options, 'optionalAccess', _4 => _4.listExtractorPaths, 'access', _5 => _5.filter, 'call', _6 => _6(
|
|
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
|
+
const roots = candidateRoots(payload);
|
|
116
|
+
const v2Raw = roots.find((root) => root.path === "toolResponse.raw");
|
|
117
|
+
for (const root of v2Raw ? [v2Raw] : roots) {
|
|
118
|
+
const candidate = findBestArrayCandidate(root.value, _nullishCoalesce(root.path, () => ( "")));
|
|
119
|
+
if (!candidate || candidate.rows.length === 0) continue;
|
|
120
|
+
return {
|
|
121
|
+
rows: candidate.rows,
|
|
122
|
+
strategy: "auto_detected",
|
|
123
|
+
sourcePath: candidate.path || root.path
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
function projectRowOutput(conversion) {
|
|
129
|
+
return {
|
|
130
|
+
rows: conversion.rows,
|
|
131
|
+
rowCount: conversion.rows.length,
|
|
132
|
+
columns: columnsForRows(conversion.rows),
|
|
133
|
+
previewRows: conversion.rows.slice(0, 5),
|
|
134
|
+
strategy: conversion.strategy,
|
|
135
|
+
sourcePath: conversion.sourcePath
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function ensureOutputDir() {
|
|
139
|
+
const outputDir = _path.join.call(void 0, _os.homedir.call(void 0, ), ".local", "share", "deepline", "data");
|
|
140
|
+
_fs.mkdirSync.call(void 0, outputDir, { recursive: true });
|
|
141
|
+
return outputDir;
|
|
142
|
+
}
|
|
143
|
+
function writeJsonOutputFile(payload, stem) {
|
|
144
|
+
const outputDir = ensureOutputDir();
|
|
145
|
+
const outputPath = _path.join.call(void 0, outputDir, `${stem}_${Date.now()}.json`);
|
|
146
|
+
_fs.writeFileSync.call(void 0, outputPath, JSON.stringify(payload, null, 2), "utf-8");
|
|
147
|
+
return outputPath;
|
|
148
|
+
}
|
|
149
|
+
function writeCsvOutputFile(rows, stem, options) {
|
|
150
|
+
const outputPath = _optionalChain([options, 'optionalAccess', _7 => _7.outPath]) ? options.outPath : _path.join.call(void 0, ensureOutputDir(), `${stem}_${Date.now()}.csv`);
|
|
151
|
+
_fs.mkdirSync.call(void 0, _path.dirname.call(void 0, outputPath), { recursive: true });
|
|
152
|
+
const columns = columnsForRows(rows);
|
|
153
|
+
const escapeCell = (value) => {
|
|
154
|
+
const normalized = value == null ? "" : typeof value === "string" || typeof value === "number" || typeof value === "boolean" ? String(value) : JSON.stringify(value);
|
|
155
|
+
if (/[",\n]/.test(normalized)) {
|
|
156
|
+
return `"${normalized.replace(/"/g, '""')}"`;
|
|
157
|
+
}
|
|
158
|
+
return normalized;
|
|
159
|
+
};
|
|
160
|
+
const fd = _fs.openSync.call(void 0, outputPath, "w");
|
|
161
|
+
try {
|
|
162
|
+
_fs.writeSync.call(void 0, fd, `${columns.map(escapeCell).join(",")}
|
|
163
|
+
`);
|
|
164
|
+
for (const row of rows) {
|
|
165
|
+
_fs.writeSync.call(void 0,
|
|
166
|
+
fd,
|
|
167
|
+
`${columns.map((column) => escapeCell(row[column])).join(",")}
|
|
168
|
+
`
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
} finally {
|
|
172
|
+
_fs.closeSync.call(void 0, fd);
|
|
173
|
+
}
|
|
174
|
+
const previewRows = rows.slice(0, 5);
|
|
175
|
+
const previewColumns = columns.slice(0, 5);
|
|
176
|
+
const preview = [
|
|
177
|
+
previewColumns.join(","),
|
|
178
|
+
...previewRows.map(
|
|
179
|
+
(row) => previewColumns.map((column) => escapeCell(row[column])).join(",")
|
|
180
|
+
)
|
|
181
|
+
].join("\n");
|
|
182
|
+
return {
|
|
183
|
+
path: outputPath,
|
|
184
|
+
rowCount: rows.length,
|
|
185
|
+
columns,
|
|
186
|
+
preview
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function extractSummaryFields(payload) {
|
|
190
|
+
const candidates = candidateRoots(payload);
|
|
191
|
+
for (const candidate of candidates) {
|
|
192
|
+
if (!isPlainObject(candidate.value)) continue;
|
|
193
|
+
const summaryEntries = Object.entries(candidate.value).filter(
|
|
194
|
+
([, value]) => {
|
|
195
|
+
return value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
if (summaryEntries.length === 0) continue;
|
|
199
|
+
return Object.fromEntries(summaryEntries);
|
|
200
|
+
}
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
exports.tryConvertToList = tryConvertToList; exports.projectRowOutput = projectRowOutput; exports.writeJsonOutputFile = writeJsonOutputFile; exports.writeCsvOutputFile = writeCsvOutputFile; exports.extractSummaryFields = extractSummaryFields;
|