@graphty/remote-logger 1.2.2 → 1.2.3

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 (64) hide show
  1. package/README.md +1 -1
  2. package/dist/client/RemoteLogClient.d.ts +2 -1
  3. package/dist/client/RemoteLogClient.d.ts.map +1 -1
  4. package/dist/client/RemoteLogClient.js +20 -10
  5. package/dist/client/RemoteLogClient.js.map +1 -1
  6. package/dist/client/types.d.ts +6 -0
  7. package/dist/client/types.d.ts.map +1 -1
  8. package/dist/mcp/index.d.ts +1 -1
  9. package/dist/mcp/index.d.ts.map +1 -1
  10. package/dist/mcp/index.js +20 -1
  11. package/dist/mcp/index.js.map +1 -1
  12. package/dist/mcp/mcp-server.d.ts +5 -0
  13. package/dist/mcp/mcp-server.d.ts.map +1 -1
  14. package/dist/mcp/mcp-server.js +6 -5
  15. package/dist/mcp/mcp-server.js.map +1 -1
  16. package/dist/mcp/tools/index.d.ts +6 -6
  17. package/dist/mcp/tools/index.d.ts.map +1 -1
  18. package/dist/mcp/tools/index.js +1 -1
  19. package/dist/mcp/tools/index.js.map +1 -1
  20. package/dist/mcp/tools/logs-clear.d.ts +1 -2
  21. package/dist/mcp/tools/logs-clear.d.ts.map +1 -1
  22. package/dist/mcp/tools/logs-get-all.d.ts +1 -2
  23. package/dist/mcp/tools/logs-get-all.d.ts.map +1 -1
  24. package/dist/mcp/tools/logs-get-errors.d.ts +1 -2
  25. package/dist/mcp/tools/logs-get-errors.d.ts.map +1 -1
  26. package/dist/mcp/tools/logs-get-file-path.d.ts +8 -2
  27. package/dist/mcp/tools/logs-get-file-path.d.ts.map +1 -1
  28. package/dist/mcp/tools/logs-get-file-path.js +1 -1
  29. package/dist/mcp/tools/logs-get-file-path.js.map +1 -1
  30. package/dist/mcp/tools/logs-receive.d.ts +1 -2
  31. package/dist/mcp/tools/logs-receive.d.ts.map +1 -1
  32. package/dist/mcp/tools/logs-search.d.ts +1 -2
  33. package/dist/mcp/tools/logs-search.d.ts.map +1 -1
  34. package/dist/server/dual-server.d.ts +7 -4
  35. package/dist/server/dual-server.d.ts.map +1 -1
  36. package/dist/server/dual-server.js +108 -46
  37. package/dist/server/dual-server.js.map +1 -1
  38. package/dist/server/log-server.d.ts +2 -2
  39. package/dist/server/log-server.d.ts.map +1 -1
  40. package/dist/server/log-server.js +32 -55
  41. package/dist/server/log-server.js.map +1 -1
  42. package/dist/server/self-signed-cert.d.ts +9 -0
  43. package/dist/server/self-signed-cert.d.ts.map +1 -1
  44. package/dist/server/self-signed-cert.js +9 -0
  45. package/dist/server/self-signed-cert.js.map +1 -1
  46. package/dist/ui/ConsoleCaptureUI.d.ts.map +1 -1
  47. package/dist/ui/ConsoleCaptureUI.js +6 -1
  48. package/dist/ui/ConsoleCaptureUI.js.map +1 -1
  49. package/package.json +2 -1
  50. package/src/client/RemoteLogClient.ts +22 -11
  51. package/src/client/types.ts +6 -0
  52. package/src/mcp/index.ts +42 -0
  53. package/src/mcp/mcp-server.ts +6 -5
  54. package/src/mcp/tools/index.ts +7 -0
  55. package/src/mcp/tools/logs-clear.ts +1 -1
  56. package/src/mcp/tools/logs-get-all.ts +1 -1
  57. package/src/mcp/tools/logs-get-errors.ts +1 -1
  58. package/src/mcp/tools/logs-get-file-path.ts +2 -2
  59. package/src/mcp/tools/logs-receive.ts +1 -1
  60. package/src/mcp/tools/logs-search.ts +1 -1
  61. package/src/server/dual-server.ts +146 -53
  62. package/src/server/log-server.ts +35 -60
  63. package/src/server/self-signed-cert.ts +9 -0
  64. package/src/ui/ConsoleCaptureUI.ts +6 -1
