brakit 0.8.7 → 9.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.
- package/README.md +15 -3
- package/dist/api.d.ts +66 -46
- package/dist/api.js +727 -730
- package/dist/bin/brakit.js +294 -432
- package/dist/dashboard-client.global.js +345 -222
- package/dist/dashboard.html +390 -231
- package/dist/mcp/server.js +7 -15
- package/dist/runtime/index.js +1367 -1607
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,19 +52,31 @@
|
|
|
52
52
|
|
|
53
53
|
## Quick Start
|
|
54
54
|
|
|
55
|
+
### Node.js
|
|
56
|
+
|
|
55
57
|
```bash
|
|
56
58
|
npx brakit install
|
|
59
|
+
npm run dev
|
|
57
60
|
```
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
### Python (FastAPI / Flask)
|
|
60
63
|
|
|
61
64
|
```bash
|
|
62
|
-
|
|
65
|
+
pip install brakit
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import brakit # must be before framework import
|
|
70
|
+
from fastapi import FastAPI
|
|
71
|
+
|
|
72
|
+
app = FastAPI()
|
|
63
73
|
```
|
|
64
74
|
|
|
65
75
|
Dashboard at `http://localhost:<port>/__brakit`. Issues in the terminal.
|
|
66
76
|
|
|
67
|
-
> **
|
|
77
|
+
> **Full setup guide:** [brakit.ai/docs/introduction](https://brakit.ai/docs/introduction)
|
|
78
|
+
|
|
79
|
+
> **Requirements:** Node.js >= 18. Python SDK requires Python >= 3.9.
|
|
68
80
|
|
|
69
81
|
---
|
|
70
82
|
|
package/dist/api.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ interface TracedRequest {
|
|
|
16
16
|
durationMs: number;
|
|
17
17
|
responseSize: number;
|
|
18
18
|
isStatic: boolean;
|
|
19
|
+
isHealthCheck: boolean;
|
|
19
20
|
}
|
|
20
21
|
type RequestListener = (req: TracedRequest) => void;
|
|
21
22
|
|
|
@@ -35,7 +36,7 @@ interface BrakitConfig {
|
|
|
35
36
|
customCommand?: string;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
type RequestCategory = "auth-handshake" | "auth-check" | "middleware" | "server-action" | "api-call" | "data-fetch" | "page-load" | "navigation" | "polling" | "static" | "unknown";
|
|
39
|
+
type RequestCategory = "auth-handshake" | "auth-check" | "health-check" | "middleware" | "server-action" | "api-call" | "data-fetch" | "page-load" | "navigation" | "polling" | "static" | "unknown";
|
|
39
40
|
interface LabeledRequest extends TracedRequest {
|
|
40
41
|
label: string;
|
|
41
42
|
category: RequestCategory;
|
|
@@ -121,6 +122,10 @@ interface EndpointMetrics {
|
|
|
121
122
|
sessions: SessionMetric[];
|
|
122
123
|
dataPoints?: LiveRequestPoint[];
|
|
123
124
|
}
|
|
125
|
+
interface MetricsData {
|
|
126
|
+
version: 1;
|
|
127
|
+
endpoints: EndpointMetrics[];
|
|
128
|
+
}
|
|
124
129
|
interface LiveRequestPoint {
|
|
125
130
|
timestamp: number;
|
|
126
131
|
durationMs: number;
|
|
@@ -382,74 +387,89 @@ interface CaptureInput {
|
|
|
382
387
|
endTime?: number;
|
|
383
388
|
config: Pick<BrakitConfig, "maxBodyCapture">;
|
|
384
389
|
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
390
|
+
declare class RequestStore {
|
|
391
|
+
private maxEntries;
|
|
392
|
+
private requests;
|
|
393
|
+
private listeners;
|
|
394
|
+
constructor(maxEntries?: number);
|
|
395
|
+
capture(input: CaptureInput): TracedRequest;
|
|
396
|
+
add(entry: TracedRequest): void;
|
|
397
|
+
getAll(): readonly TracedRequest[];
|
|
398
|
+
clear(): void;
|
|
399
|
+
onRequest(fn: RequestListener): void;
|
|
400
|
+
offRequest(fn: RequestListener): void;
|
|
389
401
|
}
|
|
390
|
-
|
|
402
|
+
|
|
403
|
+
type TelemetryListener<T> = (entry: T) => void;
|
|
404
|
+
/** Read-only view of a TelemetryStore — used by API handlers that only query data. */
|
|
405
|
+
interface ReadonlyTelemetryStore {
|
|
406
|
+
getAll(): readonly TelemetryEntry[];
|
|
407
|
+
getByRequest(requestId: string): TelemetryEntry[];
|
|
408
|
+
}
|
|
409
|
+
declare class TelemetryStore<T extends TelemetryEntry> implements ReadonlyTelemetryStore {
|
|
410
|
+
private maxEntries;
|
|
411
|
+
private entries;
|
|
412
|
+
private listeners;
|
|
413
|
+
constructor(maxEntries?: number);
|
|
391
414
|
add(data: Omit<T, "id">): T;
|
|
392
415
|
getAll(): readonly T[];
|
|
393
416
|
getByRequest(requestId: string): T[];
|
|
394
417
|
clear(): void;
|
|
418
|
+
onEntry(fn: TelemetryListener<T>): void;
|
|
419
|
+
offEntry(fn: TelemetryListener<T>): void;
|
|
395
420
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
421
|
+
|
|
422
|
+
interface MetricsPersistence {
|
|
423
|
+
load(): MetricsData;
|
|
424
|
+
loadAsync(): Promise<MetricsData>;
|
|
425
|
+
save(data: MetricsData): void;
|
|
426
|
+
saveSync(data: MetricsData): void;
|
|
427
|
+
remove(): void;
|
|
401
428
|
}
|
|
402
|
-
|
|
429
|
+
|
|
430
|
+
declare class MetricsStore {
|
|
431
|
+
private persistence;
|
|
432
|
+
private data;
|
|
433
|
+
private endpointIndex;
|
|
434
|
+
private sessionId;
|
|
435
|
+
private sessionStart;
|
|
436
|
+
private flushTimer;
|
|
437
|
+
private dirty;
|
|
438
|
+
private accumulators;
|
|
439
|
+
private pendingPoints;
|
|
440
|
+
constructor(persistence: MetricsPersistence);
|
|
441
|
+
start(): void;
|
|
442
|
+
stop(): void;
|
|
403
443
|
recordRequest(req: TracedRequest, metrics: RequestMetrics): void;
|
|
404
444
|
getAll(): readonly EndpointMetrics[];
|
|
405
445
|
getEndpoint(endpoint: string): EndpointMetrics | undefined;
|
|
406
446
|
getLiveEndpoints(): LiveEndpointData[];
|
|
407
447
|
reset(): void;
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
upsert(issue: Issue, source: IssueSource): StatefulIssue;
|
|
411
|
-
transition(issueId: string, state: IssueState): boolean;
|
|
412
|
-
reportFix(issueId: string, status: AiFixStatus, notes: string): boolean;
|
|
413
|
-
reconcile(currentIssueIds: Set<string>, activeEndpoints: Set<string>): void;
|
|
414
|
-
getAll(): readonly StatefulIssue[];
|
|
415
|
-
getByState(state: IssueState): readonly StatefulIssue[];
|
|
416
|
-
getByCategory(category: IssueCategory): readonly StatefulIssue[];
|
|
417
|
-
get(issueId: string): StatefulIssue | undefined;
|
|
418
|
-
clear(): void;
|
|
419
|
-
}
|
|
420
|
-
interface AnalysisEngineInterface extends Lifecycle {
|
|
421
|
-
recompute(): void;
|
|
422
|
-
getInsights(): readonly Insight[];
|
|
423
|
-
getFindings(): readonly SecurityFinding[];
|
|
448
|
+
flush(sync?: boolean): void;
|
|
449
|
+
private getOrCreateEndpoint;
|
|
424
450
|
}
|
|
425
451
|
|
|
426
|
-
interface
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
declare class ServiceRegistry {
|
|
438
|
-
private services;
|
|
439
|
-
register<K extends keyof ServiceMap>(name: K, service: ServiceMap[K]): void;
|
|
440
|
-
get<K extends keyof ServiceMap>(name: K): ServiceMap[K];
|
|
441
|
-
has<K extends keyof ServiceMap>(name: K): boolean;
|
|
452
|
+
interface Services {
|
|
453
|
+
bus: EventBus;
|
|
454
|
+
requestStore: RequestStore;
|
|
455
|
+
queryStore: TelemetryStore<TracedQuery>;
|
|
456
|
+
fetchStore: TelemetryStore<TracedFetch>;
|
|
457
|
+
logStore: TelemetryStore<TracedLog>;
|
|
458
|
+
errorStore: TelemetryStore<TracedError>;
|
|
459
|
+
metricsStore: MetricsStore;
|
|
460
|
+
issueStore: IssueStore;
|
|
461
|
+
analysisEngine: AnalysisEngine;
|
|
442
462
|
}
|
|
443
463
|
|
|
444
464
|
declare class AnalysisEngine {
|
|
445
|
-
private
|
|
465
|
+
private services;
|
|
446
466
|
private debounceMs;
|
|
447
467
|
private scanner;
|
|
448
468
|
private cachedInsights;
|
|
449
469
|
private cachedFindings;
|
|
450
470
|
private debounceTimer;
|
|
451
471
|
private subs;
|
|
452
|
-
constructor(
|
|
472
|
+
constructor(services: Services, debounceMs?: number);
|
|
453
473
|
start(): void;
|
|
454
474
|
stop(): void;
|
|
455
475
|
getInsights(): readonly Insight[];
|