@graphty/remote-logger 1.1.1 → 1.2.0

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 (110) hide show
  1. package/README.md +318 -10
  2. package/dist/client/RemoteLogClient.d.ts +2 -0
  3. package/dist/client/RemoteLogClient.d.ts.map +1 -1
  4. package/dist/client/RemoteLogClient.js +35 -4
  5. package/dist/client/RemoteLogClient.js.map +1 -1
  6. package/dist/client/types.d.ts +13 -0
  7. package/dist/client/types.d.ts.map +1 -1
  8. package/dist/mcp/index.d.ts +9 -0
  9. package/dist/mcp/index.d.ts.map +1 -0
  10. package/dist/mcp/index.js +9 -0
  11. package/dist/mcp/index.js.map +1 -0
  12. package/dist/mcp/mcp-server.d.ts +32 -0
  13. package/dist/mcp/mcp-server.d.ts.map +1 -0
  14. package/dist/mcp/mcp-server.js +270 -0
  15. package/dist/mcp/mcp-server.js.map +1 -0
  16. package/dist/mcp/tools/index.d.ts +14 -0
  17. package/dist/mcp/tools/index.d.ts.map +1 -0
  18. package/dist/mcp/tools/index.js +14 -0
  19. package/dist/mcp/tools/index.js.map +1 -0
  20. package/dist/mcp/tools/logs-clear.d.ts +76 -0
  21. package/dist/mcp/tools/logs-clear.d.ts.map +1 -0
  22. package/dist/mcp/tools/logs-clear.js +58 -0
  23. package/dist/mcp/tools/logs-clear.js.map +1 -0
  24. package/dist/mcp/tools/logs-get-all.d.ts +60 -0
  25. package/dist/mcp/tools/logs-get-all.d.ts.map +1 -0
  26. package/dist/mcp/tools/logs-get-all.js +50 -0
  27. package/dist/mcp/tools/logs-get-all.js.map +1 -0
  28. package/dist/mcp/tools/logs-get-errors.d.ts +65 -0
  29. package/dist/mcp/tools/logs-get-errors.d.ts.map +1 -0
  30. package/dist/mcp/tools/logs-get-errors.js +46 -0
  31. package/dist/mcp/tools/logs-get-errors.js.map +1 -0
  32. package/dist/mcp/tools/logs-get-file-path.d.ts +75 -0
  33. package/dist/mcp/tools/logs-get-file-path.d.ts.map +1 -0
  34. package/dist/mcp/tools/logs-get-file-path.js +90 -0
  35. package/dist/mcp/tools/logs-get-file-path.js.map +1 -0
  36. package/dist/mcp/tools/logs-get-recent.d.ts +89 -0
  37. package/dist/mcp/tools/logs-get-recent.d.ts.map +1 -0
  38. package/dist/mcp/tools/logs-get-recent.js +74 -0
  39. package/dist/mcp/tools/logs-get-recent.js.map +1 -0
  40. package/dist/mcp/tools/logs-list-sessions.d.ts +64 -0
  41. package/dist/mcp/tools/logs-list-sessions.d.ts.map +1 -0
  42. package/dist/mcp/tools/logs-list-sessions.js +48 -0
  43. package/dist/mcp/tools/logs-list-sessions.js.map +1 -0
  44. package/dist/mcp/tools/logs-receive.d.ts +150 -0
  45. package/dist/mcp/tools/logs-receive.d.ts.map +1 -0
  46. package/dist/mcp/tools/logs-receive.js +68 -0
  47. package/dist/mcp/tools/logs-receive.js.map +1 -0
  48. package/dist/mcp/tools/logs-search.d.ts +91 -0
  49. package/dist/mcp/tools/logs-search.d.ts.map +1 -0
  50. package/dist/mcp/tools/logs-search.js +68 -0
  51. package/dist/mcp/tools/logs-search.js.map +1 -0
  52. package/dist/mcp/tools/logs-status.d.ts +45 -0
  53. package/dist/mcp/tools/logs-status.d.ts.map +1 -0
  54. package/dist/mcp/tools/logs-status.js +45 -0
  55. package/dist/mcp/tools/logs-status.js.map +1 -0
  56. package/dist/server/dual-server.d.ts +76 -0
  57. package/dist/server/dual-server.d.ts.map +1 -0
  58. package/dist/server/dual-server.js +214 -0
  59. package/dist/server/dual-server.js.map +1 -0
  60. package/dist/server/index.d.ts +5 -1
  61. package/dist/server/index.d.ts.map +1 -1
  62. package/dist/server/index.js +5 -1
  63. package/dist/server/index.js.map +1 -1
  64. package/dist/server/jsonl-writer.d.ts +93 -0
  65. package/dist/server/jsonl-writer.d.ts.map +1 -0
  66. package/dist/server/jsonl-writer.js +205 -0
  67. package/dist/server/jsonl-writer.js.map +1 -0
  68. package/dist/server/log-server.d.ts +62 -11
  69. package/dist/server/log-server.d.ts.map +1 -1
  70. package/dist/server/log-server.js +237 -101
  71. package/dist/server/log-server.js.map +1 -1
  72. package/dist/server/log-storage.d.ts +301 -0
  73. package/dist/server/log-storage.d.ts.map +1 -0
  74. package/dist/server/log-storage.js +408 -0
  75. package/dist/server/log-storage.js.map +1 -0
  76. package/dist/server/marker-utils.d.ts +69 -0
  77. package/dist/server/marker-utils.d.ts.map +1 -0
  78. package/dist/server/marker-utils.js +118 -0
  79. package/dist/server/marker-utils.js.map +1 -0
  80. package/dist/vite/index.d.ts +8 -0
  81. package/dist/vite/index.d.ts.map +1 -0
  82. package/dist/vite/index.js +8 -0
  83. package/dist/vite/index.js.map +1 -0
  84. package/dist/vite/plugin.d.ts +42 -0
  85. package/dist/vite/plugin.d.ts.map +1 -0
  86. package/dist/vite/plugin.js +46 -0
  87. package/dist/vite/plugin.js.map +1 -0
  88. package/package.json +12 -2
  89. package/src/client/RemoteLogClient.ts +52 -4
  90. package/src/client/types.ts +13 -0
  91. package/src/mcp/index.ts +25 -0
  92. package/src/mcp/mcp-server.ts +364 -0
  93. package/src/mcp/tools/index.ts +69 -0
  94. package/src/mcp/tools/logs-clear.ts +86 -0
  95. package/src/mcp/tools/logs-get-all.ts +78 -0
  96. package/src/mcp/tools/logs-get-errors.ts +71 -0
  97. package/src/mcp/tools/logs-get-file-path.ts +121 -0
  98. package/src/mcp/tools/logs-get-recent.ts +104 -0
  99. package/src/mcp/tools/logs-list-sessions.ts +71 -0
  100. package/src/mcp/tools/logs-receive.ts +96 -0
  101. package/src/mcp/tools/logs-search.ts +95 -0
  102. package/src/mcp/tools/logs-status.ts +69 -0
  103. package/src/server/dual-server.ts +308 -0
  104. package/src/server/index.ts +37 -0
  105. package/src/server/jsonl-writer.ts +277 -0
  106. package/src/server/log-server.ts +311 -119
  107. package/src/server/log-storage.ts +651 -0
  108. package/src/server/marker-utils.ts +144 -0
  109. package/src/vite/index.ts +8 -0
  110. package/src/vite/plugin.ts +59 -0
