granttap-mcp 0.8.131 → 0.8.133
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/bin/hooks/claude-hook.ts +3 -3
- package/apps/bridge/src/policy/README.md +5 -3
- package/apps/bridge/src/policy/index.ts +4 -1
- package/apps/bridge/src/reply/index.ts +11 -19
- package/apps/bridge/src/session-catalog/README.md +4 -4
- package/apps/bridge/src/session-catalog/observed-state.ts +5 -18
- package/apps/bridge/src/task-dispatch/worker/index.ts +2 -2
- package/apps/bridge/src/task-dispatch/worker/monitor.ts +14 -11
- package/apps/bridge/src/task-dispatch/worker/readiness.ts +1 -1
- 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/apps/bridge/src/reply/native-completion.ts +0 -35
|
@@ -100,9 +100,9 @@ async function handlePreToolUse(input: HookInput): Promise<void> {
|
|
|
100
100
|
}
|
|
101
101
|
const legacyFlow = legacyGrantTapFlowAllowed(projectDecision);
|
|
102
102
|
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
if (
|
|
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).
|
|
@@ -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`
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
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.
|
|
@@ -15,7 +15,6 @@ import { abortProcesses, runProcess } from "./process";
|
|
|
15
15
|
import { routingPrompt } from "./payload/routing";
|
|
16
16
|
import type { DeliveryOptions, ReplyResult } from "./payload/types";
|
|
17
17
|
import { deliveryIntent } from './payload/identity';
|
|
18
|
-
import {NativeTurnCompletions, type NativeCompletionProof} from './native-completion';
|
|
19
18
|
import {
|
|
20
19
|
runCursorNew,
|
|
21
20
|
runCursorResume,
|
|
@@ -35,14 +34,16 @@ export function resolveAgentWorkspace(cwd: string | undefined, agent: CodingAgen
|
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
const inFlight = new Map<string, Promise<ReplyResult | null>>();
|
|
38
|
-
const physicalRuns = new Set<Promise<ReplyResult>>();
|
|
39
|
-
const nativeCompletions = new NativeTurnCompletions();
|
|
40
37
|
|
|
41
38
|
export function isDeliveryInFlight(sessionId: string): boolean { return inFlight.has(sessionId); }
|
|
42
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
|
+
|
|
43
45
|
/** Acknowledging a message does not finish the provider turn or permit a runtime handoff. */
|
|
44
|
-
export function hasPendingDeliveries(): boolean { return inFlight.size > 0
|
|
45
|
-
export const completeObservedNativeTurn = (key: string, proof: NativeCompletionProof) => nativeCompletions.complete(key, proof);
|
|
46
|
+
export function hasPendingDeliveries(): boolean { return inFlight.size > 0; }
|
|
46
47
|
|
|
47
48
|
/** Request a stop for owned processes; confirmation arrives only on process exit. */
|
|
48
49
|
export function stopDeliveries(sessionId: string): number {
|
|
@@ -113,7 +114,7 @@ export function createCodexSession(
|
|
|
113
114
|
effort?: string,
|
|
114
115
|
): Promise<ReplyResult> {
|
|
115
116
|
const workspace = resolveAgentWorkspace(cwd, "codex");
|
|
116
|
-
return queued("
|
|
117
|
+
return queued(newTaskDeliveryKey("codex", operationKey), () => withAttachments(attachments, text, (prepared) =>
|
|
117
118
|
runCodexNew(prepared.prompt, workspace, timeoutMs, prepared.images, model, operationKey, effort),
|
|
118
119
|
));
|
|
119
120
|
}
|
|
@@ -129,7 +130,7 @@ export function createClaudeSession(
|
|
|
129
130
|
effort?: string,
|
|
130
131
|
): Promise<ReplyResult> {
|
|
131
132
|
const workspace = resolveAgentWorkspace(cwd, "claude");
|
|
132
|
-
return queued("
|
|
133
|
+
return queued(newTaskDeliveryKey("claude", operationKey), () => withAttachments(attachments, text, (prepared) =>
|
|
133
134
|
runClaudeNew(prepared.claudePrompt, workspace, timeoutMs, model, operationKey, effort),
|
|
134
135
|
));
|
|
135
136
|
}
|
|
@@ -145,7 +146,7 @@ export function createCursorSession(
|
|
|
145
146
|
onNativeSession?: (sessionId: string) => void,
|
|
146
147
|
): Promise<ReplyResult> {
|
|
147
148
|
const workspace = resolveAgentWorkspace(cwd, "cursor");
|
|
148
|
-
return queued("
|
|
149
|
+
return queued(newTaskDeliveryKey("cursor", operationKey), () => withAttachments(attachments, text, (prepared) =>
|
|
149
150
|
runCursorNew(prepared.claudePrompt, workspace, timeoutMs, model, operationKey, effort, onNativeSession),
|
|
150
151
|
));
|
|
151
152
|
}
|
|
@@ -161,21 +162,14 @@ export function createGrokSession(
|
|
|
161
162
|
onNativeSession?: (sessionId: string) => void,
|
|
162
163
|
): Promise<ReplyResult> {
|
|
163
164
|
const workspace = resolveAgentWorkspace(cwd, "grok");
|
|
164
|
-
return queued("
|
|
165
|
+
return queued(newTaskDeliveryKey("grok", operationKey), () => withAttachments(attachments, text, (prepared) =>
|
|
165
166
|
runGrokNew(prepared.claudePrompt, workspace, timeoutMs, model, operationKey, effort, onNativeSession),
|
|
166
167
|
));
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
function queued(key: string, run: () => Promise<ReplyResult>): Promise<ReplyResult> {
|
|
170
171
|
const previous = inFlight.get(key) ?? Promise.resolve(null);
|
|
171
|
-
const next = previous.then(
|
|
172
|
-
const native = nativeCompletions.begin(key);
|
|
173
|
-
const physical = Promise.resolve().then(run);
|
|
174
|
-
physicalRuns.add(physical);
|
|
175
|
-
void physical.then(() => physicalRuns.delete(physical), () => physicalRuns.delete(physical));
|
|
176
|
-
try { return await Promise.race([physical, native.result]); }
|
|
177
|
-
finally { native.close(); }
|
|
178
|
-
});
|
|
172
|
+
const next = previous.then(run);
|
|
179
173
|
const settled = next.finally(() => {
|
|
180
174
|
if (inFlight.get(key) === tracked) inFlight.delete(key);
|
|
181
175
|
});
|
|
@@ -205,8 +199,6 @@ function runClaude(
|
|
|
205
199
|
timeoutMs: number,
|
|
206
200
|
options: DeliveryOptions,
|
|
207
201
|
): Promise<ReplyResult> {
|
|
208
|
-
nativeCompletions.bind(session.sessionId, text, key => localTaskTransfers()
|
|
209
|
-
.nativeSession({...session, sessionId: key}).sessionId);
|
|
210
202
|
const disabled = loadRuntimeConfig().sessionMcpDisabled[session.sessionId] ?? [];
|
|
211
203
|
const mcpArgs = disabled.length === 0
|
|
212
204
|
? []
|
|
@@ -45,7 +45,7 @@ an independently delivered completion. Runtime handoff also waits for owned
|
|
|
45
45
|
provider turns to settle, including work already acknowledged to the phone.
|
|
46
46
|
|
|
47
47
|
Fast open-chat heads use bounded native root pages. Closed chats and child
|
|
48
|
-
conversations remain on their independent refresh/request paths. A
|
|
49
|
-
|
|
50
|
-
work
|
|
51
|
-
|
|
48
|
+
conversations remain on their independent refresh/request paths. A model
|
|
49
|
+
end-turn record describes presentation; a CLI invocation may still own background
|
|
50
|
+
work. Queue admission and runtime handoff keep the physical-invocation guard
|
|
51
|
+
until that invocation returns its result.
|
|
@@ -11,12 +11,10 @@ import {observeCodexTurn,codexTurnState,type CodexTurnClock} from '../sessions/s
|
|
|
11
11
|
import {ts} from '../sessions/support/common';
|
|
12
12
|
import {grokResumeActivity} from '../providers/grok-activity';
|
|
13
13
|
import {cursorConversationSession} from '../sessions/cursor';
|
|
14
|
-
import {nativePromptDigest, type NativeCompletionProof} from '../reply/native-completion';
|
|
15
14
|
|
|
16
|
-
type NativeClock={revision:string;
|
|
17
|
-
promptAt:number;promptDigests:string[];completion?:NativeCompletionProof};
|
|
15
|
+
type NativeClock={revision:string;lastActivityAt:number;claude:ClaudeTurnClock;codex:CodexTurnClock};
|
|
18
16
|
const clocks=new Map<string,NativeClock>();
|
|
19
|
-
export type SessionObservation={session:SessionInfo;revision:string
|
|
17
|
+
export type SessionObservation={session:SessionInfo;revision:string};
|
|
20
18
|
|
|
21
19
|
/** Discovery may have started before an open chat finished its turn. Recheck before publication. */
|
|
22
20
|
export function refreshObservedCatalog(status: SessionsStatus): SessionsStatus {
|
|
@@ -49,22 +47,12 @@ export function observeSessionExecution(input:SessionInfo):SessionObservation|un
|
|
|
49
47
|
let clock=clocks.get(key);
|
|
50
48
|
if(clock?.revision!==revision){
|
|
51
49
|
const window=previousNativeLines(path,native.sessionId);if(!window)return;
|
|
52
|
-
|
|
53
|
-
const append = clock?.identity === identity && stat.size > clock.bytes;
|
|
54
|
-
clock={revision,identity,bytes:stat.size,lastActivityAt:0,claude:append?{...clock!.claude}:{},codex:{},
|
|
55
|
-
promptAt:append?clock!.promptAt:0,promptDigests:append?clock!.promptDigests:[],completion:append?clock!.completion:undefined};
|
|
50
|
+
clock={revision,lastActivityAt:0,claude:{},codex:{}};
|
|
56
51
|
for(const line of window.lines){
|
|
57
52
|
let row;try{row=JSON.parse(line.text)}catch{continue}
|
|
58
53
|
if(row.isSidechain===true||row.sessionId&&row.sessionId!==native.sessionId)continue;
|
|
59
54
|
clock.lastActivityAt=Math.max(clock.lastActivityAt,ts(row.timestamp));
|
|
60
|
-
if(native.agent==='claude')
|
|
61
|
-
observeClaudeTurn(row,clock.claude);
|
|
62
|
-
const content=row.message?.content;
|
|
63
|
-
const texts=typeof content==='string'?[content]:Array.isArray(content)?content.filter(b=>b?.type==='text'&&typeof b.text==='string').map(b=>b.text):[];
|
|
64
|
-
if(row.type==='user'&&texts.length){clock.promptAt=ts(row.timestamp);clock.promptDigests=[...texts,texts.join('\n')].map(nativePromptDigest)}
|
|
65
|
-
if(row.type==='assistant'&&clock.claude.turnEnded)clock.completion={nativeSessionId:native.sessionId,
|
|
66
|
-
promptAt:clock.promptAt,promptDigests:clock.promptDigests,completedAt:ts(row.timestamp),text:texts.join('\n')};
|
|
67
|
-
}else observeCodexTurn(row,clock.codex);
|
|
55
|
+
if(native.agent==='claude')observeClaudeTurn(row,clock.claude);else observeCodexTurn(row,clock.codex);
|
|
68
56
|
}
|
|
69
57
|
clocks.delete(key);clocks.set(key,clock);
|
|
70
58
|
while(clocks.size>256)clocks.delete(clocks.keys().next().value!);
|
|
@@ -72,7 +60,6 @@ export function observeSessionExecution(input:SessionInfo):SessionObservation|un
|
|
|
72
60
|
const at=Math.max(input.lastActivityAt,clock!.lastActivityAt);
|
|
73
61
|
const state=native.agent==='claude'?claudeTurnState(clock!.claude,at,input.state)
|
|
74
62
|
:clock!.codex.startedAt||clock!.codex.endedAt?codexTurnState(clock!.codex,at):input.state;
|
|
75
|
-
return {session:{...input,state,lastActivityAt:at},revision:`${revision}:${state}
|
|
76
|
-
...(native.agent==='claude'&&clock!.claude.turnEnded&&clock!.completion?{completion:clock!.completion}:{})};
|
|
63
|
+
return {session:{...input,state,lastActivityAt:at},revision:`${revision}:${state}`};
|
|
77
64
|
}catch{return;}
|
|
78
65
|
}
|
|
@@ -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(
|
|
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,12 +1,12 @@
|
|
|
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 {
|
|
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';
|
|
8
8
|
import { TaskDispatchInbox } from '../index';
|
|
9
|
-
import { TaskDispatchWorker } from './index';
|
|
9
|
+
import { TaskDispatchWorker, type TaskJobRemote, type WorkerOptions } from './index';
|
|
10
10
|
import { relayTaskJobRemote } from './remote';
|
|
11
11
|
import { NativeTaskQueueSender } from '../sender';
|
|
12
12
|
import { dispatchSessionObservation, queuedCatalogRefreshDue, taskDispatchReady } from './readiness';
|
|
@@ -16,6 +16,7 @@ import { localTaskOrigins, resolveTaskOriginJob } from '../../task-origins';
|
|
|
16
16
|
export function startTaskDispatchMonitor(input: {
|
|
17
17
|
config: PeerConfig; client: RelayClient; isLeader: () => boolean;
|
|
18
18
|
peerAllowed: (peer: string) => boolean; publish: () => Promise<void>;
|
|
19
|
+
remote?: TaskJobRemote; deliver?: WorkerOptions['deliver'];
|
|
19
20
|
}): () => void {
|
|
20
21
|
const inbox = new TaskDispatchInbox(join(configDir(), 'task-dispatch'), input.config.room);
|
|
21
22
|
const origins = localTaskOrigins();
|
|
@@ -24,11 +25,11 @@ export function startTaskDispatchMonitor(input: {
|
|
|
24
25
|
let stopped = false, reportedAt = 0, maintainedAt = 0, refreshedAt = 0;
|
|
25
26
|
const sender = new NativeTaskQueueSender({ root: join(configDir(), 'native-task-queue'), config: input.config });
|
|
26
27
|
const peerAllowed = (peer: string) => peer === input.config.myPublicKey || input.peerAllowed(peer);
|
|
27
|
-
const worker = new TaskDispatchWorker({ inbox, remote: relayTaskJobRemote(input.config),
|
|
28
|
+
const worker = new TaskDispatchWorker({ inbox, remote: input.remote ?? relayTaskJobRemote(input.config),
|
|
28
29
|
connected: () => !stopped && input.client.isConnected && input.isLeader(),
|
|
29
30
|
authorized: peerAllowed,
|
|
30
31
|
onTerminal: job => sender.confirmReceiverOutcome(job),
|
|
31
|
-
onError:
|
|
32
|
+
onError: error => reportFailure(error),
|
|
32
33
|
conversationKey: (job, peer) => resolve(job, peer).job?.sessionId
|
|
33
34
|
?? (job.operation.type === 'user.message.continue'
|
|
34
35
|
? JSON.stringify([peer, job.operation.originMessageId]) : `new:${job.operation.agent ?? 'codex'}`),
|
|
@@ -43,10 +44,9 @@ export function startTaskDispatchMonitor(input: {
|
|
|
43
44
|
const catalog = publishedCatalog(input.client);
|
|
44
45
|
const session = [...(catalog?.sessions ?? []), ...(catalog?.history ?? [])]
|
|
45
46
|
.find(item => item.sessionId === job.sessionId);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
inFlight: isDeliveryInFlight(job.sessionId ?? `__new_${job.operation.agent ?? 'codex'}_task__`),
|
|
47
|
+
const observation = { ...dispatchSessionObservation(session, catalog?.generatedAt),
|
|
48
|
+
inFlight: isDeliveryInFlight(job.sessionId ?? newTaskDeliveryKey(job.operation.agent ?? 'codex',
|
|
49
|
+
job.operation.type === 'project.task.create' ? job.operation.operationId : undefined)),
|
|
50
50
|
paused: !!job.sessionId && isSessionPaused(job.sessionId) };
|
|
51
51
|
const ready = taskDispatchReady(job, observation);
|
|
52
52
|
if (!ready && queuedCatalogRefreshDue(job, observation, refreshedAt)) {
|
|
@@ -56,6 +56,7 @@ export function startTaskDispatchMonitor(input: {
|
|
|
56
56
|
return ready;
|
|
57
57
|
},
|
|
58
58
|
deliver: async (original, beforeStart, peer) => {
|
|
59
|
+
if (input.deliver) return input.deliver(original, beforeStart, peer);
|
|
59
60
|
const job = resolve(original, peer).job;
|
|
60
61
|
if (!job || job.operation.type === 'user.message.continue') return 'rejected';
|
|
61
62
|
const outcome = job.operation.type === 'user.message'
|
|
@@ -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
|
-
|
|
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();
|
|
@@ -5,7 +5,7 @@ import { observeSessionExecution } from '../../session-catalog/observed-state';
|
|
|
5
5
|
export function dispatchSessionObservation(session: SessionInfo | undefined, generatedAt?: number) {
|
|
6
6
|
const fresh = session && observeSessionExecution(session);
|
|
7
7
|
return { session: fresh?.session ?? session, generatedAt: fresh ? Date.now() : generatedAt,
|
|
8
|
-
nativeState: fresh?.session.state
|
|
8
|
+
nativeState: fresh?.session.state };
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
/** Manual release bypasses busy state only. Pause, native admission and policy still win. */
|
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.133
|
|
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.133\";\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.133";
|
|
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,35 +0,0 @@
|
|
|
1
|
-
import {createHash} from 'node:crypto';
|
|
2
|
-
import type {ReplyResult} from './payload/types';
|
|
3
|
-
|
|
4
|
-
export const nativePromptDigest = (text: string) => createHash('sha256').update(text).digest('hex');
|
|
5
|
-
export type NativeCompletionProof = {nativeSessionId: string; promptAt: number; completedAt: number;
|
|
6
|
-
promptDigests: string[]; text: string};
|
|
7
|
-
type Run = {key: string; startedAt: number; nativeId?: string; digest?: string;
|
|
8
|
-
resolve: (result: ReplyResult) => void; result: Promise<ReplyResult>; completed: boolean};
|
|
9
|
-
|
|
10
|
-
/** Match this invocation's exact native prompt before releasing its confirmed final answer. */
|
|
11
|
-
export class NativeTurnCompletions {
|
|
12
|
-
private readonly runs = new Map<string, Run>();
|
|
13
|
-
constructor(private readonly now = Date.now) {}
|
|
14
|
-
begin(key: string) {
|
|
15
|
-
let resolve!: Run['resolve'];
|
|
16
|
-
const result = new Promise<ReplyResult>(done => {resolve = done});
|
|
17
|
-
const run: Run = {key, startedAt: this.now(), resolve, result, completed: false};
|
|
18
|
-
this.runs.set(key, run);
|
|
19
|
-
return {result, close: () => {if (this.runs.get(key) === run) this.runs.delete(key)}};
|
|
20
|
-
}
|
|
21
|
-
bind(nativeId: string, prompt: string, nativeForKey: (key: string) => string) {
|
|
22
|
-
const run = [...this.runs.values()].find(item => !item.nativeId && nativeForKey(item.key) === nativeId);
|
|
23
|
-
if (run) {run.nativeId = nativeId; run.digest = nativePromptDigest(prompt)}
|
|
24
|
-
}
|
|
25
|
-
complete(key: string, proof: NativeCompletionProof): boolean {
|
|
26
|
-
const run = this.runs.get(key);
|
|
27
|
-
if (!run || run.completed || run.nativeId !== proof.nativeSessionId || !run.digest
|
|
28
|
-
|| !proof.promptDigests.includes(run.digest) || proof.promptAt < run.startedAt
|
|
29
|
-
|| proof.completedAt < proof.promptAt || proof.completedAt > this.now() + 5_000
|
|
30
|
-
|| !proof.text.trim()) return false;
|
|
31
|
-
run.completed = true;
|
|
32
|
-
run.resolve({ok: true, text: proof.text, delivery: 'native'});
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|