granttap-mcp 0.8.170 → 0.8.172
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.
- package/apps/bridge/src/monitor/handlers/user-message.ts +2 -3
- package/apps/bridge/src/provider-account-status/native-usage/memory.ts +25 -7
- package/apps/bridge/src/provider-account-status/native-usage/projection.ts +19 -0
- package/apps/bridge/src/provider-account-status/native-usage/reader.ts +9 -5
- package/apps/bridge/src/sessions/catalog.ts +11 -1
- package/apps/bridge/src/sessions/index.ts +1 -1
- package/apps/bridge/src/sessions/scan/claude/parse.ts +4 -1
- package/apps/bridge/src/sessions/scan/claude/turn-state/waits.ts +5 -1
- package/apps/bridge/src/task-dispatch/worker/index.ts +33 -10
- package/cursor-plugin/README.md +1 -1
- package/cursor-plugin/mcp.json +1 -1
- package/cursor-plugin/stdio-bootstrap.cjs +1 -1
- package/package.json +1 -1
- package/packages/protocol/messages/mesh/catalog/provider.ts +2 -0
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import { noteDeliveredRun } from "../../mesh/delivery/run-digest";
|
|
18
18
|
import { evaluateCreateTask } from "../../mesh/tasks/create-task";
|
|
19
19
|
import { sendSessionPayload } from "../../host/session-keys";
|
|
20
|
-
import {
|
|
20
|
+
import { deliveryTarget } from "../../sessions";
|
|
21
21
|
import { publishedSession } from "../../session-catalog";
|
|
22
22
|
import { localTaskOrigins, type TaskOriginRegistry, type TaskOriginScope } from '../../task-origins';
|
|
23
23
|
import { agentEventForUserMessage, sendDeliveryReceipt } from "./receipts";
|
|
@@ -157,8 +157,7 @@ export async function handleUserMessage(
|
|
|
157
157
|
// The catalog this monitor last published already names the chat. A full
|
|
158
158
|
// provider scan blocks the event loop for seconds on a large transcript set,
|
|
159
159
|
// so it runs only for a chat newer than that catalog.
|
|
160
|
-
const target = publishedSession(client, message.sessionId)
|
|
161
|
-
?? await findSessionCooperatively(message.sessionId, false);
|
|
160
|
+
const target = await deliveryTarget(publishedSession(client, message.sessionId), message.sessionId);
|
|
162
161
|
if (!target) return refuse("This task is no longer available on the computer.");
|
|
163
162
|
|
|
164
163
|
const settings = loadRuntimeConfig().providerSettings;
|
|
@@ -34,6 +34,8 @@ export function isSignedOutUsage(report: ProviderAccountUsage): boolean {
|
|
|
34
34
|
/** The readings one process holds, kept in step with the other processes on the computer. */
|
|
35
35
|
export function createUsageMemory(saved: SharedUsage | undefined, clock: () => number, known: (provider: string) => boolean) {
|
|
36
36
|
const reports = new Map<NativeUsageProvider, ProviderAccountUsage>();
|
|
37
|
+
/** Limits narrower than the account, such as one model's. They are read with the account's reading and follow it. */
|
|
38
|
+
const scoped = new Map<NativeUsageProvider, ProviderAccountUsage[]>();
|
|
37
39
|
const pauses = new Map<NativeUsageProvider, number>(), failures = new Map<NativeUsageProvider, number>();
|
|
38
40
|
const notBefore = (provider: NativeUsageProvider) => {
|
|
39
41
|
let shared = -Infinity;
|
|
@@ -46,19 +48,35 @@ export function createUsageMemory(saved: SharedUsage | undefined, clock: () => n
|
|
|
46
48
|
};
|
|
47
49
|
const restore = () => {
|
|
48
50
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const stored = saved?.read() ?? [];
|
|
52
|
+
for (const report of stored) {
|
|
53
|
+
const provider = report.provider as NativeUsageProvider, held = reports.get(provider);
|
|
54
|
+
if (!known(provider) || report.limitId !== provider || isSignedOutUsage(report)
|
|
55
|
+
|| (held?.observedAt ?? -Infinity) >= report.observedAt || held && isSignedOutUsage(held)) continue;
|
|
56
|
+
reports.set(provider, report);
|
|
57
|
+
scoped.set(provider, stored.filter(other => other.provider === provider && other.limitId !== provider
|
|
58
|
+
&& !isSignedOutUsage(other)).slice(0, 4));
|
|
53
59
|
}
|
|
54
60
|
} catch { /* A missing or damaged file only means nothing is remembered. */ }
|
|
55
61
|
};
|
|
62
|
+
const persist = () => {
|
|
63
|
+
const kept = [...reports.values()].filter(report => !isSignedOutUsage(report));
|
|
64
|
+
try { saved?.write([...kept, ...kept.flatMap(report => scoped.get(report.provider as NativeUsageProvider) ?? [])]); }
|
|
65
|
+
catch { /* Best effort. */ }
|
|
66
|
+
};
|
|
56
67
|
restore();
|
|
57
68
|
return {
|
|
58
69
|
reports, restore,
|
|
59
|
-
remember(): void {
|
|
60
|
-
|
|
61
|
-
|
|
70
|
+
remember(): void { restore(); persist(); },
|
|
71
|
+
/** A fresh reading names every narrower limit the provider still reports; one it dropped is not kept. */
|
|
72
|
+
setScoped(provider: NativeUsageProvider, limits: ProviderAccountUsage[]): void { scoped.set(provider, limits.slice(0, 4)); },
|
|
73
|
+
scopedFor(provider: NativeUsageProvider): ProviderAccountUsage[] {
|
|
74
|
+
const main = reports.get(provider);
|
|
75
|
+
return main && !isSignedOutUsage(main) ? scoped.get(provider) ?? [] : [];
|
|
76
|
+
},
|
|
77
|
+
/** The login is gone: its readings leave this process and the shared file, instead of coming back from it. */
|
|
78
|
+
forget(provider: NativeUsageProvider): void {
|
|
79
|
+
restore(); reports.delete(provider); scoped.delete(provider); persist();
|
|
62
80
|
},
|
|
63
81
|
/** Not while another process has just read it, or while the provider asked everyone to wait. */
|
|
64
82
|
due(provider: NativeUsageProvider, now: number): boolean {
|
|
@@ -38,6 +38,25 @@ export function projectNativeAccountUsage(provider: NativeUsageProvider, input:
|
|
|
38
38
|
return windows.length ? { provider, limitId: provider, observedAt: now, windows } : undefined;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Limits narrower than the whole account. Claude reports a weekly limit for one model beside the
|
|
43
|
+
* account-wide windows; each becomes its own report, named after the model, so the phone can show
|
|
44
|
+
* it without mistaking it for the account's limit. Only the name and the share cross the wire.
|
|
45
|
+
*/
|
|
46
|
+
export function projectScopedLimits(provider: NativeUsageProvider, input: any, now = Date.now()): ProviderAccountUsage[] {
|
|
47
|
+
if (provider !== "claude" || !Array.isArray(input?.limits)) return [];
|
|
48
|
+
const reports = new Map<string, ProviderAccountUsage>();
|
|
49
|
+
for (const limit of input.limits.slice(0, 16)) {
|
|
50
|
+
const name = typeof limit?.scope?.model?.display_name === "string" ? limit.scope.model.display_name.trim().slice(0, 40) : "";
|
|
51
|
+
const slug = name.toLowerCase().replace(/[^a-z0-9.]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60);
|
|
52
|
+
const resetsAt = timestamp(limit?.resets_at);
|
|
53
|
+
if (limit?.kind !== "weekly_scoped" || !name || !slug || !percent(limit.percent) || !(resetsAt > now)) continue;
|
|
54
|
+
reports.set(slug, { provider, limitId: `${provider}:model:${slug}`, label: name, observedAt: now,
|
|
55
|
+
windows: [{ id: "secondary", usedPercent: limit.percent, windowMinutes: 10_080, resetsAt }] });
|
|
56
|
+
}
|
|
57
|
+
return [...reports.values()].slice(0, 4);
|
|
58
|
+
}
|
|
59
|
+
|
|
41
60
|
/** Older Cursor plans report a billing-period pool rather than a weekly pool. */
|
|
42
61
|
export function projectCursorPeriodUsage(input: any, now = Date.now()): ProviderAccountUsage | undefined {
|
|
43
62
|
const start = Number(input?.billingCycleStart), end = Number(input?.billingCycleEnd);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ProviderAccountUsage } from "../../../../../packages/protocol/schema";
|
|
2
|
-
import { projectCursorPeriodUsage, projectNativeAccountUsage, type NativeUsageProvider } from "./projection";
|
|
2
|
+
import { projectCursorPeriodUsage, projectNativeAccountUsage, projectScopedLimits, type NativeUsageProvider } from "./projection";
|
|
3
3
|
import { CHECK_EVERY_MS, createUsageMemory, isSignedOutUsage, signedOutUsage, type SharedUsage } from "./memory";
|
|
4
4
|
export { isSignedOutUsage, SIGNED_OUT_SUFFIX, signedOutUsage } from "./memory";
|
|
5
5
|
|
|
@@ -71,7 +71,7 @@ export function createNativeAccountUsageReader(options: Options) {
|
|
|
71
71
|
if (isSignedOutUsage(reports.get(provider) ?? signedOutUsage(provider, 0))) reports.delete(provider);
|
|
72
72
|
restore();
|
|
73
73
|
note(provider, "its saved access token has expired; the provider renews it on its next run");
|
|
74
|
-
} else {
|
|
74
|
+
} else { memory.forget(provider); reasons.delete(provider); }
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
restore();
|
|
@@ -97,8 +97,11 @@ export function createNativeAccountUsageReader(options: Options) {
|
|
|
97
97
|
});
|
|
98
98
|
report = projectCursorPeriodUsage(await boundedResponse(legacy), clock());
|
|
99
99
|
}
|
|
100
|
-
if (report) {
|
|
101
|
-
|
|
100
|
+
if (report) {
|
|
101
|
+
memory.succeeded(provider); reports.set(provider, report);
|
|
102
|
+
memory.setScoped(provider, projectScopedLimits(provider, value, report.observedAt));
|
|
103
|
+
remember();
|
|
104
|
+
} else if (response.ok) memory.forget(provider);
|
|
102
105
|
else memory.refused(provider, response);
|
|
103
106
|
note(provider, report ? undefined : response.ok ? "unrecognized response" : `HTTP ${response.status}`);
|
|
104
107
|
} catch (error) {
|
|
@@ -110,7 +113,8 @@ export function createNativeAccountUsageReader(options: Options) {
|
|
|
110
113
|
return {
|
|
111
114
|
current(): ProviderAccountUsage[] {
|
|
112
115
|
const now = clock();
|
|
113
|
-
|
|
116
|
+
const held = [...reports.values()].flatMap(report => [report, ...memory.scopedFor(report.provider as NativeUsageProvider)]);
|
|
117
|
+
return held.flatMap(report => {
|
|
114
118
|
const windows = report.windows.filter(window => window.resetsAt > now);
|
|
115
119
|
return isSignedOutUsage(report) ? (now - report.observedAt <= MARKER_MS ? [report] : [])
|
|
116
120
|
: windows.length && now - report.observedAt <= HELD_USAGE_MS ? [{ ...report, windows }] : [];
|
|
@@ -76,7 +76,17 @@ export async function scanSessionHistoryCooperatively(): Promise<SessionInfo[]>
|
|
|
76
76
|
export async function findSessionCooperatively(sessionId: string, includeHistory = true): Promise<SessionInfo | undefined> {
|
|
77
77
|
const catalog = catalogFromScans(await cooperativeProviderScans());
|
|
78
78
|
return liveCatalog(catalog).sessions.find(session => session.sessionId === sessionId)
|
|
79
|
-
?? (includeHistory ? historyCatalog(catalog.all).find(session => session.sessionId === sessionId)
|
|
79
|
+
?? (includeHistory ? historyCatalog(catalog.all).find(session => session.sessionId === sessionId)
|
|
80
|
+
?? catalog.all.find(session => session.sessionId === sessionId) : undefined);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The chat a phone message is for. The catalog this monitor last published is used first: a scan can
|
|
85
|
+
* take seconds. A chat missing from it is looked up among every chat on the computer, not only the
|
|
86
|
+
* ones active in the last hours: a chat left idle for days was refused as "no longer available".
|
|
87
|
+
*/
|
|
88
|
+
export async function deliveryTarget(published: SessionInfo | undefined, sessionId: string): Promise<SessionInfo | undefined> {
|
|
89
|
+
return published ?? await findSessionCooperatively(sessionId);
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
export function scanSessions(): { sessions: SessionInfo[]; tokensRecent: number } {
|
|
@@ -47,7 +47,7 @@ export { MAX_ACTIVITY_ENTRIES, MAX_ACTIVITY_TEXT, TOKEN_WINDOW_HOURS };
|
|
|
47
47
|
export { nativeTranscriptRoots, nativeTranscriptSource, restoreNativeTranscriptSource } from "./native-source";
|
|
48
48
|
|
|
49
49
|
export { scanSessions, scanSessionHistory, scanSessionHistoryForPaging,
|
|
50
|
-
scanSessionsCooperatively, scanSessionHistoryCooperatively, findSessionCooperatively } from "./catalog";
|
|
50
|
+
scanSessionsCooperatively, scanSessionHistoryCooperatively, findSessionCooperatively, deliveryTarget } from "./catalog";
|
|
51
51
|
import { scanSessions, scanSessionHistory } from "./catalog";
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -100,7 +100,10 @@ function applyClaudeLine(d: any, state: ClaudeParseState): void {
|
|
|
100
100
|
}
|
|
101
101
|
state.contextTokensUsed = claudeContextUsage(usage) ?? state.contextTokensUsed;
|
|
102
102
|
if (d.isSidechain !== true) state.contextUsage = claudeContextReport(usage, ts(d.timestamp) ?? 0) ?? state.contextUsage;
|
|
103
|
-
|
|
103
|
+
// The chat's own latest answer names its model. The first one used to stay for good, so the phone's
|
|
104
|
+
// header kept the old model after a change; a subagent's model and an error placeholder are not it.
|
|
105
|
+
const model = typeof d.message?.model === "string" ? d.message.model.trim() : "";
|
|
106
|
+
if (model && model !== "<synthetic>" && d.isSidechain !== true && d.isApiErrorMessage !== true) state.model = model;
|
|
104
107
|
}
|
|
105
108
|
if (d.message?.role === "assistant") {
|
|
106
109
|
const content = d.message.content;
|
|
@@ -7,6 +7,8 @@ export type ClaudeUsageLimit = {resetsAt: number; window?: string};
|
|
|
7
7
|
export type ClaudeWaits = {background?: Record<string, ClaudeBackgroundWork>; limit?: ClaudeUsageLimit};
|
|
8
8
|
|
|
9
9
|
const BASH_DEFAULT_MS = 600_000, LONGEST_MS = 7_200_000, MAX_TRACKED = 32;
|
|
10
|
+
/** The same hour after which the computer no longer continues a limited chat by itself. */
|
|
11
|
+
const LIMIT_STALE_MS = 3_600_000;
|
|
10
12
|
const BASH_LAUNCH = /^Command running in background with ID: ([\w-]+)/;
|
|
11
13
|
const AGENT_LAUNCH = /^Async agent launched/;
|
|
12
14
|
const AGENT_ID = /agentId: ([\w-]+)/;
|
|
@@ -89,6 +91,8 @@ export function claudeWaits(waits: ClaudeWaits, turnEnded: boolean | undefined,
|
|
|
89
91
|
{backgroundTasks?: number; usageLimit?: ClaudeUsageLimit} {
|
|
90
92
|
if (!turnEnded) return {};
|
|
91
93
|
const pending = Object.values(waits.background ?? {}).filter(work => work.until > now).length;
|
|
94
|
+
// A chat left at a limit that reset long ago is simply idle; the phone said it was "continuing" a week later.
|
|
95
|
+
const limited = waits.limit && waits.limit.resetsAt > now - LIMIT_STALE_MS ? waits.limit : undefined;
|
|
92
96
|
return {...(pending ? {backgroundTasks: Math.min(pending, 32)} : {}),
|
|
93
|
-
...(
|
|
97
|
+
...(limited ? {usageLimit: limited} : {})};
|
|
94
98
|
}
|
|
@@ -18,23 +18,39 @@ export type WorkerOptions = {
|
|
|
18
18
|
deliver: (job: TaskDispatch, beforeStart: () => Promise<void>, peer: string) => Promise<'accepted' | 'rejected'>;
|
|
19
19
|
};
|
|
20
20
|
class DeferredLaunch extends Error {}
|
|
21
|
+
const REFUSED_LOOKUP_MS = 10 * 60_000;
|
|
21
22
|
|
|
22
23
|
/** Server acceptance follows local fsync. Native submission is never replayed on a lease timer. */
|
|
23
24
|
export class TaskDispatchWorker {
|
|
24
25
|
private readonly active = new Map<string, Promise<void>>();
|
|
25
26
|
private readonly conversations = new Set<string>();
|
|
27
|
+
/** When each refused job was last looked up on the relay; it only waits there to be cancelled or to expire. */
|
|
28
|
+
private readonly refusedLookups = new Map<string, number>();
|
|
26
29
|
constructor(private readonly options: WorkerOptions) {}
|
|
27
30
|
|
|
28
|
-
async tick(): Promise<void> {
|
|
31
|
+
async tick(now = Date.now()): Promise<void> {
|
|
29
32
|
if (!this.options.connected()) return;
|
|
30
33
|
const launched: Promise<void>[] = [];
|
|
31
34
|
const records = this.options.inbox.pendingRecords().sort((a, b) =>
|
|
32
35
|
Number(b.job.deliveryMode === 'immediate') - Number(a.job.deliveryMode === 'immediate')
|
|
33
36
|
|| a.job.createdAt - b.job.createdAt);
|
|
37
|
+
const keyOf = (record: StoredTaskDispatch) => this.options.conversationKey?.(record.job, record.peerPublicKey)
|
|
38
|
+
?? record.job.sessionId ?? `new:${record.job.operation.agent ?? 'codex'}`;
|
|
39
|
+
// A refusal is final for its message. It keeps holding the follow-ups that were already queued behind
|
|
40
|
+
// it until the person cancels it; it used to hold every later message of the chat as well, for days.
|
|
41
|
+
const refusedAt = new Map<string, number>();
|
|
34
42
|
for (const record of records) {
|
|
35
|
-
if (
|
|
36
|
-
const key =
|
|
37
|
-
|
|
43
|
+
if (record.phase !== 'rejected') continue;
|
|
44
|
+
const key = keyOf(record);
|
|
45
|
+
refusedAt.set(key, Math.max(refusedAt.get(key) ?? -Infinity, record.updatedAt));
|
|
46
|
+
if (!this.active.has(record.job.jobId)) launched.push(this.settleRefused(record, now));
|
|
47
|
+
}
|
|
48
|
+
for (const record of records) {
|
|
49
|
+
if (['completed', 'cancelled', 'rejected'].includes(record.phase) || this.active.has(record.job.jobId)) continue;
|
|
50
|
+
const key = keyOf(record);
|
|
51
|
+
// Staged before the refusal: a follow-up written for the message that failed. Staged after it: the
|
|
52
|
+
// person saw the failure and sent this anyway.
|
|
53
|
+
if (record.stagedAt <= (refusedAt.get(key) ?? -Infinity)) continue;
|
|
38
54
|
if (this.conversations.has(key)) continue;
|
|
39
55
|
this.conversations.add(key);
|
|
40
56
|
const work = this.process(record).catch(error => { this.options.onError?.(error); }).finally(() => {
|
|
@@ -62,12 +78,6 @@ export class TaskDispatchWorker {
|
|
|
62
78
|
this.options.onTerminal?.(job); return;
|
|
63
79
|
}
|
|
64
80
|
const state = await remote.get(job);
|
|
65
|
-
if (record.phase === 'rejected') {
|
|
66
|
-
if (['cancelled', 'expired'].includes(state)) {
|
|
67
|
-
inbox.transition(job.jobId, 'cancelled'); inbox.retire(job.jobId);
|
|
68
|
-
}
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
81
|
if (['cancelled', 'expired'].includes(state)) { inbox.transition(job.jobId, 'cancelled'); inbox.retire(job.jobId); return; }
|
|
72
82
|
if (state === 'completed' || state === 'failed') {
|
|
73
83
|
// A server terminal state cannot authorize a new native invocation.
|
|
@@ -105,6 +115,19 @@ export class TaskDispatchWorker {
|
|
|
105
115
|
await this.finish(inbox.get(job.jobId));
|
|
106
116
|
}
|
|
107
117
|
|
|
118
|
+
/** A refused job leaves once the relay cancelled or expired it. Asking every two seconds was only load. */
|
|
119
|
+
private async settleRefused(record: StoredTaskDispatch, now: number): Promise<void> {
|
|
120
|
+
const { inbox, remote } = this.options, id = record.job.jobId;
|
|
121
|
+
if (now - (this.refusedLookups.get(id) ?? -Infinity) < REFUSED_LOOKUP_MS) return;
|
|
122
|
+
this.refusedLookups.set(id, now);
|
|
123
|
+
const work = (async () => {
|
|
124
|
+
if (!['cancelled', 'expired'].includes(await remote.get(record.job))) return;
|
|
125
|
+
inbox.transition(id, 'cancelled'); inbox.retire(id); this.refusedLookups.delete(id);
|
|
126
|
+
})().catch(error => { this.options.onError?.(error); }).finally(() => { this.active.delete(id); });
|
|
127
|
+
this.active.set(id, work);
|
|
128
|
+
await work;
|
|
129
|
+
}
|
|
130
|
+
|
|
108
131
|
private async reject(record: StoredTaskDispatch, code: string): Promise<void> {
|
|
109
132
|
const claimId = this.options.inbox.reserveClaim(record.job.jobId);
|
|
110
133
|
if (!await this.options.remote.claim(record.job, claimId)) return;
|
package/cursor-plugin/README.md
CHANGED
|
@@ -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.
|
|
13
|
+
npm install -g granttap-mcp@0.8.172
|
|
14
14
|
granttap setup
|
|
15
15
|
granttap status
|
|
16
16
|
```
|
package/cursor-plugin/mcp.json
CHANGED
|
@@ -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.
|
|
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.172\";\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.
|
|
10
|
+
const PACKAGE = "granttap-mcp@0.8.172";
|
|
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
|
@@ -21,6 +21,8 @@ export type SharedSkill = z.infer<typeof SharedSkill>;
|
|
|
21
21
|
export const ProviderAccountUsage = z.object({
|
|
22
22
|
provider: MeshProvider,
|
|
23
23
|
limitId: z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,159}$/),
|
|
24
|
+
/** What a limit narrower than the whole account covers, such as one model's name. Absent for the account-wide limit. */
|
|
25
|
+
label: z.string().trim().min(1).max(40).optional(),
|
|
24
26
|
observedAt: z.number().nonnegative(),
|
|
25
27
|
windows: z.array(z.object({
|
|
26
28
|
id: z.enum(["primary", "secondary"]),
|