granttap-mcp 0.8.181 → 0.8.183

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.
@@ -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; }
@@ -21,6 +21,7 @@ import { queueProjectBindingSync } from "../../engine/runtime/engine-projects";
21
21
  import { isCursorTaskCloneId } from "../../sessions/cursor/catalog";
22
22
  import { localTaskTransfers } from '../../task-transfer';
23
23
  import { helperRunFolder } from '../../helper-runs';
24
+ import { presentableTitle } from '../../sessions/support/activity-helpers';
24
25
  export { inspectRepositoryAsync, inspectWorkingTreeAsync, readRepositoryGit } from "./repository-inspection";
25
26
  export { prepareMonitorInspection } from "./monitor-inspection";
26
27
  import type { CatalogInspection } from "./monitor-inspection";
@@ -105,8 +106,8 @@ function provider(value: string): MeshProvider | undefined {
105
106
  * even that is the fallback.
106
107
  */
107
108
  export function meshTaskTitle(session: SessionInfo, agent: string): string {
108
- const named = session.title?.trim();
109
- if (named) return named.slice(0, 160);
109
+ const named = presentableTitle(session.title);
110
+ if (named) return named;
110
111
  const opening = session.summary
111
112
  ?.split("\n")
112
113
  .map((line) => line.trim())
@@ -1,6 +1,7 @@
1
1
  import type { MeshEvent, SessionInfo, TaskCapsule } from '../../../../../../packages/protocol/schema';
2
2
  import type { MeshRuntimeDependencies } from '../dependencies';
3
3
  import { captureTransferContext } from '../../../task-transfer';
4
+ import { presentableTitle } from '../../../sessions/support/activity-helpers';
4
5
 
5
6
  /** The private computer transport owns context; phone notifications are observations only. */
6
7
  export function preparedHandoffMetadata(event: MeshEvent): MeshEvent {
@@ -15,7 +16,7 @@ export async function capturePreparedHandoff(deps: MeshRuntimeDependencies, sess
15
16
  const captured = await capture(session, facts);
16
17
  const task = deps.store().task(facts.taskId);
17
18
  return { transferContext: captured.context,
18
- capsule: { ...facts, title: task?.title ?? session.title ?? facts.goal.slice(0, 160),
19
+ capsule: { ...facts, title: presentableTitle(task?.title) ?? presentableTitle(session.title) ?? facts.goal.slice(0, 160),
19
20
  launch: 'on_message' as const, contextHash: captured.hash },
20
21
  confirm: async () => {
21
22
  const current = deps.sessions().find(row => row.sessionId === session.sessionId);
@@ -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));
@@ -46,7 +46,8 @@ export function stripTranscriptMarkup(value: unknown): string {
46
46
  text = text.replace(/<\/?user_query\b[^>]*>/gi, "");
47
47
  text = text.replace(/<\/?timestamp\b[^>]*>/gi, "");
48
48
  // Claude Code wraps text the person pasted; the words are theirs, the tags are not.
49
- text = text.replace(/<pasted_content\b[^>]*>[ \t]*\n?|\n?[ \t]*<\/pasted_content\s*>/gi, "");
49
+ // A name cut short can end inside the opening tag.
50
+ text = text.replace(/<pasted_content\b[^>]*>[ \t]*\n?|\n?[ \t]*<\/pasted_content\s*>|<pasted_content\b[^>]*$/gi, "");
50
51
  return text.replace(/^\s+|\s+$/g, "");
51
52
  }
52
53
 
@@ -86,6 +87,16 @@ export function stripAttachmentNote(text: string): string {
86
87
  ).trim();
87
88
  }
88
89
 
90
+ /**
91
+ * A chat's or Task's name as a person reads it: without the host's wrappers and on one line.
92
+ * A name saved before a wrapper was recognised is cleaned the same way wherever it is shown.
93
+ */
94
+ export function presentableTitle(value: unknown, max = 160): string | undefined {
95
+ if (typeof value !== "string") return undefined;
96
+ const clean = visibleUserText(value).replace(/\s+/g, " ").trim();
97
+ return clean ? clean.slice(0, max) : undefined;
98
+ }
99
+
89
100
  export function visibleUserText(value: unknown): string {
90
101
  const heartbeat = heartbeatDisplayText(value, 'user');
91
102
  if (heartbeat !== undefined) return heartbeat;
@@ -1,5 +1,6 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import type { SessionsStatus } from '../../../../packages/protocol/schema';
3
+ import { presentableTitle } from '../sessions/support/activity-helpers';
3
4
 
4
5
  export type TaskActivitySnapshot = {version: 1; keyId: string; machine: string; taskCount: number;
5
6
  generatedAt: number; rows: {id: string; title: string; preview: string; state: string; lastActivityAt: number}[]};
@@ -28,7 +29,7 @@ export function taskActivitySnapshot(catalog: SessionsStatus,
28
29
  taskCount: tasks.size, generatedAt: catalog.generatedAt,
29
30
  rows: options.previews ? sorted.slice(0, 2).map(([id, item]) => ({
30
31
  id: createHash('sha256').update(id).digest('hex').slice(0, 24),
31
- title: text(item.title, 128) || 'GrantTap', preview: text(item.summary, 256),
32
+ title: text(presentableTitle(item.title), 128) || 'GrantTap', preview: text(item.summary, 256),
32
33
  state: item.state, lastActivityAt: item.lastActivityAt,
33
34
  })) : []};
34
35
  }
@@ -1,5 +1,6 @@
1
1
  import type { CodingAgent, SessionInfo, UserAttachment } from '../../../../packages/protocol/schema';
2
2
  import type { DeliveryOptions, ReplyResult } from '../reply';
3
+ import { presentableTitle } from '../sessions/support/activity-helpers';
3
4
  import { TransferPersistence } from './persistence';
4
5
  import type { PreparedTransfer } from './records';
5
6
  import type { MeshStore } from '../mesh/store';
@@ -36,7 +37,8 @@ export class PreparedTaskTransfers extends TransferPersistence {
36
37
  && !rows.some(prepared => prepared.sessionId === row.sessionId));
37
38
  return [...ordinary, ...rows.map(row => {
38
39
  const actual = native.find(session => session.sessionId === row.nativeSessionId);
39
- return { ...this.session(row), ...actual, sessionId: row.sessionId, title: row.title,
40
+ // The Task's name, saved when it moved; one saved with a host's wrapper reads without it.
41
+ return { ...this.session(row), ...actual, sessionId: row.sessionId, title: presentableTitle(row.title),
40
42
  projectId: row.projectId, taskId: row.capsule.taskId, computerId: row.capsule.targetComputer,
41
43
  cwd: row.workspace, worktree: row.capsule.workspaceMode ? undefined : row.workspace, branch: row.branch };
42
44
  })];
@@ -113,7 +115,8 @@ export class PreparedTaskTransfers extends TransferPersistence {
113
115
  private session(row: PreparedTransfer): SessionInfo {
114
116
  return { sessionId: row.sessionId, agent: row.capsule.targetProvider as CodingAgent,
115
117
  projectId: row.projectId, taskId: row.capsule.taskId, computerId: row.capsule.targetComputer,
116
- title: row.title, cwd: row.workspace, worktree: row.capsule.workspaceMode ? undefined : row.workspace, branch: row.branch,
118
+ title: presentableTitle(row.title), cwd: row.workspace,
119
+ worktree: row.capsule.workspaceMode ? undefined : row.workspace, branch: row.branch,
117
120
  model: row.capsule.targetModel, summary: row.capsule.currentStatus,
118
121
  state: row.phase === 'starting' ? 'working' : row.phase === 'uncertain' ? 'waiting' : 'idle',
119
122
  startedAt: row.acceptedAt, lastActivityAt: row.updatedAt, tokensSession: 0, tokensLastTurn: 0 };
@@ -122,7 +125,7 @@ export class PreparedTaskTransfers extends TransferPersistence {
122
125
  private prompt(row: PreparedTransfer, context: string, message: string): string {
123
126
  const location = this.providerContextPath(row.sessionId);
124
127
  const inline = !context.startsWith('{') && Buffer.byteLength(context) <= 32_000 ? `\n<prior-visible-context>\n${context}\n</prior-visible-context>` : '';
125
- return `Continue the existing GrantTap Task ${row.capsule.taskId}: ${row.title}.\n`
128
+ return `Continue the existing GrantTap Task ${row.capsule.taskId}: ${presentableTitle(row.title) ?? row.capsule.taskId}.\n`
126
129
  + (row.capsule.workspaceMode ? 'Continue in the same working folder on this computer. Its files are shared with the source chat.\n'
127
130
  : `Repository revision: ${row.capsule.latestCommit ?? row.capsule.baseSha}.\n`)
128
131
  + `The complete visible conversation and project facts are saved at ${JSON.stringify(location)}. `
@@ -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.181
13
+ npm install -g granttap-mcp@0.8.183
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.181\";\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.183\";\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.181";
10
+ const PACKAGE = "granttap-mcp@0.8.183";
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.181",
3
+ "version": "0.8.183",
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": {