package/README.md CHANGED
@@ -2,15 +2,31 @@
2
2
 
3
3
  Remote logging client and server for browser debugging. Send console logs from browsers to a terminal-based log server for easy debugging of web applications.
4
4
 
5
+ ## Why Remote Logging?
6
+
7
+ Browser applications run in a sandbox - their `console.log()` output appears in browser DevTools but is not accessible to CLI tools, terminal sessions, or AI assistants. Remote logging bridges this gap by sending browser logs to a server where they can be viewed, searched, and analyzed.
8
+
9
+ **Use cases where remote logging shines:**
10
+
11
+ - **Storybook & Component Development** - See console output without switching to browser DevTools
12
+ - **Mobile Web Apps** - Phones and tablets require USB debugging to access DevTools
13
+ - **VR/AR Applications** - You can't see a browser console while wearing a headset
14
+ - **Embedded Devices** - Kiosks, smart displays, and IoT devices without keyboard access
15
+ - **CI/CD & Automated Testing** - Capture browser logs during headless test runs
16
+ - **LLM-Assisted Debugging** - AI assistants can read, interpret, and act on logs without requiring user interaction with browser DevTools
17
+
5
18
  ## Features
6
19
 
7
20
  - **Browser Client**: Lightweight client for sending logs from browser to server
