granttap-mcp 0.8.141 → 0.8.143
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/apps/bridge/src/machine-load/host/ps-reader.ts +6 -1
- package/apps/bridge/src/machine-load/index.ts +16 -7
- package/apps/bridge/src/runtime-updates/index.ts +5 -2
- package/apps/bridge/src/runtime-watchdog/worker.mjs +8 -3
- package/apps/bridge/src/sessions/scan/claude/activity.ts +2 -2
- package/apps/bridge/src/sessions/scan/claude/parse.ts +2 -1
- package/apps/bridge/src/sessions/scan/claude/shared.ts +2 -1
- package/apps/bridge/src/sessions/support/activity-helpers.ts +9 -0
- package/cursor-plugin/README.md +1 -1
- package/cursor-plugin/mcp.json +1 -1
- package/cursor-plugin/stdio-bootstrap.cjs +1 -1
- package/package.json +1 -1
- package/packages/core/relay-client.ts +2 -1
- package/packages/core/replay-store.ts +6 -1
|
@@ -80,6 +80,10 @@ export function withCommandLines(rows: readonly ProcessRow[], commands: Readonly
|
|
|
80
80
|
* Two listings: the executable path on its own, then the command line, joined
|
|
81
81
|
* by pid — one listing cannot carry both once a path has a space in it.
|
|
82
82
|
*/
|
|
83
|
+
/**
|
|
84
|
+
* A listing that fails or times out is unknown, not empty: under heavy load an
|
|
85
|
+
* empty answer told the phone that every agent had stopped.
|
|
86
|
+
*/
|
|
83
87
|
export async function sampleProcessRows(): Promise<ProcessRow[]> {
|
|
84
88
|
try {
|
|
85
89
|
const [{ stdout: executables }, { stdout: commands }] = await Promise.all([
|
|
@@ -88,6 +92,7 @@ export async function sampleProcessRows(): Promise<ProcessRow[]> {
|
|
|
88
92
|
]);
|
|
89
93
|
return withCommandLines(parsePsOutput(String(executables)), parsePidListing(String(commands)));
|
|
90
94
|
} catch {
|
|
91
|
-
|
|
95
|
+
// The execFile error carries every command line it read; none of them leaves here.
|
|
96
|
+
throw new Error("process listing unavailable");
|
|
92
97
|
}
|
|
93
98
|
}
|
|
@@ -137,22 +137,31 @@ export function createMachineLoadPublisher(dependencies: {
|
|
|
137
137
|
const sampleDisk = dependencies.sampleDisk ?? createDiskUsageSampler().sample;
|
|
138
138
|
const now = dependencies.now ?? Date.now;
|
|
139
139
|
let loggedAt: number | undefined;
|
|
140
|
-
let active: Promise<MachineLoad> | undefined;
|
|
140
|
+
let active: Promise<MachineLoad | undefined> | undefined;
|
|
141
|
+
const logDue = (): boolean => {
|
|
142
|
+
if (!dependencies.log || (loggedAt !== undefined && now() - loggedAt < LOAD_LOG_INTERVAL_MS)) return false;
|
|
143
|
+
loggedAt = now();
|
|
144
|
+
return true;
|
|
145
|
+
};
|
|
141
146
|
return (
|
|
142
147
|
client: LoadRelay,
|
|
143
148
|
status: SessionsStatus,
|
|
144
149
|
intervalMs: number,
|
|
145
|
-
): Promise<MachineLoad> => {
|
|
150
|
+
): Promise<MachineLoad | undefined> => {
|
|
146
151
|
if (active) return active;
|
|
147
152
|
active = (async () => {
|
|
148
|
-
|
|
153
|
+
let processes: Record<string, AgentProcessLoad>;
|
|
154
|
+
try {
|
|
155
|
+
processes = await sampleProcesses();
|
|
156
|
+
} catch {
|
|
157
|
+
// The phone keeps the previous report until its TTL; zeros would read as every agent stopping.
|
|
158
|
+
if (logDue()) dependencies.log?.("[load] process listing unavailable; the previous report stands");
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
149
161
|
recordAgentLoad(processes, now(), agentLanes(status.sessions));
|
|
150
162
|
const disk = sampleDisk(Object.keys(processes));
|
|
151
163
|
const load = buildMachineLoad({ status, processes, self: sampleSelf(), disk });
|
|
152
|
-
if (dependencies.log
|
|
153
|
-
loggedAt = now();
|
|
154
|
-
dependencies.log(describeLoad(load));
|
|
155
|
-
}
|
|
164
|
+
if (logDue()) dependencies.log?.(describeLoad(load));
|
|
156
165
|
await client.send(load, "phone", { ttlMs: intervalMs * 3, reliable: false });
|
|
157
166
|
return load;
|
|
158
167
|
})().finally(() => {
|
|
@@ -11,7 +11,10 @@ type Options={root:string;stateDirectory:string;manual?:boolean;now?:()=>number;
|
|
|
11
11
|
idle:()=>boolean;install?:(release:Release,directory:string)=>Promise<void>;
|
|
12
12
|
verify?:(root:string)=>Promise<void>;activate?:(root:string)=>void};
|
|
13
13
|
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Stage releases independently; verification and activation wait until no request or decision is pending.
|
|
16
|
+
* A phone-started run can keep the monitor busy for hours, and each check would otherwise start two Node processes.
|
|
17
|
+
*/
|
|
15
18
|
export async function checkForRuntimeUpdate(options:Options):Promise<string|undefined> {
|
|
16
19
|
const allowed=()=>options.manual===true || automaticUpdatesAllowed(options.stateDirectory);
|
|
17
20
|
if(!allowed())return;
|
|
@@ -28,7 +31,7 @@ export async function checkForRuntimeUpdate(options:Options):Promise<string|unde
|
|
|
28
31
|
if(!validRuntime(candidate,options.stateDirectory,release.version)) {
|
|
29
32
|
await (options.install??installRelease)(release,options.stateDirectory);
|
|
30
33
|
}
|
|
31
|
-
if(!allowed())return;
|
|
34
|
+
if(!options.idle() || !allowed())return;
|
|
32
35
|
await (options.verify??verifyRelease)(candidate);
|
|
33
36
|
if(!validRuntime(candidate,options.stateDirectory,release.version))throw Error('Runtime verification failed');
|
|
34
37
|
if(!options.idle() || !allowed())return;
|
|
@@ -14,13 +14,13 @@ const beat = new BigInt64Array(buffer);
|
|
|
14
14
|
const send = () => reportUrl ? sendPendingFaults(directory, reportUrl).catch(() => 0) : Promise.resolve(0);
|
|
15
15
|
const within = (work, ms) => Promise.race([work, new Promise(resolve => setTimeout(resolve, ms))]);
|
|
16
16
|
|
|
17
|
-
let lastCheck = Date.now(), graceUntil = 0, reported = false, busy = false;
|
|
17
|
+
let lastCheck = Date.now(), graceUntil = 0, reported = false, busy = false, killed = false;
|
|
18
18
|
const record = (kind, stalledMs, action, restartsInWindow) => {
|
|
19
19
|
rememberFault(directory, faultReport({ id: randomUUID(), kind, at: Date.now(), stalledMs, action, restartsInWindow, version }));
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
async function check() {
|
|
23
|
-
if (busy) return;
|
|
23
|
+
if (busy || killed) return;
|
|
24
24
|
busy = true;
|
|
25
25
|
try {
|
|
26
26
|
const now = Date.now(), last = Number(Atomics.load(beat, 0));
|
|
@@ -38,7 +38,12 @@ async function check() {
|
|
|
38
38
|
record('event-loop-stall', now - last, budget.restart ? 'restart' : 'held', budget.restartsInWindow);
|
|
39
39
|
reported = true;
|
|
40
40
|
await within(send(), 5_000);
|
|
41
|
-
if (budget.restart)
|
|
41
|
+
if (budget.restart) {
|
|
42
|
+
// macOS can let this thread run briefly after the kill; under load a second
|
|
43
|
+
// check spent another restart on the same hang.
|
|
44
|
+
killed = true;
|
|
45
|
+
process.kill(process.pid, 'SIGKILL');
|
|
46
|
+
}
|
|
42
47
|
} catch { /* A watchdog fault must never become the monitor's fault. */ }
|
|
43
48
|
finally { busy = false; }
|
|
44
49
|
}
|
|
@@ -3,7 +3,7 @@ import { createClaudeUsageRecorder } from './recorded-usage';
|
|
|
3
3
|
import { readFileSync, statSync } from "node:fs";
|
|
4
4
|
import type { ActivityEntry, ChildThreadInfo, SessionInfo } from "../../../../../../packages/protocol/schema";
|
|
5
5
|
import { safeParse, ts } from "../../support/common";
|
|
6
|
-
import { classifyTool, estimateTokens, pastedImageLabel, pushEntry as appendEntry, type PushEntryInput, toolDescription, toolSummary } from "../../support/activity-helpers";
|
|
6
|
+
import { claudeTranscriptRecord, classifyTool, estimateTokens, pastedImageLabel, pushEntry as appendEntry, type PushEntryInput, toolDescription, toolSummary } from "../../support/activity-helpers";
|
|
7
7
|
import { childEntryFields } from "../../support/child-threads";
|
|
8
8
|
import { diffPreviewFromInput, patchStatsByToolUse, sensitivePath, statsFromInput } from "../../support/edit-stats";
|
|
9
9
|
import { redactSecrets } from "../../telemetry/command-preview";
|
|
@@ -246,7 +246,7 @@ export function appendClaudeActivity(input: {
|
|
|
246
246
|
const patches = patchStatsByToolUse(lines, safeParse, redactSecrets);
|
|
247
247
|
lines.forEach((line, index) => {
|
|
248
248
|
const d = safeParse(line);
|
|
249
|
-
if (!d) return;
|
|
249
|
+
if (!d || !claudeTranscriptRecord(d)) return;
|
|
250
250
|
const createdAt = ts(d.timestamp) || session.lastActivityAt;
|
|
251
251
|
const content = d.message?.content;
|
|
252
252
|
if (d.type === "user" || d.message?.role === "user") {
|
|
@@ -8,7 +8,7 @@ import { observeClaudeTurn } from "./turn-state";
|
|
|
8
8
|
import { LIVE_MS, safeParse, stateFor, ts } from "../../support/common";
|
|
9
9
|
import { finishScan } from "../../cooperative-scan";
|
|
10
10
|
import { claudeCapabilityUsage, createClaudeCapabilityCollector } from "./activity";
|
|
11
|
-
import { pastedImageLabel } from "../../support/activity-helpers";
|
|
11
|
+
import { claudeTranscriptRecord, pastedImageLabel } from "../../support/activity-helpers";
|
|
12
12
|
import { claudeChangedPaths, claudeCheckout, claudeRepositoryPaths } from "./repository-observation";
|
|
13
13
|
import {
|
|
14
14
|
childLogsFingerprint,
|
|
@@ -40,6 +40,7 @@ type ClaudeParseState = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
function applyClaudeLine(d: any, state: ClaudeParseState): void {
|
|
43
|
+
if (!claudeTranscriptRecord(d)) return;
|
|
43
44
|
observeClaudeTurn(d, state);
|
|
44
45
|
if (d.isSidechain !== true) {
|
|
45
46
|
state.repositoryPaths.push(...claudeRepositoryPaths(d));
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
type Scan,
|
|
24
24
|
} from "../../support/common";
|
|
25
25
|
import {
|
|
26
|
+
claudeTranscriptRecord,
|
|
26
27
|
classifyTool,
|
|
27
28
|
estimateTokens,
|
|
28
29
|
pastedImageLabel,
|
|
@@ -105,7 +106,7 @@ export function claudeChildSummary(
|
|
|
105
106
|
let tokensLastTurn = 0;
|
|
106
107
|
for (const line of lines) {
|
|
107
108
|
const row = safeParse(line);
|
|
108
|
-
if (!row) continue;
|
|
109
|
+
if (!row || !claudeTranscriptRecord(row)) continue;
|
|
109
110
|
if (typeof row.agentId === "string" && row.agentId) threadId = row.agentId;
|
|
110
111
|
const at = ts(row.timestamp);
|
|
111
112
|
if (at) {
|
|
@@ -55,6 +55,15 @@ const IMAGE_LABEL = /^\[Image(?: #\d+|: source: .+|: original .+)\]$/;
|
|
|
55
55
|
* (`[Image: source: /private/tmp/…]`, `[Image #1]`). With the image itself in
|
|
56
56
|
* the same message, a block of only such labels is not something anyone typed.
|
|
57
57
|
*/
|
|
58
|
+
/**
|
|
59
|
+
* Claude Code also journals a copy of each API request (`api-request-blob`).
|
|
60
|
+
* Its user-role content repeats tool results and host notes such as
|
|
61
|
+
* "Tool loaded."; it is not a turn the person wrote or the agent took.
|
|
62
|
+
*/
|
|
63
|
+
export function claudeTranscriptRecord(d: any): boolean {
|
|
64
|
+
return d?.type !== "api-request-blob";
|
|
65
|
+
}
|
|
66
|
+
|
|
58
67
|
export function pastedImageLabel(block: any, content: readonly any[]): boolean {
|
|
59
68
|
if (block?.type !== "text" || typeof block.text !== "string") return false;
|
|
60
69
|
const lines = block.text.split("\n").map((line: string) => line.trim()).filter(Boolean);
|
package/cursor-plugin/README.md
CHANGED
|
@@ -10,7 +10,7 @@ keeps each phone response tied to the exact originating chat and prompt.
|
|
|
10
10
|
Install the supported CLI on this computer, then run:
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npm install -g granttap-mcp@0.8.
|
|
13
|
+
npm install -g granttap-mcp@0.8.143
|
|
14
14
|
granttap setup
|
|
15
15
|
granttap status
|
|
16
16
|
```
|
package/cursor-plugin/mcp.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"command": "node",
|
|
5
5
|
"args": [
|
|
6
6
|
"-e",
|
|
7
|
-
"\"use strict\";\n\n// Cursor may start this MCP from any cwd. Execute JavaScript entry points with\n// Node itself: Windows batch shims require shell quoting that differs by host.\nconst { spawn } = require(\"node:child_process\");\nconst { existsSync } = require(\"node:fs\");\nconst { delimiter, dirname, join } = require(\"node:path\");\n\nconst PACKAGE = \"granttap-mcp@0.8.
|
|
7
|
+
"\"use strict\";\n\n// Cursor may start this MCP from any cwd. Execute JavaScript entry points with\n// Node itself: Windows batch shims require shell quoting that differs by host.\nconst { spawn } = require(\"node:child_process\");\nconst { existsSync } = require(\"node:fs\");\nconst { delimiter, dirname, join } = require(\"node:path\");\n\nconst PACKAGE = \"granttap-mcp@0.8.143\";\nconst dryRun = process.env.GRANTTAP_BOOTSTRAP_DRY_RUN === \"1\";\nconst platform = dryRun && process.env.GRANTTAP_BOOTSTRAP_PLATFORM\n ? process.env.GRANTTAP_BOOTSTRAP_PLATFORM : process.platform;\nconst nodeRoot = dryRun && process.env.GRANTTAP_BOOTSTRAP_NODE_ROOT\n ? process.env.GRANTTAP_BOOTSTRAP_NODE_ROOT : dirname(process.execPath);\nconst pathRoots = (process.env.PATH || \"\").split(delimiter).filter(Boolean);\nconst appData = process.env.APPDATA;\nconst roots = [nodeRoot, ...pathRoots, ...(appData ? [join(appData, \"npm\")] : [])];\nconst first = (paths) => paths.find((path) => existsSync(path));\n\nfunction launch() {\n if (platform !== \"win32\") {\n const installed = first(roots.map((root) => join(root, \"granttap-mcp\")));\n if (installed) return { command: installed, args: [] };\n const npx = first(roots.map((root) => join(root, \"npx\"))) || \"npx\";\n return { command: npx, args: [\"-y\", PACKAGE] };\n }\n const installed = first(roots.map((root) =>\n join(root, \"node_modules\", \"granttap-mcp\", \"bin\", \"granttap-mcp.mjs\")));\n if (installed) return { command: process.execPath, args: [installed] };\n const npx = first(roots.map((root) =>\n join(root, \"node_modules\", \"npm\", \"bin\", \"npx-cli.js\")));\n if (npx) return { command: process.execPath, args: [npx, \"-y\", PACKAGE] };\n throw new Error(\"Node.js/npm 22.13.0+ is required on this Windows device. Install npm and retry GrantTap.\");\n}\n\nlet target;\ntry { target = launch(); }\ncatch (error) {\n process.stderr.write(`[granttap] ${error.message}\\n`);\n process.exit(1);\n}\n\nif (dryRun) {\n process.stdout.write(JSON.stringify(target));\n process.exit(0);\n}\n\nconst child = spawn(target.command, target.args, { stdio: \"inherit\", windowsHide: true });\nchild.on(\"error\", (error) => {\n process.stderr.write(`[granttap] ${error.message}\\n`);\n process.exit(1);\n});\nchild.on(\"exit\", (code, signal) => {\n if (signal && platform !== \"win32\") {\n try { process.kill(process.pid, signal); } catch { process.exit(code ?? 1); }\n return;\n }\n process.exit(code ?? 1);\n});\n"
|
|
8
8
|
]
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -7,7 +7,7 @@ const { spawn } = require("node:child_process");
|
|
|
7
7
|
const { existsSync } = require("node:fs");
|
|
8
8
|
const { delimiter, dirname, join } = require("node:path");
|
|
9
9
|
|
|
10
|
-
const PACKAGE = "granttap-mcp@0.8.
|
|
10
|
+
const PACKAGE = "granttap-mcp@0.8.143";
|
|
11
11
|
const dryRun = process.env.GRANTTAP_BOOTSTRAP_DRY_RUN === "1";
|
|
12
12
|
const platform = dryRun && process.env.GRANTTAP_BOOTSTRAP_PLATFORM
|
|
13
13
|
? process.env.GRANTTAP_BOOTSTRAP_PLATFORM : process.platform;
|
package/package.json
CHANGED
|
@@ -103,7 +103,8 @@ export class RelayClient {
|
|
|
103
103
|
resolve();
|
|
104
104
|
this.connections.connected();
|
|
105
105
|
});
|
|
106
|
-
|
|
106
|
+
// One frame that fails to apply must not end the process; an unacknowledged one is redelivered.
|
|
107
|
+
ws.on("message", (data: WebSocket.RawData) => void this.onRaw(data.toString()).catch(() => {}));
|
|
107
108
|
ws.on('unexpected-response', (_request, response) => {
|
|
108
109
|
this.reconnect.defer(response.headers['retry-after']);
|
|
109
110
|
response.resume(); ws.terminate();
|
|
@@ -56,7 +56,12 @@ export class RelayMessageAcceptance {
|
|
|
56
56
|
const oldest = this.seen.values().next().value;
|
|
57
57
|
if (oldest) this.seen.delete(oldest);
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
try {
|
|
60
|
+
saveReplayFingerprints(this.path, this.seen);
|
|
61
|
+
} catch {
|
|
62
|
+
// On a full disk this once ended the monitor and the relay redelivered the
|
|
63
|
+
// message after the restart. The next save the disk accepts writes the whole set.
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
finish(fingerprint: string): void { this.processing.delete(fingerprint); }
|