granttap-mcp 0.8.182 → 0.8.184

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.
@@ -55,9 +55,11 @@ picture's content, never a path, and only the chat that started the run is
55
55
  answered.
56
56
 
57
57
  **Meshes.** A run is not passed to the Mesh, and a generator's folder never
58
- registers one. A Mesh without a remote whose folder is a generator's, or is
59
- gone from inside a Git checkout or the temp directory, was registered for a
60
- run before the run was recognised: it stays in the Mesh store and is left out
58
+ registers one. A Mesh without a remote whose folder is a generator's, is
59
+ gone from the temp directory, or lies inside a Git checkout without being a
60
+ checkout of its own (there or gone), was registered for a run before the run
61
+ was recognised: a chat working in a folder of a checkout belongs to the
62
+ checkout's Mesh: it stays in the Mesh store and is left out
61
63
  of every list of this computer's Projects. A workspace of its own is kept
62
64
  whether its folder is there or not.
63
65
 
@@ -99,7 +99,7 @@ export function helperRunLabel(kind: string): string {
99
99
  */
100
100
  export function helperRunProject(
101
101
  project: { repositoryRoot?: string; canonicalRepositoryId: string },
102
- vanished: (folder: string | undefined) => boolean = vanishedRunFolder,
102
+ vanished: (folder: string | undefined) => boolean = leftoverRunFolder,
103
103
  ): boolean {
104
104
  const identity = project.canonicalRepositoryId;
105
105
  if (!identity.startsWith("local:")) return false;
@@ -124,31 +124,53 @@ function parentOf(folder: string): string | undefined {
124
124
  return parent === folder || /^[A-Za-z]:$/.test(parent) ? undefined : parent;
125
125
  }
126
126
 
127
- /**
128
- * A folder that was made for one run and removed after it: it is gone, and it lay directly inside a
129
- * temp directory or anywhere inside a Git checkout. Had it been a workspace of its own it would have
130
- * been that checkout's. The answer is kept for a minute; a Mesh list asks about every Project.
131
- */
132
- export function vanishedRunFolder(path: string | undefined, now = Date.now()): boolean {
127
+ /** Whether a folder lies inside a Git checkout: one of the folders above it holds `.git`. */
128
+ function insideCheckout(folder: string): boolean {
129
+ let above = parentOf(folder);
130
+ for (let depth = 0; above !== undefined && depth < 48; depth += 1) {
131
+ if (existsSync(`${above === "/" ? "" : above}/.git`)) return true;
132
+ above = parentOf(above);
133
+ }
134
+ return false;
135
+ }
136
+
137
+ /** One answer per folder and question for a minute; a Mesh list asks about every Project. */
138
+ function remembered(kind: string, path: string | undefined, now: number, look: (folder: string) => boolean): boolean {
133
139
  if (!path) return false;
134
140
  const folder = plainFolder(path);
135
141
  if (!absolute(folder)) return false;
136
- const known = vanishedChecks.get(folder);
142
+ const key = `${kind}\0${folder}`;
143
+ const known = vanishedChecks.get(key);
137
144
  if (known && now - known.at < CHECK_AGAIN_MS && now >= known.at) return known.vanished;
138
- let vanished = false;
139
- try {
140
- if (!existsSync(folder)) {
141
- let above = parentOf(folder);
142
- vanished = above !== undefined && isTempRoot(above);
143
- for (let depth = 0; !vanished && above !== undefined && depth < 48; depth += 1) {
144
- vanished = existsSync(`${above === "/" ? "" : above}/.git`);
145
- above = parentOf(above);
146
- }
147
- }
148
- } catch { /* A folder that cannot be looked at is not called gone. */ }
145
+ let answer = false;
146
+ try { answer = look(folder); } catch { /* A folder that cannot be looked at is not called a run's. */ }
149
147
  if (vanishedChecks.size >= MAX_REMEMBERED) vanishedChecks.clear();
150
- vanishedChecks.set(folder, { at: now, vanished });
151
- return vanished;
148
+ vanishedChecks.set(key, { at: now, vanished: answer });
149
+ return answer;
150
+ }
151
+
152
+ /**
153
+ * A folder that was made for one run and removed after it: it is gone, and it lay directly inside a
154
+ * temp directory or anywhere inside a Git checkout. Had it been a workspace of its own it would have
155
+ * been that checkout's.
156
+ */
157
+ export function vanishedRunFolder(path: string | undefined, now = Date.now()): boolean {
158
+ return remembered("vanished", path, now, (folder) => {
159
+ if (existsSync(folder)) return false;
160
+ const above = parentOf(folder);
161
+ return (above !== undefined && isTempRoot(above)) || insideCheckout(folder);
162
+ });
163
+ }
164
+
165
+ /**
166
+ * The folder of a Mesh without Git that can only have been registered for a run: one gone as
167
+ * `vanishedRunFolder` says, or one inside a Git checkout that is not a checkout of its own, there or
168
+ * not. A chat working in such a folder belongs to the checkout's Mesh, so a Mesh of its own was
169
+ * registered while the folder could not be read as part of the checkout.
170
+ */
171
+ export function leftoverRunFolder(path: string | undefined, now = Date.now()): boolean {
172
+ return vanishedRunFolder(path, now) || remembered("inside", path, now, (folder) =>
173
+ existsSync(folder) && !existsSync(`${folder}/.git`) && insideCheckout(folder));
152
174
  }
153
175
 
154
176
  /** For tests: look at every folder again. */
@@ -70,7 +70,10 @@ async function withdraw(state: LimitContinuationState, byId: Map<string, Session
70
70
  let changed = false;
71
71
  for (const [sessionId, job] of Object.entries(state.scheduled)) {
72
72
  const session = byId.get(sessionId);
73
- const current = session?.usageLimit?.resetsAt === job.resetsAt && wanted(session, off, now);
73
+ // The relay delivers only to an idle chat, so a chat busy for a moment (an early attempt the limit
74
+ // refused again, a message of the person's) keeps its continuation. It is withdrawn only when the chat
75
+ // is no longer held by that limit or the person turned it off.
76
+ const current = session?.usageLimit?.resetsAt === job.resetsAt && !off.has(sessionId);
74
77
  const missing = !session && job.resetsAt > now - 7 * 86_400_000 && !off.has(sessionId);
75
78
  // A job queued before its time was recorded counts from now, so no older reading speaks for it.
76
79
  if (current && job.scheduledAt === undefined) { job.scheduledAt = now; changed = true; }
@@ -173,7 +173,9 @@ async function publishMonitorTick(input: {
173
173
  if (includeHistory || initial) lastHistoryPublishedAt = Date.now();
174
174
  loadLoop.updateStatus(status);
175
175
  void refreshMcpLoad(status.sessions).catch(() => {});
176
- void scheduleLimitContinuations(status.sessions, undefined, Date.now(), cachedNativeAccountUsage).catch(() => {});
176
+ // A weekly limit resets long after its chat has left the live list, so history is looked at too.
177
+ void scheduleLimitContinuations([...status.sessions, ...(status.history ?? [])], undefined, Date.now(),
178
+ cachedNativeAccountUsage).catch(() => {});
177
179
  publishCatalogHeads(client, status, subscriptions, publishSessionEvents);
178
180
  if (loadRuntimeConfig().meshEnabled) publishMonitorMeshes(client, status);
179
181
  publishMonitorCapabilities(client, status, () => history(false));
@@ -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.182
13
+ npm install -g granttap-mcp@0.8.184
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.182\";\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.184\";\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.182";
10
+ const PACKAGE = "granttap-mcp@0.8.184";
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.182",
3
+ "version": "0.8.184",
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": {