marmonitor 0.1.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/LICENSE +21 -0
- package/README.md +219 -0
- package/bin/marmonitor.js +2 -0
- package/dist/banner/index.d.ts +7 -0
- package/dist/banner/index.js +212 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +855 -0
- package/dist/config/index.d.ts +105 -0
- package/dist/config/index.js +218 -0
- package/dist/guard/index.d.ts +23 -0
- package/dist/guard/index.js +128 -0
- package/dist/output/index.d.ts +28 -0
- package/dist/output/index.js +457 -0
- package/dist/output/utils.d.ts +138 -0
- package/dist/output/utils.js +588 -0
- package/dist/process-safety.d.ts +2 -0
- package/dist/process-safety.js +7 -0
- package/dist/scanner/bounded-map.d.ts +10 -0
- package/dist/scanner/bounded-map.js +25 -0
- package/dist/scanner/cache.d.ts +88 -0
- package/dist/scanner/cache.js +32 -0
- package/dist/scanner/claude.d.ts +25 -0
- package/dist/scanner/claude.js +425 -0
- package/dist/scanner/codex.d.ts +14 -0
- package/dist/scanner/codex.js +195 -0
- package/dist/scanner/gemini.d.ts +21 -0
- package/dist/scanner/gemini.js +131 -0
- package/dist/scanner/group.d.ts +7 -0
- package/dist/scanner/group.js +54 -0
- package/dist/scanner/index.d.ts +16 -0
- package/dist/scanner/index.js +256 -0
- package/dist/scanner/process.d.ts +17 -0
- package/dist/scanner/process.js +91 -0
- package/dist/scanner/status.d.ts +8 -0
- package/dist/scanner/status.js +45 -0
- package/dist/scanner/types.d.ts +6 -0
- package/dist/scanner/types.js +4 -0
- package/dist/tmux/index.d.ts +34 -0
- package/dist/tmux/index.js +166 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.js +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/docs/banner-ansi.png +0 -0
- package/docs/marmot-small.png +0 -0
- package/package.json +70 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process utilities for the scanner.
|
|
3
|
+
*/
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import type { MarmonitorConfig } from "../config/index.js";
|
|
6
|
+
import type { RuntimeSource } from "../types.js";
|
|
7
|
+
export declare const execFileAsync: typeof execFile.__promisify__;
|
|
8
|
+
/** Get process cwd via lsof (fallback for non-Claude agents) */
|
|
9
|
+
export declare function getProcessCwd(pid: number): Promise<string | undefined>;
|
|
10
|
+
export declare function getProcessStartTime(pid: number): Promise<number | undefined>;
|
|
11
|
+
export declare function detectRuntimeSource(agentName: string, cmd?: string): RuntimeSource | undefined;
|
|
12
|
+
export declare function matchesProcessCommand(command: string, processName: string): boolean;
|
|
13
|
+
/** Match a process against agent signatures using process name first, then cmd fallback. */
|
|
14
|
+
export declare function detectAgentFromProcessSignature(proc: {
|
|
15
|
+
name: string;
|
|
16
|
+
cmd?: string;
|
|
17
|
+
}, config: MarmonitorConfig): string | null;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process utilities for the scanner.
|
|
3
|
+
*/
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import { PROCESS_CWD_TTL_MS, PROCESS_START_TTL_MS, processCwdCache, processStartCache, } from "./cache.js";
|
|
7
|
+
export const execFileAsync = promisify(execFile);
|
|
8
|
+
/** Get process cwd via lsof (fallback for non-Claude agents) */
|
|
9
|
+
export async function getProcessCwd(pid) {
|
|
10
|
+
const cached = processCwdCache.get(pid);
|
|
11
|
+
if (cached && Date.now() - cached.checkedAt < PROCESS_CWD_TTL_MS) {
|
|
12
|
+
return cached.cwd;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const { stdout } = await execFileAsync("lsof", ["-p", String(pid), "-Fn"], {
|
|
16
|
+
encoding: "utf-8",
|
|
17
|
+
timeout: 3000,
|
|
18
|
+
});
|
|
19
|
+
const match = stdout.split("\n").find((line) => line.startsWith("n/"));
|
|
20
|
+
const cwd = match ? match.slice(1) : undefined;
|
|
21
|
+
processCwdCache.set(pid, {
|
|
22
|
+
checkedAt: Date.now(),
|
|
23
|
+
cwd,
|
|
24
|
+
});
|
|
25
|
+
return cwd;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
processCwdCache.set(pid, {
|
|
29
|
+
checkedAt: Date.now(),
|
|
30
|
+
cwd: undefined,
|
|
31
|
+
});
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function getProcessStartTime(pid) {
|
|
36
|
+
const cached = processStartCache.get(pid);
|
|
37
|
+
if (cached && Date.now() - cached.checkedAt < PROCESS_START_TTL_MS) {
|
|
38
|
+
return cached.startedAt;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const { stdout } = await execFileAsync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
42
|
+
encoding: "utf-8",
|
|
43
|
+
timeout: 2000,
|
|
44
|
+
});
|
|
45
|
+
const trimmed = stdout.trim();
|
|
46
|
+
const startedAt = trimmed ? new Date(trimmed).getTime() / 1000 : undefined;
|
|
47
|
+
processStartCache.set(pid, {
|
|
48
|
+
checkedAt: Date.now(),
|
|
49
|
+
startedAt,
|
|
50
|
+
});
|
|
51
|
+
return startedAt;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
processStartCache.set(pid, {
|
|
55
|
+
checkedAt: Date.now(),
|
|
56
|
+
startedAt: undefined,
|
|
57
|
+
});
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function detectRuntimeSource(agentName, cmd) {
|
|
62
|
+
if (agentName === "Gemini")
|
|
63
|
+
return "cli";
|
|
64
|
+
if (agentName !== "Codex")
|
|
65
|
+
return undefined;
|
|
66
|
+
const normalized = (cmd ?? "").toLowerCase();
|
|
67
|
+
if (!normalized)
|
|
68
|
+
return "unknown";
|
|
69
|
+
if (normalized.includes(".vscode/extensions") || normalized.includes("app-server")) {
|
|
70
|
+
return "vscode";
|
|
71
|
+
}
|
|
72
|
+
return "cli";
|
|
73
|
+
}
|
|
74
|
+
export function matchesProcessCommand(command, processName) {
|
|
75
|
+
const escaped = processName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
76
|
+
return new RegExp(`(?:^|[/\\\\])${escaped}(?:\\s|$)`, "i").test(command);
|
|
77
|
+
}
|
|
78
|
+
/** Match a process against agent signatures using process name first, then cmd fallback. */
|
|
79
|
+
export function detectAgentFromProcessSignature(proc, config) {
|
|
80
|
+
const name = proc.name.toLowerCase();
|
|
81
|
+
const command = (proc.cmd ?? "").toLowerCase();
|
|
82
|
+
for (const [agentName, agentConfig] of Object.entries(config.agents)) {
|
|
83
|
+
for (const pname of agentConfig.processNames) {
|
|
84
|
+
if (name === pname)
|
|
85
|
+
return agentName;
|
|
86
|
+
if (command && matchesProcessCommand(command, pname))
|
|
87
|
+
return agentName;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status determination and CLI stdout phase detection.
|
|
3
|
+
*/
|
|
4
|
+
import type { MarmonitorConfig } from "../config/index.js";
|
|
5
|
+
import type { AgentSession, SessionPhase, SessionStatus } from "../types.js";
|
|
6
|
+
/** Determine agent activity status */
|
|
7
|
+
export declare function determineStatus(cpuPercent: number, elapsedSec: number | undefined, sessionMatched: boolean, phase: SessionPhase | undefined, config: MarmonitorConfig): SessionStatus;
|
|
8
|
+
export declare function detectCliStdoutPhase(agent: Pick<AgentSession, "pid" | "cwd">, config: MarmonitorConfig): Promise<SessionPhase>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Status determination and CLI stdout phase detection.
|
|
3
|
+
*/
|
|
4
|
+
import { detectApprovalPromptPhase } from "../output/utils.js";
|
|
5
|
+
import { captureTmuxPaneOutput, resolveTmuxJumpTarget } from "../tmux/index.js";
|
|
6
|
+
import { RECENT_ACTIVITY_ACTIVE_SEC, stdoutHeuristicCache } from "./cache.js";
|
|
7
|
+
/** Determine agent activity status */
|
|
8
|
+
export function determineStatus(cpuPercent, elapsedSec, sessionMatched, phase, config) {
|
|
9
|
+
// Zombie: process exists but no matching session
|
|
10
|
+
if (!sessionMatched)
|
|
11
|
+
return "Unmatched";
|
|
12
|
+
// Active: CPU above threshold
|
|
13
|
+
if (cpuPercent > config.status.activeCpuThreshold)
|
|
14
|
+
return "Active";
|
|
15
|
+
// Permission/thinking override: these phases require user attention
|
|
16
|
+
// regardless of how long the process has been running
|
|
17
|
+
if (phase === "permission" || phase === "thinking")
|
|
18
|
+
return "Idle";
|
|
19
|
+
if (phase === "tool" && (elapsedSec === undefined || elapsedSec <= RECENT_ACTIVITY_ACTIVE_SEC)) {
|
|
20
|
+
return "Active";
|
|
21
|
+
}
|
|
22
|
+
// Stalled: idle for longer than configured threshold
|
|
23
|
+
const stalledSec = config.status.stalledAfterMin * 60;
|
|
24
|
+
if (elapsedSec !== undefined && elapsedSec > stalledSec && cpuPercent < 0.1) {
|
|
25
|
+
return "Stalled";
|
|
26
|
+
}
|
|
27
|
+
return "Idle";
|
|
28
|
+
}
|
|
29
|
+
export async function detectCliStdoutPhase(agent, config) {
|
|
30
|
+
const cached = stdoutHeuristicCache.get(agent.pid);
|
|
31
|
+
if (cached && Date.now() - cached.checkedAt < config.performance.stdoutHeuristicTtlMs) {
|
|
32
|
+
return cached.phase;
|
|
33
|
+
}
|
|
34
|
+
const target = await resolveTmuxJumpTarget(agent);
|
|
35
|
+
if (!target) {
|
|
36
|
+
stdoutHeuristicCache.set(agent.pid, { checkedAt: Date.now(), phase: undefined });
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
const output = await captureTmuxPaneOutput(target, 30);
|
|
40
|
+
const phase = output
|
|
41
|
+
? detectApprovalPromptPhase(output, config.status.stdoutHeuristic.approvalPatterns, config.status.stdoutHeuristic.clearPatterns)
|
|
42
|
+
: undefined;
|
|
43
|
+
stdoutHeuristicCache.set(agent.pid, { checkedAt: Date.now(), phase });
|
|
44
|
+
return phase;
|
|
45
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AgentSession } from "../types.js";
|
|
2
|
+
export interface TmuxPane {
|
|
3
|
+
target: string;
|
|
4
|
+
sessionName: string;
|
|
5
|
+
windowIndex: number;
|
|
6
|
+
paneIndex: number;
|
|
7
|
+
panePid: number;
|
|
8
|
+
cwd: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TmuxJumpTarget {
|
|
11
|
+
pane: TmuxPane;
|
|
12
|
+
match: "pid-tree" | "cwd";
|
|
13
|
+
}
|
|
14
|
+
export interface TmuxJumpResult {
|
|
15
|
+
found: boolean;
|
|
16
|
+
executed: boolean;
|
|
17
|
+
insideTmux: boolean;
|
|
18
|
+
pid: number;
|
|
19
|
+
match?: "pid-tree" | "cwd";
|
|
20
|
+
target?: string;
|
|
21
|
+
sessionName?: string;
|
|
22
|
+
cwd?: string;
|
|
23
|
+
message?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function parseTmuxPanes(raw: string): TmuxPane[];
|
|
26
|
+
export declare function parseProcessTree(raw: string): Map<number, number[]>;
|
|
27
|
+
export declare function isPidInTree(rootPid: number, targetPid: number, childMap: Map<number, number[]>): boolean;
|
|
28
|
+
export declare function selectTmuxPaneForAgent(agent: Pick<AgentSession, "pid" | "cwd">, panes: TmuxPane[], childMap: Map<number, number[]>): TmuxJumpTarget | undefined;
|
|
29
|
+
export declare function listTmuxPanes(): Promise<TmuxPane[]>;
|
|
30
|
+
export declare function getProcessTree(): Promise<Map<number, number[]>>;
|
|
31
|
+
export declare function resolveTmuxJumpTarget(agent: Pick<AgentSession, "pid" | "cwd">): Promise<TmuxJumpTarget | undefined>;
|
|
32
|
+
export declare function captureTmuxPaneOutput(target: TmuxJumpTarget, lines?: number): Promise<string | undefined>;
|
|
33
|
+
export declare function jumpToTmuxPane(target: TmuxJumpTarget): Promise<boolean>;
|
|
34
|
+
export declare function jumpToAgent(agent: Pick<AgentSession, "pid" | "cwd">): Promise<TmuxJumpResult>;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const execFileAsync = promisify(execFile);
|
|
4
|
+
export function parseTmuxPanes(raw) {
|
|
5
|
+
return raw
|
|
6
|
+
.split("\n")
|
|
7
|
+
.map((line) => line.trim())
|
|
8
|
+
.filter(Boolean)
|
|
9
|
+
.flatMap((line) => {
|
|
10
|
+
const [target, panePidRaw, cwd] = line.split("\t");
|
|
11
|
+
if (!target || !panePidRaw || !cwd)
|
|
12
|
+
return [];
|
|
13
|
+
const [sessionName, coords] = target.split(":");
|
|
14
|
+
if (!sessionName || !coords)
|
|
15
|
+
return [];
|
|
16
|
+
const [windowIndexRaw, paneIndexRaw] = coords.split(".");
|
|
17
|
+
if (!windowIndexRaw || !paneIndexRaw)
|
|
18
|
+
return [];
|
|
19
|
+
const pane = {
|
|
20
|
+
target,
|
|
21
|
+
sessionName,
|
|
22
|
+
windowIndex: Number.parseInt(windowIndexRaw, 10),
|
|
23
|
+
paneIndex: Number.parseInt(paneIndexRaw, 10),
|
|
24
|
+
panePid: Number.parseInt(panePidRaw, 10),
|
|
25
|
+
cwd,
|
|
26
|
+
};
|
|
27
|
+
return Number.isFinite(pane.panePid) ? [pane] : [];
|
|
28
|
+
})
|
|
29
|
+
.filter((pane) => Number.isFinite(pane.panePid));
|
|
30
|
+
}
|
|
31
|
+
export function parseProcessTree(raw) {
|
|
32
|
+
const childMap = new Map();
|
|
33
|
+
for (const line of raw.split("\n")) {
|
|
34
|
+
const trimmed = line.trim();
|
|
35
|
+
if (!trimmed)
|
|
36
|
+
continue;
|
|
37
|
+
const [pidRaw, ppidRaw] = trimmed.split(/\s+/);
|
|
38
|
+
const pid = Number.parseInt(pidRaw, 10);
|
|
39
|
+
const ppid = Number.parseInt(ppidRaw, 10);
|
|
40
|
+
if (!Number.isFinite(pid) || !Number.isFinite(ppid))
|
|
41
|
+
continue;
|
|
42
|
+
const children = childMap.get(ppid) ?? [];
|
|
43
|
+
children.push(pid);
|
|
44
|
+
childMap.set(ppid, children);
|
|
45
|
+
}
|
|
46
|
+
return childMap;
|
|
47
|
+
}
|
|
48
|
+
export function isPidInTree(rootPid, targetPid, childMap) {
|
|
49
|
+
if (rootPid === targetPid)
|
|
50
|
+
return true;
|
|
51
|
+
const queue = [...(childMap.get(rootPid) ?? [])];
|
|
52
|
+
const seen = new Set();
|
|
53
|
+
while (queue.length > 0) {
|
|
54
|
+
const pid = queue.shift();
|
|
55
|
+
if (pid === undefined || seen.has(pid))
|
|
56
|
+
continue;
|
|
57
|
+
if (pid === targetPid)
|
|
58
|
+
return true;
|
|
59
|
+
seen.add(pid);
|
|
60
|
+
queue.push(...(childMap.get(pid) ?? []));
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
export function selectTmuxPaneForAgent(agent, panes, childMap) {
|
|
65
|
+
const treeMatch = panes.find((pane) => isPidInTree(pane.panePid, agent.pid, childMap));
|
|
66
|
+
if (treeMatch) {
|
|
67
|
+
return { pane: treeMatch, match: "pid-tree" };
|
|
68
|
+
}
|
|
69
|
+
const cwdMatch = panes.find((pane) => pane.cwd === agent.cwd);
|
|
70
|
+
if (cwdMatch) {
|
|
71
|
+
return { pane: cwdMatch, match: "cwd" };
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
export async function listTmuxPanes() {
|
|
76
|
+
try {
|
|
77
|
+
const { stdout } = await execFileAsync("tmux", [
|
|
78
|
+
"list-panes",
|
|
79
|
+
"-a",
|
|
80
|
+
"-F",
|
|
81
|
+
"#{session_name}:#{window_index}.#{pane_index}\t#{pane_pid}\t#{pane_current_path}",
|
|
82
|
+
]);
|
|
83
|
+
return parseTmuxPanes(stdout);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export async function getProcessTree() {
|
|
90
|
+
try {
|
|
91
|
+
const { stdout } = await execFileAsync("ps", ["-eo", "pid=,ppid="]);
|
|
92
|
+
return parseProcessTree(stdout);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return new Map();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export async function resolveTmuxJumpTarget(agent) {
|
|
99
|
+
try {
|
|
100
|
+
const [panes, childMap] = await Promise.all([listTmuxPanes(), getProcessTree()]);
|
|
101
|
+
return selectTmuxPaneForAgent(agent, panes, childMap);
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
export async function captureTmuxPaneOutput(target, lines = 30) {
|
|
108
|
+
try {
|
|
109
|
+
const { stdout } = await execFileAsync("tmux", [
|
|
110
|
+
"capture-pane",
|
|
111
|
+
"-p",
|
|
112
|
+
"-t",
|
|
113
|
+
target.pane.target,
|
|
114
|
+
"-S",
|
|
115
|
+
`-${lines}`,
|
|
116
|
+
]);
|
|
117
|
+
return stdout;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export async function jumpToTmuxPane(target) {
|
|
124
|
+
const windowTarget = `${target.pane.sessionName}:${target.pane.windowIndex}`;
|
|
125
|
+
try {
|
|
126
|
+
if (process.env.TMUX) {
|
|
127
|
+
await execFileAsync("tmux", ["switch-client", "-t", windowTarget]);
|
|
128
|
+
await execFileAsync("tmux", ["select-window", "-t", windowTarget]);
|
|
129
|
+
await execFileAsync("tmux", ["select-pane", "-t", target.pane.target]);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
await execFileAsync("tmux", ["select-window", "-t", windowTarget]);
|
|
133
|
+
await execFileAsync("tmux", ["select-pane", "-t", target.pane.target]);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
export async function jumpToAgent(agent) {
|
|
141
|
+
const target = await resolveTmuxJumpTarget(agent);
|
|
142
|
+
if (!target) {
|
|
143
|
+
return {
|
|
144
|
+
found: false,
|
|
145
|
+
executed: false,
|
|
146
|
+
insideTmux: Boolean(process.env.TMUX),
|
|
147
|
+
pid: agent.pid,
|
|
148
|
+
cwd: agent.cwd,
|
|
149
|
+
message: "No tmux pane matched this AI session.",
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const executed = await jumpToTmuxPane(target);
|
|
153
|
+
return {
|
|
154
|
+
found: true,
|
|
155
|
+
executed,
|
|
156
|
+
insideTmux: Boolean(process.env.TMUX),
|
|
157
|
+
pid: agent.pid,
|
|
158
|
+
match: target.match,
|
|
159
|
+
target: target.pane.target,
|
|
160
|
+
sessionName: target.pane.sessionName,
|
|
161
|
+
cwd: target.pane.cwd,
|
|
162
|
+
message: executed
|
|
163
|
+
? `Switched to ${target.pane.target} via ${target.match}.`
|
|
164
|
+
: `Matched ${target.pane.target} via ${target.match}, but tmux switch failed.`,
|
|
165
|
+
};
|
|
166
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Token usage data */
|
|
2
|
+
export interface TokenUsage {
|
|
3
|
+
inputTokens: number;
|
|
4
|
+
outputTokens: number;
|
|
5
|
+
cacheCreationTokens: number;
|
|
6
|
+
cacheReadTokens: number;
|
|
7
|
+
totalTokens: number;
|
|
8
|
+
}
|
|
9
|
+
/** Agent session status */
|
|
10
|
+
export type SessionStatus = "Active" | "Idle" | "Stalled" | "Unmatched" | "Dead";
|
|
11
|
+
/** Agent activity phase (what the AI is doing right now) */
|
|
12
|
+
export type SessionPhase = "thinking" | "tool" | "permission" | "done" | undefined;
|
|
13
|
+
/** Runtime source / host environment */
|
|
14
|
+
export type RuntimeSource = "cli" | "vscode" | "unknown";
|
|
15
|
+
/** Child/worker process info */
|
|
16
|
+
export interface WorkerProcess {
|
|
17
|
+
pid: number;
|
|
18
|
+
cpuPercent: number;
|
|
19
|
+
memoryMb: number;
|
|
20
|
+
status: SessionStatus;
|
|
21
|
+
}
|
|
22
|
+
/** Detected AI agent session */
|
|
23
|
+
export interface AgentSession {
|
|
24
|
+
agentName: string;
|
|
25
|
+
pid: number;
|
|
26
|
+
ppid?: number;
|
|
27
|
+
cwd: string;
|
|
28
|
+
cpuPercent: number;
|
|
29
|
+
memoryMb: number;
|
|
30
|
+
status: SessionStatus;
|
|
31
|
+
startedAt?: number;
|
|
32
|
+
sessionId?: string;
|
|
33
|
+
lastActivity?: string;
|
|
34
|
+
tokenUsage?: TokenUsage;
|
|
35
|
+
model?: string;
|
|
36
|
+
workers?: WorkerProcess[];
|
|
37
|
+
sessionMatched?: boolean;
|
|
38
|
+
phase?: SessionPhase;
|
|
39
|
+
lastResponseAt?: number;
|
|
40
|
+
lastActivityAt?: number;
|
|
41
|
+
runtimeSource?: RuntimeSource;
|
|
42
|
+
}
|
|
43
|
+
/** Agent detection signature */
|
|
44
|
+
export interface AgentSignature {
|
|
45
|
+
processNames: string[];
|
|
46
|
+
sessionDir: string;
|
|
47
|
+
}
|
|
48
|
+
/** System resource snapshot */
|
|
49
|
+
export interface SystemInfo {
|
|
50
|
+
cpuPercent: number;
|
|
51
|
+
memoryUsedGb: number;
|
|
52
|
+
memoryTotalGb: number;
|
|
53
|
+
batteryPercent?: number;
|
|
54
|
+
batteryCharging?: boolean;
|
|
55
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "0.1.0";
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VERSION = "0.1.0";
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "marmonitor",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"author": "MJ JO <mjjo16@gmail.com>",
|
|
5
|
+
"description": "tmux status bar monitor for AI coding agents — track Claude Code, Codex, Gemini sessions, tokens, and phases in real time",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"os": [
|
|
8
|
+
"darwin",
|
|
9
|
+
"linux"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"marmonitor": "./bin/marmonitor.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"bin/",
|
|
16
|
+
"dist/",
|
|
17
|
+
"docs/banner-ansi.png",
|
|
18
|
+
"docs/marmot-small.png",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"keywords": [
|
|
23
|
+
"ai",
|
|
24
|
+
"ai-agent",
|
|
25
|
+
"monitor",
|
|
26
|
+
"cli",
|
|
27
|
+
"tmux",
|
|
28
|
+
"statusbar",
|
|
29
|
+
"claude",
|
|
30
|
+
"claude-code",
|
|
31
|
+
"codex",
|
|
32
|
+
"gemini",
|
|
33
|
+
"terminal",
|
|
34
|
+
"developer-tools",
|
|
35
|
+
"session-manager"
|
|
36
|
+
],
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/mjjo16/marmonitor.git"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/mjjo16/marmonitor#readme",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/mjjo16/marmonitor/issues"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc",
|
|
47
|
+
"dev": "tsc --watch",
|
|
48
|
+
"start": "node bin/marmonitor.js",
|
|
49
|
+
"lint": "biome check src tests",
|
|
50
|
+
"test": "node --test tests/*.test.mjs",
|
|
51
|
+
"prepublishOnly": "npm run build && npm test"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"chalk": "^5.3",
|
|
55
|
+
"commander": "^12.1",
|
|
56
|
+
"pidusage": "^3.0",
|
|
57
|
+
"ps-list": "^8.1",
|
|
58
|
+
"systeminformation": "^5.22"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@biomejs/biome": "^1.9.4",
|
|
62
|
+
"@types/node": "^20.14",
|
|
63
|
+
"@types/pidusage": "^2.0.5",
|
|
64
|
+
"typescript": "^5.5"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=18"
|
|
68
|
+
},
|
|
69
|
+
"license": "MIT"
|
|
70
|
+
}
|