wiretap-mcp 2.0.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 (105) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +68 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/monitors/crash-android.d.ts +20 -0
  8. package/dist/monitors/crash-android.d.ts.map +1 -0
  9. package/dist/monitors/crash-android.js +134 -0
  10. package/dist/monitors/crash-android.js.map +1 -0
  11. package/dist/monitors/crash-ios.d.ts +17 -0
  12. package/dist/monitors/crash-ios.d.ts.map +1 -0
  13. package/dist/monitors/crash-ios.js +116 -0
  14. package/dist/monitors/crash-ios.js.map +1 -0
  15. package/dist/monitors/hermes.d.ts +26 -0
  16. package/dist/monitors/hermes.d.ts.map +1 -0
  17. package/dist/monitors/hermes.js +175 -0
  18. package/dist/monitors/hermes.js.map +1 -0
  19. package/dist/monitors/reactotron.d.ts +18 -0
  20. package/dist/monitors/reactotron.d.ts.map +1 -0
  21. package/dist/monitors/reactotron.js +106 -0
  22. package/dist/monitors/reactotron.js.map +1 -0
  23. package/dist/monitors/terminal.d.ts +25 -0
  24. package/dist/monitors/terminal.d.ts.map +1 -0
  25. package/dist/monitors/terminal.js +154 -0
  26. package/dist/monitors/terminal.js.map +1 -0
  27. package/dist/parsers/cdp-parser.d.ts +64 -0
  28. package/dist/parsers/cdp-parser.d.ts.map +1 -0
  29. package/dist/parsers/cdp-parser.js +115 -0
  30. package/dist/parsers/cdp-parser.js.map +1 -0
  31. package/dist/parsers/crash-parser.d.ts +5 -0
  32. package/dist/parsers/crash-parser.d.ts.map +1 -0
  33. package/dist/parsers/crash-parser.js +112 -0
  34. package/dist/parsers/crash-parser.js.map +1 -0
  35. package/dist/parsers/log-parser.d.ts +5 -0
  36. package/dist/parsers/log-parser.d.ts.map +1 -0
  37. package/dist/parsers/log-parser.js +141 -0
  38. package/dist/parsers/log-parser.js.map +1 -0
  39. package/dist/parsers/reactotron-parser.d.ts +17 -0
  40. package/dist/parsers/reactotron-parser.d.ts.map +1 -0
  41. package/dist/parsers/reactotron-parser.js +83 -0
  42. package/dist/parsers/reactotron-parser.js.map +1 -0
  43. package/dist/server.d.ts +19 -0
  44. package/dist/server.d.ts.map +1 -0
  45. package/dist/server.js +224 -0
  46. package/dist/server.js.map +1 -0
  47. package/dist/storage/log-store.d.ts +41 -0
  48. package/dist/storage/log-store.d.ts.map +1 -0
  49. package/dist/storage/log-store.js +118 -0
  50. package/dist/storage/log-store.js.map +1 -0
  51. package/dist/storage/persistence.d.ts +26 -0
  52. package/dist/storage/persistence.d.ts.map +1 -0
  53. package/dist/storage/persistence.js +123 -0
  54. package/dist/storage/persistence.js.map +1 -0
  55. package/dist/tools/clear-logs.d.ts +8 -0
  56. package/dist/tools/clear-logs.d.ts.map +1 -0
  57. package/dist/tools/clear-logs.js +15 -0
  58. package/dist/tools/clear-logs.js.map +1 -0
  59. package/dist/tools/get-api-calls.d.ts +11 -0
  60. package/dist/tools/get-api-calls.d.ts.map +1 -0
  61. package/dist/tools/get-api-calls.js +26 -0
  62. package/dist/tools/get-api-calls.js.map +1 -0
  63. package/dist/tools/get-crashes.d.ts +11 -0
  64. package/dist/tools/get-crashes.d.ts.map +1 -0
  65. package/dist/tools/get-crashes.js +42 -0
  66. package/dist/tools/get-crashes.js.map +1 -0
  67. package/dist/tools/get-errors.d.ts +12 -0
  68. package/dist/tools/get-errors.d.ts.map +1 -0
  69. package/dist/tools/get-errors.js +52 -0
  70. package/dist/tools/get-errors.js.map +1 -0
  71. package/dist/tools/get-hermes-logs.d.ts +12 -0
  72. package/dist/tools/get-hermes-logs.d.ts.map +1 -0
  73. package/dist/tools/get-hermes-logs.js +33 -0
  74. package/dist/tools/get-hermes-logs.js.map +1 -0
  75. package/dist/tools/get-logs.d.ts +21 -0
  76. package/dist/tools/get-logs.d.ts.map +1 -0
  77. package/dist/tools/get-logs.js +50 -0
  78. package/dist/tools/get-logs.js.map +1 -0
  79. package/dist/tools/get-network.d.ts +12 -0
  80. package/dist/tools/get-network.d.ts.map +1 -0
  81. package/dist/tools/get-network.js +35 -0
  82. package/dist/tools/get-network.js.map +1 -0
  83. package/dist/tools/get-performance.d.ts +10 -0
  84. package/dist/tools/get-performance.d.ts.map +1 -0
  85. package/dist/tools/get-performance.js +32 -0
  86. package/dist/tools/get-performance.js.map +1 -0
  87. package/dist/tools/get-state.d.ts +11 -0
  88. package/dist/tools/get-state.d.ts.map +1 -0
  89. package/dist/tools/get-state.js +26 -0
  90. package/dist/tools/get-state.js.map +1 -0
  91. package/dist/tools/get-status.d.ts +20 -0
  92. package/dist/tools/get-status.d.ts.map +1 -0
  93. package/dist/tools/get-status.js +52 -0
  94. package/dist/tools/get-status.js.map +1 -0
  95. package/dist/tools/search-logs.d.ts +11 -0
  96. package/dist/tools/search-logs.d.ts.map +1 -0
  97. package/dist/tools/search-logs.js +68 -0
  98. package/dist/tools/search-logs.js.map +1 -0
  99. package/dist/types.d.ts +123 -0
  100. package/dist/types.d.ts.map +1 -0
  101. package/dist/types.js +3 -0
  102. package/dist/types.js.map +1 -0
  103. package/package.json +65 -0
  104. package/scripts/install.sh +33 -0
  105. package/wiretap.config.json +8 -0
