granttap-mcp 0.8.184 → 0.8.185

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.
@@ -82,16 +82,18 @@ async function startNewAgentTask(input: {
82
82
  throw error;
83
83
  }
84
84
  await say(`Creating a new ${displayName} task…`, undefined, false, "status");
85
- const create = {
86
- claude: createClaudeSession,
87
- codex: createCodexSession,
88
- cursor: createCursorSession,
89
- grok: createGrokSession,
90
- }[agent];
85
+ // Claude, Grok and Cursor name the chat as it starts; Codex only when its run ends.
86
+ const started = (sessionId: string) => {
87
+ try { input.origin?.registry.started(input.origin.scope, sessionId); } catch { /* The run's end records it. */ }
88
+ };
89
+ const prompt = projectGuidancePrompt(admittedProjectId, message.text);
91
90
  let run: Promise<ReplyResult>;
92
91
  try {
93
- run = create(projectGuidancePrompt(admittedProjectId, message.text), requestedCwd, PHONE_RUN_LIMIT_MS, resolved.attachments,
94
- message.model, message.messageId, message.effort).catch(() => {
92
+ run = (agent === 'codex'
93
+ ? createCodexSession(prompt, requestedCwd, PHONE_RUN_LIMIT_MS, resolved.attachments, message.model, message.messageId,
94
+ message.effort)
95
+ : { claude: createClaudeSession, cursor: createCursorSession, grok: createGrokSession }[agent](prompt, requestedCwd,
96
+ PHONE_RUN_LIMIT_MS, resolved.attachments, message.model, message.messageId, message.effort, started)).catch(() => {
95
97
  input.origin?.registry.complete(input.origin.scope, { ok: true });
96
98
  return { ok: false, error: 'The provider task stopped unexpectedly.' } as ReplyResult;
97
99
  });
@@ -2,6 +2,7 @@ import { projectGuidancePrompt } from "../mesh/restrictions/guidance";
2
2
  /** Deliver phone messages into existing sessions or start a new Codex task. */
3
3
  import { localTaskTransfers, localTransferContinuations } from "../task-transfer";
4
4
  import { localRoutingRequests } from '../task-routing/requests';
5
+ import { randomUUID } from "node:crypto";
5
6
  import { mkdirSync } from "node:fs";
6
7
  import { join } from "node:path";
7
8
  import type { SessionInfo, UserAttachment } from "../../../../packages/protocol/schema";
@@ -123,10 +124,11 @@ export function createClaudeSession(
123
124
  model?: string,
124
125
  operationKey?: string,
125
126
  effort?: string,
127
+ onNativeSession?: (sessionId: string) => void,
126
128
  ): Promise<ReplyResult> {
127
129
  const workspace = resolveAgentWorkspace(cwd, "claude");
128
130
  return queued(newTaskDeliveryKey("claude", operationKey), () => withAttachments(attachments, text, (prepared) =>
129
- runClaudeNew(prepared.claudePrompt, workspace, timeoutMs, model, operationKey, effort),
131
+ runClaudeNew(prepared.claudePrompt, workspace, timeoutMs, model, operationKey, effort, onNativeSession),
130
132
  ));
131
133
  }
132
134
 
@@ -218,9 +220,15 @@ function runClaude(
218
220
 
219
221
  function runClaudeNew(
220
222
  text: string, cwd: string, timeoutMs: number, model?: string, operationKey?: string, effort?: string,
223
+ onNativeSession?: (sessionId: string) => void,
221
224
  ): Promise<ReplyResult> {
222
- const args = ["-p", ...(model ? ["--model", model] : []), ...providerEffortArgs("claude", effort), "--output-format", "json", text];
225
+ // The chat is given its id before it starts, so the phone can show the one chat it asked for
226
+ // while the first answer is still being written, instead of a placeholder beside it.
227
+ const sessionId = randomUUID();
228
+ const args = ["-p", "--session-id", sessionId, ...(model ? ["--model", model] : []), ...providerEffortArgs("claude", effort),
229
+ "--output-format", "json", text];
223
230
  const claude = resolveClaudeBinary();
231
+ onNativeSession?.(sessionId);
224
232
  return runProcess(claude.path, args, cwd, timeoutMs, (stdout) => {
225
233
  try {
226
234
  const parsed = JSON.parse(stdout) as { result?: string; is_error?: boolean; session_id?: string };
@@ -228,7 +236,7 @@ function runClaudeNew(
228
236
  return { ok: false, error: explainClaudeFailure(parsed.result ?? "agent error", claude) };
229
237
  }
230
238
  if (typeof parsed.result === "string") {
231
- return { ok: true, text: parsed.result.slice(0, 4000), sessionId: parsed.session_id };
239
+ return { ok: true, text: parsed.result.slice(0, 4000), sessionId: parsed.session_id ?? sessionId };
232
240
  }
233
241
  } catch {
234
242
  // Fall through to plain output.
@@ -59,6 +59,21 @@ export class TaskOriginRegistry {
59
59
  });
60
60
  }
61
61
 
62
+ /**
63
+ * The provider named the chat it is creating. The creation is not settled, so a retry still waits
64
+ * for it, but the catalog can tell the phone which chat its message became as soon as it is listed.
65
+ */
66
+ started(scope: TaskOriginScope, sessionId: string): void {
67
+ const id = sessionId.trim();
68
+ if (!id || id.length > 180) return;
69
+ const path = this.path(scope);
70
+ withStoreLock(path, () => {
71
+ const record = this.read(scope);
72
+ if (!record || record.owner !== process.pid || record.phase !== 'creating' || record.sessionId) return;
73
+ writeOrigin(path, Record.parse({ ...record, sessionId: id }));
74
+ });
75
+ }
76
+
62
77
  complete(scope: TaskOriginScope, result: { ok: boolean; sessionId?: string }): void {
63
78
  const path = this.path(scope);
64
79
  withStoreLock(path, () => {
@@ -66,7 +81,7 @@ export class TaskOriginRegistry {
66
81
  if (!record || record.owner !== process.pid) throw new Error('Task origin owner mismatch');
67
82
  if (record.phase !== 'creating') return;
68
83
  const candidate = result.sessionId?.trim();
69
- const sessionId = candidate && candidate.length <= 180 ? candidate : undefined;
84
+ const sessionId = (candidate && candidate.length <= 180 ? candidate : undefined) ?? record.sessionId;
70
85
  const phase = !result.ok ? 'failed' : sessionId ? 'ready' : 'uncertain';
71
86
  writeOrigin(path, Record.parse({ ...record, phase, sessionId }));
72
87
  });
@@ -97,7 +112,9 @@ export class TaskOriginRegistry {
97
112
  const record = cached?.version === version ? cached.record : Record.parse(readOrigin(path));
98
113
  if (this.path(record.scope) !== path) return [];
99
114
  this.catalogCache.set(path, { version, record });
100
- if (record.scope.room !== room || record.phase !== 'ready' || !record.sessionId
115
+ // A creation still running is listed once its provider has named the chat.
116
+ const linked = record.phase === 'ready' || record.phase === 'creating';
117
+ if (record.scope.room !== room || !linked || !record.sessionId
101
118
  || record.expiresAt <= this.now()) return [];
102
119
  return [{ sessionId: record.sessionId, agent: record.agent, projectId: record.projectId,
103
120
  originId: record.scope.originMessageId, controllerPublicKey: record.scope.peerPublicKey }];
@@ -8,8 +8,9 @@ export function decorateTaskOriginCatalog(status: SessionsStatus, room: string,
8
8
  try { origins = (registry ?? localTaskOrigins()).readyInRoom(room); }
9
9
  catch { return status; }
10
10
  const decorate = (session: SessionInfo): SessionInfo => {
11
- const matching = origins.filter(origin => origin.sessionId === session.sessionId && origin.agent === session.agent
12
- && (!origin.projectId || !session.projectId || origin.projectId === session.projectId));
11
+ // The chat is the one its provider named; the Mesh it is listed in can differ from the one the
12
+ // message asked for, as when that Mesh was a stale twin of the repository's own.
13
+ const matching = origins.filter(origin => origin.sessionId === session.sessionId && origin.agent === session.agent);
13
14
  if (!matching.length && !session.creationOrigins) return session;
14
15
  const { creationOrigins: _previous, ...native } = session;
15
16
  return matching.length ? { ...native, creationOrigins: matching.slice(0, 32).map(origin => ({
@@ -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.184
13
+ npm install -g granttap-mcp@0.8.185
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.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"
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.185\";\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.184";
10
+ const PACKAGE = "granttap-mcp@0.8.185";
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.184",
3
+ "version": "0.8.185",
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": {