granttap-mcp 0.8.160 → 0.8.162

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.
@@ -4,6 +4,7 @@ import type { CodingAgent, ProviderLoginProgress } from '../../../../packages/pr
4
4
  import { signalOwnedProcess } from '../reply/process';
5
5
  import { stripAnsi } from '../tools/version';
6
6
  import { allowedLoginURL, installedProvider, loginArguments, providerCommand, providerEnvironment } from './provider-command';
7
+ import { providerSignIns } from '../reply/process/auth-failure';
7
8
 
8
9
  type Flow = { scope: string; child: ChildProcess; progress: ProviderLoginProgress; output: string;
9
10
  timer: NodeJS.Timeout; emit: (value: ProviderLoginProgress) => void };
@@ -98,6 +99,7 @@ export class ProviderLogins {
98
99
  const flow = this.flows.get(id);
99
100
  if (!flow || terminal.has(flow.progress.phase)) return;
100
101
  clearTimeout(flow.timer);
102
+ if (phase === 'signed-in') providerSignIns.accepted(flow.progress.agent);
101
103
  if (phase !== 'signed-in') {
102
104
  signalOwnedProcess(flow.child, 'SIGTERM');
103
105
  const kill = setTimeout(() => {
@@ -7,6 +7,7 @@ import { executableOnPath, resolveClaudeBinary } from '../providers/claude-bin';
7
7
  import { resolveCodexBinary } from '../providers/codex-bin';
8
8
  import { resolveGrokBinary } from '../providers/grok-bin';
9
9
  import { resolveCursorAgentBin } from '../reply/process/cursor-agent-bin';
10
+ import { providerSignIns } from '../reply/process/auth-failure';
10
11
 
11
12
  export function providerCommand(agent: CodingAgent): string {
12
13
  switch (agent) {
@@ -52,6 +53,11 @@ type Authentication = 'signed-in' | 'signed-out' | 'unknown' | 'not-installed';
52
53
 
53
54
  /** Presence is reported separately from a successful agent turn; credentials never leave their native store. */
54
55
  export async function providerAuthentication(agent: CodingAgent, command = providerCommand(agent)): Promise<Authentication> {
56
+ const reported = await reportedAuthentication(agent, command);
57
+ return reported === 'signed-in' && providerSignIns.wasRefused(agent) ? 'signed-out' : reported;
58
+ }
59
+
60
+ async function reportedAuthentication(agent: CodingAgent, command: string): Promise<Authentication> {
55
61
  if (!installedProvider(command)) return 'not-installed';
56
62
  if (agent === 'grok') {
57
63
  try {
@@ -1,15 +1,51 @@
1
1
  import { basename } from 'node:path';
2
+ import type { CodingAgent } from '../../../../../packages/protocol/schema';
2
3
 
3
- /** A native sign-in prompt before admission is actionable, not a minute-long delivery timeout. */
4
- export function providerSignInFailure(command: string, stderr: string): string | undefined {
5
- const text = stderr.replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, '');
6
- if (!/(?:^|\n)\s*(?:not (?:logged|signed) in\b|(?:error:\s*)?authentication required\b|(?:please\s+)?(?:sign|log) in (?:first|to (?:continue|use))\b|to sign in, open this url)/i.test(text)) return;
4
+ /**
5
+ * Provider phrases that mean its own login is missing or can no longer be used.
6
+ * Claude Code reports an expired login as `Failed to authenticate: … Run
7
+ * \`claude auth login\`` in its stream-json result while `claude auth status`
8
+ * still says logged in, so the run itself is the evidence.
9
+ */
10
+ const SIGN_IN_REQUIRED = new RegExp([
11
+ String.raw`(?:^|\n)\s*(?:not (?:logged|signed) in\b|(?:error:\s*)?authentication required\b|(?:please\s+)?(?:sign|log) in (?:first|to (?:continue|use))\b|to sign in, open this url|failed to authenticate\b|oauth token has expired\b)`,
12
+ String.raw`\brun\s+[\x60'"]?claude\s+(?:auth\s+)?login\b`,
13
+ String.raw`\bplease run /login\b`,
14
+ String.raw`"type"\s*:\s*"authentication_error"`,
15
+ ].join('|'), 'i');
16
+
17
+ export function providerAgent(command: string): CodingAgent | undefined {
7
18
  const executable = basename(command).toLowerCase();
8
- const provider = executable.includes('grok') ? 'Grok' : executable.includes('claude') ? 'Claude Code'
9
- : executable.includes('codex') ? 'Codex' : executable.includes('cursor') ? 'Cursor' : 'the coding agent';
19
+ return executable.includes('grok') ? 'grok' : executable.includes('claude') ? 'claude'
20
+ : executable.includes('codex') ? 'codex' : executable.includes('cursor') ? 'cursor' : undefined;
21
+ }
22
+
23
+ const PROVIDER_NAMES: Record<CodingAgent, string> = { claude: 'Claude Code', codex: 'Codex', grok: 'Grok', cursor: 'Cursor' };
24
+
25
+ /** A native sign-in prompt before admission is actionable, not a minute-long delivery timeout. */
26
+ export function providerSignInFailure(command: string, ...outputs: string[]): string | undefined {
27
+ const text = outputs.join('\n').replace(/\u001b\[[0-9;?]*[ -/]*[@-~]/g, '');
28
+ if (!SIGN_IN_REQUIRED.test(text)) return;
29
+ const agent = providerAgent(command);
30
+ const provider = agent ? PROVIDER_NAMES[agent] : 'the coding agent';
10
31
  return `Sign-in required for ${provider}. Open Devices, choose this computer, then Sign in for ${provider}. This message has not been submitted to the agent.`;
11
32
  }
12
33
 
34
+ export function isSignInFailure(error: string): boolean { return error.startsWith('Sign-in required for '); }
35
+
36
+ /**
37
+ * `claude auth status` keeps reporting a login whose token can no longer be
38
+ * renewed, so Devices said "Signed in" while every phone message was refused.
39
+ * A run refused for sign-in outranks that status until the provider signs in
40
+ * again or completes a run.
41
+ */
42
+ const refusedSignIns = new Set<CodingAgent>();
43
+ export const providerSignIns = {
44
+ refused(agent: CodingAgent | undefined): void { if (agent) refusedSignIns.add(agent); },
45
+ accepted(agent: CodingAgent | undefined): void { if (agent) refusedSignIns.delete(agent); },
46
+ wasRefused(agent: CodingAgent): boolean { return refusedSignIns.has(agent); },
47
+ };
48
+
13
49
  /** Match the provider's explicit diagnostic, not an arbitrary HTTP 402 from a tool. */
14
50
  export function providerUsageFailure(stderr: string): string | undefined {
15
51
  if (!/\bGrok Build usage balance exhausted\b/i.test(stderr)) return;
@@ -38,6 +74,8 @@ export function providerResultFailure(stdout: string): string | undefined {
38
74
  }
39
75
 
40
76
  export function providerExitFailure(command: string, stderr: string, stdout: string, code: number | null): string {
77
+ const signIn = providerSignInFailure(command, stderr, providerResultFailure(stdout) ?? '');
78
+ if (signIn) return signIn;
41
79
  const reported = stderr.trim() ? undefined : providerResultFailure(stdout);
42
80
  return providerUsageFailure(stderr)
43
81
  ?? (reported ? `${basename(command)} stopped with code ${code}: ${reported}`
@@ -1,7 +1,7 @@
1
1
  import { spawn, type ChildProcess } from "node:child_process";
2
2
  import { delimiter, dirname } from 'node:path';
3
3
  import { realpathSync } from 'node:fs';
4
- import { providerSignInFailure, providerExitFailure } from './auth-failure';
4
+ import { isSignInFailure, providerAgent, providerSignIns, providerSignInFailure, providerExitFailure } from './auth-failure';
5
5
  import { computerId } from "../../mesh/identity/computer";
6
6
  import { inspectRepository } from "../../mesh/catalog";
7
7
  import { localMeshStore } from "../../mesh/local-remote/local";
@@ -161,7 +161,7 @@ export function runProcess(
161
161
  stderr += chunk;
162
162
  if (done || (admission && admission.confirmed(stdout))) return;
163
163
  const error = providerSignInFailure(command, stderr);
164
- if (error) { signalOwnedProcess(child, 'SIGKILL'); finish({ ok: false, error }); }
164
+ if (error) { providerSignIns.refused(providerAgent(command)); signalOwnedProcess(child, 'SIGKILL'); finish({ ok: false, error }); }
165
165
  });
166
166
  child.on("error", (error) => {
167
167
  finish({ ok: false, error: `${command}: ${error.message}` });
@@ -172,12 +172,11 @@ export function runProcess(
172
172
  return;
173
173
  }
174
174
  if (code !== 0) {
175
- finish({
176
- ok: false,
177
- error: providerExitFailure(command, stderr, stdout, code),
178
- });
179
- return;
175
+ const error = providerExitFailure(command, stderr, stdout, code);
176
+ if (isSignInFailure(error)) providerSignIns.refused(providerAgent(command));
177
+ return finish({ ok: false, error });
180
178
  }
179
+ providerSignIns.accepted(providerAgent(command));
181
180
  try {
182
181
  finish(parse(stdout));
183
182
  } catch (error) {
@@ -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.160
13
+ npm install -g granttap-mcp@0.8.162
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.160\";\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.162\";\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.160";
10
+ const PACKAGE = "granttap-mcp@0.8.162";
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.160",
3
+ "version": "0.8.162",
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": {