granttap-mcp 0.8.155 → 0.8.157

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.
@@ -41,6 +41,9 @@ owner, without a competing `exec resume` writer. The `codex-desktop` feature own
41
41
  that versioned local connection and durable admission receipt. Headless resume is
42
42
  used only when no native owner exists. Native admission carries the controller's
43
43
  message ID and returns promptly; the provider transcript supplies the answer.
44
+ Local image and document files remain available for one day after native
45
+ admission, because accepting a queued turn does not mean its files were read.
46
+ The regular attachment sweep removes expired stages without following symlinks.
44
47
 
45
48
  New and resumed headless Codex tasks both accept workspaces outside Git. The
46
49
  repository presence check is skipped consistently; configured sandbox, approval,
@@ -27,7 +27,7 @@ export async function withAttachments(
27
27
  claudePrompt: `${text || "Please inspect the attached content."}${claudeNote}`,
28
28
  images: files.filter((file) => file.image).map((file) => file.path),
29
29
  });
30
- retained = result.delivery === 'native' && documents.length > 0;
30
+ retained = result.delivery === 'native' && files.length > 0;
31
31
  return result;
32
32
  } catch (error) {
33
33
  return { ok: false, error: `Could not prepare attachment: ${(error as Error).message}` };
@@ -36,7 +36,7 @@ export async function withAttachments(
36
36
  }
37
37
  }
38
38
 
