Initial release — gstack v0.0.1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Garry Tan
2026-03-12 01:32:16 -07:00
co-authored by Claude Opus 4.6
commit 3d901066cd
34 changed files with 5415 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
/**
* Shared buffers and types — extracted to break circular dependency
* between server.ts and browser-manager.ts
*/
export interface LogEntry {
timestamp: number;
level: string;
text: string;
}
export interface NetworkEntry {
timestamp: number;
method: string;
url: string;
status?: number;
duration?: number;
size?: number;
}
export const consoleBuffer: LogEntry[] = [];
export const networkBuffer: NetworkEntry[] = [];
const HIGH_WATER_MARK = 50_000;
// Total entries ever added — used by server.ts flush logic as a cursor
// that keeps advancing even after the ring buffer wraps.
export let consoleTotalAdded = 0;
export let networkTotalAdded = 0;
export function addConsoleEntry(entry: LogEntry) {
if (consoleBuffer.length >= HIGH_WATER_MARK) {
consoleBuffer.shift();
}
consoleBuffer.push(entry);
consoleTotalAdded++;
}
export function addNetworkEntry(entry: NetworkEntry) {
if (networkBuffer.length >= HIGH_WATER_MARK) {
networkBuffer.shift();
}
networkBuffer.push(entry);
networkTotalAdded++;
}