everything-dev 0.3.3 → 1.3.3
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 +64 -0
- package/cli.js +10 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/api-contract.cjs +172 -0
- package/dist/api-contract.cjs.map +1 -0
- package/dist/api-contract.mjs +171 -0
- package/dist/api-contract.mjs.map +1 -0
- package/dist/api.cjs +124 -0
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +36 -0
- package/dist/api.d.cts.map +1 -0
- package/dist/api.d.mts +36 -0
- package/dist/api.d.mts.map +1 -0
- package/dist/api.mjs +119 -0
- package/dist/api.mjs.map +1 -0
- package/dist/app.cjs +156 -0
- package/dist/app.cjs.map +1 -0
- package/dist/app.mjs +153 -0
- package/dist/app.mjs.map +1 -0
- package/dist/cli/catalog.cjs +30 -0
- package/dist/cli/catalog.cjs.map +1 -0
- package/dist/cli/catalog.mjs +29 -0
- package/dist/cli/catalog.mjs.map +1 -0
- package/dist/cli/help.cjs +16 -0
- package/dist/cli/help.cjs.map +1 -0
- package/dist/cli/help.mjs +16 -0
- package/dist/cli/help.mjs.map +1 -0
- package/dist/cli/init.cjs +287 -0
- package/dist/cli/init.cjs.map +1 -0
- package/dist/cli/init.d.cts +36 -0
- package/dist/cli/init.d.cts.map +1 -0
- package/dist/cli/init.d.mts +36 -0
- package/dist/cli/init.d.mts.map +1 -0
- package/dist/cli/init.mjs +279 -0
- package/dist/cli/init.mjs.map +1 -0
- package/dist/cli/parse.cjs +96 -0
- package/dist/cli/parse.cjs.map +1 -0
- package/dist/cli/parse.mjs +95 -0
- package/dist/cli/parse.mjs.map +1 -0
- package/dist/cli/prompts.cjs +42 -0
- package/dist/cli/prompts.cjs.map +1 -0
- package/dist/cli/prompts.mjs +41 -0
- package/dist/cli/prompts.mjs.map +1 -0
- package/dist/cli.cjs +167 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +166 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/components/dev-view.cjs +307 -0
- package/dist/components/dev-view.cjs.map +1 -0
- package/dist/components/dev-view.mjs +306 -0
- package/dist/components/dev-view.mjs.map +1 -0
- package/dist/components/streaming-view.cjs +146 -0
- package/dist/components/streaming-view.cjs.map +1 -0
- package/dist/components/streaming-view.mjs +144 -0
- package/dist/components/streaming-view.mjs.map +1 -0
- package/dist/config.cjs +280 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +35 -0
- package/dist/config.d.cts.map +1 -0
- package/dist/config.d.mts +35 -0
- package/dist/config.d.mts.map +1 -0
- package/dist/config.mjs +266 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contract.cjs +209 -0
- package/dist/contract.cjs.map +1 -0
- package/dist/contract.d.cts +490 -0
- package/dist/contract.d.cts.map +1 -0
- package/dist/contract.d.mts +490 -0
- package/dist/contract.d.mts.map +1 -0
- package/dist/contract.meta.cjs +104 -0
- package/dist/contract.meta.cjs.map +1 -0
- package/dist/contract.meta.d.cts +141 -0
- package/dist/contract.meta.d.cts.map +1 -0
- package/dist/contract.meta.d.mts +141 -0
- package/dist/contract.meta.d.mts.map +1 -0
- package/dist/contract.meta.mjs +102 -0
- package/dist/contract.meta.mjs.map +1 -0
- package/dist/contract.mjs +186 -0
- package/dist/contract.mjs.map +1 -0
- package/dist/dev-logs.cjs +53 -0
- package/dist/dev-logs.cjs.map +1 -0
- package/dist/dev-logs.mjs +51 -0
- package/dist/dev-logs.mjs.map +1 -0
- package/dist/dev-session.cjs +195 -0
- package/dist/dev-session.cjs.map +1 -0
- package/dist/dev-session.mjs +194 -0
- package/dist/dev-session.mjs.map +1 -0
- package/dist/fastkv.cjs +89 -0
- package/dist/fastkv.cjs.map +1 -0
- package/dist/fastkv.d.cts +11 -0
- package/dist/fastkv.d.cts.map +1 -0
- package/dist/fastkv.d.mts +11 -0
- package/dist/fastkv.d.mts.map +1 -0
- package/dist/fastkv.mjs +82 -0
- package/dist/fastkv.mjs.map +1 -0
- package/dist/federation.server.cjs +27 -0
- package/dist/federation.server.cjs.map +1 -0
- package/dist/federation.server.mjs +27 -0
- package/dist/federation.server.mjs.map +1 -0
- package/dist/host.cjs +367 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.d.cts +22 -0
- package/dist/host.d.cts.map +1 -0
- package/dist/host.d.mts +22 -0
- package/dist/host.d.mts.map +1 -0
- package/dist/host.mjs +364 -0
- package/dist/host.mjs.map +1 -0
- package/dist/index.cjs +122 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +9 -0
- package/dist/integrity.cjs +39 -0
- package/dist/integrity.cjs.map +1 -0
- package/dist/integrity.d.cts +7 -0
- package/dist/integrity.d.cts.map +1 -0
- package/dist/integrity.d.mts +7 -0
- package/dist/integrity.d.mts.map +1 -0
- package/dist/integrity.mjs +35 -0
- package/dist/integrity.mjs.map +1 -0
- package/dist/internal/manifest-normalizer.cjs +140 -0
- package/dist/internal/manifest-normalizer.cjs.map +1 -0
- package/dist/internal/manifest-normalizer.mjs +138 -0
- package/dist/internal/manifest-normalizer.mjs.map +1 -0
- package/dist/mf.cjs +77 -0
- package/dist/mf.cjs.map +1 -0
- package/dist/mf.d.cts +19 -0
- package/dist/mf.d.cts.map +1 -0
- package/dist/mf.d.mts +19 -0
- package/dist/mf.d.mts.map +1 -0
- package/dist/mf.mjs +71 -0
- package/dist/mf.mjs.map +1 -0
- package/dist/near-cli.cjs +196 -0
- package/dist/near-cli.cjs.map +1 -0
- package/dist/near-cli.mjs +193 -0
- package/dist/near-cli.mjs.map +1 -0
- package/dist/network.cjs +9 -0
- package/dist/network.cjs.map +1 -0
- package/dist/network.mjs +8 -0
- package/dist/network.mjs.map +1 -0
- package/dist/orchestrator.cjs +441 -0
- package/dist/orchestrator.cjs.map +1 -0
- package/dist/orchestrator.d.cts +40 -0
- package/dist/orchestrator.d.cts.map +1 -0
- package/dist/orchestrator.d.mts +40 -0
- package/dist/orchestrator.d.mts.map +1 -0
- package/dist/orchestrator.mjs +436 -0
- package/dist/orchestrator.mjs.map +1 -0
- package/dist/plugin.cjs +830 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts +347 -0
- package/dist/plugin.d.cts.map +1 -0
- package/dist/plugin.d.mts +348 -0
- package/dist/plugin.d.mts.map +1 -0
- package/dist/plugin.mjs +827 -0
- package/dist/plugin.mjs.map +1 -0
- package/dist/process-registry.cjs +120 -0
- package/dist/process-registry.cjs.map +1 -0
- package/dist/process-registry.d.cts +25 -0
- package/dist/process-registry.d.cts.map +1 -0
- package/dist/process-registry.d.mts +25 -0
- package/dist/process-registry.d.mts.map +1 -0
- package/dist/process-registry.mjs +119 -0
- package/dist/process-registry.mjs.map +1 -0
- package/dist/sdk.cjs +61 -0
- package/dist/sdk.d.cts +5 -0
- package/dist/sdk.d.mts +5 -0
- package/dist/sdk.mjs +6 -0
- package/dist/shared.cjs +143 -0
- package/dist/shared.cjs.map +1 -0
- package/dist/shared.d.cts +33 -0
- package/dist/shared.d.cts.map +1 -0
- package/dist/shared.d.mts +33 -0
- package/dist/shared.d.mts.map +1 -0
- package/dist/shared.mjs +140 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/types.cjs +160 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +269 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +269 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +144 -0
- package/dist/types.mjs.map +1 -0
- package/dist/ui/head.cjs +67 -0
- package/dist/ui/head.cjs.map +1 -0
- package/dist/ui/head.d.cts +19 -0
- package/dist/ui/head.d.cts.map +1 -0
- package/dist/ui/head.d.mts +19 -0
- package/dist/ui/head.d.mts.map +1 -0
- package/dist/ui/head.mjs +61 -0
- package/dist/ui/head.mjs.map +1 -0
- package/dist/ui/index.cjs +32 -0
- package/dist/ui/index.d.cts +7 -0
- package/dist/ui/index.d.mts +7 -0
- package/dist/ui/index.mjs +6 -0
- package/dist/ui/metadata.cjs +106 -0
- package/dist/ui/metadata.cjs.map +1 -0
- package/dist/ui/metadata.d.cts +35 -0
- package/dist/ui/metadata.d.cts.map +1 -0
- package/dist/ui/metadata.d.mts +35 -0
- package/dist/ui/metadata.d.mts.map +1 -0
- package/dist/ui/metadata.mjs +100 -0
- package/dist/ui/metadata.mjs.map +1 -0
- package/dist/ui/router.cjs +56 -0
- package/dist/ui/router.cjs.map +1 -0
- package/dist/ui/router.d.cts +11 -0
- package/dist/ui/router.d.cts.map +1 -0
- package/dist/ui/router.d.mts +11 -0
- package/dist/ui/router.d.mts.map +1 -0
- package/dist/ui/router.mjs +51 -0
- package/dist/ui/router.mjs.map +1 -0
- package/dist/ui/runtime.cjs +65 -0
- package/dist/ui/runtime.cjs.map +1 -0
- package/dist/ui/runtime.d.cts +29 -0
- package/dist/ui/runtime.d.cts.map +1 -0
- package/dist/ui/runtime.d.mts +29 -0
- package/dist/ui/runtime.d.mts.map +1 -0
- package/dist/ui/runtime.mjs +53 -0
- package/dist/ui/runtime.mjs.map +1 -0
- package/dist/ui/types.cjs +0 -0
- package/dist/ui/types.d.cts +52 -0
- package/dist/ui/types.d.cts.map +1 -0
- package/dist/ui/types.d.mts +52 -0
- package/dist/ui/types.d.mts.map +1 -0
- package/dist/ui/types.mjs +1 -0
- package/dist/utils/banner.cjs +24 -0
- package/dist/utils/banner.cjs.map +1 -0
- package/dist/utils/banner.mjs +23 -0
- package/dist/utils/banner.mjs.map +1 -0
- package/dist/utils/linkify.cjs +15 -0
- package/dist/utils/linkify.cjs.map +1 -0
- package/dist/utils/linkify.mjs +14 -0
- package/dist/utils/linkify.mjs.map +1 -0
- package/dist/utils/run.cjs +40 -0
- package/dist/utils/run.cjs.map +1 -0
- package/dist/utils/run.mjs +39 -0
- package/dist/utils/run.mjs.map +1 -0
- package/dist/utils/theme.cjs +44 -0
- package/dist/utils/theme.cjs.map +1 -0
- package/dist/utils/theme.mjs +37 -0
- package/dist/utils/theme.mjs.map +1 -0
- package/package.json +269 -80
- package/src/api-contract.ts +309 -0
- package/src/api.ts +181 -0
- package/src/app.ts +346 -0
- package/src/cli/catalog.ts +49 -0
- package/src/cli/help.ts +13 -0
- package/src/cli/init.ts +386 -0
- package/src/cli/parse.ts +130 -0
- package/src/cli/prompts.ts +64 -0
- package/src/cli.ts +203 -1507
- package/src/components/dev-view.tsx +307 -255
- package/src/components/streaming-view.ts +164 -128
- package/src/config.ts +462 -532
- package/src/contract.meta.ts +96 -0
- package/src/contract.ts +164 -561
- package/src/dev-logs.ts +85 -0
- package/src/dev-session.ts +318 -0
- package/src/fastkv.ts +153 -0
- package/src/federation.server.ts +43 -0
- package/src/host.ts +526 -0
- package/src/index.ts +6 -3
- package/src/integrity.ts +54 -0
- package/src/internal/manifest-normalizer.ts +251 -0
- package/src/mf.ts +105 -0
- package/src/near-cli.ts +284 -0
- package/src/network.ts +3 -0
- package/src/orchestrator.ts +648 -0
- package/src/plugin.ts +1130 -2311
- package/src/process-registry.ts +154 -0
- package/src/scripts/sync-api-contract.ts +24 -0
- package/src/sdk.ts +14 -0
- package/src/shared.ts +206 -0
- package/src/types.ts +152 -206
- package/src/ui/head.ts +34 -27
- package/src/ui/index.ts +3 -3
- package/src/ui/metadata.ts +95 -0
- package/src/ui/router.ts +22 -6
- package/src/ui/runtime.ts +55 -6
- package/src/ui/types.ts +24 -11
- package/src/utils/banner.ts +10 -6
- package/src/utils/run.ts +26 -27
- package/src/utils/theme.ts +3 -66
- package/src/components/monitor-view.tsx +0 -475
- package/src/components/status-view.tsx +0 -173
- package/src/lib/env.ts +0 -109
- package/src/lib/near-cli.ts +0 -289
- package/src/lib/nova.ts +0 -266
- package/src/lib/orchestrator.ts +0 -276
- package/src/lib/process-registry.ts +0 -166
- package/src/lib/process.ts +0 -550
- package/src/lib/resource-monitor/assertions.ts +0 -234
- package/src/lib/resource-monitor/command.ts +0 -283
- package/src/lib/resource-monitor/diff.ts +0 -157
- package/src/lib/resource-monitor/errors.ts +0 -127
- package/src/lib/resource-monitor/index.ts +0 -305
- package/src/lib/resource-monitor/platform/darwin.ts +0 -306
- package/src/lib/resource-monitor/platform/index.ts +0 -35
- package/src/lib/resource-monitor/platform/linux.ts +0 -332
- package/src/lib/resource-monitor/platform/windows.ts +0 -298
- package/src/lib/resource-monitor/snapshot.ts +0 -217
- package/src/lib/resource-monitor/types.ts +0 -74
- package/src/lib/session-recorder/errors.ts +0 -102
- package/src/lib/session-recorder/flows/login.ts +0 -210
- package/src/lib/session-recorder/index.ts +0 -361
- package/src/lib/session-recorder/playwright.ts +0 -257
- package/src/lib/session-recorder/report.ts +0 -353
- package/src/lib/session-recorder/server.ts +0 -268
- package/src/lib/session-recorder/types.ts +0 -115
- package/src/lib/sync.ts +0 -1
- package/src/ui/files.ts +0 -134
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { Data } from "effect";
|
|
2
|
-
import type { PortInfo, ProcessInfo } from "./types";
|
|
3
|
-
|
|
4
|
-
export class CommandFailed extends Data.TaggedError("CommandFailed")<{
|
|
5
|
-
readonly command: string;
|
|
6
|
-
readonly args: string[];
|
|
7
|
-
readonly exitCode: number;
|
|
8
|
-
readonly stderr: string;
|
|
9
|
-
}> {
|
|
10
|
-
get message() {
|
|
11
|
-
return `Command '${this.command} ${this.args.join(" ")}' failed with exit code ${this.exitCode}: ${this.stderr}`;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class CommandTimeout extends Data.TaggedError("CommandTimeout")<{
|
|
16
|
-
readonly command: string;
|
|
17
|
-
readonly timeoutMs: number;
|
|
18
|
-
}> {
|
|
19
|
-
get message() {
|
|
20
|
-
return `Command '${this.command}' timed out after ${this.timeoutMs}ms`;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class ParseError extends Data.TaggedError("ParseError")<{
|
|
25
|
-
readonly source: string;
|
|
26
|
-
readonly raw: string;
|
|
27
|
-
readonly reason: string;
|
|
28
|
-
}> {
|
|
29
|
-
get message() {
|
|
30
|
-
return `Failed to parse ${this.source}: ${this.reason}`;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class PortStillBound extends Data.TaggedError("PortStillBound")<{
|
|
35
|
-
readonly ports: Array<{ port: number; pid: number | null; command: string | null }>;
|
|
36
|
-
}> {
|
|
37
|
-
get message() {
|
|
38
|
-
const portList = this.ports.map((p) => `:${p.port} (PID ${p.pid})`).join(", ");
|
|
39
|
-
return `Expected ports to be free, but still bound: ${portList}`;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export class OrphanedProcesses extends Data.TaggedError("OrphanedProcesses")<{
|
|
44
|
-
readonly processes: Array<{ pid: number; command: string; rss: number }>;
|
|
45
|
-
}> {
|
|
46
|
-
get message() {
|
|
47
|
-
return `Found ${this.processes.length} orphaned processes still running`;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export class MemoryLimitExceeded extends Data.TaggedError("MemoryLimitExceeded")<{
|
|
52
|
-
readonly deltaMB: number;
|
|
53
|
-
readonly limitMB: number;
|
|
54
|
-
readonly baselineRss: number;
|
|
55
|
-
readonly afterRss: number;
|
|
56
|
-
}> {
|
|
57
|
-
get message() {
|
|
58
|
-
return `Memory delta ${this.deltaMB.toFixed(1)} MB exceeds limit ${this.limitMB} MB`;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export class MemoryPercentExceeded extends Data.TaggedError("MemoryPercentExceeded")<{
|
|
63
|
-
readonly deltaPercent: number;
|
|
64
|
-
readonly limitPercent: number;
|
|
65
|
-
readonly baselineRss: number;
|
|
66
|
-
readonly afterRss: number;
|
|
67
|
-
}> {
|
|
68
|
-
get message() {
|
|
69
|
-
return `Memory delta ${this.deltaPercent.toFixed(1)}% exceeds limit ${this.limitPercent}%`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export class ProcessesStillAlive extends Data.TaggedError("ProcessesStillAlive")<{
|
|
74
|
-
readonly pids: number[];
|
|
75
|
-
}> {
|
|
76
|
-
get message() {
|
|
77
|
-
return `Expected processes to be dead, but ${this.pids.length} still alive: ${this.pids.join(", ")}`;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export class ResourceLeaks extends Data.TaggedError("ResourceLeaks")<{
|
|
82
|
-
readonly orphanedProcesses: ProcessInfo[];
|
|
83
|
-
readonly stillBoundPorts: PortInfo[];
|
|
84
|
-
}> {
|
|
85
|
-
get message() {
|
|
86
|
-
const parts: string[] = [];
|
|
87
|
-
if (this.orphanedProcesses.length > 0) {
|
|
88
|
-
parts.push(`${this.orphanedProcesses.length} orphaned processes`);
|
|
89
|
-
}
|
|
90
|
-
if (this.stillBoundPorts.length > 0) {
|
|
91
|
-
parts.push(`${this.stillBoundPorts.length} ports still bound`);
|
|
92
|
-
}
|
|
93
|
-
return `Resource leaks detected: ${parts.join(", ")}`;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export class ConfigNotFound extends Data.TaggedError("ConfigNotFound")<{
|
|
98
|
-
readonly path: string | undefined;
|
|
99
|
-
}> {
|
|
100
|
-
get message() {
|
|
101
|
-
return this.path
|
|
102
|
-
? `Config not found at ${this.path}`
|
|
103
|
-
: `No bos.config.json found in project`;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export class FileReadError extends Data.TaggedError("FileReadError")<{
|
|
108
|
-
readonly path: string;
|
|
109
|
-
readonly reason: string;
|
|
110
|
-
}> {
|
|
111
|
-
get message() {
|
|
112
|
-
return `Failed to read ${this.path}: ${this.reason}`;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export type MonitorError =
|
|
117
|
-
| CommandFailed
|
|
118
|
-
| CommandTimeout
|
|
119
|
-
| ParseError
|
|
120
|
-
| PortStillBound
|
|
121
|
-
| OrphanedProcesses
|
|
122
|
-
| MemoryLimitExceeded
|
|
123
|
-
| MemoryPercentExceeded
|
|
124
|
-
| ProcessesStillAlive
|
|
125
|
-
| ResourceLeaks
|
|
126
|
-
| ConfigNotFound
|
|
127
|
-
| FileReadError;
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
import { writeFile } from "node:fs/promises";
|
|
2
|
-
import { Effect, Logger, LogLevel } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
assertAllPortsFree,
|
|
5
|
-
assertAllPortsFreeWithPlatform,
|
|
6
|
-
assertCleanState,
|
|
7
|
-
assertCleanStateWithPlatform,
|
|
8
|
-
assertMemoryDelta,
|
|
9
|
-
assertNoLeaks,
|
|
10
|
-
assertNoOrphanProcesses,
|
|
11
|
-
assertProcessesDead,
|
|
12
|
-
} from "./assertions";
|
|
13
|
-
import { diffSnapshots, formatDiff, formatSnapshotSummary, hasLeaks } from "./diff";
|
|
14
|
-
import {
|
|
15
|
-
MemoryLimitExceeded,
|
|
16
|
-
MemoryPercentExceeded,
|
|
17
|
-
OrphanedProcesses,
|
|
18
|
-
PortStillBound,
|
|
19
|
-
ProcessesStillAlive,
|
|
20
|
-
ResourceLeaks,
|
|
21
|
-
} from "./errors";
|
|
22
|
-
import { PlatformLive, PlatformService, withPlatform } from "./platform";
|
|
23
|
-
import {
|
|
24
|
-
createSnapshot,
|
|
25
|
-
createSnapshotWithPlatform,
|
|
26
|
-
findBosProcesses,
|
|
27
|
-
isProcessAlive,
|
|
28
|
-
isProcessAliveSync,
|
|
29
|
-
waitForPortFree,
|
|
30
|
-
waitForPortFreeWithPlatform,
|
|
31
|
-
waitForProcessDeath,
|
|
32
|
-
} from "./snapshot";
|
|
33
|
-
import type {
|
|
34
|
-
MemoryInfo,
|
|
35
|
-
MonitorConfig,
|
|
36
|
-
PortInfo,
|
|
37
|
-
ProcessInfo,
|
|
38
|
-
Snapshot,
|
|
39
|
-
SnapshotDiff,
|
|
40
|
-
} from "./types";
|
|
41
|
-
|
|
42
|
-
export class ResourceMonitor {
|
|
43
|
-
private config: MonitorConfig;
|
|
44
|
-
private baseline: Snapshot | null = null;
|
|
45
|
-
private snapshots: Snapshot[] = [];
|
|
46
|
-
|
|
47
|
-
private constructor(config: MonitorConfig) {
|
|
48
|
-
this.config = config;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static create = (
|
|
52
|
-
config?: MonitorConfig
|
|
53
|
-
): Effect.Effect<ResourceMonitor, never, PlatformService> =>
|
|
54
|
-
Effect.gen(function* () {
|
|
55
|
-
yield* Effect.logInfo("Creating ResourceMonitor instance");
|
|
56
|
-
return new ResourceMonitor(config || {});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
static createWithPlatform = (
|
|
60
|
-
config?: MonitorConfig
|
|
61
|
-
): Effect.Effect<ResourceMonitor> =>
|
|
62
|
-
withPlatform(ResourceMonitor.create(config));
|
|
63
|
-
|
|
64
|
-
snapshot(): Effect.Effect<Snapshot, never, PlatformService> {
|
|
65
|
-
const self = this;
|
|
66
|
-
return Effect.gen(function* () {
|
|
67
|
-
const snap = yield* createSnapshot(self.config);
|
|
68
|
-
self.snapshots.push(snap);
|
|
69
|
-
return snap;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
snapshotWithPlatform(): Effect.Effect<Snapshot> {
|
|
74
|
-
return withPlatform(this.snapshot());
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
setBaseline(): Effect.Effect<Snapshot, never, PlatformService> {
|
|
78
|
-
const self = this;
|
|
79
|
-
return Effect.gen(function* () {
|
|
80
|
-
yield* Effect.logInfo("Setting baseline snapshot");
|
|
81
|
-
self.baseline = yield* self.snapshot();
|
|
82
|
-
return self.baseline;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
setBaselineWithPlatform(): Effect.Effect<Snapshot> {
|
|
87
|
-
return withPlatform(this.setBaseline());
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
getBaseline(): Effect.Effect<Snapshot | null> {
|
|
91
|
-
return Effect.succeed(this.baseline);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
clearBaseline(): Effect.Effect<void> {
|
|
95
|
-
return Effect.sync(() => {
|
|
96
|
-
this.baseline = null;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
getSnapshots(): Effect.Effect<Snapshot[]> {
|
|
101
|
-
return Effect.succeed([...this.snapshots]);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
clearSnapshots(): Effect.Effect<void> {
|
|
105
|
-
return Effect.sync(() => {
|
|
106
|
-
this.snapshots = [];
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
diff(from: Snapshot, to: Snapshot): Effect.Effect<SnapshotDiff> {
|
|
111
|
-
return Effect.sync(() => diffSnapshots(from, to));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
diffFromBaseline(to: Snapshot): Effect.Effect<SnapshotDiff | null> {
|
|
115
|
-
return Effect.sync(() => {
|
|
116
|
-
if (!this.baseline) return null;
|
|
117
|
-
return diffSnapshots(this.baseline, to);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
hasLeaks(diff: SnapshotDiff): Effect.Effect<boolean> {
|
|
122
|
-
return Effect.sync(() => hasLeaks(diff));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
assertAllPortsFree(
|
|
126
|
-
ports?: number[]
|
|
127
|
-
): Effect.Effect<void, PortStillBound, PlatformService> {
|
|
128
|
-
const portsToCheck =
|
|
129
|
-
ports ||
|
|
130
|
-
Object.keys(this.baseline?.ports || {}).map((p) => parseInt(p, 10));
|
|
131
|
-
return assertAllPortsFree(portsToCheck);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
assertAllPortsFreeWithPlatform(
|
|
135
|
-
ports?: number[]
|
|
136
|
-
): Effect.Effect<void, PortStillBound> {
|
|
137
|
-
const portsToCheck =
|
|
138
|
-
ports ||
|
|
139
|
-
Object.keys(this.baseline?.ports || {}).map((p) => parseInt(p, 10));
|
|
140
|
-
return assertAllPortsFreeWithPlatform(portsToCheck);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
assertNoOrphanProcesses(
|
|
144
|
-
running: Snapshot,
|
|
145
|
-
after: Snapshot
|
|
146
|
-
): Effect.Effect<void, OrphanedProcesses> {
|
|
147
|
-
return assertNoOrphanProcesses(running, after);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
assertMemoryDelta(
|
|
151
|
-
baseline: Snapshot,
|
|
152
|
-
after: Snapshot,
|
|
153
|
-
options: { maxDeltaMB?: number; maxDeltaPercent?: number }
|
|
154
|
-
): Effect.Effect<void, MemoryLimitExceeded | MemoryPercentExceeded> {
|
|
155
|
-
return assertMemoryDelta(baseline, after, options);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
assertProcessesDead(pids: number[]): Effect.Effect<void, ProcessesStillAlive> {
|
|
159
|
-
return assertProcessesDead(pids);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
assertNoLeaks(diff: SnapshotDiff): Effect.Effect<void, ResourceLeaks> {
|
|
163
|
-
return assertNoLeaks(diff);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
assertCleanState(
|
|
167
|
-
running: Snapshot
|
|
168
|
-
): Effect.Effect<void, PortStillBound | ProcessesStillAlive, PlatformService> {
|
|
169
|
-
return assertCleanState(running);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
assertCleanStateWithPlatform(
|
|
173
|
-
running: Snapshot
|
|
174
|
-
): Effect.Effect<void, PortStillBound | ProcessesStillAlive> {
|
|
175
|
-
return assertCleanStateWithPlatform(running);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
waitForPortFree(
|
|
179
|
-
port: number,
|
|
180
|
-
timeoutMs?: number
|
|
181
|
-
): Effect.Effect<boolean, never, PlatformService> {
|
|
182
|
-
return waitForPortFree(port, timeoutMs);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
waitForPortFreeWithPlatform(
|
|
186
|
-
port: number,
|
|
187
|
-
timeoutMs?: number
|
|
188
|
-
): Effect.Effect<boolean> {
|
|
189
|
-
return waitForPortFreeWithPlatform(port, timeoutMs);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
waitForProcessDeath(pid: number, timeoutMs?: number): Effect.Effect<boolean> {
|
|
193
|
-
return waitForProcessDeath(pid, timeoutMs);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
formatSnapshot(snapshot: Snapshot): Effect.Effect<string> {
|
|
197
|
-
return Effect.sync(() => formatSnapshotSummary(snapshot));
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
formatDiff(diff: SnapshotDiff): Effect.Effect<string> {
|
|
201
|
-
return Effect.sync(() => formatDiff(diff));
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export(filepath: string): Effect.Effect<void> {
|
|
205
|
-
const self = this;
|
|
206
|
-
return Effect.gen(function* () {
|
|
207
|
-
yield* Effect.logInfo(`Exporting monitor data to ${filepath}`);
|
|
208
|
-
|
|
209
|
-
const data = {
|
|
210
|
-
config: self.config,
|
|
211
|
-
baseline: self.baseline,
|
|
212
|
-
snapshots: self.snapshots,
|
|
213
|
-
exportedAt: new Date().toISOString(),
|
|
214
|
-
platform: process.platform,
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
yield* Effect.tryPromise({
|
|
218
|
-
try: () => writeFile(filepath, JSON.stringify(data, null, 2)),
|
|
219
|
-
catch: (e) => new Error(`Failed to export: ${e}`),
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
yield* Effect.logInfo(`Exported ${self.snapshots.length} snapshots`);
|
|
223
|
-
}).pipe(Effect.catchAll(() => Effect.void));
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
toJSON(): Effect.Effect<{
|
|
227
|
-
config: MonitorConfig;
|
|
228
|
-
baseline: Snapshot | null;
|
|
229
|
-
snapshots: Snapshot[];
|
|
230
|
-
}> {
|
|
231
|
-
return Effect.succeed({
|
|
232
|
-
config: this.config,
|
|
233
|
-
baseline: this.baseline,
|
|
234
|
-
snapshots: this.snapshots,
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export const runWithLogging = <A, E>(
|
|
240
|
-
effect: Effect.Effect<A, E, PlatformService>
|
|
241
|
-
): Promise<A> =>
|
|
242
|
-
effect.pipe(
|
|
243
|
-
Effect.provide(PlatformLive),
|
|
244
|
-
Logger.withMinimumLogLevel(LogLevel.Debug),
|
|
245
|
-
Effect.runPromise
|
|
246
|
-
);
|
|
247
|
-
|
|
248
|
-
export const runWithInfo = <A, E>(
|
|
249
|
-
effect: Effect.Effect<A, E, PlatformService>
|
|
250
|
-
): Promise<A> =>
|
|
251
|
-
effect.pipe(
|
|
252
|
-
Effect.provide(PlatformLive),
|
|
253
|
-
Logger.withMinimumLogLevel(LogLevel.Info),
|
|
254
|
-
Effect.runPromise
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
export const runSilent = <A, E>(
|
|
258
|
-
effect: Effect.Effect<A, E, PlatformService>
|
|
259
|
-
): Promise<A> =>
|
|
260
|
-
effect.pipe(
|
|
261
|
-
Effect.provide(PlatformLive),
|
|
262
|
-
Logger.withMinimumLogLevel(LogLevel.Error),
|
|
263
|
-
Effect.runPromise
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
export {
|
|
267
|
-
assertAllPortsFree,
|
|
268
|
-
assertAllPortsFreeWithPlatform,
|
|
269
|
-
assertCleanState,
|
|
270
|
-
assertCleanStateWithPlatform,
|
|
271
|
-
assertMemoryDelta,
|
|
272
|
-
assertNoLeaks,
|
|
273
|
-
assertNoOrphanProcesses,
|
|
274
|
-
assertProcessesDead,
|
|
275
|
-
createSnapshot,
|
|
276
|
-
createSnapshotWithPlatform,
|
|
277
|
-
diffSnapshots,
|
|
278
|
-
findBosProcesses,
|
|
279
|
-
formatDiff,
|
|
280
|
-
formatSnapshotSummary,
|
|
281
|
-
hasLeaks,
|
|
282
|
-
isProcessAlive,
|
|
283
|
-
isProcessAliveSync,
|
|
284
|
-
MemoryLimitExceeded,
|
|
285
|
-
MemoryPercentExceeded,
|
|
286
|
-
OrphanedProcesses,
|
|
287
|
-
PlatformLive,
|
|
288
|
-
PlatformService,
|
|
289
|
-
PortStillBound,
|
|
290
|
-
ProcessesStillAlive,
|
|
291
|
-
ResourceLeaks,
|
|
292
|
-
waitForPortFree,
|
|
293
|
-
waitForPortFreeWithPlatform,
|
|
294
|
-
waitForProcessDeath,
|
|
295
|
-
withPlatform,
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
export type {
|
|
299
|
-
MemoryInfo,
|
|
300
|
-
MonitorConfig,
|
|
301
|
-
PortInfo,
|
|
302
|
-
ProcessInfo,
|
|
303
|
-
Snapshot,
|
|
304
|
-
SnapshotDiff,
|
|
305
|
-
};
|