granttap-mcp 0.8.132 → 0.8.134

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.
@@ -100,9 +100,9 @@ async function handlePreToolUse(input: HookInput): Promise<void> {
100
100
  }
101
101
  const legacyFlow = legacyGrantTapFlowAllowed(projectDecision);
102
102
 
103
- // Claude already granted this chat unconditional tool access. GrantTap's
104
- // Project ASK/DENY is a parent boundary, so bypass mode cannot weaken it.
105
- if (legacyFlow && input.permission_mode === "bypassPermissions" && input.tool_name !== "AskUserQuestion") return;
103
+ // The person gave this chat unconditional tool access, so nothing here waits
104
+ // for their phone. Project DENY returned above and stays binding.
105
+ if (input.permission_mode === "bypassPermissions" && input.tool_name !== "AskUserQuestion") return;
106
106
 
107
107
  // Gating paused, or this session is exempt → abstain (empty output = Claude
108
108
  // uses its normal permission flow, exactly as if GrantTap weren't installed).
@@ -15,6 +15,7 @@ import { controllerPeerGate } from "../../pairing/controllers";
15
15
  import { applyNetworkRoute } from "../../device-network/settings";
16
16
  import { startEndpointPublisher } from "../../device-network/directory";
17
17
  import { managedAdmissionOptions } from "../../managed-admission";
18
+ import { publishStableNode } from "../../install/stable-node/index";
18
19
 
19
20
  import { startTaskDispatchMonitor } from "../../task-dispatch/worker/monitor";
20
21
  import { startTaskNetworkMonitor } from '../../task-network/runtime';
@@ -30,6 +31,8 @@ let stopEngineRecovery = () => {};
30
31
  let stopRuntimeUpdates = () => {};
31
32
  let stopUpdateReadiness = () => {};
32
33
 
