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,475 +0,0 @@
|
|
|
1
|
-
import { Effect, Logger, LogLevel } from "effect";
|
|
2
|
-
import { Box, render, Text, useApp, useInput } from "ink";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { getConfig, getProjectRoot } from "../config";
|
|
5
|
-
import {
|
|
6
|
-
createSnapshotWithPlatform,
|
|
7
|
-
diffSnapshots,
|
|
8
|
-
type MonitorConfig,
|
|
9
|
-
PlatformLive,
|
|
10
|
-
ResourceMonitor,
|
|
11
|
-
type Snapshot,
|
|
12
|
-
type SnapshotDiff,
|
|
13
|
-
} from "../lib/resource-monitor";
|
|
14
|
-
import { colors, divider, frames, gradients, icons } from "../utils/theme";
|
|
15
|
-
|
|
16
|
-
type Phase = "baseline" | "running" | "stopped";
|
|
17
|
-
|
|
18
|
-
interface MonitorViewProps {
|
|
19
|
-
baseline: Snapshot | null;
|
|
20
|
-
current: Snapshot | null;
|
|
21
|
-
diff: SnapshotDiff | null;
|
|
22
|
-
phase: Phase;
|
|
23
|
-
refreshing: boolean;
|
|
24
|
-
onRefresh: () => void;
|
|
25
|
-
onSnapshot: () => void;
|
|
26
|
-
onExport: () => void;
|
|
27
|
-
onExit: () => void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function formatBytes(bytes: number): string {
|
|
31
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
32
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
33
|
-
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function PortRow({
|
|
37
|
-
port,
|
|
38
|
-
info,
|
|
39
|
-
}: {
|
|
40
|
-
port: number;
|
|
41
|
-
info: { pid: number | null; command: string | null; state: string };
|
|
42
|
-
}) {
|
|
43
|
-
const isFree = info.state === "FREE";
|
|
44
|
-
const icon = isFree ? "○" : "●";
|
|
45
|
-
const statusColor = isFree ? "gray" : "#00ff41";
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Box>
|
|
49
|
-
<Text color={statusColor}> {icon} </Text>
|
|
50
|
-
<Text color="#00ffff">:{port.toString().padEnd(5)}</Text>
|
|
51
|
-
{isFree ? (
|
|
52
|
-
<Text color="gray">free</Text>
|
|
53
|
-
) : (
|
|
54
|
-
<Text>
|
|
55
|
-
<Text color="#ff00ff">{info.pid}</Text>
|
|
56
|
-
<Text color="gray"> {info.command}</Text>
|
|
57
|
-
</Text>
|
|
58
|
-
)}
|
|
59
|
-
</Box>
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function ProcessRow({
|
|
64
|
-
proc,
|
|
65
|
-
}: {
|
|
66
|
-
proc: { pid: number; command: string; rss: number; children: number[] };
|
|
67
|
-
}) {
|
|
68
|
-
const childCount = proc.children.length;
|
|
69
|
-
const childText = childCount > 0 ? ` [${childCount}]` : "";
|
|
70
|
-
|
|
71
|
-
return (
|
|
72
|
-
<Box>
|
|
73
|
-
<Text color="#00ffff"> {proc.pid.toString().padEnd(7)}</Text>
|
|
74
|
-
<Text>{proc.command.slice(0, 20).padEnd(20)}</Text>
|
|
75
|
-
<Text color="#ff00ff">{formatBytes(proc.rss).padStart(10)}</Text>
|
|
76
|
-
<Text color="gray">{childText}</Text>
|
|
77
|
-
</Box>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function SnapshotSection({
|
|
82
|
-
title,
|
|
83
|
-
snapshot,
|
|
84
|
-
}: {
|
|
85
|
-
title: string;
|
|
86
|
-
snapshot: Snapshot | null;
|
|
87
|
-
}) {
|
|
88
|
-
if (!snapshot) {
|
|
89
|
-
return (
|
|
90
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
91
|
-
<Text color="#00ffff"> {title}</Text>
|
|
92
|
-
<Text color="gray"> (waiting for snapshot...)</Text>
|
|
93
|
-
</Box>
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const ports = Object.entries(snapshot.ports);
|
|
98
|
-
const boundPorts = ports.filter(([, info]) => info.state !== "FREE").length;
|
|
99
|
-
const totalRss = formatBytes(snapshot.memory.processRss);
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
103
|
-
<Text color="#00ffff"> {title}</Text>
|
|
104
|
-
<Text color="gray">{divider(50)}</Text>
|
|
105
|
-
|
|
106
|
-
<Text color="gray">
|
|
107
|
-
{" "}
|
|
108
|
-
PORTS ({boundPorts}/{ports.length} bound)
|
|
109
|
-
</Text>
|
|
110
|
-
{ports.map(([port, info]) => (
|
|
111
|
-
<PortRow key={port} port={parseInt(port, 10)} info={info} />
|
|
112
|
-
))}
|
|
113
|
-
|
|
114
|
-
{snapshot.processes.length > 0 && (
|
|
115
|
-
<>
|
|
116
|
-
<Box marginTop={1}>
|
|
117
|
-
<Text color="gray"> PROCESSES ({snapshot.processes.length})</Text>
|
|
118
|
-
</Box>
|
|
119
|
-
{snapshot.processes.slice(0, 8).map((proc) => (
|
|
120
|
-
<ProcessRow key={proc.pid} proc={proc} />
|
|
121
|
-
))}
|
|
122
|
-
{snapshot.processes.length > 8 && (
|
|
123
|
-
<Text color="gray">
|
|
124
|
-
{" "}
|
|
125
|
-
... and {snapshot.processes.length - 8} more
|
|
126
|
-
</Text>
|
|
127
|
-
)}
|
|
128
|
-
</>
|
|
129
|
-
)}
|
|
130
|
-
|
|
131
|
-
<Box marginTop={1}>
|
|
132
|
-
<Text color="gray"> Memory: {totalRss}</Text>
|
|
133
|
-
</Box>
|
|
134
|
-
</Box>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
function DiffSection({ diff }: { diff: SnapshotDiff | null }) {
|
|
139
|
-
if (!diff) return null;
|
|
140
|
-
|
|
141
|
-
const hasLeaks =
|
|
142
|
-
diff.orphanedProcesses.length > 0 || diff.stillBoundPorts.length > 0;
|
|
143
|
-
const memDelta = diff.memoryDeltaBytes;
|
|
144
|
-
const memSign = memDelta >= 0 ? "+" : "";
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<Box flexDirection="column" marginBottom={1}>
|
|
148
|
-
<Text color={hasLeaks ? "#ff3366" : "#00ff41"}>
|
|
149
|
-
{hasLeaks ? ` ${icons.err} LEAKS DETECTED` : ` ${icons.ok} CLEAN`}
|
|
150
|
-
</Text>
|
|
151
|
-
|
|
152
|
-
{diff.stillBoundPorts.length > 0 && (
|
|
153
|
-
<>
|
|
154
|
-
<Text color="#ff3366"> Still Bound:</Text>
|
|
155
|
-
{diff.stillBoundPorts.map((port) => (
|
|
156
|
-
<Text key={port.port} color="#ff3366">
|
|
157
|
-
{" "}
|
|
158
|
-
:{port.port} ← PID {port.pid}
|
|
159
|
-
</Text>
|
|
160
|
-
))}
|
|
161
|
-
</>
|
|
162
|
-
)}
|
|
163
|
-
|
|
164
|
-
{diff.orphanedProcesses.length > 0 && (
|
|
165
|
-
<>
|
|
166
|
-
<Text color="#ff3366"> Orphaned Processes:</Text>
|
|
167
|
-
{diff.orphanedProcesses.map((proc) => (
|
|
168
|
-
<Text key={proc.pid} color="#ff3366">
|
|
169
|
-
{" "}
|
|
170
|
-
{proc.pid} {proc.command}
|
|
171
|
-
</Text>
|
|
172
|
-
))}
|
|
173
|
-
</>
|
|
174
|
-
)}
|
|
175
|
-
|
|
176
|
-
{diff.freedPorts.length > 0 && (
|
|
177
|
-
<Text color="#00ff41"> Freed: {diff.freedPorts.join(", ")}</Text>
|
|
178
|
-
)}
|
|
179
|
-
|
|
180
|
-
<Text color={memDelta > 50 * 1024 * 1024 ? "#ff3366" : "gray"}>
|
|
181
|
-
Memory Delta: {memSign}
|
|
182
|
-
{formatBytes(memDelta)}
|
|
183
|
-
</Text>
|
|
184
|
-
</Box>
|
|
185
|
-
);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function MonitorView({
|
|
189
|
-
baseline,
|
|
190
|
-
current,
|
|
191
|
-
diff,
|
|
192
|
-
phase,
|
|
193
|
-
refreshing,
|
|
194
|
-
onRefresh,
|
|
195
|
-
onSnapshot,
|
|
196
|
-
onExport,
|
|
197
|
-
onExit,
|
|
198
|
-
}: MonitorViewProps) {
|
|
199
|
-
const { exit } = useApp();
|
|
200
|
-
|
|
201
|
-
useInput((input, key) => {
|
|
202
|
-
if (input === "q" || (key.ctrl && input === "c")) {
|
|
203
|
-
onExit();
|
|
204
|
-
exit();
|
|
205
|
-
}
|
|
206
|
-
if (input === "r") onRefresh();
|
|
207
|
-
if (input === "s") onSnapshot();
|
|
208
|
-
if (input === "e") onExport();
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
let account = "unknown";
|
|
212
|
-
let configPath = "";
|
|
213
|
-
try {
|
|
214
|
-
const config = getConfig();
|
|
215
|
-
if (config) {
|
|
216
|
-
account = config.account;
|
|
217
|
-
configPath = `${getProjectRoot()}/bos.config.json`;
|
|
218
|
-
}
|
|
219
|
-
} catch {
|
|
220
|
-
// No config
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const phaseLabel =
|
|
224
|
-
phase === "baseline"
|
|
225
|
-
? "BASELINE"
|
|
226
|
-
: phase === "running"
|
|
227
|
-
? "RUNNING"
|
|
228
|
-
: "STOPPED";
|
|
229
|
-
const phaseColor =
|
|
230
|
-
phase === "baseline" ? "gray" : phase === "running" ? "#00ffff" : "#ff00ff";
|
|
231
|
-
|
|
232
|
-
return (
|
|
233
|
-
<Box flexDirection="column">
|
|
234
|
-
<Box marginBottom={0}>
|
|
235
|
-
<Text color="#00ffff">{frames.top(56)}</Text>
|
|
236
|
-
</Box>
|
|
237
|
-
<Box>
|
|
238
|
-
<Text>
|
|
239
|
-
{" "}
|
|
240
|
-
{icons.scan} {gradients.cyber("BOS RESOURCE MONITOR")}
|
|
241
|
-
</Text>
|
|
242
|
-
</Box>
|
|
243
|
-
<Box marginBottom={1}>
|
|
244
|
-
<Text color="#00ffff">{frames.bottom(56)}</Text>
|
|
245
|
-
</Box>
|
|
246
|
-
|
|
247
|
-
<Box marginBottom={1}>
|
|
248
|
-
<Text color="gray"> Account: </Text>
|
|
249
|
-
<Text color="#00ffff">{account}</Text>
|
|
250
|
-
</Box>
|
|
251
|
-
{configPath && (
|
|
252
|
-
<Box marginBottom={1}>
|
|
253
|
-
<Text color="gray"> Config: </Text>
|
|
254
|
-
<Text color="gray">{configPath}</Text>
|
|
255
|
-
</Box>
|
|
256
|
-
)}
|
|
257
|
-
|
|
258
|
-
<Box marginBottom={1}>
|
|
259
|
-
<Text color="gray"> Phase: </Text>
|
|
260
|
-
<Text color={phaseColor}>{phaseLabel}</Text>
|
|
261
|
-
{refreshing && <Text color="gray"> (refreshing...)</Text>}
|
|
262
|
-
</Box>
|
|
263
|
-
|
|
264
|
-
<Text>{colors.dim(divider(56))}</Text>
|
|
265
|
-
|
|
266
|
-
{phase === "baseline" && (
|
|
267
|
-
<SnapshotSection title="📊 BASELINE" snapshot={baseline} />
|
|
268
|
-
)}
|
|
269
|
-
|
|
270
|
-
{phase === "running" && (
|
|
271
|
-
<>
|
|
272
|
-
<SnapshotSection title="📊 BASELINE" snapshot={baseline} />
|
|
273
|
-
<SnapshotSection title="🔄 CURRENT" snapshot={current} />
|
|
274
|
-
</>
|
|
275
|
-
)}
|
|
276
|
-
|
|
277
|
-
{phase === "stopped" && (
|
|
278
|
-
<>
|
|
279
|
-
<SnapshotSection title="🔄 AFTER STOP" snapshot={current} />
|
|
280
|
-
<DiffSection diff={diff} />
|
|
281
|
-
</>
|
|
282
|
-
)}
|
|
283
|
-
|
|
284
|
-
<Text>{colors.dim(divider(56))}</Text>
|
|
285
|
-
<Box marginTop={1}>
|
|
286
|
-
<Text color="gray"> [r] refresh [s] snapshot [e] export [q] quit</Text>
|
|
287
|
-
</Box>
|
|
288
|
-
</Box>
|
|
289
|
-
);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export interface MonitorViewHandle {
|
|
293
|
-
setPhase: (phase: Phase) => void;
|
|
294
|
-
setBaseline: (snapshot: Snapshot) => void;
|
|
295
|
-
setCurrent: (snapshot: Snapshot) => void;
|
|
296
|
-
setDiff: (diff: SnapshotDiff) => void;
|
|
297
|
-
unmount: () => void;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export interface MonitorViewOptions {
|
|
301
|
-
ports?: number[];
|
|
302
|
-
onExit?: () => void;
|
|
303
|
-
onExport?: (data: unknown) => void;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const runEffect = <A,>(effect: Effect.Effect<A, unknown, never>): Promise<A> =>
|
|
307
|
-
effect.pipe(Logger.withMinimumLogLevel(LogLevel.Info), Effect.runPromise);
|
|
308
|
-
|
|
309
|
-
const runSnapshotEffect = (config?: MonitorConfig): Promise<Snapshot> =>
|
|
310
|
-
createSnapshotWithPlatform(config).pipe(
|
|
311
|
-
Effect.provide(PlatformLive),
|
|
312
|
-
Logger.withMinimumLogLevel(LogLevel.Info),
|
|
313
|
-
Effect.runPromise,
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
export function renderMonitorView(
|
|
317
|
-
options: MonitorViewOptions = {},
|
|
318
|
-
): MonitorViewHandle {
|
|
319
|
-
let phase: Phase = "baseline";
|
|
320
|
-
let baseline: Snapshot | null = null;
|
|
321
|
-
let current: Snapshot | null = null;
|
|
322
|
-
let diff: SnapshotDiff | null = null;
|
|
323
|
-
let refreshing = false;
|
|
324
|
-
let rerender: (() => void) | null = null;
|
|
325
|
-
let monitor: ResourceMonitor | null = null;
|
|
326
|
-
const config: MonitorConfig | undefined = options.ports
|
|
327
|
-
? { ports: options.ports }
|
|
328
|
-
: undefined;
|
|
329
|
-
|
|
330
|
-
const initMonitor = async () => {
|
|
331
|
-
monitor = await runEffect(ResourceMonitor.createWithPlatform(config));
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
initMonitor();
|
|
335
|
-
|
|
336
|
-
const setPhase = (p: Phase) => {
|
|
337
|
-
phase = p;
|
|
338
|
-
rerender?.();
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
const setBaseline = (snap: Snapshot) => {
|
|
342
|
-
baseline = snap;
|
|
343
|
-
rerender?.();
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
const setCurrent = (snap: Snapshot) => {
|
|
347
|
-
current = snap;
|
|
348
|
-
if (baseline && phase === "stopped") {
|
|
349
|
-
diff = diffSnapshots(baseline, snap);
|
|
350
|
-
}
|
|
351
|
-
rerender?.();
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
const setDiff = (d: SnapshotDiff) => {
|
|
355
|
-
diff = d;
|
|
356
|
-
rerender?.();
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
const handleRefresh = async () => {
|
|
360
|
-
if (!monitor) return;
|
|
361
|
-
refreshing = true;
|
|
362
|
-
rerender?.();
|
|
363
|
-
|
|
364
|
-
const snap = await runEffect(monitor.snapshotWithPlatform());
|
|
365
|
-
if (phase === "baseline") {
|
|
366
|
-
baseline = snap;
|
|
367
|
-
} else {
|
|
368
|
-
current = snap;
|
|
369
|
-
if (baseline && phase === "stopped") {
|
|
370
|
-
diff = diffSnapshots(baseline, snap);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
refreshing = false;
|
|
375
|
-
rerender?.();
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
const handleSnapshot = async () => {
|
|
379
|
-
if (!monitor) return;
|
|
380
|
-
const snap = await runEffect(monitor.snapshotWithPlatform());
|
|
381
|
-
|
|
382
|
-
if (!baseline) {
|
|
383
|
-
baseline = snap;
|
|
384
|
-
phase = "running";
|
|
385
|
-
} else if (phase === "running") {
|
|
386
|
-
current = snap;
|
|
387
|
-
} else {
|
|
388
|
-
current = snap;
|
|
389
|
-
diff = diffSnapshots(baseline, snap);
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
rerender?.();
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
const handleExport = async () => {
|
|
396
|
-
if (!monitor) return;
|
|
397
|
-
const exportPath = `.bos/monitor-export-${Date.now()}.json`;
|
|
398
|
-
await runEffect(monitor.export(exportPath));
|
|
399
|
-
options.onExport?.({ path: exportPath });
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
const handleExit = () => {
|
|
403
|
-
options.onExit?.();
|
|
404
|
-
};
|
|
405
|
-
|
|
406
|
-
function MonitorViewWrapper() {
|
|
407
|
-
const [, forceUpdate] = useState(0);
|
|
408
|
-
|
|
409
|
-
useEffect(() => {
|
|
410
|
-
rerender = () => forceUpdate((n) => n + 1);
|
|
411
|
-
|
|
412
|
-
handleRefresh();
|
|
413
|
-
|
|
414
|
-
return () => {
|
|
415
|
-
rerender = null;
|
|
416
|
-
};
|
|
417
|
-
}, []);
|
|
418
|
-
|
|
419
|
-
return (
|
|
420
|
-
<MonitorView
|
|
421
|
-
baseline={baseline}
|
|
422
|
-
current={current}
|
|
423
|
-
diff={diff}
|
|
424
|
-
phase={phase}
|
|
425
|
-
refreshing={refreshing}
|
|
426
|
-
onRefresh={handleRefresh}
|
|
427
|
-
onSnapshot={handleSnapshot}
|
|
428
|
-
onExport={handleExport}
|
|
429
|
-
onExit={handleExit}
|
|
430
|
-
/>
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
const { unmount } = render(<MonitorViewWrapper />);
|
|
435
|
-
|
|
436
|
-
return { setPhase, setBaseline, setCurrent, setDiff, unmount };
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
export async function runMonitorCli(
|
|
440
|
-
options: { ports?: number[]; json?: boolean } = {},
|
|
441
|
-
) {
|
|
442
|
-
const config: MonitorConfig | undefined = options.ports
|
|
443
|
-
? { ports: options.ports }
|
|
444
|
-
: undefined;
|
|
445
|
-
|
|
446
|
-
if (options.json) {
|
|
447
|
-
const snapshot = await runSnapshotEffect(config);
|
|
448
|
-
console.log(JSON.stringify(snapshot, null, 2));
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
const monitor = await runEffect(ResourceMonitor.createWithPlatform(config));
|
|
453
|
-
|
|
454
|
-
const view = renderMonitorView({
|
|
455
|
-
ports: options.ports,
|
|
456
|
-
onExit: () => process.exit(0),
|
|
457
|
-
onExport: (data) =>
|
|
458
|
-
console.log("Exported to:", (data as { path: string }).path),
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
const baseline = await runEffect(monitor.setBaselineWithPlatform());
|
|
462
|
-
view.setBaseline(baseline);
|
|
463
|
-
view.setPhase("baseline");
|
|
464
|
-
|
|
465
|
-
const interval = setInterval(async () => {
|
|
466
|
-
const snap = await runEffect(monitor.snapshotWithPlatform());
|
|
467
|
-
view.setCurrent(snap);
|
|
468
|
-
}, 2000);
|
|
469
|
-
|
|
470
|
-
process.on("SIGINT", () => {
|
|
471
|
-
clearInterval(interval);
|
|
472
|
-
view.unmount();
|
|
473
|
-
process.exit(0);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import { render, Text, Box } from "ink";
|
|
3
|
-
import { colors, icons, gradients, divider } from "../utils/theme";
|
|
4
|
-
|
|
5
|
-
interface Endpoint {
|
|
6
|
-
name: string;
|
|
7
|
-
url: string;
|
|
8
|
-
type: "host" | "remote" | "ssr";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface StatusResult {
|
|
12
|
-
ok: boolean;
|
|
13
|
-
ms: number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface StatusViewProps {
|
|
17
|
-
endpoints: Endpoint[];
|
|
18
|
-
env: string;
|
|
19
|
-
onComplete?: () => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function checkHealth(url: string): Promise<StatusResult> {
|
|
23
|
-
const start = Date.now();
|
|
24
|
-
try {
|
|
25
|
-
const response = await fetch(url, { method: "HEAD" });
|
|
26
|
-
return { ok: response.ok, ms: Date.now() - start };
|
|
27
|
-
} catch {
|
|
28
|
-
return { ok: false, ms: Date.now() - start };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function StatusRow({
|
|
33
|
-
name,
|
|
34
|
-
url,
|
|
35
|
-
status,
|
|
36
|
-
}: {
|
|
37
|
-
name: string;
|
|
38
|
-
url: string;
|
|
39
|
-
status: StatusResult | "checking" | "pending";
|
|
40
|
-
}) {
|
|
41
|
-
const icon =
|
|
42
|
-
status === "checking"
|
|
43
|
-
? colors.cyan("[~]")
|
|
44
|
-
: status === "pending"
|
|
45
|
-
? colors.dim("[ ]")
|
|
46
|
-
: status.ok
|
|
47
|
-
? colors.green("[-]")
|
|
48
|
-
: colors.magenta("[!]");
|
|
49
|
-
|
|
50
|
-
const timing =
|
|
51
|
-
status === "checking"
|
|
52
|
-
? colors.cyan("checking...")
|
|
53
|
-
: status === "pending"
|
|
54
|
-
? colors.dim("--")
|
|
55
|
-
: status.ok
|
|
56
|
-
? colors.green(`${status.ms}ms`)
|
|
57
|
-
: colors.magenta(`${status.ms}ms`);
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<Box>
|
|
61
|
-
<Text>
|
|
62
|
-
{" "}
|
|
63
|
-
{icon} {name.padEnd(12)} {timing.padEnd(14)} {colors.dim(url)}
|
|
64
|
-
</Text>
|
|
65
|
-
</Box>
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function StatusView({ endpoints, env, onComplete }: StatusViewProps) {
|
|
70
|
-
const [results, setResults] = useState<
|
|
71
|
-
Record<string, StatusResult | "checking" | "pending">
|
|
72
|
-
>(() => {
|
|
73
|
-
const initial: Record<string, "pending"> = {};
|
|
74
|
-
for (const ep of endpoints) {
|
|
75
|
-
initial[ep.name] = "pending";
|
|
76
|
-
}
|
|
77
|
-
return initial;
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const [done, setDone] = useState(false);
|
|
81
|
-
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
let mounted = true;
|
|
84
|
-
|
|
85
|
-
async function runChecks() {
|
|
86
|
-
for (const ep of endpoints) {
|
|
87
|
-
if (!mounted) return;
|
|
88
|
-
setResults((prev) => ({ ...prev, [ep.name]: "checking" }));
|
|
89
|
-
|
|
90
|
-
const result = await checkHealth(ep.url);
|
|
91
|
-
|
|
92
|
-
if (!mounted) return;
|
|
93
|
-
setResults((prev) => ({ ...prev, [ep.name]: result }));
|
|
94
|
-
}
|
|
95
|
-
setDone(true);
|
|
96
|
-
onComplete?.();
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
runChecks();
|
|
100
|
-
|
|
101
|
-
return () => {
|
|
102
|
-
mounted = false;
|
|
103
|
-
};
|
|
104
|
-
}, [endpoints, onComplete]);
|
|
105
|
-
|
|
106
|
-
const healthy = Object.values(results).filter(
|
|
107
|
-
(r) => typeof r === "object" && r.ok
|
|
108
|
-
).length;
|
|
109
|
-
const total = endpoints.length;
|
|
110
|
-
const checking = Object.values(results).filter(
|
|
111
|
-
(r) => r === "checking"
|
|
112
|
-
).length;
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<Box flexDirection="column">
|
|
116
|
-
<Box marginBottom={1}>
|
|
117
|
-
<Text>
|
|
118
|
-
{colors.cyan(`+${"-".repeat(46)}+`)}
|
|
119
|
-
</Text>
|
|
120
|
-
</Box>
|
|
121
|
-
<Box marginBottom={1}>
|
|
122
|
-
<Text>
|
|
123
|
-
{" "}
|
|
124
|
-
{icons.scan} {gradients.cyber(`SCANNING ${env} endpoints`)}
|
|
125
|
-
</Text>
|
|
126
|
-
</Box>
|
|
127
|
-
<Box marginBottom={1}>
|
|
128
|
-
<Text>{colors.cyan(`+${"-".repeat(46)}+`)}</Text>
|
|
129
|
-
</Box>
|
|
130
|
-
|
|
131
|
-
{endpoints.map((ep) => (
|
|
132
|
-
<StatusRow
|
|
133
|
-
key={ep.name}
|
|
134
|
-
name={ep.name}
|
|
135
|
-
url={ep.url}
|
|
136
|
-
status={results[ep.name]}
|
|
137
|
-
/>
|
|
138
|
-
))}
|
|
139
|
-
|
|
140
|
-
<Box marginTop={1}>
|
|
141
|
-
<Text>{colors.dim(divider(48))}</Text>
|
|
142
|
-
</Box>
|
|
143
|
-
<Box>
|
|
144
|
-
<Text>
|
|
145
|
-
{" "}
|
|
146
|
-
{done
|
|
147
|
-
? colors.green(`${healthy}/${total} healthy`)
|
|
148
|
-
: colors.cyan(`${checking} checking...`)}
|
|
149
|
-
</Text>
|
|
150
|
-
</Box>
|
|
151
|
-
</Box>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function renderStatusView(
|
|
156
|
-
endpoints: Endpoint[],
|
|
157
|
-
env: string
|
|
158
|
-
): Promise<void> {
|
|
159
|
-
return new Promise((resolve) => {
|
|
160
|
-
const { unmount } = render(
|
|
161
|
-
<StatusView
|
|
162
|
-
endpoints={endpoints}
|
|
163
|
-
env={env}
|
|
164
|
-
onComplete={() => {
|
|
165
|
-
setTimeout(() => {
|
|
166
|
-
unmount();
|
|
167
|
-
resolve();
|
|
168
|
-
}, 100);
|
|
169
|
-
}}
|
|
170
|
-
/>
|
|
171
|
-
);
|
|
172
|
-
});
|
|
173
|
-
}
|