8
21
  - **Log Server**: HTTPS/HTTP server with colored terminal output and REST API
22
+ - **MCP Server**: Model Context Protocol server for Claude Code integration
9
23
  - **Console Capture UI**: Floating widget to copy/download/view browser console logs
10
24
  - **Batching & Retry**: Efficient log delivery with automatic retry on failure
11
25
  - **Session Tracking**: Unique session IDs for correlating logs across page loads
26
+ - **Project Markers**: Filter logs by git worktree or project name
12
27
  - **Throttling**: Configurable rate limiting for high-frequency log messages
13
- - **File Logging**: Optional JSONL file output for persistent log storage
28
+ - **File Logging**: JSONL file streaming organized by project marker
29
+ - **Log Retention**: Automatic cleanup of old logs (configurable, default 7 days)
14
30
 
15
31
  ## Installation
16
32
 
@@ -26,10 +42,10 @@ pnpm add @graphty/remote-logger
26
42
 
27
43
  ```bash
28
44
  # Using npx
29
- npx remote-log-server --http --port 9080
45
+ npx remote-log-server --port 9080
30
46
 
31
47
  # Or via CLI after installation
32
- remote-log-server --http --port 9080
48
+ remote-log-server --port 9080
33
49
  ```
34
50
 
35
51
  ### 2. Add Client to Your Application
@@ -84,19 +100,31 @@ Usage:
84
100
  Options:
85
101
  --port, -p <port> Port to listen on (default: 9080)
86
102
  --host, -h <host> Hostname to bind to (default: localhost)
87
- --cert, -c <path> Path to SSL certificate file
88
- --key, -k <path> Path to SSL private key file
103
+ --cert, -c <path> Path to SSL certificate file (enables HTTPS)
104
+ --key, -k <path> Path to SSL private key file (enables HTTPS)
89
105
  --log-file, -l <path> Write logs to file (JSONL format)
90
- --http Use HTTP instead of HTTPS
91
106
  --quiet, -q Suppress startup banner
107
+ --mcp-only Start only MCP server (no HTTP)
108
+ --http-only Start only HTTP server (no MCP)
92
109
  --help Show help message
93
110
 
111
+ Protocol:
112
+ HTTP is used by default. To use HTTPS, provide both --cert and --key.
113
+
94
114
  Examples:
95
- npx remote-log-server # HTTPS with auto-generated cert
96
- npx remote-log-server --http --port 9080 # HTTP on port 9080
97
- npx remote-log-server --cert cert.pem --key key.pem # Custom SSL certs
115
+ npx remote-log-server # Dual mode: HTTP + MCP (default)
116
+ npx remote-log-server --port 9080 # HTTP on port 9080 + MCP
117
+ npx remote-log-server --mcp-only # MCP only (for Claude Code)
118
+ npx remote-log-server --http-only # HTTP only (legacy mode)
119
+ npx remote-log-server --cert cert.pem --key key.pem # Use HTTPS with custom certs
98
120
  ```
99
121
 
122
+ ### Environment Variables
123
+
124
+ | Variable | Default | Description |
125
+ |----------|---------|-------------|
126
+ | `REMOTE_LOG_RETENTION_DAYS` | `7` | Number of days to retain logs before cleanup |
127
+
100
128
  ## API Reference
101
129
 
102
130
  ### RemoteLogClient
@@ -123,6 +151,8 @@ const client = createRemoteLogClient(options);
123
151
  | `maxRetries` | `number` | `3` | Max retry attempts on failure |
124
152
  | `retryDelayMs` | `number` | `1000` | Base delay between retries (uses exponential backoff) |
125
153
  | `throttlePatterns` | `ThrottlePattern[]` | `[]` | Patterns to throttle (see below) |
154
+ | `projectMarker` | `string` | auto | Project identifier for filtering (auto-detected from Vite globals) |
155
+ | `worktreePath` | `string` | auto | Full worktree path for debugging (auto-detected from Vite globals) |
126
156
 
127
157
  #### Throttling High-Frequency Logs
128
158
 
@@ -283,7 +313,208 @@ Health check endpoint for monitoring.
283
313
  { "status": "ok", "sessions": 3 }
284
314
  ```
