granttap-mcp 0.8.144 → 0.8.146
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/host/session-keys.ts +3 -1
- package/apps/bridge/src/mesh/runtime/snapshot/fit.ts +35 -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 +4 -0
- package/packages/core/relay-envelope.ts +13 -1
|
@@ -2,6 +2,7 @@ import { retainedPayloadOptions } from "../../../../packages/core/retained-state
|
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { loadSessionKeys, persistedSessionKey } from "./session-key-store";
|
|
5
|
+
import { fitMeshSnapshot } from "../mesh/runtime/snapshot/fit";
|
|
5
6
|
import { RelayClient, type SendOptions } from "../../../../packages/core/relay-client";
|
|
6
7
|
import type {
|
|
7
8
|
MeshClaimReleaseResult,
|
|
@@ -49,7 +50,8 @@ export async function sendMeshPayload(
|
|
|
49
50
|
options: SendOptions = {},
|
|
50
51
|
): Promise<void> {
|
|
51
52
|
const purpose = payload.type === "mesh.snapshot" ? "project" : "task";
|
|
52
|
-
|
|
53
|
+
const fitted = payload.type === "mesh.snapshot" ? fitMeshSnapshot(payload) : payload;
|
|
54
|
+
await sendScopedPayload({ client, payload: fitted, sessionId: fitted.sessionId, purpose, to, options });
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
export async function sendProjectPayload(
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MeshSnapshot, ProjectRepositoryGraph } from "../../../../../../packages/protocol/schema";
|
|
2
|
+
import { fitRepositoryGraph } from "../../../engine/runtime/repository-graph/fit";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A snapshot is sealed twice, with the task key and then for transport, and each base64 layer adds a
|
|
6
|
+
* third; this plaintext budget keeps the sealed frame under the relay's 1.8 MB stored-message limit.
|
|
7
|
+
*/
|
|
8
|
+
export const MESH_SNAPSHOT_BUDGET_BYTES = 900_000;
|
|
9
|
+
|
|
10
|
+
const size = (value: unknown) => Buffer.byteLength(JSON.stringify(value), "utf8");
|
|
11
|
+
|
|
12
|
+
function cut(graph: ProjectRepositoryGraph, maxBytes: number): ProjectRepositoryGraph {
|
|
13
|
+
return fitRepositoryGraph(graph, maxBytes)
|
|
14
|
+
?? { ...graph, codeMap: undefined, nodes: [], relations: [], truncated: true };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Each repository graph is bounded on its own, so a Project bound to many checkouts outgrew the relay
|
|
19
|
+
* as a whole. Graphs are shrunk first, then repository details and graphs are left out; the Project,
|
|
20
|
+
* its tasks and its people are never cut here.
|
|
21
|
+
*/
|
|
22
|
+
export function fitMeshSnapshot(snapshot: MeshSnapshot, maxBytes = MESH_SNAPSHOT_BUDGET_BYTES): MeshSnapshot {
|
|
23
|
+
if (size(snapshot) <= maxBytes) return snapshot;
|
|
24
|
+
const graphs = snapshot.repositoryGraphs ?? [];
|
|
25
|
+
let fitted = snapshot;
|
|
26
|
+
for (const perGraph of graphs.length ? [96, 48, 24, 12] : []) {
|
|
27
|
+
fitted = { ...fitted, repositoryGraphs: graphs.map(graph => ({ ...cut(graph, perGraph * 1_024), truncated: true })) };
|
|
28
|
+
if (size(fitted) <= maxBytes) return fitted;
|
|
29
|
+
}
|
|
30
|
+
if (fitted.repositoryDetails) {
|
|
31
|
+
fitted = { ...fitted, repositoryDetails: undefined };
|
|
32
|
+
if (size(fitted) <= maxBytes) return fitted;
|
|
33
|
+
}
|
|
34
|
+
return { ...fitted, repositoryGraphs: undefined, repositoryDetails: undefined };
|
|
35
|
+
}
|
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.146
|
|
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.146\";\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.146";
|
|
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
|
@@ -120,6 +120,10 @@ export class RelayClient {
|
|
|
120
120
|
this.socketHealth.stop(ws);
|
|
121
121
|
this.admissionLease.stop(ws);
|
|
122
122
|
if (this.ws === ws) { this.reconnect.closed(openedAt, code, reason.toString()); this.ws = undefined; }
|
|
123
|
+
// The relay names why it closed; without this a refusal loop looked like an idle, online computer.
|
|
124
|
+
if (opened && code !== 1000 && code !== 1001 && code !== 1005) {
|
|
125
|
+
process.stderr.write(`[relay] connection closed: ${code} ${reason.toString().slice(0, 80)}\n`);
|
|
126
|
+
}
|
|
123
127
|
if (!opened) reject(new Error(`relay connection closed (${this.cfg.relayUrl})`));
|
|
124
128
|
this.scheduleReconnect();
|
|
125
129
|
});
|
|
@@ -39,9 +39,21 @@ export function sealEnvelope(
|
|
|
39
39
|
nonce,
|
|
40
40
|
box,
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
const frame = JSON.stringify(envelope);
|
|
43
|
+
if (envelope.deliveryId && to !== "all" && Buffer.byteLength(frame) > MAX_STORED_FRAME_BYTES) {
|
|
44
|
+
throw new Error(`relay frame of ${Buffer.byteLength(frame)} bytes exceeds the stored-message limit`);
|
|
45
|
+
}
|
|
46
|
+
return frame;
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The relay stores a frame that carries a `deliveryId` until the peer confirms it, and refuses one
|
|
51
|
+
* larger than this by closing the sender's socket with a cool-down. A computer whose Mesh snapshot
|
|
52
|
+
* outgrew it reconnected every few seconds and never stayed long enough to receive a phone message,
|
|
53
|
+
* so such a frame is refused here and the socket stays up.
|
|
54
|
+
*/
|
|
55
|
+
export const MAX_STORED_FRAME_BYTES = 1_800_000;
|
|
56
|
+
|
|
45
57
|
/** Apply the independent task encryption layer before transport encryption. */
|
|
46
58
|
export function sealSessionPayload(payload: Payload, sessionId: string, key: string | undefined): Payload {
|
|
47
59
|
if (!key) throw new Error(`no encryption key for task ${sessionId}`);
|