@@ -81,7 +81,7 @@ const colors = {
81
81
  export interface LogServerOptions {
82
82
  /** Port to listen on (default: 9080) */
83
83
  port?: number;
84
- /** Hostname to bind to (default: localhost) */
84
+ /** Hostname to bind to (default: 0.0.0.0) */
85
85
  host?: string;
86
86
  /** Path to SSL certificate file (HTTPS only used if both certPath and keyPath provided) */
87
87
  certPath?: string;
@@ -477,7 +477,7 @@ export function createLogServer(options: CreateLogServerOptions): CreateLogServe
477
477
  */
478
478
  export function startLogServer(options: LogServerOptions = {}): http.Server | https.Server {
479
479
  const port = options.port ?? 9080;
480
- const host = options.host ?? "localhost";
480
+ const host = options.host ?? "0.0.0.0";
481
481
  const quiet = options.quiet ?? false;
482
482
 
483
483
  // Set up log file if specified
@@ -555,7 +555,7 @@ Usage:
555
555
 
556
556
  Options:
557
557
  --port, -p <port> Port to listen on (default: 9080)
558
- --host, -h <host> Hostname to bind to (default: localhost)
558
+ --host, -h <host> Hostname to bind to (default: 0.0.0.0)
559
559
  --cert, -c <path> Path to SSL certificate file (enables HTTPS)
560
560
  --key, -k <path> Path to SSL private key file (enables HTTPS)
561
561
  --log-file, -l <path> Write logs to file
@@ -677,87 +677,62 @@ export async function main(): Promise<void> {
677
677
 
678
678
  const { options } = result;
679
679
 
680
+ // Common server options shared across all modes
681
+ const baseOptions = {
682
+ httpPort: options.port ?? 9080,
683
+ httpHost: options.host ?? "0.0.0.0",
684
+ quiet: options.quiet ?? false,
685
+ certPath: options.certPath,
686
+ keyPath: options.keyPath,
687
+ };
688
+
680
689
  // Determine mode: mcp-only, http-only, or dual (default)
681
690
  // All modes now use createDualServer with different options
682
691
  const { createDualServer } = await import("./dual-server.js");
683
692
 
693
+ let dualServer;
694
+ let modeMessage: string;
695
+
684
696
  if (options.mcpOnly) {
685
697
  // MCP-only mode: HTTP only serves /log endpoint, MCP enabled
686
- const dualServer = await createDualServer({
687
- httpPort: options.port ?? 9080,
688
- httpHost: options.host ?? "localhost",
698
+ dualServer = await createDualServer({
699
+ ...baseOptions,
689
700
  httpEnabled: true,
690
701
  mcpEnabled: true,
691
- quiet: options.quiet ?? false,
692
702
  logReceiveOnly: true, // Only serve /log and /health endpoints
693
- certPath: options.certPath,
694
- keyPath: options.keyPath,
695
- });
696
-
697
- // Handle graceful shutdown
698
- process.on("SIGINT", () => {
699
- // eslint-disable-next-line no-console
700
- console.log("\nShutting down...");
701
- void dualServer.shutdown().then(() => {
702
- process.exit(0);
703
- });
704
703
  });
705
-
706
- if (!options.quiet) {
707
- // eslint-disable-next-line no-console
708
- console.log("MCP mode: Log receive endpoint and MCP tools running");
709
- }
704
+ modeMessage = "MCP mode: Log receive endpoint and MCP tools running";
710
705
  } else if (options.httpOnly) {
711
706
  // HTTP-only mode: All HTTP endpoints, no MCP
712
- const dualServer = await createDualServer({
713
- httpPort: options.port ?? 9080,
714
- httpHost: options.host ?? "localhost",
707
+ dualServer = await createDualServer({
708
+ ...baseOptions,
715
709
  httpEnabled: true,
716
710
  mcpEnabled: false,
717
- quiet: options.quiet ?? false,
718
- certPath: options.certPath,
719
- keyPath: options.keyPath,
720
711
  logFile: options.logFile,
721
712
  });
722
-
723
- // Handle graceful shutdown
724
- process.on("SIGINT", () => {
725
- // eslint-disable-next-line no-console
726
- console.log("\nShutting down...");
727
- void dualServer.shutdown().then(() => {
728
- process.exit(0);
729
- });
730
- });
731
-
732
- if (!options.quiet) {
733
- // eslint-disable-next-line no-console
734
- console.log("HTTP-only mode: All HTTP endpoints running");
735
- }
713
+ modeMessage = "HTTP-only mode: All HTTP endpoints running";
736
714
  } else {
737
715
  // Dual mode (default): All HTTP endpoints and MCP
738
- const dualServer = await createDualServer({
739
- httpPort: options.port ?? 9080,
740
- httpHost: options.host ?? "localhost",
716
+ dualServer = await createDualServer({
717
+ ...baseOptions,
741
718
  httpEnabled: true,
742
719
  mcpEnabled: true,
743
- quiet: options.quiet ?? false,
744
- certPath: options.certPath,
745
- keyPath: options.keyPath,
746
720
  logFile: options.logFile,
747
721
  });
722
+ modeMessage = "Dual mode: HTTP and MCP servers running";
723
+ }
748
724
 
749
- // Handle graceful shutdown
750
- process.on("SIGINT", () => {
751
- // eslint-disable-next-line no-console
752
- console.log("\nShutting down...");
753
- void dualServer.shutdown().then(() => {
754
- process.exit(0);
755
- });
725
+ // Single SIGINT handler for all modes
726
+ process.on("SIGINT", () => {
727
+ // eslint-disable-next-line no-console
728
+ console.log("\nShutting down...");
729
+ void dualServer.shutdown().then(() => {
730
+ process.exit(0);
756
731
  });
732
+ });
757
733
 
758
- if (!options.quiet) {
759
- // eslint-disable-next-line no-console
760
- console.log("Dual mode: HTTP and MCP servers running");
761
- }
734
+ if (!options.quiet) {
735
+ // eslint-disable-next-line no-console
736
+ console.log(modeMessage);
762
737
  }
763
738
  }
@@ -14,8 +14,17 @@ export interface GeneratedCert {
14
14
  /**
15
15
  * Generate a self-signed certificate for HTTPS.
16
16
  * The certificate is valid for localhost and common local development hostnames.
17
+ *
18
+ * NOTE: This function is currently unused because modern browsers reject
19
+ * self-signed certificates by default. It is retained for potential use cases:
20
+ * - Node.js clients that can disable certificate verification
21
+ * - Testing environments
22
+ * - Development setups where users manually trust the certificate
23
+ *
24
+ * For browser use, provide valid certificates via --cert and --key flags.
17
25
  * @param hostname - Optional hostname to include in the certificate (default: localhost)
18
26
  * @returns Object containing PEM-encoded certificate and private key
27
+ * @internal
19
28
  */
20
29
  export function generateSelfSignedCert(hostname = "localhost"): GeneratedCert {
21
30
  const attrs = [
@@ -313,6 +313,8 @@ export class ConsoleCaptureUI {
313
313
  */
314
314
  private setupGlobalMethods(): void {
315
315
  if (typeof window !== "undefined") {
316
+ // Create a function that returns current logs to avoid stale reference
317
+ const getCurrentLogs = (): CapturedLogEntry[] => [...this.logs];
316
318
  window.__console__ = {
317
319
  copy: () => this.copyLogs(),
318
320
  download: () => {
@@ -322,7 +324,10 @@ export class ConsoleCaptureUI {
322
324
  this.clearLogs();
323
325
  },
324
326
  get: () => this.getLogs(),
325
- logs: this.logs,
327
+ // Use getter to always return fresh copy of current logs
328
+ get logs() {
329
+ return getCurrentLogs();
330
+ },
326
331
  };
327
332
  }
328
333
  }