285
315
 
286
- ### ConsoleCaptureUI
316
+ ## MCP Server (Claude Code Integration)
317
+
318
+ The remote-logger includes a Model Context Protocol (MCP) server that allows Claude Code to directly query and manage logs. This enables AI-assisted debugging by letting Claude Code see browser console output in real-time.
319
+
320
+ ### Setup with Claude Code
321
+
322
+ Add the following to your Claude Code MCP configuration (`~/.config/claude-code/mcp.json` or project settings):
323
+
324
+ ```json
325
+ {
326
+ "mcpServers": {
327
+ "remote-logger": {
328
+ "command": "npx",
329
+ "args": ["remote-log-server", "--mcp-only"]
330
+ }
331
+ }
332
+ }
333
+ ```
334
+
335
+ Or if installed globally:
336
+
337
+ ```json
338
+ {
339
+ "mcpServers": {
340
+ "remote-logger": {
341
+ "command": "remote-log-server",
342
+ "args": ["--mcp-only"]
343
+ }
344
+ }
345
+ }
346
+ ```
347
+
348
+ ### Dual Mode (HTTP + MCP)
349
+
350
+ By default, the server runs in dual mode with both HTTP and MCP interfaces sharing the same log storage. This allows browsers to send logs via HTTP while Claude Code queries them via MCP.
351
+
352
+ ```bash
353
+ # Start dual server (HTTP + MCP)
354
+ npx remote-log-server --port 9080
355
+ ```
356
+
357
+ ### MCP Tools
358
+
359
+ The MCP server provides 9 tools for log management:
360
+
361
+ #### `logs_get_recent`
362
+
363
+ Get recent logs from the server, sorted by time (oldest first).
364
+
365
+ **Parameters:**
366
+ | Parameter | Type | Default | Description |
367
+ |-----------|------|---------|-------------|
368
+ | `count` | `number` | `50` | Number of logs to return (max 500) |
369
+ | `projectMarker` | `string` | - | Filter by project marker |
370
+ | `workingDirectory` | `string` | - | Derive marker from path (e.g., `/path/.worktrees/my-branch`) |
371
+ | `level` | `string` | - | Filter by log level (ERROR, WARN, INFO, DEBUG) |
372
+ | `since` | `string` | - | Only logs after this ISO timestamp |
373
+
374
+ **Example usage in Claude Code:**
375
+ > "Show me the last 20 logs from the graphty-element project"
376
+
377
+ #### `logs_status`
378
+
379
+ Get the status of the remote log server.
380
+
381
+ **Returns:**
382
+ - Server status, uptime, session count, log count, error count, memory usage
383
+ - HTTP endpoint configuration (port, host, protocol, full URL for browser clients)
384
+ - Retention settings (how long logs are kept before automatic cleanup)
385
+
386
+ **Example usage:**
387
+ > "What is the status of the remote logger?"
388
+ > "What URL should I use to configure the browser client?"
389
+ > "How long are logs retained?"
390
+
391
+ #### `logs_list_sessions`
392
+
393
+ List all logging sessions with their metadata.
394
+
395
+ **Parameters:**
396
+ | Parameter | Type | Description |
397
+ |-----------|------|-------------|
398
+ | `projectMarker` | `string` | Filter by project marker |
399
+ | `hasErrors` | `boolean` | Only show sessions with errors |
400
+
401
+ **Returns:** Array of sessions with:
402
+ - `sessionId`, `projectMarker`, `worktreePath`, `pageUrl`
403
+ - `firstLogTime`, `lastLogTime`, `logCount`, `errorCount`
404
+
405
+ **Example usage:**
406
+ > "List all logging sessions that have errors"
407
+
408
+ #### `logs_receive`
409
+
410
+ Store logs from a browser or application session.
411
+
412
+ **Parameters:**
413
+ | Parameter | Type | Required | Description |
414
+ |-----------|------|----------|-------------|
415
+ | `sessionId` | `string` | Yes | Unique session identifier |
416
+ | `logs` | `array` | Yes | Array of log entries |
417
+ | `projectMarker` | `string` | No | Project identifier |
418
+ | `worktreePath` | `string` | No | Full worktree path |
419
+ | `pageUrl` | `string` | No | Browser page URL |
420
+
421
+ #### `logs_get_all`
422
+
423
+ Get all logs grouped by session.
424
+
425
+ **Parameters:**
426
+ | Parameter | Type | Description |
427
+ |-----------|------|-------------|
428
+ | `projectMarker` | `string` | Filter by project marker |
429
+
430
+ **Returns:** Object mapping session IDs to log arrays
431
+
432
+ #### `logs_get_errors`
433
+
434
+ Get only ERROR level logs.
435
+
436
+ **Parameters:**
437
+ | Parameter | Type | Description |
438
+ |-----------|------|-------------|
439
+ | `projectMarker` | `string` | Filter by project marker |
440
+ | `since` | `string` | Only errors after this timestamp |
441
+
442
+ **Example usage:**
443
+ > "Show me all errors from the current project"
444
+
445
+ #### `logs_clear`
446
+
447
+ Clear logs from the server.
448
+
449
+ **Parameters:**
450
+ | Parameter | Type | Required | Description |
451
+ |-----------|------|----------|-------------|
452
+ | `confirm` | `boolean` | Yes | Must be `true` to proceed |
453
+ | `projectMarker` | `string` | No | Only clear this project's logs |
454
+ | `sessionId` | `string` | No | Only clear this session's logs |
455
+
456
+ **Example usage:**
457
+ > "Clear all logs for the remote-logging project, confirm"
458
+
459
+ #### `logs_search`
460
+
461
+ Search logs by text pattern.
462
+
463
+ **Parameters:**
464
+ | Parameter | Type | Default | Description |
465
+ |-----------|------|---------|-------------|
466
+ | `query` | `string` | required | Search text or regex pattern |
467
+ | `regex` | `boolean` | `false` | Treat query as regex |
468
+ | `projectMarker` | `string` | - | Filter by project |
469
+ | `level` | `string` | - | Filter by log level |
470
+ | `limit` | `number` | `100` | Max results (max 1000) |
471
+
472
+ **Example usage:**
473
+ > "Search the logs for 'connection failed'"
474
+ > "Search logs for any network errors using regex 'network|timeout|connection'"
475
+
476
+ #### `logs_get_file_path`
477
+
478
+ Get the file path to the JSONL log file for a project.
479
+
480
+ **Parameters:**
481
+ | Parameter | Type | Description |
482
+ |-----------|------|-------------|
483
+ | `projectMarker` | `string` | Project marker |
484
+ | `workingDirectory` | `string` | Derive marker from path |
485
+
486
+ **Returns:** File path, existence status, and size
487
+
488
+ **Example usage:**
489
+ > "Get the log file path for this project so I can grep it"
490
+
491
+ This tool is useful for accessing logs via file-based tools like `Grep` or `Read` when you need more advanced searching capabilities.
492
+
493
+ ### Project Markers
494
+
495
+ Project markers allow you to filter logs by project, which is especially useful in monorepos or when working with multiple projects simultaneously.
496
+
497
+ Markers are determined in the following priority:
498
+ 1. Explicit `projectMarker` parameter
499
+ 2. Derived from `workingDirectory` path (extracts from `.worktrees/` or uses basename)
500
+ 3. Extracted from `sessionId` prefix (e.g., `graphty-element-123-abc` → `graphty-element`)
501
+ 4. Default: `"default"`
502
+
503
+ ### JSONL File Organization
504
+
505
+ Logs are streamed to JSONL files organized by project marker:
506
+
507
+ ```
508
+ {tmpdir}/remote-logger/
509
+ ├── graphty-element/
510
+ │ └── logs.jsonl
511
+ ├── remote-logging/
512
+ │ └── logs.jsonl
513
+ └── default/
514
+ └── logs.jsonl
515
+ ```
516
+
517
+ ## ConsoleCaptureUI
287
518
 
