marmonitor 0.2.2 → 0.2.4
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.ko.md +60 -17
- package/README.md +37 -2
- package/bin/postinstall.cjs +1 -0
- package/dist/cli.js +277 -103
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -0
- package/dist/output/badge-themes.js +14 -0
- package/dist/output/index.d.ts +1 -0
- package/dist/output/index.js +154 -32
- package/dist/output/utils.d.ts +3 -2
- package/dist/output/utils.js +14 -2
- package/dist/scanner/activity-log.d.ts +29 -0
- package/dist/scanner/activity-log.js +225 -0
- package/dist/scanner/cache.d.ts +1 -0
- package/dist/scanner/cache.js +1 -0
- package/dist/scanner/codex-binding-registry.d.ts +30 -0
- package/dist/scanner/codex-binding-registry.js +87 -0
- package/dist/scanner/codex-sqlite.d.ts +6 -1
- package/dist/scanner/codex-sqlite.js +27 -7
- package/dist/scanner/codex.d.ts +3 -1
- package/dist/scanner/codex.js +14 -4
- package/dist/scanner/daemon-entry.js +3 -0
- package/dist/scanner/daemon-loop.d.ts +3 -0
- package/dist/scanner/daemon-loop.js +88 -4
- package/dist/scanner/index.js +73 -7
- package/dist/scanner/process.js +6 -0
- package/dist/scanner/session-registry.d.ts +4 -1
- package/dist/scanner/session-registry.js +16 -9
- package/dist/scanner/status.d.ts +3 -1
- package/dist/scanner/status.js +53 -8
- package/dist/scanner/types.d.ts +4 -0
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/scanner/status.js
CHANGED
|
@@ -3,29 +3,74 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { detectApprovalPromptPhase } from "../output/utils.js";
|
|
5
5
|
import { captureTmuxPaneOutput, resolveTmuxJumpTarget } from "../tmux/index.js";
|
|
6
|
-
import { RECENT_ACTIVITY_ACTIVE_SEC, stdoutHeuristicCache } from "./cache.js";
|
|
6
|
+
import { RECENT_ACTIVITY_ACTIVE_SEC, STATUS_HYSTERESIS_SEC, stdoutHeuristicCache, } from "./cache.js";
|
|
7
|
+
export function refreshLastActivityAt(lastActivityAt, cpuPercent, phase, activeCpuThreshold, agentName, nowSec = Math.floor(Date.now() / 1000)) {
|
|
8
|
+
if (agentName !== "Codex")
|
|
9
|
+
return lastActivityAt;
|
|
10
|
+
if (cpuPercent > activeCpuThreshold ||
|
|
11
|
+
phase === "permission" ||
|
|
12
|
+
phase === "thinking" ||
|
|
13
|
+
phase === "tool") {
|
|
14
|
+
return Math.max(lastActivityAt ?? 0, nowSec);
|
|
15
|
+
}
|
|
16
|
+
return lastActivityAt;
|
|
17
|
+
}
|
|
7
18
|
/** Determine agent activity status */
|
|
8
|
-
export function determineStatus(cpuPercent, elapsedSec, sessionMatched, phase, config) {
|
|
19
|
+
export function determineStatus(cpuPercent, elapsedSec, sessionMatched, phase, config, agentName) {
|
|
9
20
|
// Zombie: process exists but no matching session
|
|
10
21
|
if (!sessionMatched)
|
|
11
22
|
return "Unmatched";
|
|
23
|
+
const stalledSec = config.status.stalledAfterMin * 60;
|
|
12
24
|
// Active: CPU above threshold
|
|
13
25
|
if (cpuPercent > config.status.activeCpuThreshold)
|
|
14
26
|
return "Active";
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return "
|
|
19
|
-
|
|
27
|
+
// Recent active phases stay active briefly even after CPU bursts end.
|
|
28
|
+
if ((phase === "permission" || phase === "thinking" || phase === "tool") &&
|
|
29
|
+
(elapsedSec === undefined || elapsedSec <= RECENT_ACTIVITY_ACTIVE_SEC)) {
|
|
30
|
+
return "Active";
|
|
31
|
+
}
|
|
32
|
+
// Codex often drops to ~0% CPU immediately after a burst.
|
|
33
|
+
// Keep it active for a short recent-activity grace window even without a strong phase.
|
|
34
|
+
if (agentName === "Codex" &&
|
|
35
|
+
elapsedSec !== undefined &&
|
|
36
|
+
elapsedSec <= Math.min(60, RECENT_ACTIVITY_ACTIVE_SEC)) {
|
|
20
37
|
return "Active";
|
|
21
38
|
}
|
|
39
|
+
// Codex quiet sessions often hold a live rollout while CPU falls to 0%.
|
|
40
|
+
// Treat them as idle for a much longer window before escalating to stalled.
|
|
41
|
+
if (agentName === "Codex" && elapsedSec !== undefined && cpuPercent < 0.1) {
|
|
42
|
+
const codexStalledSec = Math.max(stalledSec, 24 * 60 * 60);
|
|
43
|
+
if (elapsedSec > codexStalledSec)
|
|
44
|
+
return "Stalled";
|
|
45
|
+
return "Idle";
|
|
46
|
+
}
|
|
22
47
|
// Stalled: idle for longer than configured threshold
|
|
23
|
-
const stalledSec = config.status.stalledAfterMin * 60;
|
|
24
48
|
if (elapsedSec !== undefined && elapsedSec > stalledSec && cpuPercent < 0.1) {
|
|
25
49
|
return "Stalled";
|
|
26
50
|
}
|
|
27
51
|
return "Idle";
|
|
28
52
|
}
|
|
53
|
+
export function applyStatusHysteresis(nextStatus, previousStatus, elapsedSec, phase, agentName) {
|
|
54
|
+
if (!previousStatus || previousStatus === nextStatus)
|
|
55
|
+
return nextStatus;
|
|
56
|
+
if (nextStatus === "Unmatched" || nextStatus === "Dead")
|
|
57
|
+
return nextStatus;
|
|
58
|
+
if (previousStatus === "Unmatched" || previousStatus === "Dead")
|
|
59
|
+
return nextStatus;
|
|
60
|
+
const hasLivePhase = phase === "permission" || phase === "thinking" || phase === "tool";
|
|
61
|
+
const hysteresisSec = agentName === "Codex" ? Math.max(STATUS_HYSTERESIS_SEC, 60) : STATUS_HYSTERESIS_SEC;
|
|
62
|
+
if (previousStatus === "Active" && (nextStatus === "Idle" || nextStatus === "Stalled")) {
|
|
63
|
+
if (elapsedSec === undefined || elapsedSec <= hysteresisSec || hasLivePhase) {
|
|
64
|
+
return "Active";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (previousStatus === "Idle" && nextStatus === "Stalled") {
|
|
68
|
+
if (elapsedSec === undefined || elapsedSec <= hysteresisSec * 2 || hasLivePhase) {
|
|
69
|
+
return "Idle";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return nextStatus;
|
|
73
|
+
}
|
|
29
74
|
export async function detectCliStdoutPhase(agent, config) {
|
|
30
75
|
const cached = stdoutHeuristicCache.get(agent.pid);
|
|
31
76
|
if (cached && Date.now() - cached.checkedAt < config.performance.stdoutHeuristicTtlMs) {
|
package/dist/scanner/types.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Public types for the scanner module.
|
|
3
3
|
*/
|
|
4
|
+
import type { CodexBindingRegistry } from "./codex-binding-registry.js";
|
|
5
|
+
import type { SessionRegistryRecord } from "./session-registry.js";
|
|
4
6
|
export interface ScanOptions {
|
|
5
7
|
enrichmentMode?: "full" | "light";
|
|
8
|
+
codexBindingRegistry?: CodexBindingRegistry;
|
|
9
|
+
sessionRegistry?: Map<string, SessionRegistryRecord>;
|
|
6
10
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface AgentSession {
|
|
|
29
29
|
memoryMb: number;
|
|
30
30
|
status: SessionStatus;
|
|
31
31
|
startedAt?: number;
|
|
32
|
+
processStartedAt?: number;
|
|
32
33
|
sessionId?: string;
|
|
33
34
|
lastActivity?: string;
|
|
34
35
|
tokenUsage?: TokenUsage;
|
|
@@ -39,6 +40,7 @@ export interface AgentSession {
|
|
|
39
40
|
lastResponseAt?: number;
|
|
40
41
|
lastActivityAt?: number;
|
|
41
42
|
runtimeSource?: RuntimeSource;
|
|
43
|
+
branch?: string;
|
|
42
44
|
}
|
|
43
45
|
/** Agent detection signature */
|
|
44
46
|
export interface AgentSignature {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marmonitor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"author": "MJ JO <mjjo16@gmail.com>",
|
|
5
5
|
"description": "tmux status bar monitor for AI coding agents — track Claude Code, Codex, Gemini sessions, tokens, and phases in real time",
|
|
6
6
|
"type": "module",
|