34
+ publishStableNode();
35
+
33
36
  try {
34
37
  const cfg = applyNetworkRoute(loadConfig(machineConfigPath()));
35
38
  client = new RelayClient(cfg, {
@@ -0,0 +1,14 @@
1
+ # Stable Node link
2
+
3
+ Coding apps started from the Dock inherit a PATH without nvm and similar version
4
+ managers, so the Claude Code plugin's `node` command may not resolve there. The
5
+ monitor always runs under a working Node and publishes it at `bin/node` in the
6
+ private GrantTap configuration folder. The plugin appends that folder to the end
7
+ of its PATH, so a Node already on PATH still wins.
8
+
9
+ Public entry: `publishStableNode`. Windows installs Node on PATH and gets no link.
10
+ A storage failure never stops the monitor from starting. Tests run the published
11
+ link and cover replacement, Windows, and an unwritable folder.
12
+
13
+ License: this module is distributed under the GrantTap Commercial Source License
14
+ in the repository-root `LICENSE` file.
@@ -0,0 +1,30 @@
1
+ import { mkdirSync, readlinkSync, renameSync, rmSync, symlinkSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { configDir } from "../../config";
4
+
5
+ function currentTarget(link: string): string | undefined {
6
+ try { return readlinkSync(link); } catch { return undefined; }
7
+ }
8
+
9
+ /**
10
+ * Coding apps started from the Dock inherit a PATH without nvm and similar
11
+ * version managers, so a plugin's `node` command may not resolve there. The
12
+ * monitor always runs under a working Node and publishes it at one stable path.
13
+ * Windows installs Node on PATH and needs no link.
14
+ */
15
+ export function publishStableNode(root = configDir(), nodePath = process.execPath,
16
+ platform: NodeJS.Platform = process.platform): void {
17
+ if (platform === "win32") return;
18
+ const bin = join(root, "bin");
19
+ const link = join(bin, "node");
20
+ try {
21
+ mkdirSync(bin, { recursive: true, mode: 0o700 });
22
+ if (currentTarget(link) === nodePath) return;
23
+ const next = `${link}.${process.pid}.tmp`;
24
+ rmSync(next, { force: true });
25
+ symlinkSync(nodePath, next);
26
+ renameSync(next, link);
27
+ } catch {
28
+ // A plugin can still find a Node that is already on PATH.
29
+ }
30
+ }
@@ -8,9 +8,11 @@ disabled or the engine cannot answer.
8
8
 
9
9
  `capability-fingerprint.ts` turns provider tool metadata into a bounded
10
10
  capability fingerprint. It never copies raw tool arguments, commands, secrets,
11
- or absolute file paths into the fingerprint. Project `DENY` and `ASK` are parent
12
- boundaries; legacy bypass, paused gating, and auto-accept may run only after an
13
- `ALLOW` or `INHERIT` result.
11
+ or absolute file paths into the fingerprint. Project `DENY` is a parent boundary
12
+ for every chat. Claude `bypassPermissions` passes a Project `ASK` because the
13
+ person gave that chat unconditional access; paused gating and auto-accept may run
14
+ only after an `ALLOW` or `INHERIT` result. A chat's auto-accept rule can narrow an
15
+ explicit Project level; a Project without its own level sets no ceiling for it.
14
16
 
15
17
  Codex `PreToolUse` never waits for a phone. A Project `ASK` creates an owner-only
16
18
  30-second marker bound to the exact session, `tool_use_id`, tool, and normalized
@@ -127,8 +127,11 @@ export function resolveAutoAcceptLevel(opts: {
127
127
  const sid = opts.sessionId;
128
128
  const projectId = opts.projectId;
129
129
  if (projectId) {
130
- const projectLevel = opts.byProject?.[projectId] ?? opts.defaultLevel ?? "ask";
130
+ const explicitProjectLevel = opts.byProject?.[projectId];
131
131
  const taskLevel = sid ? opts.bySession?.[sid] : undefined;
132
+ // A Project without its own rule sets no ceiling for a chat rule the person chose.
133
+ if (!explicitProjectLevel && taskLevel) return taskLevel;
134
+ const projectLevel = explicitProjectLevel ?? opts.defaultLevel ?? "ask";
132
135
  if (!taskLevel) return projectLevel;
133
136
  // A native-session override can narrow Project automation, never enlarge
134
137
  // it. More permissive exceptions require a separate governed operation.
@@ -37,6 +37,11 @@ const inFlight = new Map<string, Promise<ReplyResult | null>>();
37
37
 
38
38
  export function isDeliveryInFlight(sessionId: string): boolean { return inFlight.has(sessionId); }
39
39
 
40
+ /** New tasks are separate conversations: one long run must not hold back the next. */
41
+ export function newTaskDeliveryKey(agent: string, operationKey?: string): string {
42
+ return `__new_${agent}_task__${operationKey ? `:${operationKey}` : ''}`;
43
+ }
44
+
40
45
  /** Acknowledging a message does not finish the provider turn or permit a runtime handoff. */
41
46
  export function hasPendingDeliveries(): boolean { return inFlight.size > 0; }
42
47
 
@@ -109,7 +114,7 @@ export function createCodexSession(
109
114
  effort?: string,
110
115
  ): Promise<ReplyResult> {
111
116
  const workspace = resolveAgentWorkspace(cwd, "codex");
112
- return queued("__new_codex_task__", () => withAttachments(attachments, text, (prepared) =>
117
+ return queued(newTaskDeliveryKey("codex", operationKey), () => withAttachments(attachments, text, (prepared) =>
113
118
  runCodexNew(prepared.prompt, workspace, timeoutMs, prepared.images, model, operationKey, effort),
114
119
  ));
115
120
  }
@@ -125,7 +130,7 @@ export function createClaudeSession(
125
130
  effort?: string,
126
131
  ): Promise<ReplyResult> {
127
132
  const workspace = resolveAgentWorkspace(cwd, "claude");
128
- return queued("__new_claude_task__", () => withAttachments(attachments, text, (prepared) =>
133
+ return queued(newTaskDeliveryKey("claude", operationKey), () => withAttachments(attachments, text, (prepared) =>
129
134
  runClaudeNew(prepared.claudePrompt, workspace, timeoutMs, model, operationKey, effort),
130
135
  ));
131
136
  }
@@ -141,7 +146,7 @@ export function createCursorSession(
141
146
  onNativeSession?: (sessionId: string) => void,
142
147
  ): Promise<ReplyResult> {
143
148
  const workspace = resolveAgentWorkspace(cwd, "cursor");
144
- return queued("__new_cursor_task__", () => withAttachments(attachments, text, (prepared) =>
149
+ return queued(newTaskDeliveryKey("cursor", operationKey), () => withAttachments(attachments, text, (prepared) =>
145
150
  runCursorNew(prepared.claudePrompt, workspace, timeoutMs, model, operationKey, effort, onNativeSession),
146
151
  ));
147
152
  }
@@ -157,7 +162,7 @@ export function createGrokSession(
157
162
  onNativeSession?: (sessionId: string) => void,
158
163
  ): Promise<ReplyResult> {
159
164
  const workspace = resolveAgentWorkspace(cwd, "grok");
160
- return queued("__new_grok_task__", () => withAttachments(attachments, text, (prepared) =>
165
+ return queued(newTaskDeliveryKey("grok", operationKey), () => withAttachments(attachments, text, (prepared) =>
161
166
  runGrokNew(prepared.claudePrompt, workspace, timeoutMs, model, operationKey, effort, onNativeSession),
162
167
  ));
163
168
  }
@@ -10,7 +10,7 @@ export interface TaskJobRemote {
10
10
  export type WorkerOptions = {
11
11
  inbox: TaskDispatchInbox; remote: TaskJobRemote;
12
12
  onTerminal?: (job: TaskDispatch) => void;
13
- onError?: () => void;
13
+ onError?: (error: unknown) => void;
14
14
  connected: () => boolean; authorized: (peer: string) => boolean;
15
15
  conversationKey?: (job: TaskDispatch, peer: string) => string;
16
16
  validationCode?: (job: TaskDispatch, peer: string) => string | undefined;
@@ -37,7 +37,7 @@ export class TaskDispatchWorker {
37
37
  ?? record.job.sessionId ?? `new:${record.job.operation.agent ?? 'codex'}`;
38
38
  if (this.conversations.has(key)) continue;
39
39
  this.conversations.add(key);
40
- const work = this.process(record).catch(() => { this.options.onError?.(); }).finally(() => {
40
+ const work = this.process(record).catch(error => { this.options.onError?.(error); }).finally(() => {
41
41
  this.active.delete(record.job.jobId); this.conversations.delete(key);
42
42
  });
43
43
  this.active.set(record.job.jobId, work); launched.push(work);
@@ -1,7 +1,7 @@
1
1
  import { join } from 'node:path';
2
2
  import type { PeerConfig, RelayClient } from '../../../../../packages/core/relay-client';
3
3
  import { configDir, isSessionPaused } from '../../config';
4
- import { isDeliveryInFlight } from '../../reply';
4
+ import { isDeliveryInFlight, newTaskDeliveryKey } from '../../reply';
5
5
  import { publishedCatalog } from '../../session-catalog';
6
6
  import { handleUserMessage } from '../../monitor/handlers/user-message';
7
7
  import { handleTaskCreate } from '../../monitor/handlers/task-create';
@@ -29,7 +29,7 @@ export function startTaskDispatchMonitor(input: {
29
29
  connected: () => !stopped && input.client.isConnected && input.isLeader(),
30
30
  authorized: peerAllowed,
31
31
  onTerminal: job => sender.confirmReceiverOutcome(job),
32
- onError: () => reportFailure(),
32
+ onError: error => reportFailure(error),
33
33
  conversationKey: (job, peer) => resolve(job, peer).job?.sessionId
34
34
  ?? (job.operation.type === 'user.message.continue'
35
35
  ? JSON.stringify([peer, job.operation.originMessageId]) : `new:${job.operation.agent ?? 'codex'}`),
@@ -45,7 +45,8 @@ export function startTaskDispatchMonitor(input: {
45
45
  const session = [...(catalog?.sessions ?? []), ...(catalog?.history ?? [])]
46
46
  .find(item => item.sessionId === job.sessionId);
47
47
  const observation = { ...dispatchSessionObservation(session, catalog?.generatedAt),
48
- inFlight: isDeliveryInFlight(job.sessionId ?? `__new_${job.operation.agent ?? 'codex'}_task__`),
48
+ inFlight: isDeliveryInFlight(job.sessionId ?? newTaskDeliveryKey(job.operation.agent ?? 'codex',
49
+ job.operation.type === 'project.task.create' ? job.operation.operationId : undefined)),
49
50
  paused: !!job.sessionId && isSessionPaused(job.sessionId) };
50
51
  const ready = taskDispatchReady(job, observation);
51
52
  if (!ready && queuedCatalogRefreshDue(job, observation, refreshedAt)) {
@@ -65,10 +66,12 @@ export function startTaskDispatchMonitor(input: {
65
66
  return outcome;
66
67
  },
67
68
  });
68
- const reportFailure = () => {
69
+ const reportFailure = (error: unknown) => {
69
70
  if (Date.now() - reportedAt < 60_000) return;
70
71
  reportedAt = Date.now();
71
- process.stderr.write('[monitor] Durable task queue needs storage or relay recovery. No prompt was replayed.\n');
72
+ // Storage and relay errors name a status or a path, never a prompt.
73
+ const cause = error instanceof Error ? `${error.name}: ${error.message}`.slice(0, 200) : 'unknown';
74
+ process.stderr.write(`[monitor] Durable task queue needs storage or relay recovery (${cause}). No prompt was replayed.\n`);
72
75
  };
73
76
  const tick = () => {
74
77
  if (Date.now() - maintainedAt > 3_600_000) {
@@ -80,7 +83,7 @@ export function startTaskDispatchMonitor(input: {
80
83
  const off = input.client.onTaskDispatch((job, peer) => {
81
84
  if (stopped || !input.isLeader() || !peerAllowed(peer)) return;
82
85
  try { if (inbox.stage(job, peer) !== 'conflict') tick(); }
83
- catch { reportFailure(); }
86
+ catch (error) { reportFailure(error); }
84
87
  });
85
88
  const interval = setInterval(tick, 2_000); interval.unref();
86
89
  tick();
@@ -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.132
13
+ npm install -g granttap-mcp@0.8.134
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.132\";\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.134\";\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.132";
10
+ const PACKAGE = "granttap-mcp@0.8.134";
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.132",
3
+ "version": "0.8.134",
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": {