288
519
  A floating UI widget that captures all console output (`log`, `error`, `warn`, `info`, `debug`) and provides a menu to copy, download, view, or clear the captured logs.
289
520
 
@@ -403,6 +634,39 @@ window.onunhandledrejection = (event) => {
403
634
  };
404
635
  ```
405
636
 
637
+ ### Vite Integration (Automatic Project Markers)
638
+
639
+ Use the Vite plugin to automatically inject project markers into your browser builds:
640
+
641
+ ```typescript
642
+ // vite.config.ts
643
+ import { defineConfig } from "vite";
644
+ import { remoteLoggerPlugin } from "@graphty/remote-logger/vite";
645
+
646
+ export default defineConfig({
647
+ plugins: [remoteLoggerPlugin()],
648
+ });
649
+ ```
650
+
651
+ The plugin automatically:
652
+ - Detects if you're in a git worktree (e.g., `.worktrees/my-feature`) and uses the worktree name as the marker
653
+ - Falls back to the project directory basename for regular projects
654
+ - Injects `__REMOTE_LOG_PROJECT_MARKER__` and `__REMOTE_LOG_WORKTREE_PATH__` globals
655
+
656
+ The `RemoteLogClient` automatically reads these globals when available:
657
+
658
+ ```typescript
659
+ // These are injected by the Vite plugin
660
+ declare const __REMOTE_LOG_PROJECT_MARKER__: string | undefined;
661
+ declare const __REMOTE_LOG_WORKTREE_PATH__: string | undefined;
662
+
663
+ // Client reads them automatically
664
+ const client = new RemoteLogClient({
665
+ serverUrl: "http://localhost:9080",
666
+ // projectMarker and worktreePath are auto-detected!
667
+ });
668
+ ```
669
+
406
670
  ### Usage with graphty-element
407
671
 
408
672
  Add URL parameter to enable remote logging in Storybook:
@@ -533,6 +797,8 @@ interface RemoteLogClientOptions {
533
797
  maxRetries?: number;
534
798
  retryDelayMs?: number;
535
799
  throttlePatterns?: ThrottlePattern[];
800
+ projectMarker?: string; // Project identifier for filtering
801
+ worktreePath?: string; // Full path for debugging
536
802
  }
537
803
 
538
804
  interface LogServerOptions {
@@ -647,6 +913,48 @@ Direct client-only imports (same as main entry):
647
913
  import { RemoteLogClient } from "@graphty/remote-logger/client";
648
914
  ```
