lmnr-cli 0.1.7 → 0.1.9
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/README.md +30 -362
- package/dist/index.cjs +139 -98
- package/dist/index.cjs.map +1 -1
- package/package.json +8 -7
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//#region
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -8,16 +8,12 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
21
17
|
}
|
|
22
18
|
return to;
|
|
23
19
|
};
|
|
@@ -25,7 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
21
|
value: mod,
|
|
26
22
|
enumerable: true
|
|
27
23
|
}) : target, mod));
|
|
28
|
-
|
|
29
24
|
//#endregion
|
|
30
25
|
let commander = require("commander");
|
|
31
26
|
let fs = require("fs");
|
|
@@ -40,6 +35,8 @@ csv_parser = __toESM(csv_parser);
|
|
|
40
35
|
let export_to_csv = require("export-to-csv");
|
|
41
36
|
let fs_promises = require("fs/promises");
|
|
42
37
|
fs_promises = __toESM(fs_promises);
|
|
38
|
+
let cli_table3 = require("cli-table3");
|
|
39
|
+
cli_table3 = __toESM(cli_table3);
|
|
43
40
|
let chokidar = require("chokidar");
|
|
44
41
|
chokidar = __toESM(chokidar);
|
|
45
42
|
let http = require("http");
|
|
@@ -49,10 +46,8 @@ let eventsource_parser = require("eventsource-parser");
|
|
|
49
46
|
let child_process = require("child_process");
|
|
50
47
|
let readline = require("readline");
|
|
51
48
|
readline = __toESM(readline);
|
|
52
|
-
|
|
53
49
|
//#region package.json
|
|
54
|
-
var version$1 = "0.1.
|
|
55
|
-
|
|
50
|
+
var version$1 = "0.1.9";
|
|
56
51
|
//#endregion
|
|
57
52
|
//#region ../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
|
|
58
53
|
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -115,10 +110,9 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
115
110
|
"browser": { "fs": false }
|
|
116
111
|
};
|
|
117
112
|
}));
|
|
118
|
-
|
|
119
113
|
//#endregion
|
|
120
|
-
//#region
|
|
121
|
-
var
|
|
114
|
+
//#region ../client/dist/index.mjs
|
|
115
|
+
var import_main = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
122
116
|
const fs$1 = require("fs");
|
|
123
117
|
const path$1 = require("path");
|
|
124
118
|
const os = require("os");
|
|
@@ -292,11 +286,11 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
292
286
|
}
|
|
293
287
|
let lastError;
|
|
294
288
|
const parsedAll = {};
|
|
295
|
-
for (const path$
|
|
296
|
-
const parsed = DotenvModule.parse(fs$1.readFileSync(path$
|
|
289
|
+
for (const path$5 of optionPaths) try {
|
|
290
|
+
const parsed = DotenvModule.parse(fs$1.readFileSync(path$5, { encoding }));
|
|
297
291
|
DotenvModule.populate(parsedAll, parsed, options);
|
|
298
292
|
} catch (e) {
|
|
299
|
-
if (debug) _debug(`Failed to load ${path$
|
|
293
|
+
if (debug) _debug(`Failed to load ${path$5} ${e.message}`);
|
|
300
294
|
lastError = e;
|
|
301
295
|
}
|
|
302
296
|
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
@@ -393,12 +387,8 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
393
387
|
module.exports.parse = DotenvModule.parse;
|
|
394
388
|
module.exports.populate = DotenvModule.populate;
|
|
395
389
|
module.exports = DotenvModule;
|
|
396
|
-
}));
|
|
397
|
-
|
|
398
|
-
//#endregion
|
|
399
|
-
//#region ../client/dist/index.mjs
|
|
400
|
-
var import_main = require_main();
|
|
401
|
-
var version = "0.8.15";
|
|
390
|
+
})))();
|
|
391
|
+
var version = "0.8.18";
|
|
402
392
|
function getLangVersion() {
|
|
403
393
|
if (typeof process !== "undefined" && process.versions && process.versions.node) return `node-${process.versions.node}`;
|
|
404
394
|
if (typeof navigator !== "undefined" && navigator.userAgent) return `browser-${navigator.userAgent}`;
|
|
@@ -425,11 +415,11 @@ var BrowserEventsResource = class extends BaseResource {
|
|
|
425
415
|
constructor(baseHttpUrl, projectApiKey) {
|
|
426
416
|
super(baseHttpUrl, projectApiKey);
|
|
427
417
|
}
|
|
428
|
-
async send({ sessionId, traceId, events
|
|
418
|
+
async send({ sessionId, traceId, events }) {
|
|
429
419
|
const payload = {
|
|
430
420
|
sessionId,
|
|
431
421
|
traceId,
|
|
432
|
-
events
|
|
422
|
+
events,
|
|
433
423
|
source: getLangVersion() ?? "javascript",
|
|
434
424
|
sdkVersion: version
|
|
435
425
|
};
|
|
@@ -781,10 +771,10 @@ var EvalsResource = class extends BaseResource {
|
|
|
781
771
|
if (lastResponse && !lastResponse.ok) await this.handleError(lastResponse);
|
|
782
772
|
}
|
|
783
773
|
};
|
|
784
|
-
var EvaluatorScoreSourceType = /* @__PURE__ */ function(EvaluatorScoreSourceType
|
|
785
|
-
EvaluatorScoreSourceType
|
|
786
|
-
EvaluatorScoreSourceType
|
|
787
|
-
return EvaluatorScoreSourceType
|
|
774
|
+
var EvaluatorScoreSourceType = /* @__PURE__ */ function(EvaluatorScoreSourceType) {
|
|
775
|
+
EvaluatorScoreSourceType["Evaluator"] = "Evaluator";
|
|
776
|
+
EvaluatorScoreSourceType["Code"] = "Code";
|
|
777
|
+
return EvaluatorScoreSourceType;
|
|
788
778
|
}(EvaluatorScoreSourceType || {});
|
|
789
779
|
/**
|
|
790
780
|
* Resource for creating evaluator scores
|
|
@@ -1017,7 +1007,6 @@ var LaminarClient = class {
|
|
|
1017
1007
|
return this._tags;
|
|
1018
1008
|
}
|
|
1019
1009
|
};
|
|
1020
|
-
|
|
1021
1010
|
//#endregion
|
|
1022
1011
|
//#region src/utils/logger.ts
|
|
1023
1012
|
function initializeLogger(options) {
|
|
@@ -1029,7 +1018,6 @@ function initializeLogger(options) {
|
|
|
1029
1018
|
destination: 2
|
|
1030
1019
|
}));
|
|
1031
1020
|
}
|
|
1032
|
-
|
|
1033
1021
|
//#endregion
|
|
1034
1022
|
//#region src/utils/file.ts
|
|
1035
1023
|
const logger$5 = initializeLogger();
|
|
@@ -1212,7 +1200,6 @@ const printToConsole = (data, format = "json") => {
|
|
|
1212
1200
|
} else if (format === "jsonl") data.forEach((item) => console.log(JSON.stringify(item)));
|
|
1213
1201
|
else throw new Error(`Unsupported output format: ${String(format)}. (supported formats: json, csv, jsonl)`);
|
|
1214
1202
|
};
|
|
1215
|
-
|
|
1216
1203
|
//#endregion
|
|
1217
1204
|
//#region src/utils/output.ts
|
|
1218
1205
|
/**
|
|
@@ -1230,7 +1217,67 @@ function outputJsonError(error, exitCode = 1) {
|
|
|
1230
1217
|
console.log(JSON.stringify({ error: error instanceof Error ? error.message : String(error) }));
|
|
1231
1218
|
process.exit(exitCode);
|
|
1232
1219
|
}
|
|
1233
|
-
|
|
1220
|
+
//#endregion
|
|
1221
|
+
//#region src/utils/table.ts
|
|
1222
|
+
const DEFAULT_TERMINAL_WIDTH = 80;
|
|
1223
|
+
const PADDING_RIGHT = 2;
|
|
1224
|
+
const noBorderChars = {
|
|
1225
|
+
top: "",
|
|
1226
|
+
"top-mid": "",
|
|
1227
|
+
"top-left": "",
|
|
1228
|
+
"top-right": "",
|
|
1229
|
+
bottom: "",
|
|
1230
|
+
"bottom-mid": "",
|
|
1231
|
+
"bottom-left": "",
|
|
1232
|
+
"bottom-right": "",
|
|
1233
|
+
left: "",
|
|
1234
|
+
"left-mid": "",
|
|
1235
|
+
mid: "",
|
|
1236
|
+
"mid-mid": "",
|
|
1237
|
+
right: "",
|
|
1238
|
+
"right-mid": "",
|
|
1239
|
+
middle: ""
|
|
1240
|
+
};
|
|
1241
|
+
function getTerminalWidth() {
|
|
1242
|
+
return process.stdout.columns || DEFAULT_TERMINAL_WIDTH;
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Calculate column widths that fit within the terminal width.
|
|
1246
|
+
* Distributes available space proportionally based on content width.
|
|
1247
|
+
*/
|
|
1248
|
+
function fitColumnWidths(contentWidths, terminalWidth) {
|
|
1249
|
+
const overhead = contentWidths.length * PADDING_RIGHT;
|
|
1250
|
+
const totalContentWidth = contentWidths.reduce((sum, w) => sum + w, 0);
|
|
1251
|
+
if (totalContentWidth + overhead <= terminalWidth) return;
|
|
1252
|
+
const availableContent = terminalWidth - overhead;
|
|
1253
|
+
const minColWidth = 5;
|
|
1254
|
+
return contentWidths.map((w) => Math.max(minColWidth + PADDING_RIGHT, Math.floor(w / totalContentWidth * availableContent) + PADDING_RIGHT));
|
|
1255
|
+
}
|
|
1256
|
+
function truncate(str, maxLen) {
|
|
1257
|
+
if (maxLen < 1) return str;
|
|
1258
|
+
if (str.length <= maxLen) return str;
|
|
1259
|
+
return str.slice(0, maxLen - 1) + "…";
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Render a borderless table from column headers and row data.
|
|
1263
|
+
* Automatically truncates content when the table exceeds terminal width.
|
|
1264
|
+
*/
|
|
1265
|
+
function renderTable(head, rows) {
|
|
1266
|
+
const terminalWidth = getTerminalWidth();
|
|
1267
|
+
const colWidths = fitColumnWidths(head.map((h, i) => rows.reduce((max, row) => Math.max(max, (row[i] ?? "").length), h.length)), terminalWidth);
|
|
1268
|
+
const table = new cli_table3.default({
|
|
1269
|
+
head: colWidths ? head.map((h, i) => truncate(h, colWidths[i] - PADDING_RIGHT)) : head,
|
|
1270
|
+
chars: noBorderChars,
|
|
1271
|
+
style: {
|
|
1272
|
+
"padding-left": 0,
|
|
1273
|
+
"padding-right": PADDING_RIGHT
|
|
1274
|
+
},
|
|
1275
|
+
...colWidths && { colWidths }
|
|
1276
|
+
});
|
|
1277
|
+
if (colWidths) for (const row of rows) table.push(row.map((cell, i) => truncate(cell, colWidths[i] - PADDING_RIGHT)));
|
|
1278
|
+
else for (const row of rows) table.push(row);
|
|
1279
|
+
return table.toString();
|
|
1280
|
+
}
|
|
1234
1281
|
//#endregion
|
|
1235
1282
|
//#region src/commands/dataset/index.ts
|
|
1236
1283
|
const logger$4 = initializeLogger();
|
|
@@ -1278,14 +1325,19 @@ const handleDatasetsList = async (options) => {
|
|
|
1278
1325
|
console.log("No datasets found.");
|
|
1279
1326
|
return;
|
|
1280
1327
|
}
|
|
1281
|
-
const
|
|
1282
|
-
const createdAtWidth = 19;
|
|
1283
|
-
console.log(`\n${"ID".padEnd(idWidth)} ${"Created At".padEnd(createdAtWidth)} Name`);
|
|
1284
|
-
console.log(`${"-".repeat(idWidth)} ${"-".repeat(createdAtWidth)} ${"-".repeat(20)}`);
|
|
1285
|
-
for (const dataset of datasets) {
|
|
1328
|
+
const rows = datasets.map((dataset) => {
|
|
1286
1329
|
const createdAtStr = new Date(dataset.createdAt).toISOString().replace("T", " ").substring(0, 19);
|
|
1287
|
-
|
|
1288
|
-
|
|
1330
|
+
return [
|
|
1331
|
+
dataset.id,
|
|
1332
|
+
createdAtStr,
|
|
1333
|
+
dataset.name
|
|
1334
|
+
];
|
|
1335
|
+
});
|
|
1336
|
+
console.log(renderTable([
|
|
1337
|
+
"ID",
|
|
1338
|
+
"Created At",
|
|
1339
|
+
"Name"
|
|
1340
|
+
], rows));
|
|
1289
1341
|
console.log(`\nTotal: ${datasets.length} dataset(s)\n`);
|
|
1290
1342
|
} catch (error) {
|
|
1291
1343
|
if (options.json) outputJsonError(error);
|
|
@@ -1421,7 +1473,6 @@ const handleDatasetsCreate = async (name, paths, options) => {
|
|
|
1421
1473
|
process.exit(1);
|
|
1422
1474
|
}
|
|
1423
1475
|
};
|
|
1424
|
-
|
|
1425
1476
|
//#endregion
|
|
1426
1477
|
//#region src/cache-server.ts
|
|
1427
1478
|
const DEFAULT_START_PORT = 35667;
|
|
@@ -1490,13 +1541,13 @@ async function startCacheServer(startPort = DEFAULT_START_PORT) {
|
|
|
1490
1541
|
}
|
|
1491
1542
|
if (req.method === "POST" && req.url === "/cached") {
|
|
1492
1543
|
try {
|
|
1493
|
-
const { path
|
|
1494
|
-
if (typeof path
|
|
1544
|
+
const { path, index } = await parseBody(req);
|
|
1545
|
+
if (typeof path !== "string" || typeof index !== "number") {
|
|
1495
1546
|
res.writeHead(400, { "Content-Type": "application/json" });
|
|
1496
1547
|
res.end(JSON.stringify({ error: "Invalid request: path (string) and index (number) required" }));
|
|
1497
1548
|
return;
|
|
1498
1549
|
}
|
|
1499
|
-
const cacheKey = `${index}:${path
|
|
1550
|
+
const cacheKey = `${index}:${path}`;
|
|
1500
1551
|
const response = {
|
|
1501
1552
|
span: cache.get(cacheKey),
|
|
1502
1553
|
pathToCount: metadata.pathToCount,
|
|
@@ -1534,7 +1585,6 @@ async function startCacheServer(startPort = DEFAULT_START_PORT) {
|
|
|
1534
1585
|
server.on("error", reject);
|
|
1535
1586
|
});
|
|
1536
1587
|
}
|
|
1537
|
-
|
|
1538
1588
|
//#endregion
|
|
1539
1589
|
//#region src/sse-client.ts
|
|
1540
1590
|
const HEARTBEAT_INTERVAL = 5e3;
|
|
@@ -1703,14 +1753,6 @@ var SSEClient = class extends events.EventEmitter {
|
|
|
1703
1753
|
function createSSEClient(options) {
|
|
1704
1754
|
return new SSEClient(options);
|
|
1705
1755
|
}
|
|
1706
|
-
|
|
1707
|
-
//#endregion
|
|
1708
|
-
//#region ../types/dist/index.mjs
|
|
1709
|
-
/**
|
|
1710
|
-
* Message prefix for protocol messages in stdout
|
|
1711
|
-
*/
|
|
1712
|
-
const WORKER_MESSAGE_PREFIX = "__LMNR_WORKER__:";
|
|
1713
|
-
|
|
1714
1756
|
//#endregion
|
|
1715
1757
|
//#region src/subprocess/executor.ts
|
|
1716
1758
|
const logger$3 = initializeLogger();
|
|
@@ -1725,7 +1767,7 @@ var SubprocessManager = class {
|
|
|
1725
1767
|
* Execute a subprocess and track it
|
|
1726
1768
|
*/
|
|
1727
1769
|
async execute(options) {
|
|
1728
|
-
const { command, args, config
|
|
1770
|
+
const { command, args, config } = options;
|
|
1729
1771
|
const child = (0, child_process.spawn)(command, args, { stdio: [
|
|
1730
1772
|
"pipe",
|
|
1731
1773
|
"pipe",
|
|
@@ -1739,8 +1781,8 @@ var SubprocessManager = class {
|
|
|
1739
1781
|
input: child.stdout,
|
|
1740
1782
|
crlfDelay: Infinity
|
|
1741
1783
|
}).on("line", (line) => {
|
|
1742
|
-
if (line.startsWith(
|
|
1743
|
-
const messageJson = line.substring(
|
|
1784
|
+
if (line.startsWith("__LMNR_WORKER__:")) try {
|
|
1785
|
+
const messageJson = line.substring(16);
|
|
1744
1786
|
const message = JSON.parse(messageJson);
|
|
1745
1787
|
switch (message.type) {
|
|
1746
1788
|
case "log":
|
|
@@ -1754,7 +1796,7 @@ var SubprocessManager = class {
|
|
|
1754
1796
|
}
|
|
1755
1797
|
} catch {
|
|
1756
1798
|
logger$3.debug("Failed to parse worker protocol message. Printing raw line");
|
|
1757
|
-
console.log(line.substring(
|
|
1799
|
+
console.log(line.substring(16));
|
|
1758
1800
|
}
|
|
1759
1801
|
else console.log(line);
|
|
1760
1802
|
});
|
|
@@ -1774,7 +1816,7 @@ var SubprocessManager = class {
|
|
|
1774
1816
|
this.currentProcess = null;
|
|
1775
1817
|
reject(/* @__PURE__ */ new Error(`Failed to spawn worker: ${error.message}`));
|
|
1776
1818
|
});
|
|
1777
|
-
child.stdin?.write(JSON.stringify(config
|
|
1819
|
+
child.stdin?.write(JSON.stringify(config) + "\n");
|
|
1778
1820
|
child.stdin?.end();
|
|
1779
1821
|
});
|
|
1780
1822
|
}
|
|
@@ -1803,7 +1845,6 @@ var SubprocessManager = class {
|
|
|
1803
1845
|
return this.currentProcess !== null;
|
|
1804
1846
|
}
|
|
1805
1847
|
};
|
|
1806
|
-
|
|
1807
1848
|
//#endregion
|
|
1808
1849
|
//#region src/worker-registry.ts
|
|
1809
1850
|
/**
|
|
@@ -1880,7 +1921,6 @@ function getWorkerCommand(filePath, options) {
|
|
|
1880
1921
|
}
|
|
1881
1922
|
return worker;
|
|
1882
1923
|
}
|
|
1883
|
-
|
|
1884
1924
|
//#endregion
|
|
1885
1925
|
//#region src/commands/dev/metadata.ts
|
|
1886
1926
|
const logger$2 = initializeLogger();
|
|
@@ -1981,8 +2021,8 @@ const discoverTypeScriptMetadata = async (filePath, options) => {
|
|
|
1981
2021
|
* Helper to execute subprocess commands
|
|
1982
2022
|
*/
|
|
1983
2023
|
const execCommand = async (command, args) => new Promise((resolve, reject) => {
|
|
1984
|
-
const { spawn
|
|
1985
|
-
const child = spawn
|
|
2024
|
+
const { spawn } = require("child_process");
|
|
2025
|
+
const child = spawn(command, args);
|
|
1986
2026
|
let stdout = "";
|
|
1987
2027
|
let stderr = "";
|
|
1988
2028
|
child.stdout.on("data", (data) => {
|
|
@@ -2112,7 +2152,6 @@ const discoverFunctionMetadata = async (filePathOrModule, options) => {
|
|
|
2112
2152
|
params: []
|
|
2113
2153
|
};
|
|
2114
2154
|
};
|
|
2115
|
-
|
|
2116
2155
|
//#endregion
|
|
2117
2156
|
//#region src/commands/dev/index.ts
|
|
2118
2157
|
const logger$1 = initializeLogger();
|
|
@@ -2179,8 +2218,8 @@ const handleRunEvent = async (event, sessionId, filePathOrModule, client, cacheS
|
|
|
2179
2218
|
if (!spansByPath[path$2]) spansByPath[path$2] = [];
|
|
2180
2219
|
spansByPath[path$2].push(span);
|
|
2181
2220
|
}
|
|
2182
|
-
for (const [path$
|
|
2183
|
-
const maxCount = path_to_count?.[path$
|
|
2221
|
+
for (const [path$3, pathSpans] of Object.entries(spansByPath)) {
|
|
2222
|
+
const maxCount = path_to_count?.[path$3] || 0;
|
|
2184
2223
|
const spansToCache = pathSpans.slice(0, maxCount);
|
|
2185
2224
|
spansToCache.forEach((span, index) => {
|
|
2186
2225
|
let parsedInput;
|
|
@@ -2207,10 +2246,10 @@ const handleRunEvent = async (event, sessionId, filePathOrModule, client, cacheS
|
|
|
2207
2246
|
output: parsedOutput,
|
|
2208
2247
|
attributes: parsedAttributes
|
|
2209
2248
|
};
|
|
2210
|
-
const cacheKey = `${index}:${path$
|
|
2249
|
+
const cacheKey = `${index}:${path$3}`;
|
|
2211
2250
|
cache.set(cacheKey, cachedSpan);
|
|
2212
2251
|
});
|
|
2213
|
-
logger$1.info(`Cached ${spansToCache.length} spans for path: ${path$
|
|
2252
|
+
logger$1.info(`Cached ${spansToCache.length} spans for path: ${path$3}`);
|
|
2214
2253
|
}
|
|
2215
2254
|
setMetadata({
|
|
2216
2255
|
pathToCount: path_to_count || {},
|
|
@@ -2272,8 +2311,8 @@ const handleRunEvent = async (event, sessionId, filePathOrModule, client, cacheS
|
|
|
2272
2311
|
sessionId,
|
|
2273
2312
|
status: "FINISHED"
|
|
2274
2313
|
});
|
|
2275
|
-
} catch (error
|
|
2276
|
-
logger$1.error(`Error setting debugger session status: ${error
|
|
2314
|
+
} catch (error) {
|
|
2315
|
+
logger$1.error(`Error setting debugger session status: ${error instanceof Error ? error.message : error}`);
|
|
2277
2316
|
}
|
|
2278
2317
|
}
|
|
2279
2318
|
};
|
|
@@ -2315,7 +2354,7 @@ async function runDev(filePath, options = {}) {
|
|
|
2315
2354
|
}
|
|
2316
2355
|
logger$1.debug("Setting up file watcher...");
|
|
2317
2356
|
const watcher = chokidar.default.watch(".", {
|
|
2318
|
-
ignored: (path$
|
|
2357
|
+
ignored: (path$4) => {
|
|
2319
2358
|
const ignoredDirs = [
|
|
2320
2359
|
"node_modules",
|
|
2321
2360
|
".git",
|
|
@@ -2337,8 +2376,8 @@ async function runDev(filePath, options = {}) {
|
|
|
2337
2376
|
".cache",
|
|
2338
2377
|
".DS_Store"
|
|
2339
2378
|
];
|
|
2340
|
-
if (path$
|
|
2341
|
-
if (path$
|
|
2379
|
+
if (path$4.split(/[/\\]/).some((segment) => ignoredDirs.includes(segment))) return true;
|
|
2380
|
+
if (path$4.endsWith(".log") || path$4.endsWith(".map")) return true;
|
|
2342
2381
|
return false;
|
|
2343
2382
|
},
|
|
2344
2383
|
persistent: true,
|
|
@@ -2406,9 +2445,9 @@ async function runDev(filePath, options = {}) {
|
|
|
2406
2445
|
});
|
|
2407
2446
|
sseClient.on("handshake", (event) => {
|
|
2408
2447
|
const projectId = event.data.project_id;
|
|
2409
|
-
const sessionId
|
|
2448
|
+
const sessionId = event.data.session_id;
|
|
2410
2449
|
const frontendUrl = getFrontendUrl(options.baseUrl, options.frontendPort);
|
|
2411
|
-
if (!didLogHandshake) logger$1.info(`View your session at ${frontendUrl}/project/${projectId}/debugger-sessions/${sessionId
|
|
2450
|
+
if (!didLogHandshake) logger$1.info(`View your session at ${frontendUrl}/project/${projectId}/debugger-sessions/${sessionId}`);
|
|
2412
2451
|
didLogHandshake = true;
|
|
2413
2452
|
});
|
|
2414
2453
|
sseClient.on("error", (error) => {
|
|
@@ -2476,7 +2515,6 @@ async function runDev(filePath, options = {}) {
|
|
|
2476
2515
|
});
|
|
2477
2516
|
}
|
|
2478
2517
|
}
|
|
2479
|
-
|
|
2480
2518
|
//#endregion
|
|
2481
2519
|
//#region src/commands/sql/index.ts
|
|
2482
2520
|
const logger = initializeLogger();
|
|
@@ -2497,12 +2535,8 @@ const handleSqlQuery = async (query, options) => {
|
|
|
2497
2535
|
return;
|
|
2498
2536
|
}
|
|
2499
2537
|
const columns = Object.keys(rows[0]);
|
|
2500
|
-
const
|
|
2501
|
-
|
|
2502
|
-
const divider = widths.map((w) => "-".repeat(w)).join(" ");
|
|
2503
|
-
console.log(`\n${header}`);
|
|
2504
|
-
console.log(divider);
|
|
2505
|
-
for (const row of rows) console.log(columns.map((col, i) => String(row[col] ?? "").padEnd(widths[i])).join(" "));
|
|
2538
|
+
const tableRows = rows.map((row) => columns.map((col) => String(row[col] ?? "")));
|
|
2539
|
+
console.log(renderTable(columns, tableRows));
|
|
2506
2540
|
console.log(`\n${rows.length} row(s)\n`);
|
|
2507
2541
|
} catch (error) {
|
|
2508
2542
|
if (options.json) outputJsonError(error);
|
|
@@ -2510,7 +2544,6 @@ const handleSqlQuery = async (query, options) => {
|
|
|
2510
2544
|
process.exit(1);
|
|
2511
2545
|
}
|
|
2512
2546
|
};
|
|
2513
|
-
|
|
2514
2547
|
//#endregion
|
|
2515
2548
|
//#region src/commands/sql/schema.ts
|
|
2516
2549
|
const SQL_SCHEMA_HELP = `
|
|
@@ -2557,7 +2590,6 @@ Available tables:
|
|
|
2557
2590
|
id (UUID), created_at (DateTime64), dataset_id (UUID),
|
|
2558
2591
|
data (String), target (String), metadata (String)
|
|
2559
2592
|
`;
|
|
2560
|
-
|
|
2561
2593
|
//#endregion
|
|
2562
2594
|
//#region src/index.ts
|
|
2563
2595
|
async function main() {
|
|
@@ -2606,17 +2638,26 @@ Examples:
|
|
|
2606
2638
|
process.stdout.write(SQL_SCHEMA_HELP);
|
|
2607
2639
|
});
|
|
2608
2640
|
program.addHelpText("after", `
|
|
2641
|
+
Authentication:
|
|
2642
|
+
Most commands require a project API key. Provide it in one of two ways:
|
|
2643
|
+
1. Environment variable: export LMNR_PROJECT_API_KEY=<your-key>
|
|
2644
|
+
2. CLI flag: --project-api-key <your-key>
|
|
2645
|
+
Get your key at https://www.laminar.sh (Settings > Project API Keys).
|
|
2646
|
+
|
|
2609
2647
|
Examples:
|
|
2610
|
-
lmnr-cli dev agent.ts
|
|
2611
|
-
lmnr-cli dev agent.py
|
|
2612
|
-
lmnr-cli dev -m src.agent
|
|
2613
|
-
lmnr-cli dataset list --json
|
|
2614
|
-
lmnr-cli dataset push data.jsonl -n my-dataset --json
|
|
2615
|
-
lmnr-cli dataset pull output.jsonl -n my-dataset --json
|
|
2616
|
-
lmnr-cli sql query "SELECT * FROM spans LIMIT 10" --json
|
|
2617
|
-
lmnr-cli sql query "SELECT t.id, s.name FROM traces t
|
|
2618
|
-
|
|
2619
|
-
|
|
2648
|
+
lmnr-cli dev agent.ts # Debugger TypeScript entrypoint
|
|
2649
|
+
lmnr-cli dev agent.py # Debugger Python script mode
|
|
2650
|
+
lmnr-cli dev -m src.agent # Debugger Python module mode
|
|
2651
|
+
lmnr-cli dataset list --json # List all datasets
|
|
2652
|
+
lmnr-cli dataset push data.jsonl -n my-dataset --json # Push data to a dataset
|
|
2653
|
+
lmnr-cli dataset pull output.jsonl -n my-dataset --json # Pull data from a dataset
|
|
2654
|
+
lmnr-cli sql query "SELECT * FROM spans LIMIT 10" --json # Query spans
|
|
2655
|
+
lmnr-cli sql query "SELECT t.id, s.name FROM traces t JOIN spans s ON t.id = s.trace_id" --json
|
|
2656
|
+
lmnr-cli sql schema # Show available tables
|
|
2657
|
+
|
|
2658
|
+
For more information about the Laminar platfrom:
|
|
2659
|
+
Documentation: https://laminar.sh/docs
|
|
2660
|
+
Dashboard: https://www.laminar.sh
|
|
2620
2661
|
`);
|
|
2621
2662
|
await program.parseAsync();
|
|
2622
2663
|
}
|
|
@@ -2624,6 +2665,6 @@ main().catch((err) => {
|
|
|
2624
2665
|
console.error(err instanceof Error ? err.message : err);
|
|
2625
2666
|
process.exit(1);
|
|
2626
2667
|
});
|
|
2627
|
-
|
|
2628
2668
|
//#endregion
|
|
2669
|
+
|
|
2629
2670
|
//# sourceMappingURL=index.cjs.map
|