lunel-cli 0.1.73 → 0.1.75

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 (2) hide show
  1. package/dist/index.js +44 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -45,6 +45,11 @@ let activeGatewayUrl = DEFAULT_PROXY_URL;
45
45
  let shuttingDown = false;
46
46
  let activeControlWs = null;
47
47
  let activeDataWs = null;
48
+ function logWithTimestamp(scope, message, fields) {
49
+ const timestamp = new Date().toISOString();
50
+ const suffix = fields ? ` ${JSON.stringify(fields)}` : "";
51
+ console.log(`[${timestamp}] [${scope}] ${message}${suffix}`);
52
+ }
48
53
  const activeTunnels = new Map();
49
54
  const PORT_SYNC_INTERVAL_MS = 30_000;
50
55
  let cloudJobConfig = null;
@@ -388,12 +393,21 @@ async function handleFsRead(payload) {
388
393
  const reqPath = payload.path;
389
394
  if (!reqPath)
390
395
  throw Object.assign(new Error("path is required"), { code: "EINVAL" });
396
+ const startedAt = Date.now();
397
+ logWithTimestamp("fs-read", "starting", { path: reqPath });
391
398
  const safePath = assertSafePath(reqPath);
392
399
  // Check if binary
393
400
  const stat = await fs.stat(safePath);
394
401
  const content = await fs.readFile(safePath);
395
402
  // Detect if binary
396
403
  const isBinary = isLikelyBinaryBuffer(content.subarray(0, 8192));
404
+ logWithTimestamp("fs-read", "disk read complete", {
405
+ path: reqPath,
406
+ size: stat.size,
407
+ bufferBytes: content.length,
408
+ isBinary,
409
+ durationMs: Date.now() - startedAt,
410
+ });
397
411
  if (isBinary) {
398
412
  return {
399
413
  path: reqPath,
@@ -2152,6 +2166,9 @@ function cleanupAllTunnels() {
2152
2166
  // ============================================================================
2153
2167
  async function processMessage(message) {
2154
2168
  const { v, id, ns, action, payload } = message;
2169
+ const startedAt = Date.now();
2170
+ const pathValue = typeof payload?.path === "string" ? payload.path : null;
2171
+ logWithTimestamp("router", "request received", { id, ns, action, path: pathValue });
2155
2172
  // Validate protocol version
2156
2173
  if (v !== 1) {
2157
2174
  return {
@@ -2433,11 +2450,29 @@ async function processMessage(message) {
2433
2450
  default:
2434
2451
  throw Object.assign(new Error(`Unknown namespace: ${ns}`), { code: "EINVAL" });
2435
2452
  }
2436
- return { v: 1, id, ns, action, ok: true, payload: result };
2453
+ const response = { v: 1, id, ns, action, ok: true, payload: result };
2454
+ logWithTimestamp("router", "request completed", {
2455
+ id,
2456
+ ns,
2457
+ action,
2458
+ path: pathValue,
2459
+ durationMs: Date.now() - startedAt,
2460
+ ok: true,
2461
+ });
2462
+ return response;
2437
2463
  }
2438
2464
  catch (error) {
2439
2465
  const err = error;
2440
2466
  console.error(`[router] ${ns}.${action} error:`, err.code || "ERROR", err.message);
2467
+ logWithTimestamp("router", "request failed", {
2468
+ id,
2469
+ ns,
2470
+ action,
2471
+ path: pathValue,
2472
+ durationMs: Date.now() - startedAt,
2473
+ code: err.code || "ERROR",
2474
+ message: err.message || "Unknown error",
2475
+ });
2441
2476
  return {
2442
2477
  v: 1,
2443
2478
  id,
@@ -2453,6 +2488,14 @@ async function processMessage(message) {
2453
2488
  }
2454
2489
  }
2455
2490
  function sendResponseOnData(response, dataWs) {
2491
+ const pathValue = typeof response.payload?.path === "string" ? response.payload.path : null;
2492
+ logWithTimestamp("router", "sending response on data", {
2493
+ id: response.id,
2494
+ ns: response.ns,
2495
+ action: response.action,
2496
+ path: pathValue,
2497
+ ok: response.ok,
2498
+ });
2456
2499
  if (e2eeActive && e2eeCliToAppKey) {
2457
2500
  const { payload, ...envelope } = response;
2458
2501
  dataWs.send(JSON.stringify({ ...envelope, enc: e2eeEncrypt(payload) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lunel-cli",
3
- "version": "0.1.73",
3
+ "version": "0.1.75",
4
4
  "author": [
5
5
  {
6
6
  "name": "Soham Bharambe",