649
915
 
916
+ ### Vite Entry (`@graphty/remote-logger/vite`)
917
+
918
+ Vite plugin for automatic project marker injection:
919
+
920
+ ```typescript
921
+ import { remoteLoggerPlugin } from "@graphty/remote-logger/vite";
922
+ ```
923
+
924
+ ## Log Retention
925
+
926
+ Logs are automatically cleaned up after a configurable retention period (default: 7 days). This applies to both in-memory logs and JSONL files.
927
+
928
+ ### Configuration
929
+
930
+ Set retention via environment variable:
931
+
932
+ ```bash
933
+ export REMOTE_LOG_RETENTION_DAYS=3
934
+ npx remote-log-server
935
+ ```
936
+
937
+ Or programmatically:
938
+
939
+ ```typescript
940
+ import { LogStorage } from "@graphty/remote-logger/server";
941
+
942
+ const storage = new LogStorage({
943
+ retentionDays: 3, // Keep logs for 3 days
944
+ cleanupIntervalMs: 3600000, // Check every hour (default)
945
+ });
946
+ ```
947
+
948
+ ### How It Works
949
+
950
+ 1. **Memory cleanup**: Individual logs older than the retention period are removed. Sessions with no remaining logs are deleted entirely.
951
+
952
+ 2. **JSONL cleanup**: Project directories whose files haven't been modified within the retention period are removed.
953
+
954
+ 3. **Automatic scheduling**: Cleanup runs automatically at the configured interval (default: 1 hour).
955
+
956
+ 4. **Graceful shutdown**: Call `storage.stopCleanupTimer()` when shutting down to prevent memory leaks.
957
+
650
958
  ## License
