lmnr-cli 0.1.8 → 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/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- //#region rolldown:runtime
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
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
13
- key = keys[i];
14
- if (!__hasOwnProp.call(to, key) && key !== except) {
15
- __defProp(to, key, {
16
- get: ((k) => from[k]).bind(null, key),
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");
@@ -51,10 +46,8 @@ let eventsource_parser = require("eventsource-parser");
51
46
  let child_process = require("child_process");
52
47
  let readline = require("readline");
53
48
  readline = __toESM(readline);
54
-
55
49
  //#region package.json
56
- var version$1 = "0.1.8";
57
-
50
+ var version$1 = "0.1.9";
58
51
  //#endregion
59
52
  //#region ../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
60
53
  var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
@@ -117,10 +110,9 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
117
110
  "browser": { "fs": false }
118
111
  };
119
112
  }));
120
-
121
113
  //#endregion
122
- //#region ../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
123
- var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
114
+ //#region ../client/dist/index.mjs
115
+ var import_main = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
124
116
  const fs$1 = require("fs");
125
117
  const path$1 = require("path");
126
118
  const os = require("os");
@@ -294,11 +286,11 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
294
286
  }
295
287
  let lastError;
296
288
  const parsedAll = {};
297
- for (const path$2 of optionPaths) try {
298
- const parsed = DotenvModule.parse(fs$1.readFileSync(path$2, { encoding }));
289
+ for (const path$5 of optionPaths) try {
290
+ const parsed = DotenvModule.parse(fs$1.readFileSync(path$5, { encoding }));
299
291
  DotenvModule.populate(parsedAll, parsed, options);
300
292
  } catch (e) {
301
- if (debug) _debug(`Failed to load ${path$2} ${e.message}`);
293
+ if (debug) _debug(`Failed to load ${path$5} ${e.message}`);
302
294
  lastError = e;
303
295
  }
304
296
  const populated = DotenvModule.populate(processEnv, parsedAll, options);
@@ -395,12 +387,8 @@ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
395
387
  module.exports.parse = DotenvModule.parse;
396
388
  module.exports.populate = DotenvModule.populate;
397
389
  module.exports = DotenvModule;
398
- }));
399
-
400
- //#endregion
401
- //#region ../client/dist/index.mjs
402
- var import_main = require_main();
403
- var version = "0.8.15";
390
+ })))();
391
+ var version = "0.8.18";
404
392
  function getLangVersion() {
405
393
  if (typeof process !== "undefined" && process.versions && process.versions.node) return `node-${process.versions.node}`;
406
394
  if (typeof navigator !== "undefined" && navigator.userAgent) return `browser-${navigator.userAgent}`;
@@ -427,11 +415,11 @@ var BrowserEventsResource = class extends BaseResource {
427
415
  constructor(baseHttpUrl, projectApiKey) {
428
416
  super(baseHttpUrl, projectApiKey);
429
417
  }
430
- async send({ sessionId, traceId, events: events$1 }) {
418
+ async send({ sessionId, traceId, events }) {
431
419
  const payload = {
432
420
  sessionId,
433
421
  traceId,
434
- events: events$1,
422
+ events,
435
423
  source: getLangVersion() ?? "javascript",
436
424
  sdkVersion: version
437
425
  };
@@ -783,10 +771,10 @@ var EvalsResource = class extends BaseResource {
783
771
  if (lastResponse && !lastResponse.ok) await this.handleError(lastResponse);
784
772
  }
785
773
  };
786
- var EvaluatorScoreSourceType = /* @__PURE__ */ function(EvaluatorScoreSourceType$1) {
787
- EvaluatorScoreSourceType$1["Evaluator"] = "Evaluator";
788
- EvaluatorScoreSourceType$1["Code"] = "Code";
789
- return EvaluatorScoreSourceType$1;
774
+ var EvaluatorScoreSourceType = /* @__PURE__ */ function(EvaluatorScoreSourceType) {
775
+ EvaluatorScoreSourceType["Evaluator"] = "Evaluator";
776
+ EvaluatorScoreSourceType["Code"] = "Code";
777
+ return EvaluatorScoreSourceType;
790
778
  }(EvaluatorScoreSourceType || {});
791
779
  /**
792
780
  * Resource for creating evaluator scores
@@ -1019,7 +1007,6 @@ var LaminarClient = class {
1019
1007
  return this._tags;
1020
1008
  }
1021
1009
  };
1022
-
1023
1010
  //#endregion
1024
1011
  //#region src/utils/logger.ts
1025
1012
  function initializeLogger(options) {
@@ -1031,7 +1018,6 @@ function initializeLogger(options) {
1031
1018
  destination: 2
1032
1019
  }));
1033
1020
  }
1034
-
1035
1021
  //#endregion
1036
1022
  //#region src/utils/file.ts
1037
1023
  const logger$5 = initializeLogger();
@@ -1214,7 +1200,6 @@ const printToConsole = (data, format = "json") => {
1214
1200
  } else if (format === "jsonl") data.forEach((item) => console.log(JSON.stringify(item)));
1215
1201
  else throw new Error(`Unsupported output format: ${String(format)}. (supported formats: json, csv, jsonl)`);
1216
1202
  };
1217
-
1218
1203
  //#endregion
1219
1204
  //#region src/utils/output.ts
1220
1205
  /**
@@ -1232,7 +1217,6 @@ function outputJsonError(error, exitCode = 1) {
1232
1217
  console.log(JSON.stringify({ error: error instanceof Error ? error.message : String(error) }));
1233
1218
  process.exit(exitCode);
1234
1219
  }
1235
-
1236
1220
  //#endregion
1237
1221
  //#region src/utils/table.ts
1238
1222
  const DEFAULT_TERMINAL_WIDTH = 80;
@@ -1294,7 +1278,6 @@ function renderTable(head, rows) {
1294
1278
  else for (const row of rows) table.push(row);
1295
1279
  return table.toString();
1296
1280
  }
1297
-
1298
1281
  //#endregion
1299
1282
  //#region src/commands/dataset/index.ts
1300
1283
  const logger$4 = initializeLogger();
@@ -1490,7 +1473,6 @@ const handleDatasetsCreate = async (name, paths, options) => {
1490
1473
  process.exit(1);
1491
1474
  }
1492
1475
  };
1493
-
1494
1476
  //#endregion
1495
1477
  //#region src/cache-server.ts
1496
1478
  const DEFAULT_START_PORT = 35667;
@@ -1559,13 +1541,13 @@ async function startCacheServer(startPort = DEFAULT_START_PORT) {
1559
1541
  }
1560
1542
  if (req.method === "POST" && req.url === "/cached") {
1561
1543
  try {
1562
- const { path: path$2, index } = await parseBody(req);
1563
- if (typeof path$2 !== "string" || typeof index !== "number") {
1544
+ const { path, index } = await parseBody(req);
1545
+ if (typeof path !== "string" || typeof index !== "number") {
1564
1546
  res.writeHead(400, { "Content-Type": "application/json" });
1565
1547
  res.end(JSON.stringify({ error: "Invalid request: path (string) and index (number) required" }));
1566
1548
  return;
1567
1549
  }
1568
- const cacheKey = `${index}:${path$2}`;
1550
+ const cacheKey = `${index}:${path}`;
1569
1551
  const response = {
1570
1552
  span: cache.get(cacheKey),
1571
1553
  pathToCount: metadata.pathToCount,
@@ -1603,7 +1585,6 @@ async function startCacheServer(startPort = DEFAULT_START_PORT) {
1603
1585
  server.on("error", reject);
1604
1586
  });
1605
1587
  }
1606
-
1607
1588
  //#endregion
1608
1589
  //#region src/sse-client.ts
1609
1590
  const HEARTBEAT_INTERVAL = 5e3;
@@ -1772,14 +1753,6 @@ var SSEClient = class extends events.EventEmitter {
1772
1753
  function createSSEClient(options) {
1773
1754
  return new SSEClient(options);
1774
1755
  }
1775
-
1776
- //#endregion
1777
- //#region ../types/dist/index.mjs
1778
- /**
1779
- * Message prefix for protocol messages in stdout
1780
- */
1781
- const WORKER_MESSAGE_PREFIX = "__LMNR_WORKER__:";
1782
-
1783
1756
  //#endregion
1784
1757
  //#region src/subprocess/executor.ts
1785
1758
  const logger$3 = initializeLogger();
@@ -1794,7 +1767,7 @@ var SubprocessManager = class {
1794
1767
  * Execute a subprocess and track it
1795
1768
  */
1796
1769
  async execute(options) {
1797
- const { command, args, config: config$1 } = options;
1770
+ const { command, args, config } = options;
1798
1771
  const child = (0, child_process.spawn)(command, args, { stdio: [
1799
1772
  "pipe",
1800
1773
  "pipe",
@@ -1808,8 +1781,8 @@ var SubprocessManager = class {
1808
1781
  input: child.stdout,
1809
1782
  crlfDelay: Infinity
1810
1783
  }).on("line", (line) => {
1811
- if (line.startsWith(WORKER_MESSAGE_PREFIX)) try {
1812
- const messageJson = line.substring(WORKER_MESSAGE_PREFIX.length);
1784
+ if (line.startsWith("__LMNR_WORKER__:")) try {
1785
+ const messageJson = line.substring(16);
1813
1786
  const message = JSON.parse(messageJson);
1814
1787
  switch (message.type) {
1815
1788
  case "log":
@@ -1823,7 +1796,7 @@ var SubprocessManager = class {
1823
1796
  }
1824
1797
  } catch {
1825
1798
  logger$3.debug("Failed to parse worker protocol message. Printing raw line");
1826
- console.log(line.substring(WORKER_MESSAGE_PREFIX.length));
1799
+ console.log(line.substring(16));
1827
1800
  }
1828
1801
  else console.log(line);
1829
1802
  });
@@ -1843,7 +1816,7 @@ var SubprocessManager = class {
1843
1816
  this.currentProcess = null;
1844
1817
  reject(/* @__PURE__ */ new Error(`Failed to spawn worker: ${error.message}`));
1845
1818
  });
1846
- child.stdin?.write(JSON.stringify(config$1) + "\n");
1819
+ child.stdin?.write(JSON.stringify(config) + "\n");
1847
1820
  child.stdin?.end();
1848
1821
  });
1849
1822
  }
@@ -1872,7 +1845,6 @@ var SubprocessManager = class {
1872
1845
  return this.currentProcess !== null;
1873
1846
  }
1874
1847
  };
1875
-
1876
1848
  //#endregion
1877
1849
  //#region src/worker-registry.ts
1878
1850
  /**
@@ -1949,7 +1921,6 @@ function getWorkerCommand(filePath, options) {
1949
1921
  }
1950
1922
  return worker;
1951
1923
  }
1952
-
1953
1924
  //#endregion
1954
1925
  //#region src/commands/dev/metadata.ts
1955
1926
  const logger$2 = initializeLogger();
@@ -2050,8 +2021,8 @@ const discoverTypeScriptMetadata = async (filePath, options) => {
2050
2021
  * Helper to execute subprocess commands
2051
2022
  */
2052
2023
  const execCommand = async (command, args) => new Promise((resolve, reject) => {
2053
- const { spawn: spawn$1 } = require("child_process");
2054
- const child = spawn$1(command, args);
2024
+ const { spawn } = require("child_process");
2025
+ const child = spawn(command, args);
2055
2026
  let stdout = "";
2056
2027
  let stderr = "";
2057
2028
  child.stdout.on("data", (data) => {
@@ -2181,7 +2152,6 @@ const discoverFunctionMetadata = async (filePathOrModule, options) => {
2181
2152
  params: []
2182
2153
  };
2183
2154
  };
2184
-
2185
2155
  //#endregion
2186
2156
  //#region src/commands/dev/index.ts
2187
2157
  const logger$1 = initializeLogger();
@@ -2248,8 +2218,8 @@ const handleRunEvent = async (event, sessionId, filePathOrModule, client, cacheS
2248
2218
  if (!spansByPath[path$2]) spansByPath[path$2] = [];
2249
2219
  spansByPath[path$2].push(span);
2250
2220
  }
2251
- for (const [path$2, pathSpans] of Object.entries(spansByPath)) {
2252
- const maxCount = path_to_count?.[path$2] || 0;
2221
+ for (const [path$3, pathSpans] of Object.entries(spansByPath)) {
2222
+ const maxCount = path_to_count?.[path$3] || 0;
2253
2223
  const spansToCache = pathSpans.slice(0, maxCount);
2254
2224
  spansToCache.forEach((span, index) => {
2255
2225
  let parsedInput;
@@ -2276,10 +2246,10 @@ const handleRunEvent = async (event, sessionId, filePathOrModule, client, cacheS
2276
2246
  output: parsedOutput,
2277
2247
  attributes: parsedAttributes
2278
2248
  };
2279
- const cacheKey = `${index}:${path$2}`;
2249
+ const cacheKey = `${index}:${path$3}`;
2280
2250
  cache.set(cacheKey, cachedSpan);
2281
2251
  });
2282
- logger$1.info(`Cached ${spansToCache.length} spans for path: ${path$2}`);
2252
+ logger$1.info(`Cached ${spansToCache.length} spans for path: ${path$3}`);
2283
2253
  }
2284
2254
  setMetadata({
2285
2255
  pathToCount: path_to_count || {},
@@ -2341,8 +2311,8 @@ const handleRunEvent = async (event, sessionId, filePathOrModule, client, cacheS
2341
2311
  sessionId,
2342
2312
  status: "FINISHED"
2343
2313
  });
2344
- } catch (error$1) {
2345
- logger$1.error(`Error setting debugger session status: ${error$1 instanceof Error ? error$1.message : error$1}`);
2314
+ } catch (error) {
2315
+ logger$1.error(`Error setting debugger session status: ${error instanceof Error ? error.message : error}`);
2346
2316
  }
2347
2317
  }
2348
2318
  };
@@ -2384,7 +2354,7 @@ async function runDev(filePath, options = {}) {
2384
2354
  }
2385
2355
  logger$1.debug("Setting up file watcher...");
2386
2356
  const watcher = chokidar.default.watch(".", {
2387
- ignored: (path$2) => {
2357
+ ignored: (path$4) => {
2388
2358
  const ignoredDirs = [
2389
2359
  "node_modules",
2390
2360
  ".git",
@@ -2406,8 +2376,8 @@ async function runDev(filePath, options = {}) {
2406
2376
  ".cache",
2407
2377
  ".DS_Store"
2408
2378
  ];
2409
- if (path$2.split(/[/\\]/).some((segment) => ignoredDirs.includes(segment))) return true;
2410
- if (path$2.endsWith(".log") || path$2.endsWith(".map")) return true;
2379
+ if (path$4.split(/[/\\]/).some((segment) => ignoredDirs.includes(segment))) return true;
2380
+ if (path$4.endsWith(".log") || path$4.endsWith(".map")) return true;
2411
2381
  return false;
2412
2382
  },
2413
2383
  persistent: true,
@@ -2475,9 +2445,9 @@ async function runDev(filePath, options = {}) {
2475
2445
  });
2476
2446
  sseClient.on("handshake", (event) => {
2477
2447
  const projectId = event.data.project_id;
2478
- const sessionId$1 = event.data.session_id;
2448
+ const sessionId = event.data.session_id;
2479
2449
  const frontendUrl = getFrontendUrl(options.baseUrl, options.frontendPort);
2480
- if (!didLogHandshake) logger$1.info(`View your session at ${frontendUrl}/project/${projectId}/debugger-sessions/${sessionId$1}`);
2450
+ if (!didLogHandshake) logger$1.info(`View your session at ${frontendUrl}/project/${projectId}/debugger-sessions/${sessionId}`);
2481
2451
  didLogHandshake = true;
2482
2452
  });
2483
2453
  sseClient.on("error", (error) => {
@@ -2545,7 +2515,6 @@ async function runDev(filePath, options = {}) {
2545
2515
  });
2546
2516
  }
2547
2517
  }
2548
-
2549
2518
  //#endregion
2550
2519
  //#region src/commands/sql/index.ts
2551
2520
  const logger = initializeLogger();
@@ -2575,7 +2544,6 @@ const handleSqlQuery = async (query, options) => {
2575
2544
  process.exit(1);
2576
2545
  }
2577
2546
  };
2578
-
2579
2547
  //#endregion
2580
2548
  //#region src/commands/sql/schema.ts
2581
2549
  const SQL_SCHEMA_HELP = `
@@ -2622,7 +2590,6 @@ Available tables:
2622
2590
  id (UUID), created_at (DateTime64), dataset_id (UUID),
2623
2591
  data (String), target (String), metadata (String)
2624
2592
  `;
2625
-
2626
2593
  //#endregion
2627
2594
  //#region src/index.ts
2628
2595
  async function main() {
@@ -2671,6 +2638,12 @@ Examples:
2671
2638
  process.stdout.write(SQL_SCHEMA_HELP);
2672
2639
  });
2673
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
+
2674
2647
  Examples:
2675
2648
  lmnr-cli dev agent.ts # Debugger TypeScript entrypoint
2676
2649
  lmnr-cli dev agent.py # Debugger Python script mode
@@ -2681,6 +2654,10 @@ Examples:
2681
2654
  lmnr-cli sql query "SELECT * FROM spans LIMIT 10" --json # Query spans
2682
2655
  lmnr-cli sql query "SELECT t.id, s.name FROM traces t JOIN spans s ON t.id = s.trace_id" --json
2683
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
2684
2661
  `);
2685
2662
  await program.parseAsync();
2686
2663
  }
@@ -2688,6 +2665,6 @@ main().catch((err) => {
2688
2665
  console.error(err instanceof Error ? err.message : err);
2689
2666
  process.exit(1);
2690
2667
  });
2691
-
2692
2668
  //#endregion
2669
+
2693
2670
  //# sourceMappingURL=index.cjs.map