@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,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utilities for extracting and resolving project markers.
|
|
3
|
+
*
|
|
4
|
+
* Project markers are used to identify which git worktree or project
|
|
5
|
+
* a log session belongs to, enabling filtering of logs by project.
|
|
6
|
+
* @module server/marker-utils
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Extract a project marker from a filesystem path.
|
|
12
|
+
*
|
|
13
|
+
* The function looks for `.worktrees` in the path and extracts the worktree name.
|
|
14
|
+
* If no worktree is found, it falls back to the directory basename.
|
|
15
|
+
* @param cwd - The filesystem path to extract a marker from
|
|
16
|
+
* @returns The extracted project marker, or "default" if extraction fails
|
|
17
|
+
* @example
|
|
18
|
+
* // Worktree paths
|
|
19
|
+
* extractMarkerFromPath("/home/user/.worktrees/remote-logging") // "remote-logging"
|
|
20
|
+
* extractMarkerFromPath("C:\\Users\\dev\\.worktrees\\feature-xyz") // "feature-xyz"
|
|
21
|
+
*
|
|
22
|
+
* // Regular paths (uses basename)
|
|
23
|
+
* extractMarkerFromPath("/home/user/my-project") // "my-project"
|
|
24
|
+
*/
|
|
25
|
+
export function extractMarkerFromPath(cwd: string): string {
|
|
26
|
+
if (!cwd || cwd === "/") {
|
|
27
|
+
return "default";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Normalize trailing slashes
|
|
31
|
+
const normalizedPath = cwd.replace(/[/\\]+$/, "");
|
|
32
|
+
|
|
33
|
+
if (!normalizedPath) {
|
|
34
|
+
return "default";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Check if in .worktrees directory (supports both Unix and Windows paths)
|
|
38
|
+
// Match: .worktrees/worktree-name or .worktrees\worktree-name
|
|
39
|
+
const worktreeMatch = normalizedPath.match(/\.worktrees[/\\]([^/\\]+)/);
|
|
40
|
+
if (worktreeMatch) {
|
|
41
|
+
return worktreeMatch[1];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Fall back to directory name
|
|
45
|
+
// Handle both Unix and Windows paths by splitting on both separators
|
|
46
|
+
const segments = normalizedPath.split(/[/\\]/);
|
|
47
|
+
const basename = segments.filter(Boolean).pop();
|
|
48
|
+
return basename || "default";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Extract a project marker from a session ID.
|
|
53
|
+
*
|
|
54
|
+
* Session IDs typically follow the format: {prefix}-{timestamp}-{random}
|
|
55
|
+
* This function extracts the prefix part as the project marker.
|
|
56
|
+
* @param sessionId - The session ID to extract a marker from
|
|
57
|
+
* @returns The extracted project marker, or "default" if extraction fails
|
|
58
|
+
* @example
|
|
59
|
+
* extractMarkerFromSessionId("graphty-element-1704067200000-abc123") // "graphty-element"
|
|
60
|
+
* extractMarkerFromSessionId("my-app-1704067200000-xyz") // "my-app"
|
|
61
|
+
* extractMarkerFromSessionId("simple") // "simple"
|
|
62
|
+
*/
|
|
63
|
+
export function extractMarkerFromSessionId(sessionId: string): string {
|
|
64
|
+
if (!sessionId) {
|
|
65
|
+
return "default";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Session IDs follow format: {prefix}-{timestamp}-{random}
|
|
69
|
+
// The timestamp is typically a 13-digit number (milliseconds since epoch)
|
|
70
|
+
// We want to extract everything before the timestamp
|
|
71
|
+
|
|
72
|
+
// Look for pattern: name-{13 digits}-{suffix}
|
|
73
|
+
const timestampMatch = sessionId.match(/^(.+?)-(\d{10,13})-[a-zA-Z0-9]+$/);
|
|
74
|
+
if (timestampMatch) {
|
|
75
|
+
return timestampMatch[1];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Fall back to first segment before hyphen
|
|
79
|
+
const firstHyphen = sessionId.indexOf("-");
|
|
80
|
+
if (firstHyphen > 0) {
|
|
81
|
+
return sessionId.substring(0, firstHyphen);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Return the whole session ID if no hyphen
|
|
85
|
+
return sessionId;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Options for resolving a project marker.
|
|
90
|
+
*/
|
|
91
|
+
export interface MarkerResolutionOptions {
|
|
92
|
+
/** Explicit project marker (highest priority) */
|
|
93
|
+
projectMarker?: string;
|
|
94
|
+
/** Working directory path to extract marker from */
|
|
95
|
+
workingDirectory?: string;
|
|
96
|
+
/** Session ID to extract marker from (lowest priority) */
|
|
97
|
+
sessionId?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Resolve a project marker using a fallback chain.
|
|
102
|
+
*
|
|
103
|
+
* Priority order:
|
|
104
|
+
* 1. Explicit projectMarker parameter
|
|
105
|
+
* 2. Extracted from workingDirectory path
|
|
106
|
+
* 3. Extracted from sessionId
|
|
107
|
+
* 4. "default" as final fallback
|
|
108
|
+
* @param options - Resolution options with various marker sources
|
|
109
|
+
* @returns The resolved project marker
|
|
110
|
+
* @example
|
|
111
|
+
* resolveProjectMarker({
|
|
112
|
+
* projectMarker: "explicit",
|
|
113
|
+
* workingDirectory: "/path/to/.worktrees/from-path"
|
|
114
|
+
* }) // "explicit"
|
|
115
|
+
*
|
|
116
|
+
* resolveProjectMarker({
|
|
117
|
+
* workingDirectory: "/path/to/.worktrees/remote-logging"
|
|
118
|
+
* }) // "remote-logging"
|
|
119
|
+
*/
|
|
120
|
+
export function resolveProjectMarker(options: MarkerResolutionOptions): string {
|
|
121
|
+
// Priority 1: Explicit project marker
|
|
122
|
+
if (options.projectMarker) {
|
|
123
|
+
return options.projectMarker;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Priority 2: Extract from working directory
|
|
127
|
+
if (options.workingDirectory) {
|
|
128
|
+
const fromPath = extractMarkerFromPath(options.workingDirectory);
|
|
129
|
+
if (fromPath !== "default") {
|
|
130
|
+
return fromPath;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Priority 3: Extract from session ID
|
|
135
|
+
if (options.sessionId) {
|
|
136
|
+
const fromSession = extractMarkerFromSessionId(options.sessionId);
|
|
137
|
+
if (fromSession !== "default") {
|
|
138
|
+
return fromSession;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Final fallback
|
|
143
|
+
return "default";
|
|
144
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-signed certificate generation for the log server.
|
|
3
|
+
* Uses the 'selfsigned' npm package to generate proper X.509 certificates.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from "fs";
|
|
7
|
+
import selfsigned from "selfsigned";
|
|
8
|
+
|
|
9
|
+
export interface GeneratedCert {
|
|
10
|
+
cert: string;
|
|
11
|
+
key: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Generate a self-signed certificate for HTTPS.
|
|
16
|
+
* The certificate is valid for localhost and common local development hostnames.
|
|
17
|
+
* @param hostname - Optional hostname to include in the certificate (default: localhost)
|
|
18
|
+
* @returns Object containing PEM-encoded certificate and private key
|
|
19
|
+
*/
|
|
20
|
+
export function generateSelfSignedCert(hostname = "localhost"): GeneratedCert {
|
|
21
|
+
const attrs = [
|
|
22
|
+
{ name: "commonName", value: hostname },
|
|
23
|
+
{ name: "organizationName", value: "Remote Log Server" },
|
|
24
|
+
{ name: "countryName", value: "US" },
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
const options = {
|
|
28
|
+
keySize: 2048,
|
|
29
|
+
days: 365,
|
|
30
|
+
algorithm: "sha256" as const,
|
|
31
|
+
extensions: [
|
|
32
|
+
{
|
|
33
|
+
name: "basicConstraints",
|
|
34
|
+
cA: false,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "keyUsage",
|
|
38
|
+
keyCertSign: false,
|
|
39
|
+
digitalSignature: true,
|
|
40
|
+
keyEncipherment: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "extKeyUsage",
|
|
44
|
+
serverAuth: true,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "subjectAltName",
|
|
48
|
+
altNames: [
|
|
49
|
+
{ type: 2, value: hostname }, // DNS name
|
|
50
|
+
{ type: 2, value: "localhost" },
|
|
51
|
+
{ type: 7, ip: "127.0.0.1" }, // IP address
|
|
52
|
+
{ type: 7, ip: "::1" }, // IPv6 localhost
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const pems = selfsigned.generate(attrs, options);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
cert: pems.cert,
|
|
62
|
+
key: pems.private,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check if certificate files exist and are readable.
|
|
68
|
+
* @param certPath - Path to the certificate file
|
|
69
|
+
* @param keyPath - Path to the private key file
|
|
70
|
+
* @returns true if both files exist and are readable
|
|
71
|
+
*/
|
|
72
|
+
export function certFilesExist(certPath: string, keyPath: string): boolean {
|
|
73
|
+
try {
|
|
74
|
+
fs.accessSync(certPath, fs.constants.R_OK);
|
|
75
|
+
fs.accessSync(keyPath, fs.constants.R_OK);
|
|
76
|
+
return true;
|
|
77
|
+
} catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Read certificate and key from files.
|
|
84
|
+
* @param certPath - Path to the certificate file
|
|
85
|
+
* @param keyPath - Path to the private key file
|
|
86
|
+
* @returns Object containing PEM-encoded certificate and private key
|
|
87
|
+
*/
|
|
88
|
+
export function readCertFiles(certPath: string, keyPath: string): GeneratedCert {
|
|
89
|
+
return {
|
|
90
|
+
cert: fs.readFileSync(certPath, "utf-8"),
|
|
91
|
+
key: fs.readFileSync(keyPath, "utf-8"),
|
|
92
|
+
};
|
|
93
|
+
}
|