651
959
 
652
960
  MIT
@@ -36,6 +36,8 @@ export declare class RemoteLogClient {
36
36
  private readonly maxRetries;
37
37
  private readonly retryDelayMs;
38
38
  private readonly throttlePatterns;
39
+ private readonly projectMarker;
40
+ private readonly worktreePath;
39
41
  private pendingLogs;
40
42
  private batchTimer;
41
43
  private isClosed;
@@ -1 +1 @@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,IAAI,OAAO,CAAC,IAAI,CAAC;IAoB5B;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAU/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CAEtF"}
@@ -3,6 +3,26 @@
3
3
  * Provides batching and automatic retry with exponential backoff.
4
4
  * @module client/RemoteLogClient
5
5
  */
6
+ /**
7
+ * Safely read a global variable that may or may not be defined.
8
+ * @param name - Name of the global variable
9
+ * @returns The value of the global variable, or undefined if not defined
10
+ */
11
+ function getGlobalValue(name) {
12
+ try {
13
+ if (name === "__REMOTE_LOG_PROJECT_MARKER__") {
14
+ return typeof __REMOTE_LOG_PROJECT_MARKER__ !== "undefined" ? __REMOTE_LOG_PROJECT_MARKER__ : undefined;
15
+ }
16
+ if (name === "__REMOTE_LOG_WORKTREE_PATH__") {
17
+ return typeof __REMOTE_LOG_WORKTREE_PATH__ !== "undefined" ? __REMOTE_LOG_WORKTREE_PATH__ : undefined;
18
+ }
19
+ }
20
+ catch {
21
+ // ReferenceError if the global is not defined at all
22
+ return undefined;
23
+ }
24
+ return undefined;
25
+ }
6
26
  /** Default configuration values */
7
27
  const DEFAULT_BATCH_INTERVAL_MS = 1000;
8
28
  const DEFAULT_MAX_RETRIES = 3;
@@ -61,6 +81,9 @@ export class RemoteLogClient {
61
81
  this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
62
82
  this.retryDelayMs = options.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS;
63
83
  this.throttlePatterns = options.throttlePatterns ?? [];
84
+ // Priority: explicit option > global variable
85
+ this.projectMarker = options.projectMarker ?? getGlobalValue("__REMOTE_LOG_PROJECT_MARKER__");
86
+ this.worktreePath = options.worktreePath ?? getGlobalValue("__REMOTE_LOG_WORKTREE_PATH__");
64
87
  }
65
88
  /**
66
89
  * Checks if a message should be throttled based on configured patterns.
@@ -165,15 +188,23 @@ export class RemoteLogClient {
165
188
  * @throws Error if the request fails
166
189
  */
167
190
  async sendRequest(logs) {
191
+ const requestBody = {
192
+ sessionId: this.sessionId,
193
+ logs,
194
+ };
195
+ // Only include these fields if they have values
196
+ if (this.projectMarker !== undefined) {
197
+ requestBody.projectMarker = this.projectMarker;
198
+ }
199
+ if (this.worktreePath !== undefined) {
200
+ requestBody.worktreePath = this.worktreePath;
201
+ }
168
202
  const response = await fetch(`${this.serverUrl}/log`, {
169
203
  method: "POST",
170
204
  headers: {
171
205
  "Content-Type": "application/json",
172
206
  },
173
- body: JSON.stringify({
174
- sessionId: this.sessionId,
175
- logs,
176
- }),
207
+ body: JSON.stringify(requestBody),
177
208
  });
178
209
  if (!response.ok) {
179
210
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteLogClient.js","sourceRoot":"","sources":["../../src/client/RemoteLogClient.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,mCAAmC;AACnC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAC9B,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,sBAAsB,GAAG,SAAS,CAAC;AAEzC;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,MAAc;IACrC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,OAAO,GAAG,MAAM,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,eAAe;IAkBxB;;;OAGG;IACH,YAAY,OAA+B;QAZnC,gBAAW,GAAe,EAAE,CAAC;QA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I,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,uBAAuB;QACvB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACJ;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACjE,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
@@ -43,5 +43,18 @@ export interface RemoteLogClientOptions {
43
43
  * Messages matching a pattern will only be sent once per the configured interval.
44
44
  */
45
45
  throttlePatterns?: ThrottlePattern[];
46
+ /**
47
+ * Project marker to identify logs from this project.
48
+ * If not provided, the client will attempt to read from the
49
+ * __REMOTE_LOG_PROJECT_MARKER__ global variable (injected by Vite plugin).
50
+ */
51
+ projectMarker?: string;
52
+ /**
53
+ * Full path to the worktree or project directory.
54
+ * Used for debugging and log organization.
55
+ * If not provided, the client will attempt to read from the
56
+ * __REMOTE_LOG_WORKTREE_PATH__ global variable (injected by Vite plugin).
57
+ */
58
+ worktreePath?: string;
46
59
  }
47
60
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACrB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,M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EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * MCP server module exports.
3
+ *
4
+ * Provides Model Context Protocol interface for log queries.
5
+ * @module mcp
6
+ */
7
+ export { createMcpServer, getToolNames, startMcpServer } from "./mcp-server.js";
8
+ export { logsGetRecentHandler, type LogsGetRecentInput, logsGetRecentInputSchema, type LogsGetRecentOutput, logsGetRecentTool, logsListSessionsHandler, type LogsListSessionsInput, logsListSessionsInputSchema, type LogsListSessionsOutput, logsListSessionsTool, logsStatusHandler, type LogsStatusInput, logsStatusInputSchema, type LogsStatusOutput, logsStatusTool, } from "./tools/index.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACH,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,wBAAwB,EACxB,KAAK,mBAAmB,EACxB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,sBAAsB,EAC3B,oBAAoB,EACpB,iBAAiB,EACjB,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,cAAc,GACjB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * MCP server module exports.
3
+ *
4
+ * Provides Model Context Protocol interface for log queries.
5
+ * @module mcp
6
+ */
7
+ export { createMcpServer, getToolNames, startMcpServer } from "./mcp-server.js";
8
+ export { logsGetRecentHandler, logsGetRecentInputSchema, logsGetRecentTool, logsListSessionsHandler, logsListSessionsInputSchema, logsListSessionsTool, logsStatusHandler, logsStatusInputSchema, logsStatusTool, } from "./tools/index.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EACH,oBAAoB,EAEpB,wBAAwB,EAExB,iBAAiB,EACjB,uBAAuB,EAEvB,2BAA2B,EAE3B,oBAAoB,EACpB,iBAAiB,EAEjB,qBAAqB,EAErB,cAAc,GACjB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * MCP Server for remote logging.
3
+ *
4
+ * Provides an MCP interface for Claude Code to query logs from browser
5
+ * applications. Uses STDIO transport for communication.
6
+ * @module mcp/mcp-server
7
+ */
8
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
9
+ import type { LogStorage } from "../server/log-storage.js";
10
+ /**
11
+ * Get the names of all registered tools.
12
+ * Useful for testing.
13
+ * @returns Array of registered tool names
14
+ */
15
+ export declare function getToolNames(): string[];
16
+ /**
17
+ * Create an MCP server with logging tools.
18
+ *
19
+ * Registers all logging tools and returns the configured server.
20
+ * The server is not started; use `startMcpServer` to run it.
21
+ * @param storage - The LogStorage instance to use for log operations
22
+ * @returns Configured McpServer instance
23
+ */
24
+ export declare function createMcpServer(storage: LogStorage): McpServer;
25
+ /**
26
+ * Start the MCP server with STDIO transport.
27
+ *
28
+ * This function runs the MCP server and blocks until the connection is closed.
29
+ * @param storage - The LogStorage instance to use for log operations
30
+ */
31
+ export declare function startMcpServer(storage: LogStorage): Promise<void>;
32
+ //# sourceMappingURL=mcp-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/mcp/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAyC3D;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAEvC;AAsFD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAkM9D;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAQvE"}