granttap-mcp 0.8.125 → 0.8.126

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.
@@ -56,3 +56,15 @@ the client. Account identity is discarded. A missing, failed or oversized respon
56
56
  advertises no models. The shared cache refreshes successful metadata every ten
57
57
  minutes, failures after two, expires after fifteen, and never blocks catalog polling.
58
58
  Tests: [`tests/claude-models.test.ts`](tests/claude-models.test.ts).
59
+
60
+ Claude account invalidation uses an opaque digest of account, organization and
61
+ model-entitlement fields, rather than the modification time of `.claude.json`.
62
+ CLI initialization updates startup counters and profile refresh dates in that
63
+ file; those writes must not discard its own reply or repeatedly launch the CLI.
64
+ Credential and settings-file changes still invalidate their own scope. The
65
+ account reader is bounded to 4 MiB and 16 cached file signatures, retaining only
66
+ digests. Raw account fields and API keys never enter the model report or cache key.
67
+ Tests cover self-updating initialization, one metadata subprocess per unchanged
68
+ account, actual account changes, private fields, malformed data and retention.
69
+
70
+ Licensed under the GrantTap Commercial Source License. See LICENSE and NOTICE.
@@ -0,0 +1,33 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { readFileSync, statSync } from 'node:fs';
3
+
4
+ const fields = ['accountUuid', 'organizationUuid', 'billingType', 'seatTier',
5
+ 'organizationRole', 'workspaceRole', 'organizationType', 'organizationRateLimitTier',
6
+ 'userRateLimitTier', 'hasExtraUsageEnabled', 'claudeCodeTrialEndsAt'];
7
+ const cache = new Map<string, { revision: string; digest: string }>();
8
+
9
+ function revision(file: string): string {
10
+ const stat = statSync(file, { bigint: true });
11
+ if (!stat.isFile() || stat.size > 4n * 1024n * 1024n) throw Error('Native account metadata unavailable');
12
+ return [stat.dev, stat.ino, stat.size, stat.mtimeNs, stat.ctimeNs].join(':');
13
+ }
14
+
15
+ /** Startup counters and profile refresh dates do not change the model account. */
16
+ export function claudeAccountScope(file: string): string {
17
+ try {
18
+ const before = revision(file), cached = cache.get(file);
19
+ if (cached?.revision === before) return cached.digest;
20
+ const value = JSON.parse(readFileSync(file, 'utf8'));
21
+ const account = value?.oauthAccount;
22
+ const scope = [fields.map(field => account?.[field]),
23
+ typeof value?.primaryApiKey === 'string' ? value.primaryApiKey : undefined];
24
+ // Keep only an opaque digest. No account fields, API keys or config text are retained.
25
+ const digest = createHash('sha256').update(JSON.stringify(scope)).digest('hex');
26
+ cache.delete(file);
27
+ if (revision(file) === before) {
28
+ if (cache.size >= 16) cache.delete(cache.keys().next().value!);
29
+ cache.set(file, { revision: before, digest });
30
+ }
31
+ return digest;
32
+ } catch { cache.delete(file); return 'unavailable'; }
33
+ }
@@ -5,6 +5,7 @@ import { statSync } from 'node:fs';
5
5
  import { join } from 'node:path';
6
6
  import type { AdvertisedModel } from '../../../../packages/protocol/schema';
7
7
  import { resolveClaudeBinary } from '../providers/claude-bin';
8
+ import { claudeAccountScope } from './claude-account-scope';
8
9
 
9
10
  const ID = /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,159}$/;
10
11
  const EFFORTS = new Set(['low', 'medium', 'high', 'xhigh', 'max']);
@@ -74,7 +75,8 @@ export function cachedClaudeModels(endpointId: string, env = process.env): Adver
74
75
  const config = env.GRANTTAP_CLAUDE_DIR ?? env.NODVOX_CLAUDE_DIR ?? env.CLAUDE_CONFIG_DIR;
75
76
  const root = config ?? join(homedir(), '.claude');
76
77
  const key = [endpointId, binary.path, binary.version, root,
77
- modified(join(root, '.credentials.json')), modified(config ? join(root, '.claude.json') : join(homedir(), '.claude.json'))].join('\u001f');
78
+ modified(join(root, '.credentials.json')), claudeAccountScope(config ? join(root, '.claude.json') : join(homedir(), '.claude.json')),
79
+ modified(join(root, 'settings.json')), modified(join(root, 'settings.local.json'))].join('\u001f');
78
80
  if (key !== scope) { scope = key; report = []; checkedAt = 0; }
79
81
  if (binary && !pending && Date.now() - checkedAt > (report.length ? 10 : 2) * 60_000) {
80
82
  checkedAt = Date.now();
@@ -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.125
13
+ npm install -g granttap-mcp@0.8.126
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.125\";\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.126\";\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.125";
10
+ const PACKAGE = "granttap-mcp@0.8.126";
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.125",
3
+ "version": "0.8.126",
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": {