39
- /** Native admission returns before the agent reads documents. Retain those for one day. */
39
+ /** Native admission queues a turn before it reads local files. Retain images and documents for one day. */
40
40
  export function prunePreparedAttachments(now = Date.now()): number {
41
41
  const root = join(configDir(), 'message-attachments');
42
42
  if (!existsSync(root)) return 0;
@@ -20,6 +20,11 @@ walking up for `.git` without running Git; the current folder decides only
20
20
  until such a change is known. Catalog linking verifies the chosen Git root while
21
21
  preserving the existing Task and Project identities.
22
22
 
23
+ Codex host question-reply envelopes remain intact in conversation history but
24
+ cannot name a Task. A native title containing that transport JSON, including a
25
+ clipped older title, yields to the person's request from the bounded log head.
26
+ Ordinary JSON requests and quoted markup remain eligible human titles.
27
+
23
28
  A pasted Claude image appears as an attachment. The label Claude Code writes
24
29
  beside it (`[Image: source: …]`, `[Image #1]`) is dropped from the chat, title
25
30
  and child title when that block holds only labels and the message carries the
@@ -0,0 +1,8 @@
1
+ # Native Task titles
2
+
3
+ `index.ts` selects human Codex Task names without changing transcript payloads.
4
+ Host question-reply envelopes and their clipped JSON metadata yield to the
5
+ original request. Ordinary JSON requests and quoted examples stay eligible.
6
+ Scanner behavior and retained history are covered in `tests/`.
7
+
8
+ Licensed under the GrantTap Commercial Source License. See LICENSE and NOTICE.
@@ -0,0 +1,15 @@
1
+ import { visibleUserText } from '../support/activity-helpers';
2
+ import { childTitle } from '../support/child-threads';
3
+
4
+ /** A host answer envelope, including a previously clipped native title, is not a Task name. */
5
+ export function isCodexQuestionReply(text: string): boolean {
6
+ const value = text.trimStart();
7
+ return value.startsWith('<send_user_message_question_reply>')
8
+ || /^\[\s*\{\s*"questionItemId"\s*:/.test(value);
9
+ }
10
+
11
+ /** Keep transport payloads intact in history; only title selection rejects them. */
12
+ export function codexRequestTitle(value: unknown): string | undefined {
13
+ const text = visibleUserText(value);
14
+ return isCodexQuestionReply(text) ? undefined : childTitle(text);
15
+ }
@@ -18,6 +18,7 @@ import { visibleUserText } from "../../support/activity-helpers";
18
18
  import { codexHeadRequest, isProvisionalPageTitle } from "../../support/codex-head";
19
19
  import { heartbeatDisplayText } from '../../host-heartbeat';
20
20
  import { codexContextReport } from "../../context-usage";
21
+ import { codexRequestTitle } from '../../native-task-titles';
21
22
 
22
23
  type CodexParseState = {
23
24
  sessionId: string;
@@ -43,7 +44,7 @@ type CodexParseState = {
43
44
  };
44
45
 
45
46
  function adoptRequestTitle(state: CodexParseState, text: string | undefined): void {
46
- const title = childTitle(text);
47
+ const title = codexRequestTitle(text);
47
48
  if (!title) return;
48
49
  if (isProvisionalPageTitle(title)) state.provisionalTitle ??= title;
49
50
  else state.title = title;
@@ -75,7 +76,7 @@ function applyCodexLine(d: any, state: CodexParseState): void {
75
76
  if (p?.model) state.model = String(p.model);
76
77
  if (p?.git?.branch) state.branch = String(p.git.branch);
77
78
  if (typeof p?.title === "string") {
78
- const title = visibleUserText(p.title);
79
+ const title = codexRequestTitle(p.title);
79
80
  if (title && !isProvisionalPageTitle(title)) state.title = title.slice(0, 120);
80
81
  }
81
82
  state.child = codexChildSource(p);
@@ -1,6 +1,7 @@
1
1
  import { closeSync, openSync, readSync } from "node:fs";
2
2
  import { visibleUserText } from "./activity-helpers";
3
3
  import { ts } from "./common";
4
+ import { isCodexQuestionReply } from '../native-task-titles';
4
5
 
5
6
  const TITLE_HEAD_BYTES = 256 * 1024;
6
7
 
@@ -69,6 +70,7 @@ export function codexHeadRequest(path: string, preferHumanTitle = false): CodexH
69
70
  for (const line of source.split("\n")) {
70
71
  const text = visibleText(line);
71
72
  if (!text) continue;
73
+ if (preferHumanTitle && isCodexQuestionReply(text)) continue;
72
74
  const request = { text, createdAt: ts(jsonStringAfter(line, "timestamp")) };
73
75
  if (preferHumanTitle && isProvisionalPageTitle(text)) { provisional ??= request; continue; }
74
76
  return request;
@@ -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.155
13
+ npm install -g granttap-mcp@0.8.157
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.155\";\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.157\";\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.155";
10
+ const PACKAGE = "granttap-mcp@0.8.157";
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.155",
3
+ "version": "0.8.157",
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,8 @@
83
83
  "access": "public"
84
84
  },
85
85
  "overrides": {
86
- "@hono/node-server": "2.1.3"
86
+ "@hono/node-server": "2.1.3",
87
+ "glob": "14.0.4",
88
+ "minimatch": "11.0.5"
87
89
  }
88
90
  }
@@ -12,6 +12,13 @@ Disconnect rejects the current write as well as queued frames. Catalog and
12
12
  history publishers can retry on the next connection even if the previous
13
13
  socket never calls its write-completion callback.
14
14
 
15
+ Supporting relays negotiate an ingress window and cumulative read receipts.
16
+ At most 64 frames then wait for relay reads, in addition to the existing pace.
17
+ Short TCP buffering or a slow relay cannot release several seconds of ordinary
18
+ traffic as one excessive burst. Controls retain queue priority and reconnecting
19
+ creates a new counter generation. Managed admission renewals use their separate
20
+ control lane. A read receipt proves no persistence, decryption or task delivery.
21
+
15
22
  Tests live in `tests/`; they include an actual WebSocket server with the relay's
16
23
  rate limit. A socket write is transport evidence, never an approval receipt.
17
24
 
@@ -17,9 +17,30 @@ export class OutboundFrameQueue {
17
17
  private closed = false;
18
18
  private timer?: NodeJS.Timeout;
19
19
  private nextAt = 0;
20
+ private ingressWindow?: number;
21
+ private sentFrames = 0;
22
+ private receivedFrames = 0;
20
23
 
21
24
  constructor(private readonly write: (frame: string) => Promise<void>, private readonly intervalMs = 6) {}
22
25
 
26
+ /** Read receipts bound TCP bursts; they never acknowledge application delivery. */
27
+ enableIngressWindow(window: number | undefined): void {
28
+ if (!Number.isSafeInteger(window) || window! < 16) return;
29
+ this.ingressWindow = Math.min(window!, 64);
30
+ this.schedule();
31
+ }
32
+
33
+ acknowledgeIngress(received: number): void {
34
+ if (this.ingressWindow === undefined || !Number.isSafeInteger(received)
35
+ || received <= this.receivedFrames || received > this.sentFrames) return;
36
+ this.receivedFrames = received;
37
+ this.schedule();
38
+ }
39
+
40
+ private get hasIngressCredit(): boolean {
41
+ return this.ingressWindow === undefined || this.sentFrames - this.receivedFrames < this.ingressWindow;
42
+ }
43
+
23
44
  send(frame: string, urgent = false): Promise<void> {
24
45
  if (this.closed) return Promise.reject(CLOSED());
25
46
  const bytes = Buffer.byteLength(frame);
@@ -45,18 +66,20 @@ export class OutboundFrameQueue {
45
66
  }
46
67
 
47
68
  private schedule(): void {
48
- if (this.closed || this.running || this.timer || (!this.controls.length && !this.snapshots.length)) return;
69
+ if (this.closed || this.running || this.timer || !this.hasIngressCredit
70
+ || (!this.controls.length && !this.snapshots.length)) return;
49
71
  this.timer = setTimeout(() => { this.timer = undefined; void this.pump(); },
50
72
  Math.max(0, this.nextAt - performance.now()));
51
73
  }
52
74
 
53
75
  private async pump(): Promise<void> {
54
- if (this.closed) return;
76
+ if (this.closed || !this.hasIngressCredit) return;
55
77
  const job = this.controls.shift() ?? this.snapshots.shift();
56
78
  if (!job) return;
57
79
  this.running = true;
58
80
  this.inFlight = job;
59
81
  this.bytes -= job.bytes;
82
+ this.sentFrames += 1;
60
83
  try {
61
84
  await this.write(job.frame);
62
85
  if (this.closed) throw CLOSED();
@@ -144,10 +144,16 @@ export class RelayClient {
144
144
  }
145
145
 
146
146
  private async onRaw(raw: string): Promise<void> {
147
- const control = parseRelayControl(raw) as { type?: string; recipientRouting?: boolean; retainedState?: boolean; retainedStateGroups?: boolean } | null;
147
+ const control = parseRelayControl(raw) as { type?: string; recipientRouting?: boolean; retainedState?: boolean;
148
+ retainedStateGroups?: boolean; ingressWindow?: number; received?: number } | null;
148
149
  if (control?.type === "relay.capabilities" && control.recipientRouting === true) {
149
150
  this.recipientRouting = true;
150
151
  this.retainedState = control.retainedState === true && control.retainedStateGroups === true;
152
+ this.frames?.enableIngressWindow(control.ingressWindow);
153
+ return;
154
+ }
155
+ if (control?.type === 'relay.ingress') {
156
+ if (typeof control.received === 'number') this.frames?.acknowledgeIngress(control.received);
151
157
  return;
152
158
  }
153
159
  if (control?.type === "relay.task-job") {
@@ -3,7 +3,7 @@ import { publicKeyIdentifier } from '../ciphertext-recipient';
3
3
 
4
4
  /** Bind optional mailbox routing to this endpoint's real encryption identity. */
5
5
  export function relayUpgradeHeaders(cfg: PeerConfig, admission: Record<string, string>, durableReceiver: boolean) {
6
- return { ...admission, 'X-GrantTap-Recipient-Routing': '1',
6
+ return { ...admission, 'X-GrantTap-Recipient-Routing': '1', 'X-GrantTap-Ingress-Flow': '1',
7
7
  'X-GrantTap-Recipient-Key-Id': publicKeyIdentifier(cfg.myPublicKey),
8
8
  ...(durableReceiver ? { 'X-GrantTap-Task-Dispatch': '1' } : {}),
9
9
  ...(cfg.pushAuth ? { Authorization: `Bearer ${cfg.pushAuth}` } : {}) };