granttap-mcp 0.8.148 → 0.8.150

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.
@@ -6,6 +6,7 @@ import { blockedSessionCapability, isProviderEnabled } from "../../config";
6
6
  import { recordCodexProjectAsk } from "../../policy/codex-project-ask";
7
7
  import { evaluateEffectiveAction } from "../../policy/effective-action";
8
8
  import { protectedGrantTapAccess } from "../../host/self-protection";
9
+ import { recordAttributedCall } from "../../mesh/identity/call-scope";
9
10
 
10
11
  async function readStdin(): Promise<string> {
11
12
  const chunks: Buffer[] = [];
@@ -51,7 +52,11 @@ async function main(): Promise<void> {
51
52
  deny(decision.reason);
52
53
  return;
53
54
  }
54
- if (decision.effect !== "ask") return;
55
+ if (decision.effect !== "ask") {
56
+ recordAttributedCall({ provider: "codex", sessionId: input.session_id,
57
+ toolName: input.tool_name, args: input.tool_input });
58
+ return;
59
+ }
55
60
  const recorded = recordCodexProjectAsk({
56
61
  sessionId: input.session_id,
57
62
  toolUseId: input.tool_use_id,
@@ -3,18 +3,19 @@ import { fileURLToPath } from "node:url";
3
3
  import { ProviderHook, type ProviderHook as Hook } from "../../../../packages/protocol/messages/provider-hooks";
4
4
  import { configDir } from "../config/runtime/paths";
5
5
  import { cachedHookLauncher, runtimeVersion } from "../runtime-updates/selection.mjs";
6
+ import { hookNodeCommand } from "../install/stable-node";
6
7
 
7
8
  const root = join(dirname(fileURLToPath(import.meta.url)), "..", "..", "..", "..");
8
9
 
9
10
  export function ownedHookCommands() {
10
- const base = `node "${join(root, "bin", "granttap-mcp.mjs")}" internal hook`;
11
+ const base = `${hookNodeCommand("codex")} "${join(root, "bin", "granttap-mcp.mjs")}" internal hook`;
11
12
  return { policy: `${base} codex-policy`, permission: `${base} codex` };
12
13
  }
13
14
 
14
15
  /** This runtime's command, or an earlier runtime's cached launcher that hands off to it. */
15
16
  export function ownedHookCommand(command: unknown, kind: "policy" | "permission"): boolean {
16
17
  return command === ownedHookCommands()[kind] || cachedHookLauncher(command,
17
- kind === "policy" ? "codex-policy" : "codex", join(configDir(), "runtime-updates"), runtimeVersion(root));
18
+ kind === "policy" ? "codex-policy" : "codex", join(configDir(), "runtime-updates"), runtimeVersion(root), hookNodeCommand("codex"));
18
19
  }
19
20
 
20
21
  /** Only the two exact user-config hooks installed by this runtime are reviewable. */
@@ -44,6 +44,7 @@ import { inspectLinuxService } from "./linux-service";
44
44
  import { codexHooksExplicitlyDisabled } from "./hooks";
45
45
  import { cachedCodexHooks, codexHookSet } from "../codex-hook-trust";
46
46
  import { cachedHookLauncher, runtimeVersion } from "../runtime-updates/selection.mjs";
47
+ import { hookNodeCommand } from "./stable-node";
47
48
  import type { ProviderHook } from "../../../../packages/protocol/messages/provider-hooks";
48
49
  export { codexHookSet } from "../codex-hook-trust";
49
50
 
@@ -63,7 +64,7 @@ export type HookRoute =
63
64
 
64
65
  /** The stable command agents will call. */
65
66
  export function hookCommand(agent: HookRoute): string {
66
- return `node "${join(repoRoot, "bin", "granttap-mcp.mjs")}" internal hook ${agent}`;
67
+ return `${hookNodeCommand(agent)} "${join(repoRoot, "bin", "granttap-mcp.mjs")}" internal hook ${agent}`;
67
68
  }
68
69
 
69
70
  export function commandHasRoute(command: unknown, route: HookRoute): boolean {
@@ -79,7 +80,7 @@ export function commandHasRoute(command: unknown, route: HookRoute): boolean {
79
80
  */
80
81
  export function hookCommandIsCurrent(command: unknown, route: HookRoute): boolean {
81
82
  return typeof command === "string" && (command.trim() === hookCommand(route)
82
- || cachedHookLauncher(command, route, join(configDir(), "runtime-updates"), runtimeVersion(repoRoot)));
83
+ || cachedHookLauncher(command, route, join(configDir(), "runtime-updates"), runtimeVersion(repoRoot), hookNodeCommand(route)));
83
84
  }
84
85
 
85
86
  export type InstallResult = { status: "installed" | "already" | "manual"; detail: string };
@@ -6,7 +6,13 @@ monitor always runs under a working Node and publishes it at `bin/node` in the
6
6
  private GrantTap configuration folder. The plugin appends that folder to the end
7
7
  of its PATH, so a Node already on PATH still wins.
8
8
 
9
- Public entry: `publishStableNode`. Windows installs Node on PATH and gets no link.
9
+ Codex's user hooks run outside that plugin environment. Their installed commands
10
+ name the working Node executable by absolute path. Setup repairs older commands
11
+ that require `node` on PATH; the changed definitions require native hook review.
12
+ The launcher path can still survive runtime updates when the Node command is
13
+ unchanged. Other providers keep their existing hook definitions.
14
+
15
+ Public entries: `publishStableNode` and `hookNodeCommand`. Windows gets no link.
10
16
  A storage failure never stops the monitor from starting. Tests run the published
11
17
  link and cover replacement, Windows, and an unwritable folder.
12
18
 
@@ -2,6 +2,15 @@ import { mkdirSync, readlinkSync, renameSync, rmSync, symlinkSync } from "node:f
2
2
  import { join } from "node:path";
3
3
  import { configDir } from "../../config";
4
4
 
5
+ /** User Codex hooks run outside the plugin PATH, including apps started from the Dock. */
6
+ export function hookNodeCommand(route: string, nodePath = process.execPath,
7
+ platform: NodeJS.Platform = process.platform): string {
8
+ if (route !== "codex" && route !== "codex-policy") return "node";
9
+ const escaped = platform === "win32" ? nodePath.replaceAll('"', '""')
10
+ : nodePath.replace(/["\\$`]/g, "\\$&");
11
+ return `"${escaped}"`;
12
+ }
13
+
5
14
  function currentTarget(link: string): string | undefined {
6
15
  try { return readlinkSync(link); } catch { return undefined; }
7
16
  }
@@ -7,5 +7,5 @@ export function runtimeVersion(root:string):string;
7
7
  export function versionRoot(directory:string,version:string):string;
8
8
  export function validRuntime(root:string|undefined,directory:string,version:string|undefined):boolean;
9
9
  export function selectedRuntime(bundled:string,directory:string):string;
10
- export function cachedHookLauncher(command:unknown,route:string,directory:string,current:string):boolean;
10
+ export function cachedHookLauncher(command:unknown,route:string,directory:string,current:string,nodeCommand?:string):boolean;
11
11
  export function rollbackRuntime(bundled:string,directory:string,failedRoot?:string):boolean;
@@ -39,8 +39,9 @@ export function selectedRuntime(bundled, directory) {
39
39
  * this cache. Each cached launcher hands off to the selection above, so the hook
40
40
  * stays current after an update; one naming a newer, rolled-back release does not.
41
41
  */
42
- export function cachedHookLauncher(command, route, directory, current) {
43
- const match=typeof command==='string' && command.trim().match(/^node "(.+)[\\/]bin[\\/]granttap-mcp\.mjs" internal hook (\S+)$/);
42
+ export function cachedHookLauncher(command, route, directory, current, nodeCommand = 'node') {
43
+ const prefix=nodeCommand+' "', raw=typeof command==='string' ? command.trim() : '';
44
+ const match=raw.startsWith(prefix) && raw.slice(prefix.length).match(/^(.+)[\\/]bin[\\/]granttap-mcp\.mjs" internal hook (\S+)$/);
44
45
  if(!match || match[2]!==route) return false;
45
46
  try { const version=runtimeVersion(match[1]);
46
47
  return validRuntime(match[1],directory,version) && !newerVersion(version,current); } catch { return false; }
@@ -32,9 +32,12 @@ export function createMcpSessionHandler(): {
32
32
  await transport.handleRequest(req, res, req.body);
33
33
  return;
34
34
  }
35
- res.status(400).json({
35
+ const staleSession = typeof sessionId === "string";
36
+ res.status(staleSession ? 404 : 400).json({
36
37
  jsonrpc: "2.0",
37
- error: { code: -32000, message: "Bad Request: No valid session ID provided" },
38
+ error: staleSession
39
+ ? { code: -32001, message: "Session not found" }
40
+ : { code: -32000, message: "Bad Request: No valid session ID provided" },
38
41
  id: null,
39
42
  });
40
43
  } catch (error) {
@@ -18,6 +18,10 @@ Both are caller-scoped. `granttap://mesh/current` returns no Project data;
18
18
  Task, owners, claims, dependencies, and relevant events. A `notify` Mesh event
19
19
  is published for the session its provider hook attributed, never for a session
20
20
  the model named, and ownership-transfer event types are refused outright.
21
+ Codex records allowed calls in its trusted `PreToolUse` hook, because normally
22
+ allowed MCP calls need not emit `PermissionRequest`. Governed requests retain
23
+ the permission hook's attribution after their decision. Untrusted or disabled
24
+ native hooks cannot establish a caller scope.
21
25
 
22
26
  `mesh-tools.ts`, `mesh-actions.ts`, and `mesh-relay.ts` serve the separate scoped
23
27
  server started by `granttap internal mesh-mcp` for a connected Grok Bot endpoint.
@@ -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.148
13
+ npm install -g granttap-mcp@0.8.150
14
14
  granttap setup
15
15
  granttap status
16
16
  ```
@@ -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.148\";\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"
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.150\";\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.148";
10
+ const PACKAGE = "granttap-mcp@0.8.150";
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "granttap-mcp",
3
- "version": "0.8.148",
3
+ "version": "0.8.150",
4
4
  "description": "Commercial computer runtime connecting local coding agents to GrantTap on Mac, iPhone, iPad and Apple Watch.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -83,6 +83,6 @@
83
83
  "access": "public"
84
84
  },
85
85
  "overrides": {
86
- "@hono/node-server": "2.0.11"
86
+ "@hono/node-server": "2.1.3"
87
87
  }
88
88
  }