package/dist/server.js ADDED
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCompanionServer = createCompanionServer;
4
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
5
+ const zod_1 = require("zod");
6
+ const log_store_js_1 = require("./storage/log-store.js");
7
+ const persistence_js_1 = require("./storage/persistence.js");
8
+ const terminal_js_1 = require("./monitors/terminal.js");
9
+ const reactotron_js_1 = require("./monitors/reactotron.js");
10
+ const hermes_js_1 = require("./monitors/hermes.js");
11
+ const crash_ios_js_1 = require("./monitors/crash-ios.js");
12
+ const crash_android_js_1 = require("./monitors/crash-android.js");
13
+ const get_logs_js_1 = require("./tools/get-logs.js");
14
+ const get_errors_js_1 = require("./tools/get-errors.js");
15
+ const get_api_calls_js_1 = require("./tools/get-api-calls.js");
16
+ const get_state_js_1 = require("./tools/get-state.js");
17
+ const get_status_js_1 = require("./tools/get-status.js");
18
+ const get_performance_js_1 = require("./tools/get-performance.js");
19
+ const search_logs_js_1 = require("./tools/search-logs.js");
20
+ const clear_logs_js_1 = require("./tools/clear-logs.js");
21
+ const get_hermes_logs_js_1 = require("./tools/get-hermes-logs.js");
22
+ const get_network_js_1 = require("./tools/get-network.js");
23
+ const get_crashes_js_1 = require("./tools/get-crashes.js");
24
+ function createCompanionServer(config) {
25
+ const store = new log_store_js_1.LogStore(config.terminalLogBufferSize, config.reactotronLogBufferSize);
26
+ // --- Persistence ---
27
+ let persistence = null;
28
+ if (config.persistLogs) {
29
+ persistence = new persistence_js_1.LogPersistence({
30
+ persistPath: config.persistPath,
31
+ flushIntervalMs: config.persistFlushIntervalMs,
32
+ maxEntriesOnLoad: config.persistMaxEntriesOnLoad,
33
+ });
34
+ persistence.loadInto(store);
35
+ persistence.attach(store);
36
+ }
37
+ // --- Monitors ---
38
+ const terminalMonitor = new terminal_js_1.TerminalMonitor(store, config.filterPatterns);
39
+ const reactotronMonitor = new reactotron_js_1.ReactotronMonitor(store, config.reactotronPort);
40
+ let hermesMonitor = null;
41
+ if (config.hermesEnabled) {
42
+ hermesMonitor = new hermes_js_1.HermesMonitor(store, config.metroPort, config.cdpCaptureNetwork);
43
+ }
44
+ let iosCrashMonitor = null;
45
+ if (config.iosCrashMonitorEnabled) {
46
+ iosCrashMonitor = new crash_ios_js_1.IOSCrashMonitor(store, config.iosCrashReportPath);
47
+ }
48
+ let androidCrashMonitor = null;
49
+ if (config.androidCrashMonitorEnabled) {
50
+ androidCrashMonitor = new crash_android_js_1.AndroidCrashMonitor(store, config.adbPath);
51
+ }
52
+ const startTime = Date.now();
53
+ const monitors = {
54
+ terminalMonitor,
55
+ reactotronMonitor,
56
+ hermesMonitor,
57
+ iosCrashMonitor,
58
+ androidCrashMonitor,
59
+ };
60
+ const server = new mcp_js_1.McpServer({
61
+ name: "wiretap",
62
+ version: "2.0.0",
63
+ });
64
+ // --- Tools ---
65
+ server.tool("get_terminal_logs", "Get terminal logs from Metro/Expo/React Native CLI with optional filtering", {
66
+ filter: zod_1.z.string().optional().describe("Regex filter for log messages"),
67
+ severity: zod_1.z
68
+ .enum(["error", "warn", "info", "all"])
69
+ .optional()
70
+ .describe("Filter by severity level"),
71
+ last_n: zod_1.z
72
+ .number()
73
+ .optional()
74
+ .describe("Return only the last N logs"),
75
+ }, async (args) => (0, get_logs_js_1.handleGetTerminalLogs)(store, args));
76
+ server.tool("get_reactotron_logs", "Get Reactotron logs with optional type filtering", {
77
+ type: zod_1.z
78
+ .enum(["api", "state", "log", "benchmark", "all"])
79
+ .optional()
80
+ .describe("Filter by log type"),
81
+ last_n: zod_1.z
82
+ .number()
83
+ .optional()
84
+ .describe("Return only the last N logs"),
85
+ }, async (args) => (0, get_logs_js_1.handleGetReactotronLogs)(store, args));
86
+ server.tool("get_errors", "Get consolidated errors and crashes from terminal, Reactotron, and Hermes with optional filtering", {
87
+ source: zod_1.z
88
+ .enum(["terminal", "reactotron", "hermes", "all"])
89
+ .optional()
90
+ .describe("Filter by error source"),
91
+ filter: zod_1.z
92
+ .string()
93
+ .optional()
94
+ .describe("Regex filter for error messages"),
95
+ last_n: zod_1.z
96
+ .number()
97
+ .optional()
98
+ .describe("Return only the last N errors"),
99
+ }, async (args) => (0, get_errors_js_1.handleGetErrors)(store, args));
100
+ server.tool("get_api_calls", "Get API calls captured by Reactotron with optional endpoint filtering", {
101
+ endpoint_filter: zod_1.z
102
+ .string()
103
+ .optional()
104
+ .describe("Regex filter for API endpoint URLs"),
105
+ last_n: zod_1.z
106
+ .number()
107
+ .optional()
108
+ .describe("Return only the last N calls"),
109
+ }, async (args) => (0, get_api_calls_js_1.handleGetApiCalls)(store, args));
110
+ server.tool("get_state_changes", "Get state changes (Redux/MobX/Zustand) captured by Reactotron", {
111
+ store_name: zod_1.z
112
+ .string()
113
+ .optional()
114
+ .describe("Filter by store name or action"),
115
+ last_n: zod_1.z
116
+ .number()
117
+ .optional()
118
+ .describe("Return only the last N changes"),
119
+ }, async (args) => (0, get_state_js_1.handleGetStateChanges)(store, args));
120
+ server.tool("get_app_status", "Get overall status: Metro running, Reactotron connected, Hermes connected, error/warning counts, last crash, uptime", {}, async () => (0, get_status_js_1.handleGetStatus)(store, monitors, startTime));
121
+ server.tool("get_performance", "Get performance metrics (benchmarks, render times) from Reactotron", {
122
+ last_n: zod_1.z
123
+ .number()
124
+ .optional()
125
+ .describe("Return only the last N entries"),
126
+ }, async (args) => (0, get_performance_js_1.handleGetPerformance)(store, args));
127
+ server.tool("search_logs", "Full-text search across all terminal, Reactotron, Hermes logs, network calls, and crash reports", {
128
+ query: zod_1.z.string().describe("Search query (regex supported)"),
129
+ last_n: zod_1.z
130
+ .number()
131
+ .optional()
132
+ .describe("Return only the last N results per source"),
133
+ }, async (args) => (0, search_logs_js_1.handleSearchLogs)(store, args));
134
+ server.tool("clear_logs", "Clear all log buffers (terminal, Reactotron, Hermes, network, API calls, state changes, performance, crashes)", {}, async () => (0, clear_logs_js_1.handleClearLogs)(store));
135
+ server.tool("get_hermes_logs", "Get JS runtime logs from Hermes/CDP (console.log/warn/error) with optional filtering", {
136
+ level: zod_1.z
137
+ .enum(["error", "warn", "info", "debug", "all"])
138
+ .optional()
139
+ .describe("Filter by log level"),
140
+ filter: zod_1.z.string().optional().describe("Regex filter for log messages"),
141
+ last_n: zod_1.z
142
+ .number()
143
+ .optional()
144
+ .describe("Return only the last N logs"),
145
+ }, async (args) => (0, get_hermes_logs_js_1.handleGetHermesLogs)(store, args));
146
+ server.tool("get_network_calls", "Get HTTP network calls captured via CDP (Chrome DevTools Protocol)", {
147
+ url_filter: zod_1.z
148
+ .string()
149
+ .optional()
150
+ .describe("Regex filter for URL"),
151
+ status_code: zod_1.z
152
+ .number()
153
+ .optional()
154
+ .describe("Filter by HTTP status code"),
155
+ last_n: zod_1.z
156
+ .number()
157
+ .optional()
158
+ .describe("Return only the last N calls"),
159
+ }, async (args) => (0, get_network_js_1.handleGetNetworkCalls)(store, args));
160
+ server.tool("get_native_crashes", "Get native crash reports from iOS (DiagnosticReports) and Android (adb logcat)", {
161
+ platform: zod_1.z
162
+ .enum(["ios", "android", "all"])
163
+ .optional()
164
+ .describe("Filter by platform"),
165
+ last_n: zod_1.z
166
+ .number()
167
+ .optional()
168
+ .describe("Return only the last N crashes"),
169
+ }, async (args) => (0, get_crashes_js_1.handleGetCrashes)(store, args));
170
+ // --- Resources ---
171
+ server.resource("status", "wiretap://status", { description: "Current connection and app status" }, async () => {
172
+ const result = (0, get_status_js_1.handleGetStatus)(store, monitors, startTime);
173
+ return { contents: [{ uri: "wiretap://status", ...result.content[0] }] };
174
+ });
175
+ server.resource("errors-latest", "wiretap://errors/latest", { description: "Latest consolidated errors" }, async () => {
176
+ const result = (0, get_errors_js_1.handleGetErrors)(store);
177
+ return {
178
+ contents: [
179
+ { uri: "wiretap://errors/latest", ...result.content[0] },
180
+ ],
181
+ };
182
+ });
183
+ server.resource("logs-terminal", "wiretap://logs/terminal", { description: "Terminal logs stream" }, async () => {
184
+ const result = (0, get_logs_js_1.handleGetTerminalLogs)(store, { last_n: 50 });
185
+ return {
186
+ contents: [
187
+ { uri: "wiretap://logs/terminal", ...result.content[0] },
188
+ ],
189
+ };
190
+ });
191
+ server.resource("logs-reactotron", "wiretap://logs/reactotron", { description: "Reactotron logs stream" }, async () => {
192
+ const result = (0, get_logs_js_1.handleGetReactotronLogs)(store, { last_n: 50 });
193
+ return {
194
+ contents: [
195
+ { uri: "wiretap://logs/reactotron", ...result.content[0] },
196
+ ],
197
+ };
198
+ });
199
+ server.resource("logs-hermes", "wiretap://logs/hermes", { description: "Hermes/JS runtime logs" }, async () => {
200
+ const result = (0, get_hermes_logs_js_1.handleGetHermesLogs)(store, { last_n: 50 });
201
+ return {
202
+ contents: [
203
+ { uri: "wiretap://logs/hermes", ...result.content[0] },
204
+ ],
205
+ };
206
+ });
207
+ // --- Start monitors ---
208
+ terminalMonitor.start(config.autoDetectTerminal);
209
+ reactotronMonitor.start();
210
+ hermesMonitor?.start();
211
+ iosCrashMonitor?.start();
212
+ androidCrashMonitor?.start();
213
+ // --- Shutdown ---
214
+ const shutdown = () => {
215
+ terminalMonitor.stop();
216
+ reactotronMonitor.stop();
217
+ hermesMonitor?.stop();
218
+ iosCrashMonitor?.stop();
219
+ androidCrashMonitor?.stop();
220
+ persistence?.shutdown();
221
+ };
222
+ return { server, store, terminalMonitor, reactotronMonitor, hermesMonitor, iosCrashMonitor, androidCrashMonitor, shutdown };
223
+ }
224
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;AAsBA,sDAkUC;AAxVD,oEAAoE;AACpE,6BAAwB;AACxB,yDAAkD;AAClD,6DAA0D;AAC1D,wDAAyD;AACzD,4DAA6D;AAC7D,oDAAqD;AACrD,0DAA0D;AAC1D,kEAAkE;AAElE,qDAAqF;AACrF,yDAAwD;AACxD,+DAA6D;AAC7D,uDAA6D;AAC7D,yDAAwE;AACxE,mEAAkE;AAClE,2DAA0D;AAC1D,yDAAwD;AACxD,mEAAiE;AACjE,2DAA+D;AAC/D,2DAA0D;AAE1D,SAAgB,qBAAqB,CAAC,MAAuB;IAC3D,MAAM,KAAK,GAAG,IAAI,uBAAQ,CACxB,MAAM,CAAC,qBAAqB,EAC5B,MAAM,CAAC,uBAAuB,CAC/B,CAAC;IAEF,sBAAsB;IACtB,IAAI,WAAW,GAA0B,IAAI,CAAC;IAC9C,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,WAAW,GAAG,IAAI,+BAAc,CAAC;YAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,eAAe,EAAE,MAAM,CAAC,sBA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AAC,kBAAkB,CAAC,CAAC;IACjD,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAC1B,aAAa,EAAE,KAAK,EAAE,CAAC;IACvB,eAAe,EAAE,KAAK,EAAE,CAAC;IACzB,mBAAmB,EAAE,KAAK,EAAE,CAAC;IAE7B,mBAAmB;IAEnB,MAAM,QAAQ,GAAG,GAAG,EAAE;QACpB,eAAe,CAAC,IAAI,EAAE,CAAC;QACvB,iBAAiB,CAAC,IAAI,EAAE,CAAC;QACzB,aAAa,EAAE,IAAI,EAAE,CAAC;QACtB,eAAe,EAAE,IAAI,EAAE,CAAC;QACxB,mBAAmB,EAAE,IAAI,EAAE,CAAC;QAC5B,WAAW,EAAE,QAAQ,EAAE,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EAAE,QAAQ,EAAE,CAAC;AAC9H,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { TerminalLogEntry, ReactotronLogEntry, ApiCallEntry, StateChangeEntry, PerformanceEntry, HermesLogEntry, NetworkEntry, CrashLogEntry } from "../types.js";
2
+ export declare class CircularBuffer<T extends {
3
+ id: number;
4
+ }> {
5
+ private buffer;
6
+ private maxSize;
7
+ private nextId;
8
+ private _onAdd?;
9
+ constructor(maxSize: number);
10
+ onAdd(callback: (item: T) => void): void;
11
+ add(item: Omit<T, "id">): T;
12
+ loadBulk(items: T[]): void;
13
+ getAll(): T[];
14
+ getLast(n: number): T[];
15
+ filter(predicate: (item: T) => boolean): T[];
16
+ search(query: string): T[];
17
+ count(): number;
18
+ clear(): void;
19
+ }
20
+ export declare class LogStore {
21
+ readonly terminalLogs: CircularBuffer<TerminalLogEntry>;
22
+ readonly reactotronLogs: CircularBuffer<ReactotronLogEntry>;
23
+ readonly apiCalls: CircularBuffer<ApiCallEntry>;
24
+ readonly stateChanges: CircularBuffer<StateChangeEntry>;
25
+ readonly performanceEntries: CircularBuffer<PerformanceEntry>;
26
+ readonly hermesLogs: CircularBuffer<HermesLogEntry>;
27
+ readonly networkCalls: CircularBuffer<NetworkEntry>;
28
+ readonly crashLogs: CircularBuffer<CrashLogEntry>;
29
+ constructor(terminalBufferSize?: number, reactotronBufferSize?: number);
30
+ getErrors(): (TerminalLogEntry | ReactotronLogEntry | HermesLogEntry)[];
31
+ getLastCrash(): TerminalLogEntry | CrashLogEntry | null;
32
+ searchAll(query: string): {
33
+ terminal: TerminalLogEntry[];
34
+ reactotron: ReactotronLogEntry[];
35
+ hermes: HermesLogEntry[];
36
+ network: NetworkEntry[];
37
+ crashes: CrashLogEntry[];
38
+ };
39
+ clearAll(): void;
40
+ }
41
+ //# sourceMappingURL=log-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-store.d.ts","sourceRoot":"","sources":["../../src/storage/log-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,EACd,MAAM,aAAa,CAAC;AAErB,qBAAa,cAAc,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IAClD,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,MAAM,CAAC,CAAoB;gBAEvB,OAAO,EAAE,MAAM;IAI3B,KAAK,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI;IAIxC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC;IAU3B,QAAQ,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI;IAY1B,MAAM,IAAI,CAAC,EAAE;IAIb,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,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
3
+ exports.LogStore = exports.CircularBuffer = void 0;
4
+ class CircularBuffer {
5
+ buffer = [];
6
+ maxSize;
7
+ nextId = 1;
8
+ _onAdd;
9
+ constructor(maxSize) {
10
+ this.maxSize = maxSize;
11
+ }
12
+ onAdd(callback) {
13
+ this._onAdd = callback;
14
+ }
15
+ add(item) {
16
+ const entry = { ...item, id: this.nextId++ };
17
+ if (this.buffer.length >= this.maxSize) {
18
+ this.buffer.shift();
19
+ }
20
+ this.buffer.push(entry);
21
+ this._onAdd?.(entry);
22
+ return entry;
23
+ }
24
+ loadBulk(items) {
25
+ for (const item of items) {
26
+ if (this.buffer.length >= this.maxSize) {
27
+ this.buffer.shift();
28
+ }
29
+ this.buffer.push(item);
30
+ if (item.id >= this.nextId) {
31
+ this.nextId = item.id + 1;
32
+ }
33
+ }
34
+ }
35
+ getAll() {
36
+ return [...this.buffer];
37
+ }
38
+ getLast(n) {
39
+ return this.buffer.slice(-n);
40
+ }
41
+ filter(predicate) {
42
+ return this.buffer.filter(predicate);
43
+ }
44
+ search(query) {
45
+ const regex = new RegExp(query, "i");
46
+ return this.buffer.filter((item) => regex.test(JSON.stringify(item)));
47
+ }
48
+ count() {
49
+ return this.buffer.length;
50
+ }
51
+ clear() {
52
+ this.buffer = [];
53
+ this.nextId = 1;
54
+ }
55
+ }
56
+ exports.CircularBuffer = CircularBuffer;
57
+ class LogStore {
58
+ terminalLogs;
59
+ reactotronLogs;
60
+ apiCalls;
61
+ stateChanges;
62
+ performanceEntries;
63
+ hermesLogs;
64
+ networkCalls;
65
+ crashLogs;
66
+ constructor(terminalBufferSize = 500, reactotronBufferSize = 500) {
67
+ this.terminalLogs = new CircularBuffer(terminalBufferSize);
68
+ this.reactotronLogs = new CircularBuffer(reactotronBufferSize);
69
+ this.apiCalls = new CircularBuffer(reactotronBufferSize);
70
+ this.stateChanges = new CircularBuffer(reactotronBufferSize);
71
+ this.performanceEntries = new CircularBuffer(reactotronBufferSize);
72
+ this.hermesLogs = new CircularBuffer(reactotronBufferSize);
73
+ this.networkCalls = new CircularBuffer(reactotronBufferSize);
74
+ this.crashLogs = new CircularBuffer(200);
75
+ }
76
+ getErrors() {
77
+ const terminalErrors = this.terminalLogs.filter((log) => log.severity === "error" || log.isNativeCrash === true);
78
+ const reactotronErrors = this.reactotronLogs.filter((log) => log.type === "log" && log.important === true);
79
+ const hermesErrors = this.hermesLogs.filter((log) => log.level === "error");
80
+ return [
81
+ ...terminalErrors.map((e) => ({ ...e, _source: "terminal" })),
82
+ ...reactotronErrors.map((e) => ({ ...e, _source: "reactotron" })),
83
+ ...hermesErrors.map((e) => ({ ...e, _source: "hermes" })),
84
+ ].sort((a, b) => a.timestamp.localeCompare(b.timestamp));
85
+ }
86
+ getLastCrash() {
87
+ const terminalCrashes = this.terminalLogs.filter((log) => log.isNativeCrash || log.severity === "error");
88
+ const nativeCrashes = this.crashLogs.getAll();
89
+ const lastTerminal = terminalCrashes.length > 0 ? terminalCrashes[terminalCrashes.length - 1] : null;
90
+ const lastNative = nativeCrashes.length > 0 ? nativeCrashes[nativeCrashes.length - 1] : null;
91
+ if (!lastTerminal)
92
+ return lastNative;
93
+ if (!lastNative)
94
+ return lastTerminal;
95
+ return lastTerminal.timestamp > lastNative.timestamp ? lastTerminal : lastNative;
96
+ }
97
+ searchAll(query) {
98
+ return {
99
+ terminal: this.terminalLogs.search(query),
100
+ reactotron: this.reactotronLogs.search(query),
101
+ hermes: this.hermesLogs.search(query),
102
+ network: this.networkCalls.search(query),
103
+ crashes: this.crashLogs.search(query),
104
+ };
105
+ }
106
+ clearAll() {
107
+ this.terminalLogs.clear();
108
+ this.reactotronLogs.clear();
109
+ this.apiCalls.clear();
110
+ this.stateChanges.clear();
111
+ this.performanceEntries.clear();
112
+ this.hermesLogs.clear();
113
+ this.networkCalls.clear();
114
+ this.crashLogs.clear();
115
+ }
116
+ }
117
+ exports.LogStore = LogStore;
118
+ //# sourceMappingURL=log-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log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IAED,QAAQ;QACN,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;QAChC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF;AA9ED,4BA8EC"}
@@ -0,0 +1,26 @@
1
+ import { LogStore } from "./log-store.js";
2
+ interface PersistConfig {
3
+ persistPath: string;
4
+ flushIntervalMs: number;
5
+ maxEntriesOnLoad: number;
6
+ }
7
+ export declare class LogPersistence {
8
+ private config;
9
+ private pendingWrites;
10
+ private flushTimer;
11
+ constructor(config: PersistConfig);
12
+ private resolvedPath;
13
+ private filePath;
14
+ /** Hook all store buffers for write-behind persistence */
15
+ attach(store: LogStore): void;
16
+ /** Load persisted entries back into store buffers */
17
+ loadInto(store: LogStore): void;
18
+ private loadFile;
19
+ private startFlushTimer;
20
+ /** Flush all pending writes to disk */
21
+ flush(): void;
22
+ /** Stop flush timer and write remaining data */
23
+ shutdown(): void;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=persistence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../src/storage/persistence.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAkB,MAAM,gBAAgB,CAAC;AAE1D,UAAU,aAAa;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAeD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,UAAU,CAA+B;gBAErC,MAAM,EAAE,aAAa;IAUjC,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,QAAQ;IAIhB,0DAA0D;IAC1D,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAuB7B,qDAAqD;IACrD,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAa/B,OAAO,CAAC,QAAQ;IA8BhB,OAAO,CAAC,eAAe;IAMvB,uCAAuC;IACvC,KAAK,IAAI,IAAI;IAcb,gDAAgD;IAChD,QAAQ,IAAI,IAAI;CAOjB"}
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LogPersistence = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const FILE_MAP = {
7
+ terminal: "terminal.jsonl",
8
+ reactotron: "reactotron.jsonl",
9
+ api: "api.jsonl",
10
+ state: "state.jsonl",
11
+ performance: "performance.jsonl",
12
+ hermes: "hermes.jsonl",
13
+ network: "network.jsonl",
14
+ crash: "crash.jsonl",
15
+ };
16
+ class LogPersistence {
17
+ config;
18
+ pendingWrites = new Map();
19
+ flushTimer = null;
20
+ constructor(config) {
21
+ this.config = config;
22
+ const dir = this.resolvedPath();
23
+ (0, fs_1.mkdirSync)(dir, { recursive: true });
24
+ for (const key of Object.keys(FILE_MAP)) {
25
+ this.pendingWrites.set(key, []);
26
+ }
27
+ }
28
+ resolvedPath() {
29
+ const p = this.config.persistPath;
30
+ if (p.startsWith("~")) {
31
+ return (0, path_1.join)(process.env.HOME || "/tmp", p.slice(1));
32
+ }
33
+ return p;
34
+ }
35
+ filePath(name) {
36
+ return (0, path_1.join)(this.resolvedPath(), FILE_MAP[name]);
37
+ }
38
+ /** Hook all store buffers for write-behind persistence */
39
+ attach(store) {
40
+ const hookBuffer = (buffer, name) => {
41
+ buffer.onAdd((item) => {
42
+ const pending = this.pendingWrites.get(name);
43
+ pending.push(JSON.stringify(item));
44
+ });
45
+ };
46
+ hookBuffer(store.terminalLogs, "terminal");
47
+ hookBuffer(store.reactotronLogs, "reactotron");
48
+ hookBuffer(store.apiCalls, "api");
49
+ hookBuffer(store.stateChanges, "state");
50
+ hookBuffer(store.performanceEntries, "performance");
51
+ hookBuffer(store.hermesLogs, "hermes");
52
+ hookBuffer(store.networkCalls, "network");
53
+ hookBuffer(store.crashLogs, "crash");
54
+ this.startFlushTimer();
55
+ }
56
+ /** Load persisted entries back into store buffers */
57
+ loadInto(store) {
58
+ const max = this.config.maxEntriesOnLoad;
59
+ this.loadFile("terminal", store.terminalLogs, max);
60
+ this.loadFile("reactotron", store.reactotronLogs, max);
61
+ this.loadFile("api", store.apiCalls, max);
62
+ this.loadFile("state", store.stateChanges, max);
63
+ this.loadFile("performance", store.performanceEntries, max);
64
+ this.loadFile("hermes", store.hermesLogs, max);
65
+ this.loadFile("network", store.networkCalls, max);
66
+ this.loadFile("crash", store.crashLogs, max);
67
+ }
68
+ loadFile(name, buffer, maxEntries) {
69
+ const fp = this.filePath(name);
70
+ if (!(0, fs_1.existsSync)(fp))
71
+ return;
72
+ try {
73
+ const content = (0, fs_1.readFileSync)(fp, "utf-8");
74
+ const lines = content.trim().split("\n").filter(Boolean);
75
+ const tail = lines.slice(-maxEntries);
76
+ const items = [];
77
+ for (const line of tail) {
78
+ try {
79
+ items.push(JSON.parse(line));
80
+ }
81
+ catch {
82
+ // skip malformed lines
83
+ }
84
+ }
85
+ if (items.length > 0) {
86
+ buffer.loadBulk(items);
87
+ }
88
+ }
89
+ catch {
90
+ // file read error, skip
91
+ }
92
+ }
93
+ startFlushTimer() {
94
+ this.flushTimer = setInterval(() => {
95
+ this.flush();
96
+ }, this.config.flushIntervalMs);
97
+ }
98
+ /** Flush all pending writes to disk */
99
+ flush() {
100
+ for (const [name, lines] of this.pendingWrites.entries()) {
101
+ if (lines.length === 0)
102
+ continue;
103
+ const fp = this.filePath(name);
104
+ try {
105
+ (0, fs_1.appendFileSync)(fp, lines.join("\n") + "\n");
106
+ }
107
+ catch {
108
+ // write error, skip
109
+ }
110
+ this.pendingWrites.set(name, []);
111
+ }
112
+ }
113
+ /** Stop flush timer and write remaining data */
114
+ shutdown() {
115
+ if (this.flushTimer) {
116
+ clearInterval(this.flushTimer);
117
+ this.flushTimer = null;
118
+ }
119
+ this.flush();
120
+ }
121
+ }
122
+ exports.LogPersistence = LogPersistence;
123
+ //# sourceMappingURL=persistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persistence.js","sourceRoot":"","sources":["../../src/storage/persistence.ts"],"names":[],"mappings":";;;AAAA,2BAAyE;AACzE,+BAA4B;AAS5B,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE,gBAAgB;IAC1B,UAAU,EAAE,kBAAkB;IAC9B,GAAG,EAAE,WAAW;IAChB,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,mBAAmB;IAChC,MAAM,EAAE,cAAc;IACtB,OAAO,EAAE,eAAe;IACxB,KAAK,EAAE,aAAa;CACZ,CAAC;AAIX,MAAa,cAAc;IACjB,MAAM,CAAgB;IACtB,aAAa,GAA8B,IAAI,GAAG,EAAE,CAAC;IACrD,UAAU,GAA0B,IAAI,CAAC;IAEjD,YAAY,MAAqB;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAChC,IAAA,cAAS,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEpC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAiB,EAAE,CAAC;YACxD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAEO,YAAY;QAClB,MAAM,CAAC,GAAG,IAAI,CAAC,MA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D,QAAQ;QACN,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;QACD,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF;AA5HD,wCA4HC"}
@@ -0,0 +1,8 @@
1
+ import { LogStore } from "../storage/log-store.js";
2
+ export declare function handleClearLogs(store: LogStore): {
3
+ content: {
4
+ type: "text";
5
+ text: string;
6
+ }[];
7
+ };
8
+ //# sourceMappingURL=clear-logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-logs.d.ts","sourceRoot":"","sources":["../../src/tools/clear-logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ;;;;;EAW9C"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleClearLogs = handleClearLogs;
4
+ function handleClearLogs(store) {
5
+ store.clearAll();
6
+ return {
7
+ content: [
8
+ {
9
+ type: "text",
10
+ text: "All log buffers cleared successfully.",
11
+ },
12
+ ],
13
+ };
14
+ }
15
+ //# sourceMappingURL=clear-logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clear-logs.js","sourceRoot":"","sources":["../../src/tools/clear-logs.ts"],"names":[],"mappings":";;AAEA,0CAWC;AAXD,SAAgB,eAAe,CAAC,KAAe;IAC7C,KAAK,CAAC,QAAQ,EAAE,CAAC;IAEjB,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,uCAAuC;aAC9C;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { LogStore } from "../storage/log-store.js";
2
+ export declare function handleGetApiCalls(store: LogStore, args: {
3
+ endpoint_filter?: string;
4
+ last_n?: number;
5
+ }): {
6
+ content: {
7
+ type: "text";
8
+ text: string;
9
+ }[];
10
+ };
11
+ //# sourceMappingURL=get-api-calls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-api-calls.d.ts","sourceRoot":"","sources":["../../src/tools/get-api-calls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;EA4BpD"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleGetApiCalls = handleGetApiCalls;
4
+ function handleGetApiCalls(store, args) {
5
+ let calls = store.apiCalls.getAll();
6
+ if (args.endpoint_filter) {
7
+ const regex = new RegExp(args.endpoint_filter, "i");
8
+ calls = calls.filter((c) => regex.test(c.url));
9
+ }
10
+ if (args.last_n) {
11
+ calls = calls.slice(-args.last_n);
12
+ }
13
+ return {
14
+ content: [
15
+ {
16
+ type: "text",
17
+ text: calls.length
18
+ ? calls
19
+ .map((c) => `[${c.timestamp}] ${c.method} ${c.url} → ${c.status ?? "pending"}${c.duration ? ` (${c.duration}ms)` : ""}\nRequest: ${JSON.stringify(c.requestBody, null, 2) ?? "—"}\nResponse: ${JSON.stringify(c.responseBody, null, 2) ?? "—"}`)
20
+ .join("\n\n---\n\n")
21
+ : "No API calls captured yet.",
22
+ },
23
+ ],
24
+ };
25
+ }
26
+ //# sourceMappingURL=get-api-calls.js.map