granttap-mcp 0.8.127 → 0.8.129

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.
@@ -1,6 +1,7 @@
1
1
  import type { SessionInfo, SessionsStatus } from "../../../../../packages/protocol/schema";
2
2
  import type { RelayClient } from "../../../../../packages/core/relay-client";
3
3
  import { sendSessionPayload } from "../../host/session-keys";
4
+ import { observeSessionExecution } from "../../session-catalog/observed-state";
4
5
  import { cachedSessionActivity } from "../support/session-activity";
5
6
  import { readTranscriptHistory } from "../../transcript-history";
6
7
  import { publishedSession } from "../../session-catalog";
@@ -84,11 +85,13 @@ async function sendTranscript(
84
85
  threadId?: string,
85
86
  history?: { history?: boolean; historyCursor?: string; peerPublicKey?: string },
86
87
  ): Promise<boolean> {
87
- const session = resolveSession(client, sessionId, status);
88
- if (!session) return false;
88
+ const known = resolveSession(client, sessionId, status);
89
+ if (!known) return false;
90
+ const observation = observeSessionExecution(known);
91
+ const session = observation?.session ?? known;
89
92
  const activity = threadId ? scanThreadActivity(session, threadId)
90
93
  : (history?.history ? readTranscriptHistory(session, history.historyCursor) : undefined)
91
- ?? cachedSessionActivity(session);
94
+ ?? cachedSessionActivity(session, false, observation?.revision);
92
95
  await sendSessionPayload(client, activityWithImages(activity), sessionId, "phone", {
93
96
  ttlMs: INTERVAL_MS * 24,
94
97
  reliable: false,
@@ -22,6 +22,9 @@ import { HEARTBEAT_INTERVAL_MS, publishHeartbeat } from "./heartbeat";
22
22
  import { confirmPendingController } from "../../pairing/controllers";
23
23
  import { recordControllerName } from "../../pairing/presence";
24
24
  import { startPublishLoop } from "./publish-loop";
25
+ import { openChatUpdates, OPEN_CHAT_INTERVAL_MS } from "../../session-catalog/open-chat-updates";
26
+ import { refreshObservedCatalog } from "../../session-catalog/observed-state";
27
+ import { hasPendingDeliveries } from "../../reply";
25
28
  import { singleFlightPublisher } from "./single-flight";
26
29
  import { publishedCatalog, rememberPublishedCatalog, resumePublishedChats,
27
30
  publishCatalogHeads, stopCatalogHeads } from "../../session-catalog";
@@ -150,7 +153,7 @@ async function publishMonitorTick(input: {
150
153
  const includeHistory = forceHistory || (!initial && Date.now() - lastHistoryPublishedAt >= HISTORY_INTERVAL_MS);
151
154
  const snapshot = await monitorSnapshot({ includeHistory, forceHistory, subscriptions, history });
152
155
  if (!input.active()) return { lastHistoryPublishedAt };
153
- const status = decorateTaskOriginCatalog(snapshot, client.room);
156
+ const status = decorateTaskOriginCatalog(refreshObservedCatalog(snapshot), client.room);
154
157
  rememberPublishedCatalog(client, status);
155
158
  await client.send(status, "phone", { ttlMs: INTERVAL_MS * 24, reliable: false });
156
159
  // Provider review is independent of task visibility; a hung hook RPC must
@@ -178,7 +181,7 @@ export function startSessionMonitor(client: RelayClient): SessionMonitor {
178
181
  let historyRead: Promise<SessionsStatus["sessions"]> | undefined;
179
182
  let lastHistoryPublishedAt = 0;
180
183
  let closed = false;
181
- const work = runtimeWorkTracker(() => approvalsStatus().pending.length > 0 || providerLogins.active() || deviceManagementWorkActive());
184
+ const work = runtimeWorkTracker(() => hasPendingDeliveries() || approvalsStatus().pending.length > 0 || providerLogins.active() || deviceManagementWorkActive());
182
185
  const loadLoop = monitorLoadLoop(client, leadership);
183
186
 
184
187
  const history = (force = false): Promise<SessionsStatus["sessions"]> => {
@@ -234,6 +237,15 @@ export function startSessionMonitor(client: RelayClient): SessionMonitor {
234
237
  publish: () => publishHeartbeat(client).catch(() => {}),
235
238
  });
236
239
  const stopQuestions = startQuestionLoop(client, leadership, subscriptions);
240
+ const stopChats = startPublishLoop({
241
+ connected: () => client.isConnected,
242
+ intervalMs: OPEN_CHAT_INTERVAL_MS,
243
+ publish: openChatUpdates({
244
+ catalog: () => publishedCatalog(client), subscriptions,
245
+ active: () => !closed && client.isConnected && leadership.acquire(),
246
+ publish: (id, status) => publishSessionEvents(client, id, status),
247
+ }),
248
+ });
237
249
 
238
250
  return {
239
251
  publish: () => publish(false),
@@ -248,6 +260,7 @@ export function startSessionMonitor(client: RelayClient): SessionMonitor {
248
260
  stopMonitorMeshes(client);
249
261
  stopHeartbeat();
250
262
  stopQuestions();
263
+ stopChats();
251
264
  loadLoop.stop();
252
265
  off();
253
266
  subscriptions.clear();
@@ -28,10 +28,10 @@ function cacheKey(session: SessionInfo): string {
28
28
  export function sessionActivityCache(
29
29
  read: ActivityReader,
30
30
  capacity = 64,
31
- ): (session: SessionInfo, forceScan?: boolean) => SessionActivity {
31
+ ): (session: SessionInfo, forceScan?: boolean, sourceRevision?: string) => SessionActivity {
32
32
  const cache = new Map<string, SessionActivity>();
33
- return (session, forceScan = false) => {
34
- const key = cacheKey(session);
33
+ return (session, forceScan = false, sourceRevision = "") => {
34
+ const key = `${cacheKey(session)}\0${sourceRevision}`;
35
35
  if (!forceScan) {
36
36
  const hit = cache.get(key);
37
37
  // Refresh recency so a chat the user keeps open is never the eviction
@@ -37,6 +37,9 @@ 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
+ /** Acknowledging a message does not finish the provider turn or permit a runtime handoff. */
41
+ export function hasPendingDeliveries(): boolean { return inFlight.size > 0; }
42
+
40
43
  /** Request a stop for owned processes; confirmation arrives only on process exit. */
41
44
  export function stopDeliveries(sessionId: string): number {
42
45
  try { localRoutingRequests().cancel(sessionId); } catch { /* The native stop still runs when storage is unavailable. */ }
@@ -32,3 +32,14 @@ and metadata caches serve synchronous CLI readers and cooperative live-monitor
32
32
  readers. Checkout observations are scoped to one asynchronous scan, so unrelated
33
33
  requests cannot inherit an old directory result. Socket recovery immediately
34
34
  republishes the current catalog instead of waiting for the next periodic tick.
35
+
36
+ Open and working chats follow a separate two-second loop of known native sources.
37
+ Only changed source revisions send encrypted transcript heads; reads and sends
38
+ remain single-flight and bounded to eight chats per pass. Claude end-turn and
39
+ Codex turn events update execution state immediately after observation. The same
40
+ native observation releases queued messages without waiting for full discovery.
41
+ A fresh chat does not advance the observation clock of unrelated catalog rows.
42
+ Full discoveries recheck known native execution state immediately before sending
43
+ their catalog, so a scan started during a turn cannot restore stale Working after
44
+ an independently delivered completion. Runtime handoff also waits for owned
45
+ provider turns to settle, including work already acknowledged to the phone.
@@ -0,0 +1,65 @@
1
+ import {statSync} from 'node:fs';
2
+ import {join} from 'node:path';
3
+ import {homedir} from 'node:os';
4
+ import type {SessionInfo, SessionsStatus} from '../../../../packages/protocol/schema';
5
+ import {localTaskTransfers} from '../task-transfer';
6
+ import {nativeTranscriptSource} from '../sessions/native-source';
7
+ import {claudeLogPath} from '../sessions/scan/claude/shared';
8
+ import {previousNativeLines} from '../transcript-history/native-lines';
9
+ import {observeClaudeTurn,claudeTurnState,type ClaudeTurnClock} from '../sessions/scan/claude/turn-state';
10
+ import {observeCodexTurn,codexTurnState,type CodexTurnClock} from '../sessions/scan/codex/turn-state';
11
+ import {ts} from '../sessions/support/common';
12
+ import {grokResumeActivity} from '../providers/grok-activity';
13
+ import {cursorConversationSession} from '../sessions/cursor';
14
+
15
+ type NativeClock={revision:string;lastActivityAt:number;claude:ClaudeTurnClock;codex:CodexTurnClock};
16
+ const clocks=new Map<string,NativeClock>();
17
+ export type SessionObservation={session:SessionInfo;revision:string};
18
+
19
+ /** Discovery may have started before an open chat finished its turn. Recheck before publication. */
20
+ export function refreshObservedCatalog(status: SessionsStatus): SessionsStatus {
21
+ const refresh = (session: SessionInfo) => observeSessionExecution(session)?.session ?? session;
22
+ return {...status, sessions: status.sessions.map(refresh), history: status.history?.map(refresh)};
23
+ }
24
+
25
+ /** A known chat uses one bounded native tail, never discovery across unrelated projects. */
26
+ export function observeSessionExecution(input:SessionInfo):SessionObservation|undefined {
27
+ const native=localTaskTransfers().nativeSession(input);
28
+ if(native.agent==='cursor'){
29
+ const current=cursorConversationSession(native.sessionId);
30
+ return current?{session:{...input,state:current.state,lastActivityAt:current.lastActivityAt},revision:`${current.lastActivityAt}:${current.state}`}:undefined;
31
+ }
32
+ if(native.agent==='grok'){
33
+ const live=grokResumeActivity(native);
34
+ if(!native.cwd||!live)return;
35
+ const root=process.env.GRANTTAP_GROK_SESSIONS_DIR??join(process.env.GROK_HOME??join(homedir(),'.grok'),'sessions');
36
+ try{
37
+ const stat=statSync(join(root,encodeURIComponent(native.cwd),native.sessionId,'updates.jsonl'));
38
+ return {session:{...input,state:live.state,lastActivityAt:Math.max(input.lastActivityAt,live.updatedAt)},revision:`${stat.ino}:${stat.size}:${stat.mtimeMs}:${live.state}`};
39
+ }catch{return;}
40
+ }
41
+ if(native.agent!=='claude'&&native.agent!=='codex')return;
42
+ const path=nativeTranscriptSource(native)??(native.agent==='claude'?claudeLogPath(native.sessionId):undefined);
43
+ if(!path)return;
44
+ try{
45
+ const stat=statSync(path),revision=`${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeMs}`;
46
+ const key=`${native.agent}:${native.sessionId}:${path}`;
47
+ let clock=clocks.get(key);
48
+ if(clock?.revision!==revision){
49
+ const window=previousNativeLines(path,native.sessionId);if(!window)return;
50
+ clock={revision,lastActivityAt:0,claude:{},codex:{}};
51
+ for(const line of window.lines){
52
+ let row;try{row=JSON.parse(line.text)}catch{continue}
53
+ if(row.isSidechain===true||row.sessionId&&row.sessionId!==native.sessionId)continue;
54
+ clock.lastActivityAt=Math.max(clock.lastActivityAt,ts(row.timestamp));
55
+ if(native.agent==='claude')observeClaudeTurn(row,clock.claude);else observeCodexTurn(row,clock.codex);
56
+ }
57
+ clocks.delete(key);clocks.set(key,clock);
58
+ while(clocks.size>256)clocks.delete(clocks.keys().next().value!);
59
+ }
60
+ const at=Math.max(input.lastActivityAt,clock!.lastActivityAt);
61
+ const state=native.agent==='claude'?claudeTurnState(clock!.claude,at,input.state)
62
+ :clock!.codex.startedAt||clock!.codex.endedAt?codexTurnState(clock!.codex,at):input.state;
63
+ return {session:{...input,state,lastActivityAt:at},revision:`${revision}:${state}`};
64
+ }catch{return;}
65
+ }
@@ -0,0 +1,52 @@
1
+ import type {SessionInfo, SessionsStatus} from '../../../../packages/protocol/schema';
2
+ import {observeSessionExecution, type SessionObservation} from './observed-state';
3
+
4
+ export const OPEN_CHAT_INTERVAL_MS = 2_000;
5
+
6
+ /** Follow known native files independently of discovery, without rereading unchanged heads. */
7
+ export function openChatUpdates(options: {
8
+ catalog: () => SessionsStatus | undefined;
9
+ subscriptions: ReadonlySet<string>;
10
+ active: () => boolean;
11
+ publish: (sessionId: string, status: SessionsStatus) => Promise<boolean>;
12
+ observe?: (session: SessionInfo) => SessionObservation | undefined;
13
+ }): () => Promise<void> {
14
+ const revisions = new Map<string, string>();
15
+ const observe = options.observe ?? observeSessionExecution;
16
+ let cursor = 0, openCursor = 0, running = false;
17
+ return async () => {
18
+ if (running || !options.active()) return;
19
+ const status = options.catalog();
20
+ if (!status) return;
21
+ const known = new Map([...status.sessions, ...(status.history ?? [])]
22
+ .map(session => [session.sessionId, session]));
23
+ const ids = [...new Set([...options.subscriptions,
24
+ ...status.sessions.filter(session => session.state === 'working').map(session => session.sessionId)])]
25
+ .filter(id => known.has(id));
26
+ const activeIds = new Set(ids);
27
+ for (const id of revisions.keys()) if (!activeIds.has(id)) revisions.delete(id);
28
+ if (!ids.length) return;
29
+ const opened = ids.filter(id => options.subscriptions.has(id));
30
+ const background = ids.filter(id => !options.subscriptions.has(id));
31
+ const selected = Array.from({length: Math.min(8, opened.length)}, (_, offset) => opened[(openCursor + offset) % opened.length]!);
32
+ openCursor = opened.length ? (openCursor + selected.length) % opened.length : 0;
33
+ const remaining = Math.min(8 - selected.length, background.length);
34
+ selected.push(...Array.from({length: remaining}, (_, offset) => background[(cursor + offset) % background.length]!));
35
+ cursor = background.length ? (cursor + remaining) % background.length : 0;
36
+ running = true;
37
+ try {
38
+ for (const id of selected) {
39
+ await new Promise<void>(resolve => setImmediate(resolve));
40
+ if (!options.active()) break;
41
+ let observed: SessionObservation | undefined;
42
+ try { observed = observe(known.get(id)!); } catch { continue; }
43
+ if (!observed || revisions.get(id) === observed.revision) continue;
44
+ // Keep the full catalog's clock: one fresh chat cannot refresh unrelated chats.
45
+ const fresh = {...status, sessions: [observed.session], history: undefined};
46
+ try {
47
+ if (await options.publish(id, fresh)) revisions.set(id, observed.revision);
48
+ } catch { /* Retry the same revision after a failed encrypted send. */ }
49
+ }
50
+ } finally { running = false; }
51
+ };
52
+ }
@@ -4,6 +4,7 @@ import { basename } from "node:path";
4
4
  import type { ChildThreadInfo, SessionInfo } from "../../../../../../packages/protocol/schema";
5
5
  import { aggregateChildThreads, childTitle } from "../../support/child-threads";
6
6
  import { rememberCapabilityObservation } from "../../telemetry";
7
+ import { observeClaudeTurn } from "./turn-state";
7
8
  import { safeParse, stateFor, ts } from "../../support/common";
8
9
  import { claudeCapabilityUsage } from "./activity";
9
10
  import { claudeRepositoryPaths } from "./repository-observation";
@@ -35,18 +36,8 @@ type ClaudeParseState = {
35
36
  turnEnded: boolean;
36
37
  };
37
38
 
38
- /** Stop reasons after which Claude Code waits for the person's next prompt. */
39
- const FINISHED_TURN = new Set(["end_turn", "stop_sequence", "max_tokens"]);
40
-
41
- /** Metadata, progress and subagent lines do not start or end the chat's own turn. */
42
- function noteTurnBoundary(d: any, state: ClaudeParseState): void {
43
- if (d.isSidechain === true) return;
44
- if (d.type === "user" || d.type === "queue-operation") state.turnEnded = false;
45
- else if (d.type === "assistant") state.turnEnded = FINISHED_TURN.has(d.message?.stop_reason);
46
- }
47
-
48
39
  function applyClaudeLine(d: any, state: ClaudeParseState): void {
49
- noteTurnBoundary(d, state);
40
+ observeClaudeTurn(d, state);
50
41
  if (d.isSidechain !== true) state.repositoryPaths.push(...claudeRepositoryPaths(d));
51
42
  state.repositoryPaths = state.repositoryPaths.slice(-64);
52
43
  if (d.sessionId && !state.sessionId) state.sessionId = String(d.sessionId);
@@ -0,0 +1,9 @@
1
+ # Claude turn state
2
+
3
+ Root turn boundaries are shared by full discovery and bounded live observations.
4
+ An assistant end-turn record ends Working immediately; sidechain and progress
5
+ records do not reopen that root turn. A later user or queued turn reopens it.
6
+
7
+ Covered by sessions/tests/claude-turn-state.test.ts and session-catalog freshness tests.
8
+
9
+ This module uses the GrantTap Commercial Source License.
@@ -0,0 +1,17 @@
1
+ import {stateFor} from '../../../support/common';
2
+ import type {SessionInfo} from '../../../../../../../packages/protocol/schema';
3
+
4
+ export type ClaudeTurnClock = {turnEnded?: boolean};
5
+ const finished = new Set(['end_turn','stop_sequence','max_tokens']);
6
+
7
+ /** Root turn boundaries only; progress and sidechain records cannot resume a finished turn. */
8
+ export function observeClaudeTurn(row: any, clock: ClaudeTurnClock): void {
9
+ if (row.isSidechain === true) return;
10
+ if (row.type === 'user' || row.type === 'queue-operation') clock.turnEnded = false;
11
+ else if (row.type === 'assistant') clock.turnEnded = finished.has(row.message?.stop_reason);
12
+ }
13
+
14
+ export function claudeTurnState(clock: ClaudeTurnClock, lastActivityAt: number,
15
+ fallback: SessionInfo['state']): SessionInfo['state'] {
16
+ return clock.turnEnded === undefined ? fallback : clock.turnEnded ? 'idle' : stateFor(lastActivityAt);
17
+ }
@@ -9,10 +9,8 @@ import { TaskDispatchInbox } from '../index';
9
9
  import { TaskDispatchWorker } from './index';
10
10
  import { relayTaskJobRemote } from './remote';
11
11
  import { NativeTaskQueueSender } from '../sender';
12
- import { queuedCatalogRefreshDue, taskDispatchReady } from './readiness';
12
+ import { dispatchSessionObservation, queuedCatalogRefreshDue, taskDispatchReady } from './readiness';
13
13
  import { localTaskOrigins, resolveTaskOriginJob } from '../../task-origins';
14
- import { grokResumeActivity } from '../../providers/grok-activity';
15
- import { localTaskTransfers } from '../../task-transfer';
16
14
 
17
15
  /** Only the persistent monitor advertises durable submission capability. */
18
16
  export function startTaskDispatchMonitor(input: {
@@ -45,10 +43,7 @@ export function startTaskDispatchMonitor(input: {
45
43
  const catalog = publishedCatalog(input.client);
46
44
  const session = [...(catalog?.sessions ?? []), ...(catalog?.history ?? [])]
47
45
  .find(item => item.sessionId === job.sessionId);
48
- const nativeState = session?.agent === 'grok'
49
- ? grokResumeActivity(localTaskTransfers().nativeSession(session))?.state : undefined;
50
- const observation = { session, generatedAt: catalog?.generatedAt,
51
- nativeState,
46
+ const observation = { ...dispatchSessionObservation(session, catalog?.generatedAt),
52
47
  inFlight: isDeliveryInFlight(job.sessionId ?? `__new_${job.operation.agent ?? 'codex'}_task__`),
53
48
  paused: !!job.sessionId && isSessionPaused(job.sessionId) };
54
49
  const ready = taskDispatchReady(job, observation);
@@ -1,4 +1,12 @@
1
1
  import type { SessionInfo, TaskDispatch } from '../../../../../packages/protocol/schema';
2
+ import { observeSessionExecution } from '../../session-catalog/observed-state';
3
+
4
+ /** A known native tail can release a queued turn before the next full discovery. */
5
+ export function dispatchSessionObservation(session: SessionInfo | undefined, generatedAt?: number) {
6
+ const fresh = session && observeSessionExecution(session);
7
+ return { session: fresh?.session ?? session, generatedAt: fresh ? Date.now() : generatedAt,
8
+ nativeState: fresh?.session.state };
9
+ }
2
10
 
3
11
  /** Manual release bypasses busy state only. Pause, native admission and policy still win. */
4
12
  export function taskDispatchReady(job: TaskDispatch, observation: {
@@ -1,3 +1,4 @@
1
+ import { observeSessionExecution } from "../session-catalog/observed-state";
1
2
  import { localTaskTransfers, transferHistory } from "../task-transfer";
2
3
  import type { ActivityEntry, SessionActivity, SessionInfo } from "../../../../packages/protocol/schema";
3
4
  import { appendCodexActivity, codexCapabilityUsage } from "../sessions/scan/codex/activity";
@@ -8,7 +9,6 @@ import { recordedFileChanges } from "./changes";
8
9
  import { recordedToolDetails } from "./tool-details";
9
10
  import { completedTurnChanges } from "./turn-changes";
10
11
  import { cursorActivity, cursorConversationHistory } from "../sessions/cursor";
11
- import { parseCodexFile } from '../sessions/scan/codex/parse';
12
12
  export { nativeImageLines } from "./images";
13
13
  export { nativeTranscriptImage } from './images/native';
14
14
  export { nativeTranscriptEntry } from './images/advertised-entry';
@@ -94,7 +94,7 @@ export function readTranscriptHistory(input: SessionInfo, cursor?: string): Sess
94
94
  : window.lines[0]?.offset ?? window.start;
95
95
  const prior = input.sessionId !== session.sessionId && offset === 0 ? transferHistory(input) : undefined;
96
96
  return { type: "session.activity", sessionId: input.sessionId, agent: session.agent,
97
- state: session.agent === 'codex' ? parseCodexFile(path)?.session.state ?? session.state : session.state,
97
+ state: cursor ? session.state : observeSessionExecution(input)?.session.state ?? session.state,
98
98
  entries, generatedAt: Date.now(), history: {
99
99
  hasMore: offset > 0 || Boolean(prior?.entries.length),
100
100
  ...(offset > 0 ? { cursor: window.cursorAt(offset) }
@@ -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.127
13
+ npm install -g granttap-mcp@0.8.129
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.127\";\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.129\";\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.127";
10
+ const PACKAGE = "granttap-mcp@0.8.129";
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.127",
3
+ "version": "0.8.129",
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": {