@mcp-index/sdk 0.14.1 → 0.16.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 +26 -0
- package/README.md +53 -22
- package/dist/src/canonical.d.ts +7 -0
- package/dist/src/canonical.d.ts.map +1 -1
- package/dist/src/canonical.js +56 -0
- package/dist/src/canonical.js.map +1 -1
- 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 +23 -3
- package/dist/src/gate.d.ts.map +1 -1
- package/dist/src/gate.js +56 -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 +41 -0
- package/dist/src/listingFilter.d.ts.map +1 -0
- package/dist/src/listingFilter.js +186 -0
- package/dist/src/listingFilter.js.map +1 -0
- package/dist/src/pendingStore.d.ts +53 -0
- package/dist/src/pendingStore.d.ts.map +1 -0
- package/dist/src/pendingStore.js +307 -0
- package/dist/src/pendingStore.js.map +1 -0
- package/dist/src/preflight.d.ts +49 -6
- package/dist/src/preflight.d.ts.map +1 -1
- package/dist/src/preflight.js +487 -6
- package/dist/src/preflight.js.map +1 -1
- package/dist/src/wrap.d.ts +27 -14
- package/dist/src/wrap.d.ts.map +1 -1
- package/dist/src/wrap.js +196 -19
- 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;AAoBH,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;AA6BD,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,307 @@
|
|
|
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 { randomBytes } from "node:crypto";
|
|
10
|
+
import { chmodSync, closeSync, constants, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeSync, } from "node:fs";
|
|
11
|
+
import { tmpdir, homedir } from "node:os";
|
|
12
|
+
import { basename, dirname, join } from "node:path";
|
|
13
|
+
import { withExclusiveLock } from "./fileLock.js";
|
|
14
|
+
import { approvalDigest, hashTool } from "./canonical.js";
|
|
15
|
+
import { PreflightPin, clearEverPinned, defaultPinStorePath, utcNowIso, } from "./preflight.js";
|
|
16
|
+
export const CLASS_CHANGED = "changed-without-upgrade";
|
|
17
|
+
export const CLASS_FLOATING = "floating";
|
|
18
|
+
const PENDING_VERSION = 1;
|
|
19
|
+
export const PER_SERVER_CAP = 64;
|
|
20
|
+
export const TOTAL_CAP = 512;
|
|
21
|
+
const NAME = "pending.json";
|
|
22
|
+
export function pendingPath(stateDirectory) {
|
|
23
|
+
return join(stateDirectory, NAME);
|
|
24
|
+
}
|
|
25
|
+
/** State directory for pending.json. Mirrors ``defaultPinStorePath`` root. */
|
|
26
|
+
export function defaultStateDir() {
|
|
27
|
+
const fromEnv = process.env.MCPINDEX_STATE_DIR;
|
|
28
|
+
if (typeof fromEnv === "string" && fromEnv.trim().length > 0)
|
|
29
|
+
return fromEnv;
|
|
30
|
+
if (process.execArgv.includes("--test") || process.argv.includes("--test")) {
|
|
31
|
+
return join(tmpdir(), "mcpindex-sdk-test", String(process.pid));
|
|
32
|
+
}
|
|
33
|
+
return join(homedir(), ".mcpindex");
|
|
34
|
+
}
|
|
35
|
+
export function pendingClass(prior) {
|
|
36
|
+
const keys = prior.map((pin) => pin.launchKey).filter((k) => typeof k === "string" && k.length > 0);
|
|
37
|
+
if (prior.length > 0 && keys.length === prior.length && new Set(keys).size === 1) {
|
|
38
|
+
return CLASS_CHANGED;
|
|
39
|
+
}
|
|
40
|
+
return CLASS_FLOATING;
|
|
41
|
+
}
|
|
42
|
+
function parseRecord(row) {
|
|
43
|
+
if (row === null || typeof row !== "object" || Array.isArray(row))
|
|
44
|
+
return null;
|
|
45
|
+
const body = row;
|
|
46
|
+
const server = body["server_id"];
|
|
47
|
+
const tool = body["tool_name"];
|
|
48
|
+
const definition = body["definition"];
|
|
49
|
+
const digest = body["definition_hash"];
|
|
50
|
+
const klass = body["class"];
|
|
51
|
+
const seen = body["first_seen"];
|
|
52
|
+
if (typeof server !== "string" ||
|
|
53
|
+
!server ||
|
|
54
|
+
typeof tool !== "string" ||
|
|
55
|
+
!tool ||
|
|
56
|
+
definition === null ||
|
|
57
|
+
typeof definition !== "object" ||
|
|
58
|
+
Array.isArray(definition) ||
|
|
59
|
+
typeof digest !== "string" ||
|
|
60
|
+
!digest ||
|
|
61
|
+
(klass !== CLASS_CHANGED && klass !== CLASS_FLOATING) ||
|
|
62
|
+
typeof seen !== "string" ||
|
|
63
|
+
!seen) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
const key = body["launch_key"];
|
|
67
|
+
return {
|
|
68
|
+
serverId: server,
|
|
69
|
+
toolName: tool,
|
|
70
|
+
definition: definition,
|
|
71
|
+
definitionHash: digest,
|
|
72
|
+
pendingClass: klass,
|
|
73
|
+
firstSeen: seen,
|
|
74
|
+
launchKey: typeof key === "string" && key.length > 0 ? key : undefined,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function loadUnlocked(path) {
|
|
78
|
+
try {
|
|
79
|
+
const raw = JSON.parse(readFileSync(path, "utf8"));
|
|
80
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
81
|
+
return [];
|
|
82
|
+
const rows = raw["records"];
|
|
83
|
+
if (!Array.isArray(rows))
|
|
84
|
+
return [];
|
|
85
|
+
const out = [];
|
|
86
|
+
for (const row of rows) {
|
|
87
|
+
const rec = parseRecord(row);
|
|
88
|
+
if (rec !== null)
|
|
89
|
+
out.push(rec);
|
|
90
|
+
}
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function stableStringify(value) {
|
|
98
|
+
return JSON.stringify(sortKeys(value), null, 2) + "\n";
|
|
99
|
+
}
|
|
100
|
+
function sortKeys(value) {
|
|
101
|
+
if (Array.isArray(value))
|
|
102
|
+
return value.map(sortKeys);
|
|
103
|
+
if (value !== null && typeof value === "object") {
|
|
104
|
+
const out = {};
|
|
105
|
+
for (const key of Object.keys(value).sort()) {
|
|
106
|
+
out[key] = sortKeys(value[key]);
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
function dumpUnlocked(path, records) {
|
|
113
|
+
const payload = {
|
|
114
|
+
version: PENDING_VERSION,
|
|
115
|
+
records: records.map((rec) => {
|
|
116
|
+
const row = {
|
|
117
|
+
server_id: rec.serverId,
|
|
118
|
+
tool_name: rec.toolName,
|
|
119
|
+
definition: rec.definition,
|
|
120
|
+
definition_hash: rec.definitionHash,
|
|
121
|
+
class: rec.pendingClass,
|
|
122
|
+
first_seen: rec.firstSeen,
|
|
123
|
+
};
|
|
124
|
+
if (rec.launchKey)
|
|
125
|
+
row["launch_key"] = rec.launchKey;
|
|
126
|
+
return row;
|
|
127
|
+
}),
|
|
128
|
+
};
|
|
129
|
+
const directory = dirname(path) || ".";
|
|
130
|
+
mkdirSync(directory, { recursive: true });
|
|
131
|
+
const suffix = randomBytes(8).toString("hex");
|
|
132
|
+
const tmp = join(directory, `.pending.${process.pid}.${suffix}.tmp`);
|
|
133
|
+
let flags = constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL;
|
|
134
|
+
if (typeof constants.O_NOFOLLOW === "number") {
|
|
135
|
+
flags |= constants.O_NOFOLLOW;
|
|
136
|
+
}
|
|
137
|
+
const fd = openSync(tmp, flags, 0o600);
|
|
138
|
+
try {
|
|
139
|
+
writeSync(fd, Buffer.from(stableStringify(payload), "utf8"));
|
|
140
|
+
fsyncSync(fd);
|
|
141
|
+
closeSync(fd);
|
|
142
|
+
chmodSync(tmp, 0o600);
|
|
143
|
+
renameSync(tmp, path);
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
try {
|
|
147
|
+
unlinkSync(tmp);
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
// already removed
|
|
151
|
+
}
|
|
152
|
+
throw err;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function cap(records) {
|
|
156
|
+
const ordered = [...records].sort((a, b) => {
|
|
157
|
+
if (a.firstSeen !== b.firstSeen)
|
|
158
|
+
return a.firstSeen < b.firstSeen ? -1 : 1;
|
|
159
|
+
if (a.serverId !== b.serverId)
|
|
160
|
+
return a.serverId < b.serverId ? -1 : 1;
|
|
161
|
+
return a.toolName < b.toolName ? -1 : a.toolName > b.toolName ? 1 : 0;
|
|
162
|
+
});
|
|
163
|
+
while (ordered.length > TOTAL_CAP)
|
|
164
|
+
ordered.shift();
|
|
165
|
+
const counts = new Map();
|
|
166
|
+
for (const rec of ordered)
|
|
167
|
+
counts.set(rec.serverId, (counts.get(rec.serverId) ?? 0) + 1);
|
|
168
|
+
while ([...counts.values()].some((n) => n > PER_SERVER_CAP)) {
|
|
169
|
+
for (let i = 0; i < ordered.length; i++) {
|
|
170
|
+
const rec = ordered[i];
|
|
171
|
+
if ((counts.get(rec.serverId) ?? 0) > PER_SERVER_CAP) {
|
|
172
|
+
counts.set(rec.serverId, (counts.get(rec.serverId) ?? 1) - 1);
|
|
173
|
+
ordered.splice(i, 1);
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return ordered;
|
|
179
|
+
}
|
|
180
|
+
export function recordPending(path, args) {
|
|
181
|
+
if (args.pendingClass !== CLASS_CHANGED && args.pendingClass !== CLASS_FLOATING)
|
|
182
|
+
return;
|
|
183
|
+
if (!args.definitionHash)
|
|
184
|
+
return;
|
|
185
|
+
withExclusiveLock(path, () => {
|
|
186
|
+
const rows = loadUnlocked(path);
|
|
187
|
+
const kept = [];
|
|
188
|
+
let firstSeen = utcNowIso();
|
|
189
|
+
for (const rec of rows) {
|
|
190
|
+
if (rec.serverId === args.serverId &&
|
|
191
|
+
rec.toolName === args.toolName &&
|
|
192
|
+
rec.definitionHash === args.definitionHash) {
|
|
193
|
+
firstSeen = rec.firstSeen;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
kept.push(rec);
|
|
197
|
+
}
|
|
198
|
+
kept.push({
|
|
199
|
+
serverId: args.serverId,
|
|
200
|
+
toolName: args.toolName,
|
|
201
|
+
definition: args.definition,
|
|
202
|
+
definitionHash: args.definitionHash,
|
|
203
|
+
pendingClass: args.pendingClass,
|
|
204
|
+
firstSeen,
|
|
205
|
+
launchKey: args.launchKey,
|
|
206
|
+
});
|
|
207
|
+
dumpUnlocked(path, cap(kept));
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
export function loadPending(path) {
|
|
211
|
+
try {
|
|
212
|
+
readFileSync(path);
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
return withExclusiveLock(path, () => loadUnlocked(path));
|
|
218
|
+
}
|
|
219
|
+
function pinRecord(pin, rec) {
|
|
220
|
+
try {
|
|
221
|
+
if (approvalDigest(rec.definition) !== rec.definitionHash) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
let pinHash;
|
|
229
|
+
try {
|
|
230
|
+
pinHash = hashTool(rec.definition);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
const written = {
|
|
236
|
+
serverId: rec.serverId,
|
|
237
|
+
toolName: rec.toolName,
|
|
238
|
+
definitionHash: pinHash,
|
|
239
|
+
pinnedAt: utcNowIso(),
|
|
240
|
+
schema: rec.definition,
|
|
241
|
+
via: "approve",
|
|
242
|
+
launchKey: rec.launchKey,
|
|
243
|
+
};
|
|
244
|
+
pin.put(written);
|
|
245
|
+
return written;
|
|
246
|
+
}
|
|
247
|
+
export function approveOne(pin, path, serverId, toolName, definitionHash, opts) {
|
|
248
|
+
const match = withExclusiveLock(path, () => {
|
|
249
|
+
for (const rec of loadUnlocked(path)) {
|
|
250
|
+
if (rec.serverId === serverId &&
|
|
251
|
+
rec.toolName === toolName &&
|
|
252
|
+
rec.definitionHash === definitionHash) {
|
|
253
|
+
if (opts?.floatingOnly && rec.pendingClass !== CLASS_FLOATING)
|
|
254
|
+
return null;
|
|
255
|
+
return rec;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
});
|
|
260
|
+
if (match === null)
|
|
261
|
+
return null;
|
|
262
|
+
const written = pinRecord(pin, match);
|
|
263
|
+
if (written === null)
|
|
264
|
+
return null;
|
|
265
|
+
withExclusiveLock(path, () => {
|
|
266
|
+
const remain = loadUnlocked(path).filter((rec) => !(rec.serverId === serverId &&
|
|
267
|
+
rec.toolName === toolName &&
|
|
268
|
+
rec.definitionHash === definitionHash));
|
|
269
|
+
dumpUnlocked(path, remain);
|
|
270
|
+
});
|
|
271
|
+
return written;
|
|
272
|
+
}
|
|
273
|
+
/** Basename helper kept for tests that inspect the pending file name. */
|
|
274
|
+
export function pendingFileName() {
|
|
275
|
+
return basename(NAME);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Delete one server's pin store and its ever-pinned record, and drop its
|
|
279
|
+
* pending rows. The next tools/list pins from the current contract.
|
|
280
|
+
*/
|
|
281
|
+
export function resetPins(serverId, opts) {
|
|
282
|
+
const path = opts?.path ?? defaultPinStorePath(serverId);
|
|
283
|
+
const before = new PreflightPin(path);
|
|
284
|
+
const pinCount = before.toolsFor(serverId).length;
|
|
285
|
+
const tainted = before.tainted;
|
|
286
|
+
withExclusiveLock(path, () => {
|
|
287
|
+
try {
|
|
288
|
+
unlinkSync(path);
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
// absent is fine
|
|
292
|
+
}
|
|
293
|
+
clearEverPinned(path);
|
|
294
|
+
});
|
|
295
|
+
const pending = pendingPath(defaultStateDir());
|
|
296
|
+
try {
|
|
297
|
+
withExclusiveLock(pending, () => {
|
|
298
|
+
const remain = loadUnlocked(pending).filter((rec) => rec.serverId !== serverId);
|
|
299
|
+
dumpUnlocked(pending, remain);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
// no pending file is fine
|
|
304
|
+
}
|
|
305
|
+
return { path, pinCount, tainted };
|
|
306
|
+
}
|
|
307
|
+
//# 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,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,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AAEzC,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,MAAM,IAAI,GAAG,cAAc,CAAC;AAY5B,MAAM,UAAU,WAAW,CAAC,cAAsB;I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C,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>;
|
|
@@ -19,6 +18,15 @@ export interface PinnedTool {
|
|
|
19
18
|
readonly definitionHash: string;
|
|
20
19
|
readonly pinnedAt: string;
|
|
21
20
|
readonly schema: ToolDef | null;
|
|
21
|
+
/** Omitted on disk when it is the first-seen baseline, so a Python pin round-trips. */
|
|
22
|
+
readonly via?: string;
|
|
23
|
+
/** Kept so a pin written by the Python store is not stripped on the next flush. */
|
|
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;
|
|
22
30
|
}
|
|
23
31
|
export declare function utcNowIso(): string;
|
|
24
32
|
/** Tier 0a advisory action-classification — the READ-side mirror of the Python
|
|
@@ -120,6 +128,8 @@ export interface PreflightVerdict {
|
|
|
120
128
|
* observation across the fleet, not a safety claim. null when the fleet query is off
|
|
121
129
|
* (opt-in), the tool is clean, or the answer is unknown. */
|
|
122
130
|
readonly fleetAdvisory: FleetAdvisory | null;
|
|
131
|
+
/** Set when the baseline file could not be read. Posture must not downgrade it. */
|
|
132
|
+
readonly tamperEvidence?: boolean;
|
|
123
133
|
}
|
|
124
134
|
export declare function makeVerdict(v: Pick<PreflightVerdict, "serverId" | "toolName" | "decision" | "reason"> & Partial<PreflightVerdict>): PreflightVerdict;
|
|
125
135
|
export declare function isProceed(v: PreflightVerdict): boolean;
|
|
@@ -129,16 +139,49 @@ export declare function safetyRelevantDrift(v: PreflightVerdict): Change[];
|
|
|
129
139
|
* Appends the M3 fleet advisory when present (AD-6-safe contract-diff note) — most
|
|
130
140
|
* valuable on a PROCEED that matches your pin but drifted for the fleet. */
|
|
131
141
|
export declare function renderVerdict(v: PreflightVerdict): string;
|
|
132
|
-
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
142
|
+
/** Pin store keyed by `(serverId, toolName)`. Stores ONLY hashes (+ optional
|
|
143
|
+
* PUBLIC schema). A path argument persists to JSON under a sibling flock so a
|
|
144
|
+
* Python CLI approval and another process cannot lose each other's writes. */
|
|
135
145
|
export declare class PreflightPin {
|
|
136
|
-
private
|
|
146
|
+
private index;
|
|
147
|
+
private taintedReason;
|
|
148
|
+
private newerFormat;
|
|
149
|
+
private diskSig;
|
|
150
|
+
/** On-disk baseline, or null for an in-memory pin. */
|
|
151
|
+
readonly path: string | null;
|
|
152
|
+
constructor(path?: string | null);
|
|
153
|
+
/**
|
|
154
|
+
* Taint the store when it holds no pins for `serverId` but has before.
|
|
155
|
+
*
|
|
156
|
+
* The constructor check only sees the whole file. A valid store that holds
|
|
157
|
+
* another server's pins passes it, so the per-server check runs once the
|
|
158
|
+
* server id is known (the Gate calls this). An index written before server
|
|
159
|
+
* ids were recorded never taints here.
|
|
160
|
+
*/
|
|
161
|
+
expectServer(serverId: string): void;
|
|
162
|
+
/** Closed reason when a baseline that should have been readable was not. */
|
|
163
|
+
get tainted(): string | null;
|
|
164
|
+
get unsupportedVersion(): boolean;
|
|
137
165
|
private key;
|
|
166
|
+
private lstatStore;
|
|
167
|
+
private signature;
|
|
168
|
+
private parsePin;
|
|
169
|
+
private loadIntoIndex;
|
|
170
|
+
private emptyStoreIsUnreadable;
|
|
171
|
+
private recordsFromDisk;
|
|
172
|
+
private reloadHoldingLock;
|
|
173
|
+
/** Reload when another process replaced the file. No-op for an in-memory pin. */
|
|
174
|
+
reloadIfChanged(): void;
|
|
138
175
|
get(serverId: string, toolName: string): PinnedTool | null;
|
|
139
176
|
put(pin: PinnedTool): void;
|
|
177
|
+
private flush;
|
|
140
178
|
toolsFor(serverId: string): PinnedTool[];
|
|
141
179
|
allPins(): PinnedTool[];
|
|
142
180
|
}
|
|
143
|
-
|
|
181
|
+
/** Remove ``storePath`` from the ever-pinned index. */
|
|
182
|
+
export declare function clearEverPinned(storePath: string): void;
|
|
183
|
+
export declare function sanitizeServerId(serverId: string): string;
|
|
184
|
+
/** Pin file for one server. `MCPINDEX_STATE_DIR/pins/<id>.json`, else `~/.mcpindex/pins/<id>.json`. */
|
|
185
|
+
export declare function defaultPinStorePath(serverId: string): string;
|
|
186
|
+
export { hashTool, approvalDigest } from "./canonical.js";
|
|
144
187
|
//# 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;AAsBH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKrD,MA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