granttap-mcp 0.8.123 → 0.8.124

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.
@@ -20,3 +20,8 @@ nested conversations through the public catalog and activity readers.
20
20
 
21
21
  Tests live in [`tests/`](tests/). The selected-Page regression covers the public
22
22
  catalog, cached rescans, live activity, and paginated transcript history.
23
+
24
+ Missing rollout lookups use the bounded [rollout identity index](rollout-identity/README.md).
25
+ They do not read unrelated large activity tails. Unchanged file identities are
26
+ reused; file changes invalidate them, and the selected chat keeps its existing
27
+ activity window. `tests/rollout-lookup-cost.test.ts` measures the actual read budget.
@@ -0,0 +1,16 @@
1
+ # Codex rollout identity lookup
2
+
3
+ Public entry: `index.ts`. Missing native-path lookups inspect the existing bounded
4
+ summary window, not every candidate's 16 MiB activity tail. Only the matching
5
+ rollout is opened with the activity budget. Fork ownership keeps the existing
6
+ `ownCodexLines` boundary. The cache retains at most 256 path/identity signatures,
7
+ never conversation text. Device, inode, size, modification and change times
8
+ invalidate it; a file changed during the metadata read is retried on the next
9
+ lookup. Read failures and deleted paths do not retain an identity.
10
+
11
+ Local tests cover unchanged observations, replacement with preserved timestamps,
12
+ concurrent changes, retry and bounded retention. The Codex public-reader cost
13
+ regression measures bytes actually read from a large foreign rollout, followed
14
+ by a successful full read of that rollout when it is explicitly requested.
15
+
16
+ Licensed under the GrantTap Commercial Source License. See LICENSE and NOTICE.
@@ -0,0 +1,36 @@
1
+ import { statSync } from 'node:fs';
2
+ import { safeParse } from '../../../support/common';
3
+
4
+ type Identity = { signature: string; sessionId: string };
5
+
6
+ function signature(file: string): string {
7
+ const stat = statSync(file, { bigint: true });
8
+ if (!stat.isFile()) throw Error('A rollout must be a regular file');
9
+ return [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(':');
10
+ }
11
+
12
+ /** Index bounded metadata, never another conversation's large activity window. */
13
+ export function createCodexRolloutIdentityLookup(readMetadata: (file: string) => string[]) {
14
+ const cache = new Map<string, Identity>();
15
+ return (sessionId: string, files: string[]): string | undefined => {
16
+ for (const file of files) {
17
+ try {
18
+ const before = signature(file);
19
+ let identity = cache.get(file);
20
+ if (!identity || identity.signature !== before) {
21
+ const line = readMetadata(file).find(row => safeParse(row)?.type === 'session_meta');
22
+ const meta = line ? safeParse(line) : undefined;
23
+ if (signature(file) !== before) { cache.delete(file); continue; }
24
+ identity = { signature: before, sessionId: String(meta?.payload?.id ?? meta?.id ?? '') };
25
+ cache.delete(file);
26
+ if (cache.size >= 256) cache.delete(cache.keys().next().value!);
27
+ cache.set(file, identity);
28
+ }
29
+ if (identity.sessionId && identity.sessionId === sessionId) return file;
30
+ } catch {
31
+ cache.delete(file);
32
+ }
33
+ }
34
+ return undefined;
35
+ };
36
+ }
@@ -3,6 +3,7 @@ import { diffPreviewFromInput, sensitivePath, statsFromInput } from "../../suppo
3
3
  import { redactSecrets } from "../../telemetry/command-preview";
4
4
  import { recordObservedWrite, writtenPaths } from "../../../mesh/observed/writes";
5
5
  import { ownCodexLines } from './lineage';
6
+ import { createCodexRolloutIdentityLookup } from './rollout-identity';
6
7
  /**
7
8
  * Codex session logs:
8
9
  * ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl
@@ -198,22 +199,15 @@ export function codexLogLines(sessionId: string): string[] | undefined {
198
199
  codexLogPathBySession.delete(sessionId);
199
200
  }
200
201
  }
201
- for (const file of recentLogs(codexSessionsRoot(), 5)) {
202
+ const file = findCodexRolloutIdentity(sessionId, recentLogs(codexSessionsRoot(), 5));
203
+ if (file) {
202
204
  try {
203
- const candidate = readCodexLogWindow(
204
- file, CODEX_ACTIVITY_HEAD_BYTES, CODEX_ACTIVITY_TAIL_BYTES,
205
- );
206
- if (candidate.some((line) => {
207
- const row = safeParse(line);
208
- return row?.type === "session_meta" &&
209
- String(row.payload?.id ?? row.id ?? "") === sessionId;
210
- })) {
211
- codexLogPathBySession.set(sessionId, file);
212
- return candidate;
213
- }
214
- } catch {
215
- // Keep looking through the bounded recent-file set.
216
- }
205
+ const lines = readCodexLogWindow(file, CODEX_ACTIVITY_HEAD_BYTES, CODEX_ACTIVITY_TAIL_BYTES);
206
+ codexLogPathBySession.set(sessionId, file);
207
+ return lines;
208
+ } catch { /* The matching rollout may have disappeared. */ }
217
209
  }
218
210
  return undefined;
219
211
  }
212
+
213
+ const findCodexRolloutIdentity = createCodexRolloutIdentityLookup(file => readCodexLogWindow(file));
@@ -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.123
13
+ npm install -g granttap-mcp@0.8.124
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.123\";\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.124\";\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.123";
10
+ const PACKAGE = "granttap-mcp@0.8.124";
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.123",
3
+ "version": "0.8.124",
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": {