@mcp-index/sdk 0.15.0 → 0.17.0
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/CHANGELOG.md +20 -0
- package/README.md +41 -2
- package/dist/src/canonical.d.ts +8 -0
- package/dist/src/canonical.d.ts.map +1 -1
- package/dist/src/canonical.js +57 -0
- package/dist/src/canonical.js.map +1 -1
- package/dist/src/contractFields.d.ts +42 -0
- package/dist/src/contractFields.d.ts.map +1 -0
- package/dist/src/contractFields.js +103 -0
- package/dist/src/contractFields.js.map +1 -0
- package/dist/src/fileLock.d.ts +20 -0
- package/dist/src/fileLock.d.ts.map +1 -0
- package/dist/src/fileLock.js +191 -0
- package/dist/src/fileLock.js.map +1 -0
- package/dist/src/gate.d.ts +28 -3
- package/dist/src/gate.d.ts.map +1 -1
- package/dist/src/gate.js +85 -3
- package/dist/src/gate.js.map +1 -1
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/listingFilter.d.ts +6 -3
- package/dist/src/listingFilter.d.ts.map +1 -1
- package/dist/src/listingFilter.js +17 -6
- package/dist/src/listingFilter.js.map +1 -1
- package/dist/src/pendingStore.d.ts +53 -0
- package/dist/src/pendingStore.d.ts.map +1 -0
- package/dist/src/pendingStore.js +309 -0
- package/dist/src/pendingStore.js.map +1 -0
- package/dist/src/preflight.d.ts +37 -7
- package/dist/src/preflight.d.ts.map +1 -1
- package/dist/src/preflight.js +340 -83
- package/dist/src/preflight.js.map +1 -1
- package/dist/src/wrap.d.ts +13 -7
- package/dist/src/wrap.d.ts.map +1 -1
- package/dist/src/wrap.js +199 -14
- package/dist/src/wrap.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools held for review, on disk under the gate state directory.
|
|
3
|
+
*
|
|
4
|
+
* Same file shape and lock as Python ``tooling.cse.pending_store`` so the
|
|
5
|
+
* Python CLI and this SDK share one pending list. Approval tokens are the
|
|
6
|
+
* full-contract ``approvalDigest``; a later list with a different digest is
|
|
7
|
+
* kept alongside the first rather than overwriting it.
|
|
8
|
+
*/
|
|
9
|
+
import { PreflightPin, type PinnedTool, type ToolDef } from "./preflight.js";
|
|
10
|
+
export declare const CLASS_CHANGED = "changed-without-upgrade";
|
|
11
|
+
export declare const CLASS_FLOATING = "floating";
|
|
12
|
+
export declare const PER_SERVER_CAP = 64;
|
|
13
|
+
export declare const TOTAL_CAP = 512;
|
|
14
|
+
export interface PendingRecord {
|
|
15
|
+
readonly serverId: string;
|
|
16
|
+
readonly toolName: string;
|
|
17
|
+
readonly definition: ToolDef;
|
|
18
|
+
readonly definitionHash: string;
|
|
19
|
+
readonly pendingClass: string;
|
|
20
|
+
readonly firstSeen: string;
|
|
21
|
+
readonly launchKey?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function pendingPath(stateDirectory: string): string;
|
|
24
|
+
/** State directory for pending.json. Mirrors ``defaultPinStorePath`` root. */
|
|
25
|
+
export declare function defaultStateDir(): string;
|
|
26
|
+
export declare function pendingClass(prior: readonly PinnedTool[]): string;
|
|
27
|
+
export declare function recordPending(path: string, args: {
|
|
28
|
+
serverId: string;
|
|
29
|
+
toolName: string;
|
|
30
|
+
definition: ToolDef;
|
|
31
|
+
definitionHash: string;
|
|
32
|
+
pendingClass: string;
|
|
33
|
+
launchKey?: string;
|
|
34
|
+
}): void;
|
|
35
|
+
export declare function loadPending(path: string): PendingRecord[];
|
|
36
|
+
export declare function approveOne(pin: PreflightPin, path: string, serverId: string, toolName: string, definitionHash: string, opts?: {
|
|
37
|
+
floatingOnly?: boolean;
|
|
38
|
+
}): PinnedTool | null;
|
|
39
|
+
/** Basename helper kept for tests that inspect the pending file name. */
|
|
40
|
+
export declare function pendingFileName(): string;
|
|
41
|
+
export type ResetPinsResult = {
|
|
42
|
+
path: string;
|
|
43
|
+
pinCount: number;
|
|
44
|
+
tainted: string | null;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Delete one server's pin store and its ever-pinned record, and drop its
|
|
48
|
+
* pending rows. The next tools/list pins from the current contract.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resetPins(serverId: string, opts?: {
|
|
51
|
+
path?: string;
|
|
52
|
+
}): ResetPinsResult;
|
|
53
|
+
//# sourceMappingURL=pendingStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pendingStore.d.ts","sourceRoot":"","sources":["../../src/pendingStore.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqBH,OAAO,EACL,YAAY,EAIZ,KAAK,UAAU,EACf,KAAK,OAAO,EACb,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,aAAa,4BAA4B,CAAC;AACvD,eAAO,MAAM,cAAc,aAAa,CAAC;AAGzC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,SAAS,MAAM,CAAC;AAG7B,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,IAAI,MAAM,CAOxC;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAMjE;AAuID,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IACJ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,IAAI,CA6BN;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,CAOzD;AA8BD,wBAAgB,UAAU,CACxB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,IAAI,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAChC,UAAU,GAAG,IAAI,CA6BnB;AAED,yEAAyE;AACzE,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GACvB,eAAe,CAuBjB"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tools held for review, on disk under the gate state directory.
|
|
3
|
+
*
|
|
4
|
+
* Same file shape and lock as Python ``tooling.cse.pending_store`` so the
|
|
5
|
+
* Python CLI and this SDK share one pending list. Approval tokens are the
|
|
6
|
+
* full-contract ``approvalDigest``; a later list with a different digest is
|
|
7
|
+
* kept alongside the first rather than overwriting it.
|
|
8
|
+
*/
|
|
9
|
+
import { CONTRACT_FIELDS_VERSION } from "./contractFields.js";
|
|
10
|
+
import { randomBytes } from "node:crypto";
|
|
11
|
+
import { chmodSync, closeSync, constants, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeSync, } from "node:fs";
|
|
12
|
+
import { tmpdir, homedir } from "node:os";
|
|
13
|
+
import { basename, dirname, join } from "node:path";
|
|
14
|
+
import { withExclusiveLock } from "./fileLock.js";
|
|
15
|
+
import { approvalDigest, hashTool } from "./canonical.js";
|
|
16
|
+
import { PreflightPin, clearEverPinned, defaultPinStorePath, utcNowIso, } from "./preflight.js";
|
|
17
|
+
export const CLASS_CHANGED = "changed-without-upgrade";
|
|
18
|
+
export const CLASS_FLOATING = "floating";
|
|
19
|
+
const PENDING_VERSION = 1;
|
|
20
|
+
export const PER_SERVER_CAP = 64;
|
|
21
|
+
export const TOTAL_CAP = 512;
|
|
22
|
+
const NAME = "pending.json";
|
|
23
|
+
export function pendingPath(stateDirectory) {
|
|
24
|
+
return join(stateDirectory, NAME);
|
|
25
|
+
}
|
|
26
|
+
/** State directory for pending.json. Mirrors ``defaultPinStorePath`` root. */
|
|
27
|
+
export function defaultStateDir() {
|
|
28
|
+
const fromEnv = process.env.MCPINDEX_STATE_DIR;
|
|
29
|
+
if (typeof fromEnv === "string" && fromEnv.trim().length > 0)
|
|
30
|
+
return fromEnv;
|
|
31
|
+
if (process.execArgv.includes("--test") || process.argv.includes("--test")) {
|
|
32
|
+
return join(tmpdir(), "mcpindex-sdk-test", String(process.pid));
|
|
33
|
+
}
|
|
34
|
+
return join(homedir(), ".mcpindex");
|
|
35
|
+
}
|
|
36
|
+
export function pendingClass(prior) {
|
|
37
|
+
const keys = prior.map((pin) => pin.launchKey).filter((k) => typeof k === "string" && k.length > 0);
|
|
38
|
+
if (prior.length > 0 && keys.length === prior.length && new Set(keys).size === 1) {
|
|
39
|
+
return CLASS_CHANGED;
|
|
40
|
+
}
|
|
41
|
+
return CLASS_FLOATING;
|
|
42
|
+
}
|
|
43
|
+
function parseRecord(row) {
|
|
44
|
+
if (row === null || typeof row !== "object" || Array.isArray(row))
|
|
45
|
+
return null;
|
|
46
|
+
const body = row;
|
|
47
|
+
const server = body["server_id"];
|
|
48
|
+
const tool = body["tool_name"];
|
|
49
|
+
const definition = body["definition"];
|
|
50
|
+
const digest = body["definition_hash"];
|
|
51
|
+
const klass = body["class"];
|
|
52
|
+
const seen = body["first_seen"];
|
|
53
|
+
if (typeof server !== "string" ||
|
|
54
|
+
!server ||
|
|
55
|
+
typeof tool !== "string" ||
|
|
56
|
+
!tool ||
|
|
57
|
+
definition === null ||
|
|
58
|
+
typeof definition !== "object" ||
|
|
59
|
+
Array.isArray(definition) ||
|
|
60
|
+
typeof digest !== "string" ||
|
|
61
|
+
!digest ||
|
|
62
|
+
(klass !== CLASS_CHANGED && klass !== CLASS_FLOATING) ||
|
|
63
|
+
typeof seen !== "string" ||
|
|
64
|
+
!seen) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const key = body["launch_key"];
|
|
68
|
+
return {
|
|
69
|
+
serverId: server,
|
|
70
|
+
toolName: tool,
|
|
71
|
+
definition: definition,
|
|
72
|
+
definitionHash: digest,
|
|
73
|
+
pendingClass: klass,
|
|
74
|
+
firstSeen: seen,
|
|
75
|
+
launchKey: typeof key === "string" && key.length > 0 ? key : undefined,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function loadUnlocked(path) {
|
|
79
|
+
try {
|
|
80
|
+
const raw = JSON.parse(readFileSync(path, "utf8"));
|
|
81
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
82
|
+
return [];
|
|
83
|
+
const rows = raw["records"];
|
|
84
|
+
if (!Array.isArray(rows))
|
|
85
|
+
return [];
|
|
86
|
+
const out = [];
|
|
87
|
+
for (const row of rows) {
|
|
88
|
+
const rec = parseRecord(row);
|
|
89
|
+
if (rec !== null)
|
|
90
|
+
out.push(rec);
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function stableStringify(value) {
|
|
99
|
+
return JSON.stringify(sortKeys(value), null, 2) + "\n";
|
|
100
|
+
}
|
|
101
|
+
function sortKeys(value) {
|
|
102
|
+
if (Array.isArray(value))
|
|
103
|
+
return value.map(sortKeys);
|
|
104
|
+
if (value !== null && typeof value === "object") {
|
|
105
|
+
const out = {};
|
|
106
|
+
for (const key of Object.keys(value).sort()) {
|
|
107
|
+
out[key] = sortKeys(value[key]);
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
function dumpUnlocked(path, records) {
|
|
114
|
+
const payload = {
|
|
115
|
+
version: PENDING_VERSION,
|
|
116
|
+
records: records.map((rec) => {
|
|
117
|
+
const row = {
|
|
118
|
+
server_id: rec.serverId,
|
|
119
|
+
tool_name: rec.toolName,
|
|
120
|
+
definition: rec.definition,
|
|
121
|
+
definition_hash: rec.definitionHash,
|
|
122
|
+
class: rec.pendingClass,
|
|
123
|
+
first_seen: rec.firstSeen,
|
|
124
|
+
};
|
|
125
|
+
if (rec.launchKey)
|
|
126
|
+
row["launch_key"] = rec.launchKey;
|
|
127
|
+
return row;
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
const directory = dirname(path) || ".";
|
|
131
|
+
mkdirSync(directory, { recursive: true });
|
|
132
|
+
const suffix = randomBytes(8).toString("hex");
|
|
133
|
+
const tmp = join(directory, `.pending.${process.pid}.${suffix}.tmp`);
|
|
134
|
+
let flags = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL;
|
|
135
|
+
if (typeof constants.O_NOFOLLOW === "number") {
|
|
136
|
+
flags |= constants.O_NOFOLLOW;
|
|
137
|
+
}
|
|
138
|
+
const fd = openSync(tmp, flags, 0o600);
|
|
139
|
+
try {
|
|
140
|
+
writeSync(fd, Buffer.from(stableStringify(payload), "utf8"));
|
|
141
|
+
fsyncSync(fd);
|
|
142
|
+
closeSync(fd);
|
|
143
|
+
chmodSync(tmp, 0o600);
|
|
144
|
+
renameSync(tmp, path);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
try {
|
|
148
|
+
unlinkSync(tmp);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// already removed
|
|
152
|
+
}
|
|
153
|
+
throw err;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function cap(records) {
|
|
157
|
+
const ordered = [...records].sort((a, b) => {
|
|
158
|
+
if (a.firstSeen !== b.firstSeen)
|
|
159
|
+
return a.firstSeen < b.firstSeen ? -1 : 1;
|
|
160
|
+
if (a.serverId !== b.serverId)
|
|
161
|
+
return a.serverId < b.serverId ? -1 : 1;
|
|
162
|
+
return a.toolName < b.toolName ? -1 : a.toolName > b.toolName ? 1 : 0;
|
|
163
|
+
});
|
|
164
|
+
while (ordered.length > TOTAL_CAP)
|
|
165
|
+
ordered.shift();
|
|
166
|
+
const counts = new Map();
|
|
167
|
+
for (const rec of ordered)
|
|
168
|
+
counts.set(rec.serverId, (counts.get(rec.serverId) ?? 0) + 1);
|
|
169
|
+
while ([...counts.values()].some((n) => n > PER_SERVER_CAP)) {
|
|
170
|
+
for (let i = 0; i < ordered.length; i++) {
|
|
171
|
+
const rec = ordered[i];
|
|
172
|
+
if ((counts.get(rec.serverId) ?? 0) > PER_SERVER_CAP) {
|
|
173
|
+
counts.set(rec.serverId, (counts.get(rec.serverId) ?? 1) - 1);
|
|
174
|
+
ordered.splice(i, 1);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return ordered;
|
|
180
|
+
}
|
|
181
|
+
export function recordPending(path, args) {
|
|
182
|
+
if (args.pendingClass !== CLASS_CHANGED && args.pendingClass !== CLASS_FLOATING)
|
|
183
|
+
return;
|
|
184
|
+
if (!args.definitionHash)
|
|
185
|
+
return;
|
|
186
|
+
withExclusiveLock(path, () => {
|
|
187
|
+
const rows = loadUnlocked(path);
|
|
188
|
+
const kept = [];
|
|
189
|
+
let firstSeen = utcNowIso();
|
|
190
|
+
for (const rec of rows) {
|
|
191
|
+
if (rec.serverId === args.serverId &&
|
|
192
|
+
rec.toolName === args.toolName &&
|
|
193
|
+
rec.definitionHash === args.definitionHash) {
|
|
194
|
+
firstSeen = rec.firstSeen;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
kept.push(rec);
|
|
198
|
+
}
|
|
199
|
+
kept.push({
|
|
200
|
+
serverId: args.serverId,
|
|
201
|
+
toolName: args.toolName,
|
|
202
|
+
definition: args.definition,
|
|
203
|
+
definitionHash: args.definitionHash,
|
|
204
|
+
pendingClass: args.pendingClass,
|
|
205
|
+
firstSeen,
|
|
206
|
+
launchKey: args.launchKey,
|
|
207
|
+
});
|
|
208
|
+
dumpUnlocked(path, cap(kept));
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
export function loadPending(path) {
|
|
212
|
+
try {
|
|
213
|
+
readFileSync(path);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
return withExclusiveLock(path, () => loadUnlocked(path));
|
|
219
|
+
}
|
|
220
|
+
function pinRecord(pin, rec) {
|
|
221
|
+
try {
|
|
222
|
+
if (approvalDigest(rec.definition) !== rec.definitionHash) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
let pinHash;
|
|
230
|
+
try {
|
|
231
|
+
pinHash = hashTool(rec.definition);
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
const written = {
|
|
237
|
+
serverId: rec.serverId,
|
|
238
|
+
toolName: rec.toolName,
|
|
239
|
+
definitionHash: pinHash,
|
|
240
|
+
pinnedAt: utcNowIso(),
|
|
241
|
+
schema: rec.definition,
|
|
242
|
+
via: "approve",
|
|
243
|
+
launchKey: rec.launchKey,
|
|
244
|
+
contractFields: CONTRACT_FIELDS_VERSION,
|
|
245
|
+
};
|
|
246
|
+
pin.put(written);
|
|
247
|
+
return written;
|
|
248
|
+
}
|
|
249
|
+
export function approveOne(pin, path, serverId, toolName, definitionHash, opts) {
|
|
250
|
+
const match = withExclusiveLock(path, () => {
|
|
251
|
+
for (const rec of loadUnlocked(path)) {
|
|
252
|
+
if (rec.serverId === serverId &&
|
|
253
|
+
rec.toolName === toolName &&
|
|
254
|
+
rec.definitionHash === definitionHash) {
|
|
255
|
+
if (opts?.floatingOnly && rec.pendingClass !== CLASS_FLOATING)
|
|
256
|
+
return null;
|
|
257
|
+
return rec;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return null;
|
|
261
|
+
});
|
|
262
|
+
if (match === null)
|
|
263
|
+
return null;
|
|
264
|
+
const written = pinRecord(pin, match);
|
|
265
|
+
if (written === null)
|
|
266
|
+
return null;
|
|
267
|
+
withExclusiveLock(path, () => {
|
|
268
|
+
const remain = loadUnlocked(path).filter((rec) => !(rec.serverId === serverId &&
|
|
269
|
+
rec.toolName === toolName &&
|
|
270
|
+
rec.definitionHash === definitionHash));
|
|
271
|
+
dumpUnlocked(path, remain);
|
|
272
|
+
});
|
|
273
|
+
return written;
|
|
274
|
+
}
|
|
275
|
+
/** Basename helper kept for tests that inspect the pending file name. */
|
|
276
|
+
export function pendingFileName() {
|
|
277
|
+
return basename(NAME);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Delete one server's pin store and its ever-pinned record, and drop its
|
|
281
|
+
* pending rows. The next tools/list pins from the current contract.
|
|
282
|
+
*/
|
|
283
|
+
export function resetPins(serverId, opts) {
|
|
284
|
+
const path = opts?.path ?? defaultPinStorePath(serverId);
|
|
285
|
+
const before = new PreflightPin(path);
|
|
286
|
+
const pinCount = before.toolsFor(serverId).length;
|
|
287
|
+
const tainted = before.tainted;
|
|
288
|
+
withExclusiveLock(path, () => {
|
|
289
|
+
try {
|
|
290
|
+
unlinkSync(path);
|
|
291
|
+
}
|
|
292
|
+
catch {
|
|
293
|
+
// absent is fine
|
|
294
|
+
}
|
|
295
|
+
clearEverPinned(path);
|
|
296
|
+
});
|
|
297
|
+
const pending = pendingPath(defaultStateDir());
|
|
298
|
+
try {
|
|
299
|
+
withExclusiveLock(pending, () => {
|
|
300
|
+
const remain = loadUnlocked(pending).filter((rec) => rec.serverId !== serverId);
|
|
301
|
+
dumpUnlocked(pending, remain);
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
// no pending file is fine
|
|
306
|
+
}
|
|
307
|
+
return { path, pinCount, tainted };
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=pendingStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pendingStore.js","sourceRoot":"","sources":["../../src/pendingStore.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,SAAS,GAGV,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,MAAM,aAAa,GAAG,yBAAyB,CAAC;AACvD,M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C,OAAO,CAAC;IAC/B,iBAAiB,CAAC,IAAI,EAAE,GAAG,EAAE;QAC3B,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;QACD,eAAe,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC;IAC/C,IAAI,CAAC;QACH,iBAAiB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC9B,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;YAChF,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,0BAA0B;IAC5B,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
package/dist/src/preflight.d.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* `PreflightVerdict`). The pin stores ONLY the public-contract hash (+ optional
|
|
5
5
|
* PUBLIC schema for diff detail) — NEVER a token, by construction.
|
|
6
6
|
*/
|
|
7
|
-
import { hashTool } from "./canonical.js";
|
|
8
7
|
import type { Change } from "./schemaDiff.js";
|
|
9
8
|
import type { FleetAdvisory } from "./driftQuery.js";
|
|
10
9
|
export type ToolDef = Record<string, unknown>;
|
|
@@ -23,6 +22,17 @@ export interface PinnedTool {
|
|
|
23
22
|
readonly via?: string;
|
|
24
23
|
/** Kept so a pin written by the Python store is not stripped on the next flush. */
|
|
25
24
|
readonly classification?: unknown;
|
|
25
|
+
/**
|
|
26
|
+
* Exact launch key when the pin was written, for example ``npm:pkg@1.2.3``.
|
|
27
|
+
* Absent on pins written before this field; those behave as floating.
|
|
28
|
+
*/
|
|
29
|
+
readonly launchKey?: string;
|
|
30
|
+
/**
|
|
31
|
+
* 2 when `schema` holds every top-level field the server listed (see
|
|
32
|
+
* contractFields). Absent on older pins, whose missing fields are filled in
|
|
33
|
+
* from the first matching list instead of read as a change.
|
|
34
|
+
*/
|
|
35
|
+
readonly contractFields?: number;
|
|
26
36
|
}
|
|
27
37
|
export declare function utcNowIso(): string;
|
|
28
38
|
/** Tier 0a advisory action-classification — the READ-side mirror of the Python
|
|
@@ -135,29 +145,49 @@ export declare function safetyRelevantDrift(v: PreflightVerdict): Change[];
|
|
|
135
145
|
* Appends the M3 fleet advisory when present (AD-6-safe contract-diff note) — most
|
|
136
146
|
* valuable on a PROCEED that matches your pin but drifted for the fleet. */
|
|
137
147
|
export declare function renderVerdict(v: PreflightVerdict): string;
|
|
138
|
-
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
148
|
+
/** Pin store keyed by `(serverId, toolName)`. Stores ONLY hashes (+ optional
|
|
149
|
+
* PUBLIC schema). A path argument persists to JSON under a sibling flock so a
|
|
150
|
+
* Python CLI approval and another process cannot lose each other's writes. */
|
|
141
151
|
export declare class PreflightPin {
|
|
142
|
-
private
|
|
152
|
+
private index;
|
|
143
153
|
private taintedReason;
|
|
144
154
|
private newerFormat;
|
|
155
|
+
private diskSig;
|
|
145
156
|
/** On-disk baseline, or null for an in-memory pin. */
|
|
146
157
|
readonly path: string | null;
|
|
147
158
|
constructor(path?: string | null);
|
|
159
|
+
/**
|
|
160
|
+
* Taint the store when it holds no pins for `serverId` but has before.
|
|
161
|
+
*
|
|
162
|
+
* The constructor check only sees the whole file. A valid store that holds
|
|
163
|
+
* another server's pins passes it, so the per-server check runs once the
|
|
164
|
+
* server id is known (the Gate calls this). An index written before server
|
|
165
|
+
* ids were recorded never taints here.
|
|
166
|
+
*/
|
|
167
|
+
expectServer(serverId: string): void;
|
|
148
168
|
/** Closed reason when a baseline that should have been readable was not. */
|
|
149
169
|
get tainted(): string | null;
|
|
150
170
|
get unsupportedVersion(): boolean;
|
|
151
171
|
private key;
|
|
172
|
+
private lstatStore;
|
|
173
|
+
private signature;
|
|
174
|
+
private parsePin;
|
|
175
|
+
private loadIntoIndex;
|
|
176
|
+
private emptyStoreIsUnreadable;
|
|
177
|
+
private recordsFromDisk;
|
|
178
|
+
private reloadHoldingLock;
|
|
179
|
+
/** Reload when another process replaced the file. No-op for an in-memory pin. */
|
|
180
|
+
reloadIfChanged(): void;
|
|
152
181
|
get(serverId: string, toolName: string): PinnedTool | null;
|
|
153
182
|
put(pin: PinnedTool): void;
|
|
154
|
-
private load;
|
|
155
183
|
private flush;
|
|
156
184
|
toolsFor(serverId: string): PinnedTool[];
|
|
157
185
|
allPins(): PinnedTool[];
|
|
158
186
|
}
|
|
187
|
+
/** Remove ``storePath`` from the ever-pinned index. */
|
|
188
|
+
export declare function clearEverPinned(storePath: string): void;
|
|
159
189
|
export declare function sanitizeServerId(serverId: string): string;
|
|
160
190
|
/** Pin file for one server. `MCPINDEX_STATE_DIR/pins/<id>.json`, else `~/.mcpindex/pins/<id>.json`. */
|
|
161
191
|
export declare function defaultPinStorePath(serverId: string): string;
|
|
162
|
-
export { hashTool };
|
|
192
|
+
export { hashTool, approvalDigest } from "./canonical.js";
|
|
163
193
|
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/preflight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuBH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKrD,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;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