@graphty/remote-logger 0.0.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.
- package/README.md +944 -28
- package/bin/remote-log-server.js +3 -0
- package/dist/client/RemoteLogClient.d.ts +116 -0
- package/dist/client/RemoteLogClient.d.ts.map +1 -0
- package/dist/client/RemoteLogClient.js +269 -0
- package/dist/client/RemoteLogClient.js.map +1 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +6 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +60 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +6 -0
- package/dist/client/types.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +9 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/mcp-server.d.ts +32 -0
- package/dist/mcp/mcp-server.d.ts.map +1 -0
- package/dist/mcp/mcp-server.js +270 -0
- package/dist/mcp/mcp-server.js.map +1 -0
- package/dist/mcp/tools/index.d.ts +14 -0
- package/dist/mcp/tools/index.d.ts.map +1 -0
- package/dist/mcp/tools/index.js +14 -0
- package/dist/mcp/tools/index.js.map +1 -0
- package/dist/mcp/tools/logs-clear.d.ts +76 -0
- package/dist/mcp/tools/logs-clear.d.ts.map +1 -0
- package/dist/mcp/tools/logs-clear.js +58 -0
- package/dist/mcp/tools/logs-clear.js.map +1 -0
- package/dist/mcp/tools/logs-get-all.d.ts +60 -0
- package/dist/mcp/tools/logs-get-all.d.ts.map +1 -0
- package/dist/mcp/tools/logs-get-all.js +50 -0
- package/dist/mcp/tools/logs-get-all.js.map +1 -0
- package/dist/mcp/tools/logs-get-errors.d.ts +65 -0
- package/dist/mcp/tools/logs-get-errors.d.ts.map +1 -0
- package/dist/mcp/tools/logs-get-errors.js +46 -0
- package/dist/mcp/tools/logs-get-errors.js.map +1 -0
- package/dist/mcp/tools/logs-get-file-path.d.ts +75 -0
- package/dist/mcp/tools/logs-get-file-path.d.ts.map +1 -0
- package/dist/mcp/tools/logs-get-file-path.js +90 -0
- package/dist/mcp/tools/logs-get-file-path.js.map +1 -0
- package/dist/mcp/tools/logs-get-recent.d.ts +89 -0
- package/dist/mcp/tools/logs-get-recent.d.ts.map +1 -0
- package/dist/mcp/tools/logs-get-recent.js +74 -0
- package/dist/mcp/tools/logs-get-recent.js.map +1 -0
- package/dist/mcp/tools/logs-list-sessions.d.ts +64 -0
- package/dist/mcp/tools/logs-list-sessions.d.ts.map +1 -0
- package/dist/mcp/tools/logs-list-sessions.js +48 -0
- package/dist/mcp/tools/logs-list-sessions.js.map +1 -0
- package/dist/mcp/tools/logs-receive.d.ts +150 -0
- package/dist/mcp/tools/logs-receive.d.ts.map +1 -0
- package/dist/mcp/tools/logs-receive.js +68 -0
- package/dist/mcp/tools/logs-receive.js.map +1 -0
- package/dist/mcp/tools/logs-search.d.ts +91 -0
- package/dist/mcp/tools/logs-search.d.ts.map +1 -0
- package/dist/mcp/tools/logs-search.js +68 -0
- package/dist/mcp/tools/logs-search.js.map +1 -0
- package/dist/mcp/tools/logs-status.d.ts +45 -0
- package/dist/mcp/tools/logs-status.d.ts.map +1 -0
- package/dist/mcp/tools/logs-status.js +45 -0
- package/dist/mcp/tools/logs-status.js.map +1 -0
- package/dist/server/dual-server.d.ts +76 -0
- package/dist/server/dual-server.d.ts.map +1 -0
- package/dist/server/dual-server.js +214 -0
- package/dist/server/dual-server.js.map +1 -0
- package/dist/server/index.d.ts +12 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +12 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/jsonl-writer.d.ts +93 -0
- package/dist/server/jsonl-writer.d.ts.map +1 -0
- package/dist/server/jsonl-writer.js +205 -0
- package/dist/server/jsonl-writer.js.map +1 -0
- package/dist/server/log-server.d.ts +126 -0
- package/dist/server/log-server.d.ts.map +1 -0
- package/dist/server/log-server.js +589 -0
- package/dist/server/log-server.js.map +1 -0
- package/dist/server/log-storage.d.ts +301 -0
- package/dist/server/log-storage.d.ts.map +1 -0
- package/dist/server/log-storage.js +408 -0
- package/dist/server/log-storage.js.map +1 -0
- package/dist/server/marker-utils.d.ts +69 -0
- package/dist/server/marker-utils.d.ts.map +1 -0
- package/dist/server/marker-utils.js +118 -0
- package/dist/server/marker-utils.js.map +1 -0
- package/dist/server/self-signed-cert.d.ts +30 -0
- package/dist/server/self-signed-cert.d.ts.map +1 -0
- package/dist/server/self-signed-cert.js +83 -0
- package/dist/server/self-signed-cert.js.map +1 -0
- package/dist/ui/ConsoleCaptureUI.d.ts +118 -0
- package/dist/ui/ConsoleCaptureUI.d.ts.map +1 -0
- package/dist/ui/ConsoleCaptureUI.js +571 -0
- package/dist/ui/ConsoleCaptureUI.js.map +1 -0
- package/dist/ui/index.d.ts +15 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +15 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/vite/index.d.ts +8 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +8 -0
- package/dist/vite/index.js.map +1 -0
- package/dist/vite/plugin.d.ts +42 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +46 -0
- package/dist/vite/plugin.js.map +1 -0
- package/package.json +90 -7
- package/src/client/RemoteLogClient.ts +328 -0
- package/src/client/index.ts +7 -0
- package/src/client/types.ts +62 -0
- package/src/index.ts +28 -0
- package/src/mcp/index.ts +25 -0
- package/src/mcp/mcp-server.ts +364 -0
- package/src/mcp/tools/index.ts +69 -0
- package/src/mcp/tools/logs-clear.ts +86 -0
- package/src/mcp/tools/logs-get-all.ts +78 -0
- package/src/mcp/tools/logs-get-errors.ts +71 -0
- package/src/mcp/tools/logs-get-file-path.ts +121 -0
- package/src/mcp/tools/logs-get-recent.ts +104 -0
- package/src/mcp/tools/logs-list-sessions.ts +71 -0
- package/src/mcp/tools/logs-receive.ts +96 -0
- package/src/mcp/tools/logs-search.ts +95 -0
- package/src/mcp/tools/logs-status.ts +69 -0
- package/src/server/dual-server.ts +308 -0
- package/src/server/index.ts +54 -0
- package/src/server/jsonl-writer.ts +277 -0
- package/src/server/log-server.ts +763 -0
- package/src/server/log-storage.ts +651 -0
- package/src/server/marker-utils.ts +144 -0
- package/src/server/self-signed-cert.ts +93 -0
- package/src/ui/ConsoleCaptureUI.ts +649 -0
- package/src/ui/index.ts +15 -0
- package/src/vite/index.ts +8 -0
- package/src/vite/plugin.ts +59 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser client for sending log messages to a remote server.
|
|
3
|
+
* Provides batching and automatic retry with exponential backoff.
|
|
4
|
+
* @module client/RemoteLogClient
|
|
5
|
+
*/
|
|
6
|
+
import type { RemoteLogClientOptions } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Client for sending log messages to a remote logging server.
|
|
9
|
+
*
|
|
10
|
+
* Features:
|
|
11
|
+
* - Batches multiple log entries before sending
|
|
12
|
+
* - Automatic retry with exponential backoff on network failures
|
|
13
|
+
* - Unique session ID for correlating logs
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const client = new RemoteLogClient({
|
|
17
|
+
* serverUrl: "http://localhost:9080",
|
|
18
|
+
* sessionPrefix: "myapp",
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* client.log("INFO", "User logged in", { userId: 123 });
|
|
22
|
+
* client.log("DEBUG", "Loading data...");
|
|
23
|
+
*
|
|
24
|
+
* // Flush immediately when needed
|
|
25
|
+
* await client.flush();
|
|
26
|
+
*
|
|
27
|
+
* // Clean up when done
|
|
28
|
+
* await client.close();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class RemoteLogClient {
|
|
32
|
+
/** Unique identifier for this logging session */
|
|
33
|
+
readonly sessionId: string;
|
|
34
|
+
private readonly serverUrl;
|
|
35
|
+
private readonly batchIntervalMs;
|
|
36
|
+
private readonly maxRetries;
|
|
37
|
+
private readonly retryDelayMs;
|
|
38
|
+
private readonly throttlePatterns;
|
|
39
|
+
private readonly projectMarker;
|
|
40
|
+
private readonly worktreePath;
|
|
41
|
+
private pendingLogs;
|
|
42
|
+
private batchTimer;
|
|
43
|
+
private isClosed;
|
|
44
|
+
private flushPromise;
|
|
45
|
+
/** Tracks when each throttle pattern was last allowed through */
|
|
46
|
+
private throttleLastTimes;
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new RemoteLogClient.
|
|
49
|
+
* @param options - Configuration options
|
|
50
|
+
*/
|
|
51
|
+
constructor(options: RemoteLogClientOptions);
|
|
52
|
+
/**
|
|
53
|
+
* Checks if a message should be throttled based on configured patterns.
|
|
54
|
+
* Updates the last time tracking if the message is allowed through.
|
|
55
|
+
* @param message - The message to check
|
|
56
|
+
* @returns true if the message should be dropped (throttled)
|
|
57
|
+
*/
|
|
58
|
+
private shouldThrottle;
|
|
59
|
+
/**
|
|
60
|
+
* Logs a message at the specified level.
|
|
61
|
+
* @param level - Log level (e.g., "INFO", "DEBUG", "WARN", "ERROR")
|
|
62
|
+
* @param message - The log message
|
|
63
|
+
* @param data - Optional additional data to include
|
|
64
|
+
*/
|
|
65
|
+
log(level: string, message: string, data?: Record<string, unknown>): void;
|
|
66
|
+
/**
|
|
67
|
+
* Schedules a batch send after the configured interval.
|
|
68
|
+
* If a timer is already scheduled, does nothing.
|
|
69
|
+
*/
|
|
70
|
+
private scheduleBatchSend;
|
|
71
|
+
/**
|
|
72
|
+
* Sends the current batch of logs to the server.
|
|
73
|
+
* Uses retry logic with exponential backoff on failure.
|
|
74
|
+
*/
|
|
75
|
+
private sendBatch;
|
|
76
|
+
/**
|
|
77
|
+
* Sends logs with retry logic using exponential backoff.
|
|
78
|
+
* @param logs - The log entries to send
|
|
79
|
+
*/
|
|
80
|
+
private sendWithRetry;
|
|
81
|
+
/**
|
|
82
|
+
* Makes the actual HTTP request to send logs.
|
|
83
|
+
* @param logs - The log entries to send
|
|
84
|
+
* @throws Error if the request fails
|
|
85
|
+
*/
|
|
86
|
+
private sendRequest;
|
|
87
|
+
/**
|
|
88
|
+
* Helper to sleep for the specified duration.
|
|
89
|
+
* @param ms - Milliseconds to sleep
|
|
90
|
+
* @returns A promise that resolves after the specified time
|
|
91
|
+
*/
|
|
92
|
+
private sleep;
|
|
93
|
+
/**
|
|
94
|
+
* Immediately flushes all pending logs to the server.
|
|
95
|
+
* Useful before page unload or when immediate delivery is needed.
|
|
96
|
+
*/
|
|
97
|
+
flush(): Promise<void>;
|
|
98
|
+
/**
|
|
99
|
+
* Closes the client, flushing any pending logs and stopping the batch timer.
|
|
100
|
+
* After calling close(), no more logs will be accepted.
|
|
101
|
+
*/
|
|
102
|
+
close(): Promise<void>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Factory function to create a RemoteLogClient.
|
|
106
|
+
* @param options - Configuration options
|
|
107
|
+
* @returns A new RemoteLogClient instance
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const client = createRemoteLogClient({
|
|
111
|
+
* serverUrl: "http://localhost:9080",
|
|
112
|
+
* });
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export declare function createRemoteLogClient(options: RemoteLogClientOptions): RemoteLogClient;
|
|
116
|
+
//# sourceMappingURL=RemoteLogClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteLogClient.d.ts","sourceRoot":"","sources":["../../src/client/RemoteLogClient.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAY,sBAAsB,EAAmB,MAAM,YAAY,CAAC;AA+CpF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,eAAe;IACxB,iDA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provides batching and automatic retry with exponential backoff.
|
|
4
|
+
* @module client/RemoteLogClient
|
|
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
|
+
}
|
|
26
|
+
/** Default configuration values */
|
|
27
|
+
const DEFAULT_BATCH_INTERVAL_MS = 1000;
|
|
28
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
29
|
+
const DEFAULT_RETRY_DELAY_MS = 1000;
|
|
30
|
+
const DEFAULT_SESSION_PREFIX = "session";
|
|
31
|
+
/**
|
|
32
|
+
* Generates a unique session ID with the given prefix.
|
|
33
|
+
* Format: {prefix}-{timestamp}-{random}
|
|
34
|
+
* @param prefix - The prefix to use for the session ID
|
|
35
|
+
* @returns A unique session ID string
|
|
36
|
+
*/
|
|
37
|
+
function generateSessionId(prefix) {
|
|
38
|
+
const timestamp = Date.now().toString(36);
|
|
39
|
+
const random = Math.random().toString(36).substring(2, 8);
|
|
40
|
+
return `${prefix}-${timestamp}-${random}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Client for sending log messages to a remote logging server.
|
|
44
|
+
*
|
|
45
|
+
* Features:
|
|
46
|
+
* - Batches multiple log entries before sending
|
|
47
|
+
* - Automatic retry with exponential backoff on network failures
|
|
48
|
+
* - Unique session ID for correlating logs
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const client = new RemoteLogClient({
|
|
52
|
+
* serverUrl: "http://localhost:9080",
|
|
53
|
+
* sessionPrefix: "myapp",
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* client.log("INFO", "User logged in", { userId: 123 });
|
|
57
|
+
* client.log("DEBUG", "Loading data...");
|
|
58
|
+
*
|
|
59
|
+
* // Flush immediately when needed
|
|
60
|
+
* await client.flush();
|
|
61
|
+
*
|
|
62
|
+
* // Clean up when done
|
|
63
|
+
* await client.close();
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export class RemoteLogClient {
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new RemoteLogClient.
|
|
69
|
+
* @param options - Configuration options
|
|
70
|
+
*/
|
|
71
|
+
constructor(options) {
|
|
72
|
+
this.pendingLogs = [];
|
|
73
|
+
this.batchTimer = null;
|
|
74
|
+
this.isClosed = false;
|
|
75
|
+
this.flushPromise = null;
|
|
76
|
+
/** Tracks when each throttle pattern was last allowed through */
|
|
77
|
+
this.throttleLastTimes = new Map();
|
|
78
|
+
this.serverUrl = options.serverUrl;
|
|
79
|
+
this.sessionId = generateSessionId(options.sessionPrefix ?? DEFAULT_SESSION_PREFIX);
|
|
80
|
+
this.batchIntervalMs = options.batchIntervalMs ?? DEFAULT_BATCH_INTERVAL_MS;
|
|
81
|
+
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
82
|
+
this.retryDelayMs = options.retryDelayMs ?? DEFAULT_RETRY_DELAY_MS;
|
|
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__");
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Checks if a message should be throttled based on configured patterns.
|
|
90
|
+
* Updates the last time tracking if the message is allowed through.
|
|
91
|
+
* @param message - The message to check
|
|
92
|
+
* @returns true if the message should be dropped (throttled)
|
|
93
|
+
*/
|
|
94
|
+
shouldThrottle(message) {
|
|
95
|
+
const now = Date.now();
|
|
96
|
+
for (const { pattern, intervalMs } of this.throttlePatterns) {
|
|
97
|
+
if (pattern.test(message)) {
|
|
98
|
+
const key = pattern.source;
|
|
99
|
+
const lastTime = this.throttleLastTimes.get(key) ?? 0;
|
|
100
|
+
if (now - lastTime < intervalMs) {
|
|
101
|
+
// Within throttle window, drop this message
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
// Outside throttle window, update timestamp and allow through
|
|
105
|
+
this.throttleLastTimes.set(key, now);
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// No matching pattern, allow through
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Logs a message at the specified level.
|
|
114
|
+
* @param level - Log level (e.g., "INFO", "DEBUG", "WARN", "ERROR")
|
|
115
|
+
* @param message - The log message
|
|
116
|
+
* @param data - Optional additional data to include
|
|
117
|
+
*/
|
|
118
|
+
log(level, message, data) {
|
|
119
|
+
if (this.isClosed) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
// Check throttling before adding to buffer
|
|
123
|
+
if (this.shouldThrottle(message)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const entry = {
|
|
127
|
+
time: new Date().toISOString(),
|
|
128
|
+
level,
|
|
129
|
+
message,
|
|
130
|
+
...(data !== undefined && { data }),
|
|
131
|
+
};
|
|
132
|
+
this.pendingLogs.push(entry);
|
|
133
|
+
this.scheduleBatchSend();
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Schedules a batch send after the configured interval.
|
|
137
|
+
* If a timer is already scheduled, does nothing.
|
|
138
|
+
*/
|
|
139
|
+
scheduleBatchSend() {
|
|
140
|
+
if (this.batchTimer !== null || this.isClosed) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
this.batchTimer = setTimeout(() => {
|
|
144
|
+
this.batchTimer = null;
|
|
145
|
+
void this.sendBatch();
|
|
146
|
+
}, this.batchIntervalMs);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Sends the current batch of logs to the server.
|
|
150
|
+
* Uses retry logic with exponential backoff on failure.
|
|
151
|
+
*/
|
|
152
|
+
async sendBatch() {
|
|
153
|
+
if (this.pendingLogs.length === 0) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// Take the current logs and clear the pending array
|
|
157
|
+
const logsToSend = this.pendingLogs;
|
|
158
|
+
this.pendingLogs = [];
|
|
159
|
+
await this.sendWithRetry(logsToSend);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Sends logs with retry logic using exponential backoff.
|
|
163
|
+
* @param logs - The log entries to send
|
|
164
|
+
*/
|
|
165
|
+
async sendWithRetry(logs) {
|
|
166
|
+
let lastError = null;
|
|
167
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
168
|
+
try {
|
|
169
|
+
await this.sendRequest(logs);
|
|
170
|
+
return; // Success!
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
174
|
+
if (attempt < this.maxRetries) {
|
|
175
|
+
// Exponential backoff: delay * 2^attempt
|
|
176
|
+
const delay = this.retryDelayMs * Math.pow(2, attempt);
|
|
177
|
+
await this.sleep(delay);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// All retries exhausted - log the error but don't throw
|
|
182
|
+
// In a browser context, we don't want to break the application
|
|
183
|
+
console.error("[RemoteLogClient] Failed to send logs after retries:", lastError?.message);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Makes the actual HTTP request to send logs.
|
|
187
|
+
* @param logs - The log entries to send
|
|
188
|
+
* @throws Error if the request fails
|
|
189
|
+
*/
|
|
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
|
+
}
|
|
202
|
+
const response = await fetch(`${this.serverUrl}/log`, {
|
|
203
|
+
method: "POST",
|
|
204
|
+
headers: {
|
|
205
|
+
"Content-Type": "application/json",
|
|
206
|
+
},
|
|
207
|
+
body: JSON.stringify(requestBody),
|
|
208
|
+
});
|
|
209
|
+
if (!response.ok) {
|
|
210
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Helper to sleep for the specified duration.
|
|
215
|
+
* @param ms - Milliseconds to sleep
|
|
216
|
+
* @returns A promise that resolves after the specified time
|
|
217
|
+
*/
|
|
218
|
+
sleep(ms) {
|
|
219
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Immediately flushes all pending logs to the server.
|
|
223
|
+
* Useful before page unload or when immediate delivery is needed.
|
|
224
|
+
*/
|
|
225
|
+
async flush() {
|
|
226
|
+
// Cancel any scheduled batch
|
|
227
|
+
if (this.batchTimer !== null) {
|
|
228
|
+
clearTimeout(this.batchTimer);
|
|
229
|
+
this.batchTimer = null;
|
|
230
|
+
}
|
|
231
|
+
// Wait for any in-progress flush
|
|
232
|
+
if (this.flushPromise !== null) {
|
|
233
|
+
await this.flushPromise;
|
|
234
|
+
}
|
|
235
|
+
// Send any remaining logs
|
|
236
|
+
if (this.pendingLogs.length > 0) {
|
|
237
|
+
this.flushPromise = this.sendBatch();
|
|
238
|
+
await this.flushPromise;
|
|
239
|
+
this.flushPromise = null;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Closes the client, flushing any pending logs and stopping the batch timer.
|
|
244
|
+
* After calling close(), no more logs will be accepted.
|
|
245
|
+
*/
|
|
246
|
+
async close() {
|
|
247
|
+
if (this.isClosed) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
this.isClosed = true;
|
|
251
|
+
// Flush remaining logs
|
|
252
|
+
await this.flush();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Factory function to create a RemoteLogClient.
|
|
257
|
+
* @param options - Configuration options
|
|
258
|
+
* @returns A new RemoteLogClient instance
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* const client = createRemoteLogClient({
|
|
262
|
+
* serverUrl: "http://localhost:9080",
|
|
263
|
+
* });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
export function createRemoteLogClient(options) {
|
|
267
|
+
return new RemoteLogClient(options);
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=RemoteLogClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoteLogClient.js","sourceRoot":"","sources":["../../src/client/RemoteLogClient.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAWH;;;;GAIG;AACH,SAAS,cAAc,CAAC,IAAsE;IAC1F,IAAI,CAAC;QACD,IAAI,IAAI,KAAK,+BAA+B,EAAE,CAAC;YAC3C,OAAO,OAAO,6BAA6B,KAAK,WAAW,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,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UAAU,qBAAqB,CAAC,OAA+B;IACjE,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser client for remote logging.
|
|
3
|
+
* @module client
|
|
4
|
+
*/
|
|
5
|
+
export { createRemoteLogClient, RemoteLogClient } from "./RemoteLogClient.js";
|
|
6
|
+
export type { LogEntry, RemoteLogClientOptions, ThrottlePattern } from "./types.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC9E,YAAY,EAAE,QAAQ,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the remote logging client.
|
|
3
|
+
* @module client/types
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* A single log entry to be sent to the remote server.
|
|
7
|
+
*/
|
|
8
|
+
export interface LogEntry {
|
|
9
|
+
/** ISO 8601 timestamp when the log was created */
|
|
10
|
+
time: string;
|
|
11
|
+
/** Log level (e.g., "INFO", "DEBUG", "WARN", "ERROR") */
|
|
12
|
+
level: string;
|
|
13
|
+
/** The log message */
|
|
14
|
+
message: string;
|
|
15
|
+
/** Optional additional data to include with the log */
|
|
16
|
+
data?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for throttling specific message patterns.
|
|
20
|
+
*/
|
|
21
|
+
export interface ThrottlePattern {
|
|
22
|
+
/** Regular expression pattern to match log messages */
|
|
23
|
+
pattern: RegExp;
|
|
24
|
+
/** Minimum interval in milliseconds between matching messages */
|
|
25
|
+
intervalMs: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configuration options for the RemoteLogClient.
|
|
29
|
+
*/
|
|
30
|
+
export interface RemoteLogClientOptions {
|
|
31
|
+
/** URL of the remote log server (e.g., "http://localhost:9080") */
|
|
32
|
+
serverUrl: string;
|
|
33
|
+
/** Prefix for the generated session ID (default: "session") */
|
|
34
|
+
sessionPrefix?: string;
|
|
35
|
+
/** Interval in milliseconds between batch sends (default: 1000) */
|
|
36
|
+
batchIntervalMs?: number;
|
|
37
|
+
/** Maximum number of retry attempts for failed sends (default: 3) */
|
|
38
|
+
maxRetries?: number;
|
|
39
|
+
/** Base delay in milliseconds between retries (uses exponential backoff) (default: 1000) */
|
|
40
|
+
retryDelayMs?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Patterns to throttle to prevent log flooding.
|
|
43
|
+
* Messages matching a pattern will only be sent once per the configured interval.
|
|
44
|
+
*/
|
|
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;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,MAAM,WAAW,sBAAsB;IACnC,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mEAAmE;IACnE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/client/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote logging client and server for browser debugging.
|
|
3
|
+
*
|
|
4
|
+
* Client usage (Browser):
|
|
5
|
+
* import { RemoteLogClient } from "@graphty/remote-logger";
|
|
6
|
+
* const client = new RemoteLogClient({ serverUrl: "http://localhost:9080" });
|
|
7
|
+
* client.log("INFO", "Hello from browser");
|
|
8
|
+
*
|
|
9
|
+
* Server usage (Node.js):
|
|
10
|
+
* import { startLogServer } from "@graphty/remote-logger/server";
|
|
11
|
+
* startLogServer({ port: 9080 });
|
|
12
|
+
*
|
|
13
|
+
* Or via CLI:
|
|
14
|
+
* npx remote-log-server --port 9080
|
|
15
|
+
*
|
|
16
|
+
* UI usage (Browser):
|
|
17
|
+
* import { initConsoleCaptureUI } from "@graphty/remote-logger/ui";
|
|
18
|
+
* initConsoleCaptureUI();
|
|
19
|
+
*/
|
|
20
|
+
export type { LogEntry, RemoteLogClientOptions, ThrottlePattern } from "./client/index.js";
|
|
21
|
+
export { createRemoteLogClient, RemoteLogClient } from "./client/index.js";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,YAAY,EAAE,QAAQ,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote logging client and server for browser debugging.
|
|
3
|
+
*
|
|
4
|
+
* Client usage (Browser):
|
|
5
|
+
* import { RemoteLogClient } from "@graphty/remote-logger";
|
|
6
|
+
* const client = new RemoteLogClient({ serverUrl: "http://localhost:9080" });
|
|
7
|
+
* client.log("INFO", "Hello from browser");
|
|
8
|
+
*
|
|
9
|
+
* Server usage (Node.js):
|
|
10
|
+
* import { startLogServer } from "@graphty/remote-logger/server";
|
|
11
|
+
* startLogServer({ port: 9080 });
|
|
12
|
+
*
|
|
13
|
+
* Or via CLI:
|
|
14
|
+
* npx remote-log-server --port 9080
|
|
15
|
+
*
|
|
16
|
+
* UI usage (Browser):
|
|
17
|
+
* import { initConsoleCaptureUI } from "@graphty/remote-logger/ui";
|
|
18
|
+
* initConsoleCaptureUI();
|
|
19
|
+
*/
|
|
20
|
+
export { createRemoteLogClient, RemoteLogClient } from "./client/index.js";
|
|
21
|
+
// Note: UI components are NOT re-exported here to keep the main entry lightweight.
|
|
22
|
+
// Import from "@graphty/remote-logger/ui" for UI usage.
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE3E,mFAAmF;AACnF,wDAAwD"}
|
|
@@ -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"}
|