@ev-ai/agent-hook 1.3.1 → 1.3.2
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/COLLECTED-DATA.md +2 -2
- package/README.md +5 -4
- package/dist/cli.mjs +38 -37
- package/dist/hook.mjs +32 -31
- package/dist/launcher-update.mjs +2 -2
- package/dist/launcher.mjs +1 -1
- package/dist/managed-hooks-snippet.cjs +1299 -2
- package/dist/managed-hooks-snippet.mjs +1316 -2
- package/dist/plugin-hooks.mjs +6 -1
- package/package.json +1 -1
|
@@ -1,3 +1,1104 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
// ../composition-identity/dist/mcp-launch-identity.js
|
|
34
|
+
var require_mcp_launch_identity = __commonJS({
|
|
35
|
+
"../composition-identity/dist/mcp-launch-identity.js"(exports) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.MCP_MISSING_LAUNCH_SERIALIZED = exports.MCP_LAUNCH_IDENTITY_ALGORITHM = void 0;
|
|
39
|
+
exports.foldMcpName = foldMcpName;
|
|
40
|
+
exports.buildMcpFamilyCanonicalKey = buildMcpFamilyCanonicalKey;
|
|
41
|
+
exports.launchContainsCredentials = launchContainsCredentials;
|
|
42
|
+
exports.serializeMcpLaunchIdentity = serializeMcpLaunchIdentity;
|
|
43
|
+
exports.hashMcpLaunchIdentity = hashMcpLaunchIdentity;
|
|
44
|
+
exports.projectMcpMissingLaunchIdentity = projectMcpMissingLaunchIdentity;
|
|
45
|
+
exports.projectMcpLaunchIdentity = projectMcpLaunchIdentity;
|
|
46
|
+
exports.maskMcpLaunchForDisplay = maskMcpLaunchForDisplay;
|
|
47
|
+
exports.normalizeMcpToolNames = normalizeMcpToolNames;
|
|
48
|
+
var node_crypto_1 = __require("node:crypto");
|
|
49
|
+
exports.MCP_LAUNCH_IDENTITY_ALGORITHM = "mcp-launch-v1";
|
|
50
|
+
exports.MCP_MISSING_LAUNCH_SERIALIZED = `${exports.MCP_LAUNCH_IDENTITY_ALGORITHM}|missing`;
|
|
51
|
+
function foldCase(value) {
|
|
52
|
+
return value.toLocaleLowerCase("en-US");
|
|
53
|
+
}
|
|
54
|
+
function foldMcpName(nativeName) {
|
|
55
|
+
return foldCase(nativeName);
|
|
56
|
+
}
|
|
57
|
+
function buildMcpFamilyCanonicalKey(nativeName) {
|
|
58
|
+
return `interface:${foldMcpName(nativeName)}`;
|
|
59
|
+
}
|
|
60
|
+
var CREDENTIAL_QUERY_KEYS = /* @__PURE__ */ new Set([
|
|
61
|
+
"access_token",
|
|
62
|
+
"api_key",
|
|
63
|
+
"apikey",
|
|
64
|
+
"auth",
|
|
65
|
+
"authorization",
|
|
66
|
+
"key",
|
|
67
|
+
"password",
|
|
68
|
+
"secret",
|
|
69
|
+
"token"
|
|
70
|
+
]);
|
|
71
|
+
var LITERAL_TOKEN_ARGUMENT = /^(?:--?(?:token|api[-_]?key|password|secret|authorization)(?:=|\s+)|(?:sk-|ghp_|xox[baprs]-|Bearer\s+))/i;
|
|
72
|
+
function lengthPrefixed(value) {
|
|
73
|
+
return `${Buffer.byteLength(value, "utf8")}:${value}`;
|
|
74
|
+
}
|
|
75
|
+
function launchContainsCredentials(input) {
|
|
76
|
+
if (input.kind === "url") {
|
|
77
|
+
return urlContainsCredentials(input.url);
|
|
78
|
+
}
|
|
79
|
+
if (input.kind === "command") {
|
|
80
|
+
return input.arguments.some((argument) => LITERAL_TOKEN_ARGUMENT.test(argument));
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
function urlContainsCredentials(rawUrl) {
|
|
85
|
+
try {
|
|
86
|
+
const parsed = new URL(rawUrl);
|
|
87
|
+
if (parsed.username.length > 0 || parsed.password.length > 0) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
for (const key of parsed.searchParams.keys()) {
|
|
91
|
+
if (CREDENTIAL_QUERY_KEYS.has(foldCase(key))) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
} catch {
|
|
97
|
+
const schemeSplit = rawUrl.split("://", 2);
|
|
98
|
+
const afterScheme = schemeSplit.length === 2 ? schemeSplit[1] : rawUrl;
|
|
99
|
+
const atIndex = afterScheme.indexOf("@");
|
|
100
|
+
const slashIndex = afterScheme.indexOf("/");
|
|
101
|
+
if (atIndex > 0 && (slashIndex === -1 || atIndex < slashIndex)) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
const query = rawUrl.split("?", 2)[1];
|
|
105
|
+
if (query === void 0) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return query.split("&").some((pair) => {
|
|
109
|
+
const key = foldCase(pair.split("=", 1)[0] ?? "");
|
|
110
|
+
return CREDENTIAL_QUERY_KEYS.has(key);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function serializeMcpLaunchIdentity(input) {
|
|
115
|
+
if (input.kind === "url") {
|
|
116
|
+
return [
|
|
117
|
+
exports.MCP_LAUNCH_IDENTITY_ALGORITHM,
|
|
118
|
+
"url",
|
|
119
|
+
lengthPrefixed(foldCase(input.url))
|
|
120
|
+
].join("|");
|
|
121
|
+
}
|
|
122
|
+
if (input.kind === "command") {
|
|
123
|
+
const foldedArguments = [...input.arguments].map((argument) => foldCase(argument)).sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
124
|
+
return [
|
|
125
|
+
exports.MCP_LAUNCH_IDENTITY_ALGORITHM,
|
|
126
|
+
"command",
|
|
127
|
+
lengthPrefixed(foldCase(input.command)),
|
|
128
|
+
String(foldedArguments.length),
|
|
129
|
+
...foldedArguments.map(lengthPrefixed)
|
|
130
|
+
].join("|");
|
|
131
|
+
}
|
|
132
|
+
return [
|
|
133
|
+
exports.MCP_LAUNCH_IDENTITY_ALGORITHM,
|
|
134
|
+
"unknown",
|
|
135
|
+
lengthPrefixed(input.installationRootExternalKey),
|
|
136
|
+
lengthPrefixed(input.sourcePath),
|
|
137
|
+
lengthPrefixed(input.nativeKey)
|
|
138
|
+
].join("|");
|
|
139
|
+
}
|
|
140
|
+
function hashMcpLaunchIdentity(serialized) {
|
|
141
|
+
return (0, node_crypto_1.createHash)("sha256").update(serialized).digest("hex");
|
|
142
|
+
}
|
|
143
|
+
var MCP_MISSING_LAUNCH_CONTENT_HASH = hashMcpLaunchIdentity(exports.MCP_MISSING_LAUNCH_SERIALIZED);
|
|
144
|
+
function projectMcpMissingLaunchIdentity() {
|
|
145
|
+
return {
|
|
146
|
+
kind: "unknown",
|
|
147
|
+
arguments: [],
|
|
148
|
+
serialized: exports.MCP_MISSING_LAUNCH_SERIALIZED,
|
|
149
|
+
contentHash: MCP_MISSING_LAUNCH_CONTENT_HASH
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function projectMcpLaunchIdentity(input) {
|
|
153
|
+
const serialized = serializeMcpLaunchIdentity(input);
|
|
154
|
+
if (input.kind === "url") {
|
|
155
|
+
return {
|
|
156
|
+
kind: "url",
|
|
157
|
+
url: foldCase(input.url),
|
|
158
|
+
arguments: [],
|
|
159
|
+
serialized,
|
|
160
|
+
contentHash: hashMcpLaunchIdentity(serialized)
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (input.kind === "command") {
|
|
164
|
+
return {
|
|
165
|
+
kind: "command",
|
|
166
|
+
command: foldCase(input.command),
|
|
167
|
+
arguments: [...input.arguments].map((argument) => foldCase(argument)).sort((left, right) => left < right ? -1 : left > right ? 1 : 0),
|
|
168
|
+
serialized,
|
|
169
|
+
contentHash: hashMcpLaunchIdentity(serialized)
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
kind: "unknown",
|
|
174
|
+
arguments: [],
|
|
175
|
+
serialized,
|
|
176
|
+
contentHash: hashMcpLaunchIdentity(serialized)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
var CREDENTIAL_DISPLAY = /^(https?:\/\/)([^/?#]*@)/i;
|
|
180
|
+
function maskMcpLaunchForDisplay(value) {
|
|
181
|
+
return value.replace(CREDENTIAL_DISPLAY, "$1***@").replace(/([?&](?:access_token|api_key|apikey|auth|authorization|key|password|secret|token)=)([^&]*)/gi, "$1***");
|
|
182
|
+
}
|
|
183
|
+
function normalizeMcpToolNames(names) {
|
|
184
|
+
const seen = /* @__PURE__ */ new Set();
|
|
185
|
+
const unique = [];
|
|
186
|
+
for (const name of names) {
|
|
187
|
+
if (name.length === 0 || seen.has(name)) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
seen.add(name);
|
|
191
|
+
unique.push(name);
|
|
192
|
+
}
|
|
193
|
+
unique.sort((left, right) => left < right ? -1 : left > right ? 1 : 0);
|
|
194
|
+
return unique;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// ../composition-identity/dist/npx-package.js
|
|
200
|
+
var require_npx_package = __commonJS({
|
|
201
|
+
"../composition-identity/dist/npx-package.js"(exports) {
|
|
202
|
+
"use strict";
|
|
203
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
204
|
+
exports.PACKAGE_FIELD_MAX = void 0;
|
|
205
|
+
exports.npxExecBin = npxExecBin;
|
|
206
|
+
exports.packageNameFromSpec = packageNameFromSpec;
|
|
207
|
+
exports.pinnedPackageVersionFromSpec = pinnedPackageVersionFromSpec;
|
|
208
|
+
exports.pinnedPackageVersionFromNpx = pinnedPackageVersionFromNpx;
|
|
209
|
+
exports.npxPackageSpecs = npxPackageSpecs;
|
|
210
|
+
exports.PACKAGE_FIELD_MAX = 128;
|
|
211
|
+
var PACKAGE_NAME_RE = /^(?:@[A-Za-z0-9~-][A-Za-z0-9._~-]*\/)?[A-Za-z0-9~-][A-Za-z0-9._~-]*$/;
|
|
212
|
+
var PACKAGE_FLAGS = /* @__PURE__ */ new Set(["-p", "--package"]);
|
|
213
|
+
var CALL_FLAGS = /* @__PURE__ */ new Set(["-c", "--call"]);
|
|
214
|
+
var VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
215
|
+
"--registry",
|
|
216
|
+
"--userconfig",
|
|
217
|
+
"--globalconfig",
|
|
218
|
+
"--prefix",
|
|
219
|
+
"--cache",
|
|
220
|
+
"--node-options",
|
|
221
|
+
"--workspace",
|
|
222
|
+
"-w",
|
|
223
|
+
"--loglevel"
|
|
224
|
+
]);
|
|
225
|
+
var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
226
|
+
"-y",
|
|
227
|
+
"--yes",
|
|
228
|
+
"-n",
|
|
229
|
+
"--no",
|
|
230
|
+
"-q",
|
|
231
|
+
"-s",
|
|
232
|
+
"--quiet",
|
|
233
|
+
"--silent",
|
|
234
|
+
"--offline",
|
|
235
|
+
"--prefer-offline",
|
|
236
|
+
"--prefer-online",
|
|
237
|
+
"--ignore-existing",
|
|
238
|
+
"--ignore-scripts",
|
|
239
|
+
"--legacy-peer-deps",
|
|
240
|
+
"--foreground-scripts"
|
|
241
|
+
]);
|
|
242
|
+
var NEGATED_FLAG_RE = /^--no-/;
|
|
243
|
+
function booleanFlag(flag) {
|
|
244
|
+
return BOOLEAN_FLAGS.has(flag) || NEGATED_FLAG_RE.test(flag);
|
|
245
|
+
}
|
|
246
|
+
function npxExecBin(command) {
|
|
247
|
+
const base = command.replace(/\\/g, "/").split("/").pop() ?? "";
|
|
248
|
+
const bare = base.replace(/\.(cmd|exe|bat|ps1)$/i, "").toLowerCase();
|
|
249
|
+
if (bare === "npx") {
|
|
250
|
+
return "npx";
|
|
251
|
+
}
|
|
252
|
+
return bare === "npm" ? "npm" : null;
|
|
253
|
+
}
|
|
254
|
+
var EXACT_SEMVER_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
255
|
+
function packageNameFromSpec(spec) {
|
|
256
|
+
if (spec.length === 0 || spec.length > exports.PACKAGE_FIELD_MAX) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
const at = spec.lastIndexOf("@");
|
|
260
|
+
const name = at > 0 ? spec.slice(0, at) : spec;
|
|
261
|
+
return PACKAGE_NAME_RE.test(name) ? name : null;
|
|
262
|
+
}
|
|
263
|
+
function pinnedPackageVersionFromSpec(spec) {
|
|
264
|
+
const name = packageNameFromSpec(spec);
|
|
265
|
+
if (name === null || !spec.startsWith(`${name}@`)) {
|
|
266
|
+
return void 0;
|
|
267
|
+
}
|
|
268
|
+
const selector = spec.slice(name.length + 1);
|
|
269
|
+
return EXACT_SEMVER_RE.test(selector) ? selector : void 0;
|
|
270
|
+
}
|
|
271
|
+
function pinnedPackageVersionFromNpx(command, args) {
|
|
272
|
+
for (const spec of npxPackageSpecs(command, args)) {
|
|
273
|
+
const pinned = pinnedPackageVersionFromSpec(spec);
|
|
274
|
+
if (pinned !== void 0) {
|
|
275
|
+
return pinned;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return void 0;
|
|
279
|
+
}
|
|
280
|
+
function npxPackageSpecs(command, args) {
|
|
281
|
+
const bin = npxExecBin(command);
|
|
282
|
+
if (bin === null) {
|
|
283
|
+
return [];
|
|
284
|
+
}
|
|
285
|
+
let rest = [...args];
|
|
286
|
+
if (bin === "npm") {
|
|
287
|
+
const sub = rest[0]?.toLowerCase();
|
|
288
|
+
if (sub !== "exec" && sub !== "x") {
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
rest = rest.slice(1);
|
|
292
|
+
}
|
|
293
|
+
const explicit = [];
|
|
294
|
+
let firstPositional = null;
|
|
295
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
296
|
+
const token = rest[i] ?? "";
|
|
297
|
+
if (token === "--") {
|
|
298
|
+
firstPositional = rest[i + 1] ?? null;
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
if (!token.startsWith("-")) {
|
|
302
|
+
firstPositional = token;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
const eq = token.indexOf("=");
|
|
306
|
+
const flag = eq === -1 ? token : token.slice(0, eq);
|
|
307
|
+
if (CALL_FLAGS.has(flag)) {
|
|
308
|
+
return [];
|
|
309
|
+
}
|
|
310
|
+
if (PACKAGE_FLAGS.has(flag)) {
|
|
311
|
+
const value = eq === -1 ? rest[i + 1] : token.slice(eq + 1);
|
|
312
|
+
if (value !== void 0 && value.length > 0) {
|
|
313
|
+
explicit.push(value);
|
|
314
|
+
}
|
|
315
|
+
if (eq === -1) {
|
|
316
|
+
i += 1;
|
|
317
|
+
}
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (eq !== -1 || booleanFlag(flag)) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (VALUE_FLAGS.has(flag)) {
|
|
324
|
+
i += 1;
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
return [];
|
|
328
|
+
}
|
|
329
|
+
if (explicit.length > 0) {
|
|
330
|
+
return explicit.every((spec) => packageNameFromSpec(spec) !== null) ? explicit : [];
|
|
331
|
+
}
|
|
332
|
+
if (firstPositional === null || packageNameFromSpec(firstPositional) === null) {
|
|
333
|
+
return [];
|
|
334
|
+
}
|
|
335
|
+
return [firstPositional];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
// ../composition-identity/dist/mcp-package-identity.js
|
|
341
|
+
var require_mcp_package_identity = __commonJS({
|
|
342
|
+
"../composition-identity/dist/mcp-package-identity.js"(exports) {
|
|
343
|
+
"use strict";
|
|
344
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
345
|
+
exports.McpPackageEcosystem = void 0;
|
|
346
|
+
exports.resolveMcpPackageIdentity = resolveMcpPackageIdentity;
|
|
347
|
+
var mcp_launch_identity_js_1 = require_mcp_launch_identity();
|
|
348
|
+
var npx_package_js_1 = require_npx_package();
|
|
349
|
+
exports.McpPackageEcosystem = {
|
|
350
|
+
NPM: "npm",
|
|
351
|
+
PYPI: "pypi"
|
|
352
|
+
};
|
|
353
|
+
var NPM_EXACT_VERSION_RE = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/;
|
|
354
|
+
var PYPI_NAME_RE = /^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/;
|
|
355
|
+
var PYPI_EXACT_VERSION_RE = /^(?:\d+!)?\d+(?:\.\d+)*(?:(?:a|b|rc)\d+)?(?:\.post\d+)?(?:\.dev\d+)?(?:\+[0-9A-Za-z]+(?:[.][0-9A-Za-z]+)*)?$/;
|
|
356
|
+
function pythonRunnerBin(command) {
|
|
357
|
+
const base = command.replaceAll("\\", "/").split("/").pop() ?? "";
|
|
358
|
+
const bare = base.replace(/\.(cmd|exe|bat|ps1)$/i, "").toLowerCase();
|
|
359
|
+
if (bare === "uvx" || bare === "uv" || bare === "pipx") {
|
|
360
|
+
return bare;
|
|
361
|
+
}
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
var PYTHON_SPEC_FLAGS = /* @__PURE__ */ new Set(["--from", "--spec"]);
|
|
365
|
+
var PYTHON_VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
366
|
+
"--python",
|
|
367
|
+
"-p",
|
|
368
|
+
"--with",
|
|
369
|
+
"--with-editable",
|
|
370
|
+
"--with-requirements",
|
|
371
|
+
"--index",
|
|
372
|
+
"--index-url",
|
|
373
|
+
"--default-index",
|
|
374
|
+
"--extra-index-url",
|
|
375
|
+
"--find-links",
|
|
376
|
+
"-f",
|
|
377
|
+
"--constraint",
|
|
378
|
+
"-c",
|
|
379
|
+
"--override",
|
|
380
|
+
"--refresh-package",
|
|
381
|
+
"--cache-dir",
|
|
382
|
+
"--directory",
|
|
383
|
+
"--project",
|
|
384
|
+
"--config-file",
|
|
385
|
+
"--color",
|
|
386
|
+
"--exclude-newer",
|
|
387
|
+
"--pip-args",
|
|
388
|
+
"--verbose-pip"
|
|
389
|
+
]);
|
|
390
|
+
var PYTHON_BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
|
|
391
|
+
"-q",
|
|
392
|
+
"--quiet",
|
|
393
|
+
"-v",
|
|
394
|
+
"--verbose",
|
|
395
|
+
"-n",
|
|
396
|
+
"--native-tls",
|
|
397
|
+
"--offline",
|
|
398
|
+
"--isolated",
|
|
399
|
+
"--preview",
|
|
400
|
+
"--refresh",
|
|
401
|
+
"--reinstall",
|
|
402
|
+
"--upgrade",
|
|
403
|
+
"-U",
|
|
404
|
+
"--force",
|
|
405
|
+
"--system",
|
|
406
|
+
"--system-site-packages",
|
|
407
|
+
"--path",
|
|
408
|
+
"--managed-python",
|
|
409
|
+
"--progress"
|
|
410
|
+
]);
|
|
411
|
+
var NEGATED_FLAG_RE = /^--no-/;
|
|
412
|
+
function pythonRunnerSpec(command, args) {
|
|
413
|
+
const bin = pythonRunnerBin(command);
|
|
414
|
+
if (bin === null) {
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
let rest = [...args];
|
|
418
|
+
if (bin === "uv") {
|
|
419
|
+
if (rest[0]?.toLowerCase() !== "tool" || rest[1]?.toLowerCase() !== "run") {
|
|
420
|
+
return null;
|
|
421
|
+
}
|
|
422
|
+
rest = rest.slice(2);
|
|
423
|
+
} else if (bin === "pipx") {
|
|
424
|
+
if (rest[0]?.toLowerCase() !== "run") {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
427
|
+
rest = rest.slice(1);
|
|
428
|
+
}
|
|
429
|
+
let explicit = null;
|
|
430
|
+
let firstPositional = null;
|
|
431
|
+
for (let i = 0; i < rest.length; i += 1) {
|
|
432
|
+
const token = rest[i] ?? "";
|
|
433
|
+
if (token === "--") {
|
|
434
|
+
firstPositional = rest[i + 1] ?? null;
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
if (!token.startsWith("-")) {
|
|
438
|
+
firstPositional = token;
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
const eq = token.indexOf("=");
|
|
442
|
+
const flag = eq === -1 ? token : token.slice(0, eq);
|
|
443
|
+
if (PYTHON_SPEC_FLAGS.has(flag)) {
|
|
444
|
+
const value = eq === -1 ? rest[i + 1] : token.slice(eq + 1);
|
|
445
|
+
if (value !== void 0 && value.length > 0) {
|
|
446
|
+
explicit = value;
|
|
447
|
+
}
|
|
448
|
+
if (eq === -1) {
|
|
449
|
+
i += 1;
|
|
450
|
+
}
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
if (eq !== -1 || PYTHON_BOOLEAN_FLAGS.has(flag) || NEGATED_FLAG_RE.test(flag)) {
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (PYTHON_VALUE_FLAGS.has(flag)) {
|
|
457
|
+
i += 1;
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
return explicit ?? firstPositional;
|
|
463
|
+
}
|
|
464
|
+
function pypiIdentityFromSpec(spec) {
|
|
465
|
+
if (spec.length === 0 || spec.length > npx_package_js_1.PACKAGE_FIELD_MAX) {
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
const separator = spec.includes("==") ? "==" : spec.includes("@") ? "@" : null;
|
|
469
|
+
if (separator === null) {
|
|
470
|
+
return null;
|
|
471
|
+
}
|
|
472
|
+
const at = spec.indexOf(separator);
|
|
473
|
+
const name = spec.slice(0, at);
|
|
474
|
+
const version = spec.slice(at + separator.length);
|
|
475
|
+
if (!PYPI_NAME_RE.test(name) || !PYPI_EXACT_VERSION_RE.test(version)) {
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
return { ecosystem: exports.McpPackageEcosystem.PYPI, packageName: name, version };
|
|
479
|
+
}
|
|
480
|
+
function npmIdentityFromSpec(spec) {
|
|
481
|
+
const packageName = (0, npx_package_js_1.packageNameFromSpec)(spec);
|
|
482
|
+
if (packageName === null || !spec.startsWith(`${packageName}@`)) {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
const version = spec.slice(packageName.length + 1);
|
|
486
|
+
if (!NPM_EXACT_VERSION_RE.test(version)) {
|
|
487
|
+
return null;
|
|
488
|
+
}
|
|
489
|
+
return { ecosystem: exports.McpPackageEcosystem.NPM, packageName, version };
|
|
490
|
+
}
|
|
491
|
+
function resolveMcpPackageIdentity(launch) {
|
|
492
|
+
if (launch?.kind !== "command") {
|
|
493
|
+
return void 0;
|
|
494
|
+
}
|
|
495
|
+
if ((0, mcp_launch_identity_js_1.launchContainsCredentials)(launch)) {
|
|
496
|
+
return void 0;
|
|
497
|
+
}
|
|
498
|
+
for (const spec of (0, npx_package_js_1.npxPackageSpecs)(launch.command, launch.arguments)) {
|
|
499
|
+
const identity = npmIdentityFromSpec(spec);
|
|
500
|
+
if (identity !== null) {
|
|
501
|
+
return identity;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const pythonSpec = pythonRunnerSpec(launch.command, launch.arguments);
|
|
505
|
+
if (pythonSpec !== null) {
|
|
506
|
+
return pypiIdentityFromSpec(pythonSpec) ?? void 0;
|
|
507
|
+
}
|
|
508
|
+
return void 0;
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// ../composition-identity/dist/mcp-provenance.js
|
|
514
|
+
var require_mcp_provenance = __commonJS({
|
|
515
|
+
"../composition-identity/dist/mcp-provenance.js"(exports) {
|
|
516
|
+
"use strict";
|
|
517
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
518
|
+
exports.EMPTY_NPM_PUBLISHER = void 0;
|
|
519
|
+
exports.isNpmRegistryPublisher = isNpmRegistryPublisher;
|
|
520
|
+
exports.displayPublisherName = displayPublisherName;
|
|
521
|
+
exports.classifyMcpProvenance = classifyMcpProvenance;
|
|
522
|
+
var mcp_launch_identity_js_1 = require_mcp_launch_identity();
|
|
523
|
+
var npx_package_js_1 = require_npx_package();
|
|
524
|
+
exports.EMPTY_NPM_PUBLISHER = "npm:";
|
|
525
|
+
var NPM_ACCOUNT_PREFIX = "npm:";
|
|
526
|
+
var NPM_USERNAME_RE = /^[A-Za-z0-9._-]+$/;
|
|
527
|
+
function isNpmRegistryPublisher(name) {
|
|
528
|
+
return name.startsWith(NPM_ACCOUNT_PREFIX) && name !== exports.EMPTY_NPM_PUBLISHER && NPM_USERNAME_RE.test(name.slice(NPM_ACCOUNT_PREFIX.length));
|
|
529
|
+
}
|
|
530
|
+
function displayPublisherName(name) {
|
|
531
|
+
if (name == null || name === "" || name === exports.EMPTY_NPM_PUBLISHER) {
|
|
532
|
+
return void 0;
|
|
533
|
+
}
|
|
534
|
+
return name;
|
|
535
|
+
}
|
|
536
|
+
function privateIpv4(hostname) {
|
|
537
|
+
const parts = hostname.split(".").map(Number);
|
|
538
|
+
if (parts.length !== 4 || parts.some((part) => !Number.isInteger(part) || part < 0 || part > 255)) {
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
return parts[0] === 0 || parts[0] === 10 || parts[0] === 127 || parts[0] === 169 && parts[1] === 254 || parts[0] === 172 && (parts[1] ?? 0) >= 16 && (parts[1] ?? 0) <= 31 || parts[0] === 192 && parts[1] === 168;
|
|
542
|
+
}
|
|
543
|
+
function ipv4MappedAddress(host) {
|
|
544
|
+
const dotted = /^::ffff:(\d{1,3}(?:\.\d{1,3}){3})$/i.exec(host);
|
|
545
|
+
if (dotted?.[1]) {
|
|
546
|
+
return dotted[1];
|
|
547
|
+
}
|
|
548
|
+
const hex = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i.exec(host);
|
|
549
|
+
if (!hex) {
|
|
550
|
+
return void 0;
|
|
551
|
+
}
|
|
552
|
+
const high = Number.parseInt(hex[1], 16);
|
|
553
|
+
const low = Number.parseInt(hex[2], 16);
|
|
554
|
+
return `${high >> 8 & 255}.${high & 255}.${low >> 8 & 255}.${low & 255}`;
|
|
555
|
+
}
|
|
556
|
+
function normalizedHost(hostname) {
|
|
557
|
+
return hostname.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.$/, "");
|
|
558
|
+
}
|
|
559
|
+
function privateHostname(hostname) {
|
|
560
|
+
const host = normalizedHost(hostname);
|
|
561
|
+
const mappedIpv4 = ipv4MappedAddress(host);
|
|
562
|
+
return host === "localhost" || host.endsWith(".localhost") || host === "::1" || host.endsWith(".local") || // A single-label host resolves only through a local suffix search; it is
|
|
563
|
+
// never a public internet endpoint.
|
|
564
|
+
!host.includes(".") && !host.includes(":") || privateIpv4(host) || mappedIpv4 !== void 0 && privateIpv4(mappedIpv4) || /^(?:fc|fd)[0-9a-f]{2}:/i.test(host) || /^fe[89ab][0-9a-f]:/i.test(host);
|
|
565
|
+
}
|
|
566
|
+
function publisherHost(hostname) {
|
|
567
|
+
const host = normalizedHost(hostname);
|
|
568
|
+
if (host.includes(":") || /^[0-9.]+$/.test(host)) {
|
|
569
|
+
return null;
|
|
570
|
+
}
|
|
571
|
+
return host.split(".").filter(Boolean).length < 2 ? null : host;
|
|
572
|
+
}
|
|
573
|
+
function publicOrigin(url) {
|
|
574
|
+
const host = normalizedHost(url.hostname);
|
|
575
|
+
const hostname = host.includes(":") ? `[${host}]` : host;
|
|
576
|
+
const port = url.port ? `:${url.port}` : "";
|
|
577
|
+
return `${url.protocol}//${hostname}${port}`;
|
|
578
|
+
}
|
|
579
|
+
function classifyUrl(rawUrl) {
|
|
580
|
+
const launch = { kind: "url", url: rawUrl };
|
|
581
|
+
if ((0, mcp_launch_identity_js_1.launchContainsCredentials)(launch)) {
|
|
582
|
+
return { origin: "UNKNOWN" };
|
|
583
|
+
}
|
|
584
|
+
try {
|
|
585
|
+
const url = new URL(rawUrl);
|
|
586
|
+
if (!["http:", "https:"].includes(url.protocol) || privateHostname(url.hostname)) {
|
|
587
|
+
return { origin: "UNKNOWN" };
|
|
588
|
+
}
|
|
589
|
+
const publisherName = publisherHost(url.hostname);
|
|
590
|
+
return {
|
|
591
|
+
origin: "THIRD_PARTY",
|
|
592
|
+
...publisherName === null ? {} : { publisherName },
|
|
593
|
+
packageSourceUrl: publicOrigin(url)
|
|
594
|
+
};
|
|
595
|
+
} catch {
|
|
596
|
+
return { origin: "UNKNOWN" };
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
var MCP_REMOTE_PACKAGE = "mcp-remote";
|
|
600
|
+
function remoteUrlChild(packageName, args) {
|
|
601
|
+
if (packageName !== MCP_REMOTE_PACKAGE) {
|
|
602
|
+
return void 0;
|
|
603
|
+
}
|
|
604
|
+
return args.find((arg) => /^https?:\/\//i.test(arg));
|
|
605
|
+
}
|
|
606
|
+
function thirdPartyPackage(packageName, publisherName) {
|
|
607
|
+
return {
|
|
608
|
+
origin: "THIRD_PARTY",
|
|
609
|
+
...publisherName ? { publisherName } : {},
|
|
610
|
+
packageName,
|
|
611
|
+
packageKey: packageName
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
function classifyRegistryPackage(packageName, args, publisherName) {
|
|
615
|
+
const childUrl = remoteUrlChild(packageName, args);
|
|
616
|
+
if (childUrl !== void 0) {
|
|
617
|
+
return classifyUrl(childUrl);
|
|
618
|
+
}
|
|
619
|
+
if (packageName === MCP_REMOTE_PACKAGE) {
|
|
620
|
+
return { origin: "UNKNOWN" };
|
|
621
|
+
}
|
|
622
|
+
return thirdPartyPackage(packageName, publisherName);
|
|
623
|
+
}
|
|
624
|
+
function isRepoRelativeCommand(command) {
|
|
625
|
+
const normalized = command.replaceAll("\\", "/");
|
|
626
|
+
if (normalized.startsWith("~/") || normalized.startsWith("/") || /^[A-Za-z]:\//.test(normalized)) {
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
return normalized.startsWith("./") || normalized.startsWith("../") || normalized === "scripts" || normalized.startsWith("scripts/");
|
|
630
|
+
}
|
|
631
|
+
function classifyMcpProvenance(input) {
|
|
632
|
+
const launch = input.launch;
|
|
633
|
+
if (launch === void 0 || launch.kind === "unknown") {
|
|
634
|
+
return { origin: "UNKNOWN" };
|
|
635
|
+
}
|
|
636
|
+
if ((0, mcp_launch_identity_js_1.launchContainsCredentials)(launch)) {
|
|
637
|
+
return { origin: "UNKNOWN" };
|
|
638
|
+
}
|
|
639
|
+
if (launch.kind === "url") {
|
|
640
|
+
return classifyUrl(launch.url);
|
|
641
|
+
}
|
|
642
|
+
const specs = (0, npx_package_js_1.npxPackageSpecs)(launch.command, launch.arguments);
|
|
643
|
+
const spec = specs[0];
|
|
644
|
+
if (spec !== void 0) {
|
|
645
|
+
const parsedPackageName = (0, npx_package_js_1.packageNameFromSpec)(spec);
|
|
646
|
+
if (parsedPackageName === null) {
|
|
647
|
+
return { origin: "UNKNOWN" };
|
|
648
|
+
}
|
|
649
|
+
const classified = classifyRegistryPackage(parsedPackageName, launch.arguments, input.publisherName);
|
|
650
|
+
const hookPackageName = typeof input.packageName === "string" ? (0, npx_package_js_1.packageNameFromSpec)(input.packageName) : null;
|
|
651
|
+
if (hookPackageName !== null && hookPackageName === parsedPackageName && classified.packageName !== void 0) {
|
|
652
|
+
return {
|
|
653
|
+
...classified,
|
|
654
|
+
packageName: hookPackageName,
|
|
655
|
+
packageKey: hookPackageName
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
return classified;
|
|
659
|
+
}
|
|
660
|
+
if (isRepoRelativeCommand(launch.command)) {
|
|
661
|
+
return { origin: "INTERNAL" };
|
|
662
|
+
}
|
|
663
|
+
return { origin: "UNKNOWN" };
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
// ../composition-identity/dist/mcp-server-name.js
|
|
669
|
+
var require_mcp_server_name = __commonJS({
|
|
670
|
+
"../composition-identity/dist/mcp-server-name.js"(exports) {
|
|
671
|
+
"use strict";
|
|
672
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
673
|
+
exports.mcpServerToolSegmentForms = mcpServerToolSegmentForms2;
|
|
674
|
+
exports.mcpServerNameMatchesToolSegment = mcpServerNameMatchesToolSegment2;
|
|
675
|
+
function mcpServerToolSegmentForms2(name) {
|
|
676
|
+
return [
|
|
677
|
+
.../* @__PURE__ */ new Set([
|
|
678
|
+
name,
|
|
679
|
+
name.replaceAll(/[^A-Za-z0-9_-]/g, "_"),
|
|
680
|
+
name.replaceAll(/[^A-Za-z0-9_-]+/g, "_")
|
|
681
|
+
])
|
|
682
|
+
];
|
|
683
|
+
}
|
|
684
|
+
function mcpServerNameMatchesToolSegment2(name, segment) {
|
|
685
|
+
const lower = segment.toLowerCase();
|
|
686
|
+
return mcpServerToolSegmentForms2(name).some((form) => form.toLowerCase() === lower);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
|
|
691
|
+
// ../composition-identity/dist/catalog-text.js
|
|
692
|
+
var require_catalog_text = __commonJS({
|
|
693
|
+
"../composition-identity/dist/catalog-text.js"(exports) {
|
|
694
|
+
"use strict";
|
|
695
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
696
|
+
exports.parseFrontmatterField = exports.parseFrontmatterDescription = exports.usableCatalogText = void 0;
|
|
697
|
+
var YAML_BLOCK_SCALAR_TOKEN = /^(?:>|\|)[-+]?$/;
|
|
698
|
+
var YAML_BLOCK_HEADER = /^(?:>|\|)[-+]?(?:\s+(.*))?$/;
|
|
699
|
+
var usableCatalogText = (value) => {
|
|
700
|
+
const trimmed = value?.trim() ?? "";
|
|
701
|
+
if (trimmed.length === 0 || YAML_BLOCK_SCALAR_TOKEN.test(trimmed)) {
|
|
702
|
+
return void 0;
|
|
703
|
+
}
|
|
704
|
+
return trimmed;
|
|
705
|
+
};
|
|
706
|
+
exports.usableCatalogText = usableCatalogText;
|
|
707
|
+
var parseFrontmatterDescription = (content) => (0, exports.parseFrontmatterField)(content, "description");
|
|
708
|
+
exports.parseFrontmatterDescription = parseFrontmatterDescription;
|
|
709
|
+
var parseFrontmatterField = (content, field) => {
|
|
710
|
+
const match = /^---\s*\n([\s\S]*?)\n---/.exec(content);
|
|
711
|
+
if (!match) {
|
|
712
|
+
return void 0;
|
|
713
|
+
}
|
|
714
|
+
return parseYamlFrontmatterScalar(match[1], field);
|
|
715
|
+
};
|
|
716
|
+
exports.parseFrontmatterField = parseFrontmatterField;
|
|
717
|
+
var stripYamlQuotes = (value) => value.replace(/^["']|["']$/g, "");
|
|
718
|
+
function parseYamlFrontmatterScalar(block, field) {
|
|
719
|
+
const lines = block.split("\n");
|
|
720
|
+
const prefix = `${field}:`;
|
|
721
|
+
const start = lines.findIndex((line) => line === prefix || line.startsWith(`${prefix} `) || line.startsWith(`${prefix} `));
|
|
722
|
+
if (start < 0) {
|
|
723
|
+
return void 0;
|
|
724
|
+
}
|
|
725
|
+
const remainder = (lines[start] ?? "").slice(prefix.length).trim();
|
|
726
|
+
const header = YAML_BLOCK_HEADER.exec(remainder);
|
|
727
|
+
if (!header) {
|
|
728
|
+
const inline = stripYamlQuotes(remainder).trim();
|
|
729
|
+
return (0, exports.usableCatalogText)(inline);
|
|
730
|
+
}
|
|
731
|
+
const indented = [];
|
|
732
|
+
for (let index = start + 1; index < lines.length; index += 1) {
|
|
733
|
+
const line = lines[index] ?? "";
|
|
734
|
+
if (line.trim() === "") {
|
|
735
|
+
indented.push("");
|
|
736
|
+
continue;
|
|
737
|
+
}
|
|
738
|
+
if (line.length === line.trimStart().length) {
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
indented.push(line);
|
|
742
|
+
}
|
|
743
|
+
const blockIndent = indented.reduce((min, line) => line.trim() === "" ? min : Math.min(min, line.length - line.trimStart().length), Number.POSITIVE_INFINITY);
|
|
744
|
+
const body = [];
|
|
745
|
+
const sameLine = header[1]?.trim();
|
|
746
|
+
if (sameLine) {
|
|
747
|
+
body.push(sameLine);
|
|
748
|
+
}
|
|
749
|
+
for (const line of indented) {
|
|
750
|
+
body.push(line.trim() === "" ? "" : line.slice(blockIndent));
|
|
751
|
+
}
|
|
752
|
+
while (body.length > 0 && body[body.length - 1] === "") {
|
|
753
|
+
body.pop();
|
|
754
|
+
}
|
|
755
|
+
const folded = remainder.startsWith(">");
|
|
756
|
+
const text = folded ? body.join("\n").split(/\n{2,}/).map((paragraph) => paragraph.split("\n").map((line) => line.trim()).filter(Boolean).join(" ")).filter((paragraph) => paragraph.length > 0).join("\n\n") : body.join("\n").trimEnd();
|
|
757
|
+
return (0, exports.usableCatalogText)(text);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
// ../composition-identity/dist/skill-source-redaction.js
|
|
763
|
+
var require_skill_source_redaction = __commonJS({
|
|
764
|
+
"../composition-identity/dist/skill-source-redaction.js"(exports) {
|
|
765
|
+
"use strict";
|
|
766
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
767
|
+
exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES = exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES = exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER = void 0;
|
|
768
|
+
exports.fitSnapshotInspectionTextBudget = fitSnapshotInspectionTextBudget;
|
|
769
|
+
exports.capComponentTextBytes = capComponentTextBytes;
|
|
770
|
+
exports.prepareComponentInspectionText = prepareComponentInspectionText;
|
|
771
|
+
exports.redactComponentSource = redactComponentSource;
|
|
772
|
+
exports.componentSourceContainsRedactableSecret = componentSourceContainsRedactableSecret;
|
|
773
|
+
exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER = "[REDACTED]";
|
|
774
|
+
exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES = 256 * 1024;
|
|
775
|
+
exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES = 3 * 1024 * 1024;
|
|
776
|
+
function fitSnapshotInspectionTextBudget(definitions) {
|
|
777
|
+
let usedBytes = 0;
|
|
778
|
+
return definitions.map((definition) => {
|
|
779
|
+
const flat = definition;
|
|
780
|
+
const inspectionText = flat.skill?.inspectionText;
|
|
781
|
+
if (inspectionText === void 0)
|
|
782
|
+
return definition;
|
|
783
|
+
const byteLength = Buffer.byteLength(inspectionText, "utf8");
|
|
784
|
+
if (usedBytes + byteLength <= exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES) {
|
|
785
|
+
usedBytes += byteLength;
|
|
786
|
+
return definition;
|
|
787
|
+
}
|
|
788
|
+
return {
|
|
789
|
+
...definition,
|
|
790
|
+
skill: {
|
|
791
|
+
...flat.skill,
|
|
792
|
+
inspectionText: void 0
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
function capComponentTextBytes(text, maxBytes) {
|
|
798
|
+
if (text == null || text.length === 0) {
|
|
799
|
+
return void 0;
|
|
800
|
+
}
|
|
801
|
+
const buf = Buffer.from(text, "utf8");
|
|
802
|
+
if (buf.byteLength <= maxBytes) {
|
|
803
|
+
return text;
|
|
804
|
+
}
|
|
805
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
806
|
+
for (let end = maxBytes; end > 0; end -= 1) {
|
|
807
|
+
try {
|
|
808
|
+
return decoder.decode(buf.subarray(0, end));
|
|
809
|
+
} catch {
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return void 0;
|
|
813
|
+
}
|
|
814
|
+
function prepareComponentInspectionText(text) {
|
|
815
|
+
if (text == null || text.length === 0) {
|
|
816
|
+
return void 0;
|
|
817
|
+
}
|
|
818
|
+
return capComponentTextBytes(redactComponentSource(text), exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES);
|
|
819
|
+
}
|
|
820
|
+
var TOKEN_LITERAL_RES = [
|
|
821
|
+
// OpenAI-style and generic `sk-` / `sk-proj-` keys.
|
|
822
|
+
/\bsk-(?:proj-)?[A-Za-z0-9_-]{16,}/g,
|
|
823
|
+
// GitHub personal access, OAuth, user, server, and refresh tokens.
|
|
824
|
+
/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{20,}/g,
|
|
825
|
+
/\bgithub_pat_[A-Za-z0-9_]{20,}/g,
|
|
826
|
+
// Slack bot / user / app / refresh tokens.
|
|
827
|
+
/\bxox[baprs]-[A-Za-z0-9-]{10,}/g,
|
|
828
|
+
// AWS access key ids.
|
|
829
|
+
/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
|
|
830
|
+
// Google API keys.
|
|
831
|
+
/\bAIza[0-9A-Za-z_-]{35}\b/g,
|
|
832
|
+
// JWTs (three base64url segments).
|
|
833
|
+
/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
834
|
+
];
|
|
835
|
+
var BEARER_RE = /\b(Bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi;
|
|
836
|
+
var URL_USERINFO_RE = /\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@:]+):([^\s/@]*)@/gi;
|
|
837
|
+
var URL_CREDENTIAL_PARAM_RE = /([?&](?:access_token|api_key|apikey|auth|authorization|client_secret|key|password|secret|token)=)[^&\s"'<>]+/gi;
|
|
838
|
+
var PRIVATE_KEY_BEGIN_RE = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/;
|
|
839
|
+
var PRIVATE_KEY_END_RE = /-----END [A-Z0-9 ]*PRIVATE KEY-----/;
|
|
840
|
+
function redactLine(line) {
|
|
841
|
+
let redacted = line.replace(URL_USERINFO_RE, (_match, scheme) => `${scheme}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}:${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}@`);
|
|
842
|
+
redacted = redacted.replace(URL_CREDENTIAL_PARAM_RE, (_match, prefix) => `${prefix}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);
|
|
843
|
+
redacted = redacted.replace(BEARER_RE, (_match, prefix) => `${prefix}${exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER}`);
|
|
844
|
+
for (const pattern of TOKEN_LITERAL_RES) {
|
|
845
|
+
redacted = redacted.replace(pattern, exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER);
|
|
846
|
+
}
|
|
847
|
+
return redacted;
|
|
848
|
+
}
|
|
849
|
+
function redactComponentSource(text) {
|
|
850
|
+
if (text.length === 0) {
|
|
851
|
+
return text;
|
|
852
|
+
}
|
|
853
|
+
const lines = text.split("\n");
|
|
854
|
+
let insidePrivateKey = false;
|
|
855
|
+
const redacted = lines.map((line) => {
|
|
856
|
+
if (insidePrivateKey) {
|
|
857
|
+
if (PRIVATE_KEY_END_RE.test(line)) {
|
|
858
|
+
insidePrivateKey = false;
|
|
859
|
+
return line;
|
|
860
|
+
}
|
|
861
|
+
return line.trim().length === 0 ? line : exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER;
|
|
862
|
+
}
|
|
863
|
+
if (PRIVATE_KEY_BEGIN_RE.test(line) && !PRIVATE_KEY_END_RE.test(line)) {
|
|
864
|
+
insidePrivateKey = true;
|
|
865
|
+
return line;
|
|
866
|
+
}
|
|
867
|
+
return redactLine(line);
|
|
868
|
+
});
|
|
869
|
+
return redacted.join("\n");
|
|
870
|
+
}
|
|
871
|
+
function componentSourceContainsRedactableSecret(text) {
|
|
872
|
+
return redactComponentSource(text) !== text;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
// ../composition-identity/dist/index.js
|
|
878
|
+
var require_dist = __commonJS({
|
|
879
|
+
"../composition-identity/dist/index.js"(exports) {
|
|
880
|
+
"use strict";
|
|
881
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
882
|
+
exports.redactComponentSource = exports.prepareComponentInspectionText = exports.fitSnapshotInspectionTextBudget = exports.componentSourceContainsRedactableSecret = exports.capComponentTextBytes = exports.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES = exports.COMPONENT_SOURCE_REDACTION_PLACEHOLDER = exports.COMPONENT_INSPECTION_TEXT_MAX_BYTES = exports.usableCatalogText = exports.parseFrontmatterField = exports.parseFrontmatterDescription = exports.mcpServerToolSegmentForms = exports.mcpServerNameMatchesToolSegment = exports.isNpmRegistryPublisher = exports.EMPTY_NPM_PUBLISHER = exports.displayPublisherName = exports.classifyMcpProvenance = exports.resolveMcpPackageIdentity = exports.McpPackageEcosystem = exports.pinnedPackageVersionFromSpec = exports.pinnedPackageVersionFromNpx = exports.packageNameFromSpec = exports.npxPackageSpecs = exports.npxExecBin = exports.PACKAGE_FIELD_MAX = exports.serializeMcpLaunchIdentity = exports.projectMcpMissingLaunchIdentity = exports.projectMcpLaunchIdentity = exports.normalizeMcpToolNames = exports.MCP_MISSING_LAUNCH_SERIALIZED = exports.MCP_LAUNCH_IDENTITY_ALGORITHM = exports.maskMcpLaunchForDisplay = exports.launchContainsCredentials = exports.hashMcpLaunchIdentity = exports.foldMcpName = exports.buildMcpFamilyCanonicalKey = exports.ComponentKind = void 0;
|
|
883
|
+
exports.userConfigRootFromPath = userConfigRootFromPath;
|
|
884
|
+
exports.installationRootExternalKey = installationRootExternalKey;
|
|
885
|
+
exports.normalizeRepositoryRelativePath = normalizeRepositoryRelativePath;
|
|
886
|
+
exports.nativeKeyForSkillPath = nativeKeyForSkillPath;
|
|
887
|
+
exports.nativeKeyForRulePath = nativeKeyForRulePath2;
|
|
888
|
+
exports.nativeKeyForCommandPath = nativeKeyForCommandPath2;
|
|
889
|
+
exports.serializeComponentIdentity = serializeComponentIdentity;
|
|
890
|
+
exports.buildComponentReference = buildComponentReference;
|
|
891
|
+
exports.validateComponentReference = validateComponentReference;
|
|
892
|
+
var node_crypto_1 = __require("node:crypto");
|
|
893
|
+
var node_path_1 = __require("node:path");
|
|
894
|
+
var REFERENCE_PREFIX = "cmp1_";
|
|
895
|
+
var REFERENCE_PATTERN = /^cmp1_[A-Za-z0-9_-]{43}$/;
|
|
896
|
+
var SKILLS_DIR_MARKERS = ["/skills/", "/skills-cursor/"];
|
|
897
|
+
var RULE_PATH_RE = /(?:^|\/)\.(?:cursor|claude|codex)\/rules\/(.+)$/i;
|
|
898
|
+
var COMMAND_PATH_RE = /(?:^|\/)\.(?:cursor|claude|codex)\/(?:commands|prompts)\/(.+)$/i;
|
|
899
|
+
var USER_CONFIG_ROOTS = [".cursor", ".claude", ".codex"];
|
|
900
|
+
var USER_CONFIG_ROOT_ALIASES = {
|
|
901
|
+
".claude.json": ".claude",
|
|
902
|
+
".agents": ".codex"
|
|
903
|
+
};
|
|
904
|
+
exports.ComponentKind = {
|
|
905
|
+
SKILL: "SKILL",
|
|
906
|
+
INTERFACE: "INTERFACE",
|
|
907
|
+
RULE: "RULE",
|
|
908
|
+
COMMAND: "COMMAND"
|
|
909
|
+
};
|
|
910
|
+
function userConfigRootFromPath(path) {
|
|
911
|
+
const segments = path.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
912
|
+
const knownRoot = segments.find((segment) => USER_CONFIG_ROOTS.includes(segment));
|
|
913
|
+
if (knownRoot) {
|
|
914
|
+
return knownRoot;
|
|
915
|
+
}
|
|
916
|
+
const aliasedRoot = segments.map((segment) => USER_CONFIG_ROOT_ALIASES[segment]).find((root) => root !== void 0);
|
|
917
|
+
return aliasedRoot ?? "unknown";
|
|
918
|
+
}
|
|
919
|
+
function installationRootExternalKey(installationId, configRoot) {
|
|
920
|
+
return `runtime-install:${installationId}/${configRoot}`;
|
|
921
|
+
}
|
|
922
|
+
function requireValue(value, field2) {
|
|
923
|
+
if (value.length === 0) {
|
|
924
|
+
throw new Error(`${field2} is required`);
|
|
925
|
+
}
|
|
926
|
+
return value;
|
|
927
|
+
}
|
|
928
|
+
function normalizeRepositoryRelativePath(path) {
|
|
929
|
+
const slashPath = path.replaceAll("\\", "/");
|
|
930
|
+
if (slashPath.startsWith("/") || /^[A-Za-z]:\//.test(slashPath)) {
|
|
931
|
+
throw new Error("sourcePath must be repository-relative");
|
|
932
|
+
}
|
|
933
|
+
const normalized = node_path_1.posix.normalize(slashPath).replace(/^\.\//, "");
|
|
934
|
+
if (normalized === "." || normalized === ".." || normalized.startsWith("../")) {
|
|
935
|
+
throw new Error("sourcePath must be repository-relative");
|
|
936
|
+
}
|
|
937
|
+
return requireValue(normalized, "sourcePath");
|
|
938
|
+
}
|
|
939
|
+
function nativeKeyForSkillPath(path) {
|
|
940
|
+
const normalized = path.replaceAll("\\", "/");
|
|
941
|
+
for (const marker of SKILLS_DIR_MARKERS) {
|
|
942
|
+
const segment = normalized.split(marker)[1]?.split("/")[0];
|
|
943
|
+
if (segment && segment.length > 0) {
|
|
944
|
+
return segment;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
function nativeKeyUnderLayoutRoot(path, rootPattern, extensionPattern) {
|
|
950
|
+
const normalized = path.replaceAll("\\", "/");
|
|
951
|
+
const match = rootPattern.exec(normalized);
|
|
952
|
+
const rest = match?.[1];
|
|
953
|
+
if (!rest || rest.split("/").includes("..")) {
|
|
954
|
+
return null;
|
|
955
|
+
}
|
|
956
|
+
const stripped = rest.replace(extensionPattern, "");
|
|
957
|
+
return stripped.length > 0 ? stripped : null;
|
|
958
|
+
}
|
|
959
|
+
function nativeKeyForRulePath2(path) {
|
|
960
|
+
return nativeKeyUnderLayoutRoot(path, RULE_PATH_RE, /\.(mdc|md|rules)$/i);
|
|
961
|
+
}
|
|
962
|
+
function nativeKeyForCommandPath2(path) {
|
|
963
|
+
return nativeKeyUnderLayoutRoot(path, COMMAND_PATH_RE, /\.(md|mdc|toml)$/i);
|
|
964
|
+
}
|
|
965
|
+
function field(value) {
|
|
966
|
+
return `${Buffer.byteLength(value, "utf8")}:${value}`;
|
|
967
|
+
}
|
|
968
|
+
function serializeComponentIdentity(input) {
|
|
969
|
+
const values = [
|
|
970
|
+
requireValue(input.installationRootExternalKey, "installationRootExternalKey"),
|
|
971
|
+
requireValue(input.installableKind, "installableKind"),
|
|
972
|
+
normalizeRepositoryRelativePath(input.sourcePath),
|
|
973
|
+
requireValue(input.nativeKey, "nativeKey")
|
|
974
|
+
];
|
|
975
|
+
return Buffer.from(`1|${values.map(field).join("|")}`, "utf8");
|
|
976
|
+
}
|
|
977
|
+
function buildComponentReference(input) {
|
|
978
|
+
const digest = (0, node_crypto_1.createHash)("sha256").update(serializeComponentIdentity(input)).digest("base64url");
|
|
979
|
+
return `${REFERENCE_PREFIX}${digest}`;
|
|
980
|
+
}
|
|
981
|
+
function validateComponentReference(value) {
|
|
982
|
+
return REFERENCE_PATTERN.test(value);
|
|
983
|
+
}
|
|
984
|
+
var mcp_launch_identity_js_1 = require_mcp_launch_identity();
|
|
985
|
+
Object.defineProperty(exports, "buildMcpFamilyCanonicalKey", { enumerable: true, get: function() {
|
|
986
|
+
return mcp_launch_identity_js_1.buildMcpFamilyCanonicalKey;
|
|
987
|
+
} });
|
|
988
|
+
Object.defineProperty(exports, "foldMcpName", { enumerable: true, get: function() {
|
|
989
|
+
return mcp_launch_identity_js_1.foldMcpName;
|
|
990
|
+
} });
|
|
991
|
+
Object.defineProperty(exports, "hashMcpLaunchIdentity", { enumerable: true, get: function() {
|
|
992
|
+
return mcp_launch_identity_js_1.hashMcpLaunchIdentity;
|
|
993
|
+
} });
|
|
994
|
+
Object.defineProperty(exports, "launchContainsCredentials", { enumerable: true, get: function() {
|
|
995
|
+
return mcp_launch_identity_js_1.launchContainsCredentials;
|
|
996
|
+
} });
|
|
997
|
+
Object.defineProperty(exports, "maskMcpLaunchForDisplay", { enumerable: true, get: function() {
|
|
998
|
+
return mcp_launch_identity_js_1.maskMcpLaunchForDisplay;
|
|
999
|
+
} });
|
|
1000
|
+
Object.defineProperty(exports, "MCP_LAUNCH_IDENTITY_ALGORITHM", { enumerable: true, get: function() {
|
|
1001
|
+
return mcp_launch_identity_js_1.MCP_LAUNCH_IDENTITY_ALGORITHM;
|
|
1002
|
+
} });
|
|
1003
|
+
Object.defineProperty(exports, "MCP_MISSING_LAUNCH_SERIALIZED", { enumerable: true, get: function() {
|
|
1004
|
+
return mcp_launch_identity_js_1.MCP_MISSING_LAUNCH_SERIALIZED;
|
|
1005
|
+
} });
|
|
1006
|
+
Object.defineProperty(exports, "normalizeMcpToolNames", { enumerable: true, get: function() {
|
|
1007
|
+
return mcp_launch_identity_js_1.normalizeMcpToolNames;
|
|
1008
|
+
} });
|
|
1009
|
+
Object.defineProperty(exports, "projectMcpLaunchIdentity", { enumerable: true, get: function() {
|
|
1010
|
+
return mcp_launch_identity_js_1.projectMcpLaunchIdentity;
|
|
1011
|
+
} });
|
|
1012
|
+
Object.defineProperty(exports, "projectMcpMissingLaunchIdentity", { enumerable: true, get: function() {
|
|
1013
|
+
return mcp_launch_identity_js_1.projectMcpMissingLaunchIdentity;
|
|
1014
|
+
} });
|
|
1015
|
+
Object.defineProperty(exports, "serializeMcpLaunchIdentity", { enumerable: true, get: function() {
|
|
1016
|
+
return mcp_launch_identity_js_1.serializeMcpLaunchIdentity;
|
|
1017
|
+
} });
|
|
1018
|
+
var npx_package_js_1 = require_npx_package();
|
|
1019
|
+
Object.defineProperty(exports, "PACKAGE_FIELD_MAX", { enumerable: true, get: function() {
|
|
1020
|
+
return npx_package_js_1.PACKAGE_FIELD_MAX;
|
|
1021
|
+
} });
|
|
1022
|
+
Object.defineProperty(exports, "npxExecBin", { enumerable: true, get: function() {
|
|
1023
|
+
return npx_package_js_1.npxExecBin;
|
|
1024
|
+
} });
|
|
1025
|
+
Object.defineProperty(exports, "npxPackageSpecs", { enumerable: true, get: function() {
|
|
1026
|
+
return npx_package_js_1.npxPackageSpecs;
|
|
1027
|
+
} });
|
|
1028
|
+
Object.defineProperty(exports, "packageNameFromSpec", { enumerable: true, get: function() {
|
|
1029
|
+
return npx_package_js_1.packageNameFromSpec;
|
|
1030
|
+
} });
|
|
1031
|
+
Object.defineProperty(exports, "pinnedPackageVersionFromNpx", { enumerable: true, get: function() {
|
|
1032
|
+
return npx_package_js_1.pinnedPackageVersionFromNpx;
|
|
1033
|
+
} });
|
|
1034
|
+
Object.defineProperty(exports, "pinnedPackageVersionFromSpec", { enumerable: true, get: function() {
|
|
1035
|
+
return npx_package_js_1.pinnedPackageVersionFromSpec;
|
|
1036
|
+
} });
|
|
1037
|
+
var mcp_package_identity_js_1 = require_mcp_package_identity();
|
|
1038
|
+
Object.defineProperty(exports, "McpPackageEcosystem", { enumerable: true, get: function() {
|
|
1039
|
+
return mcp_package_identity_js_1.McpPackageEcosystem;
|
|
1040
|
+
} });
|
|
1041
|
+
Object.defineProperty(exports, "resolveMcpPackageIdentity", { enumerable: true, get: function() {
|
|
1042
|
+
return mcp_package_identity_js_1.resolveMcpPackageIdentity;
|
|
1043
|
+
} });
|
|
1044
|
+
var mcp_provenance_js_1 = require_mcp_provenance();
|
|
1045
|
+
Object.defineProperty(exports, "classifyMcpProvenance", { enumerable: true, get: function() {
|
|
1046
|
+
return mcp_provenance_js_1.classifyMcpProvenance;
|
|
1047
|
+
} });
|
|
1048
|
+
Object.defineProperty(exports, "displayPublisherName", { enumerable: true, get: function() {
|
|
1049
|
+
return mcp_provenance_js_1.displayPublisherName;
|
|
1050
|
+
} });
|
|
1051
|
+
Object.defineProperty(exports, "EMPTY_NPM_PUBLISHER", { enumerable: true, get: function() {
|
|
1052
|
+
return mcp_provenance_js_1.EMPTY_NPM_PUBLISHER;
|
|
1053
|
+
} });
|
|
1054
|
+
Object.defineProperty(exports, "isNpmRegistryPublisher", { enumerable: true, get: function() {
|
|
1055
|
+
return mcp_provenance_js_1.isNpmRegistryPublisher;
|
|
1056
|
+
} });
|
|
1057
|
+
var mcp_server_name_js_1 = require_mcp_server_name();
|
|
1058
|
+
Object.defineProperty(exports, "mcpServerNameMatchesToolSegment", { enumerable: true, get: function() {
|
|
1059
|
+
return mcp_server_name_js_1.mcpServerNameMatchesToolSegment;
|
|
1060
|
+
} });
|
|
1061
|
+
Object.defineProperty(exports, "mcpServerToolSegmentForms", { enumerable: true, get: function() {
|
|
1062
|
+
return mcp_server_name_js_1.mcpServerToolSegmentForms;
|
|
1063
|
+
} });
|
|
1064
|
+
var catalog_text_js_1 = require_catalog_text();
|
|
1065
|
+
Object.defineProperty(exports, "parseFrontmatterDescription", { enumerable: true, get: function() {
|
|
1066
|
+
return catalog_text_js_1.parseFrontmatterDescription;
|
|
1067
|
+
} });
|
|
1068
|
+
Object.defineProperty(exports, "parseFrontmatterField", { enumerable: true, get: function() {
|
|
1069
|
+
return catalog_text_js_1.parseFrontmatterField;
|
|
1070
|
+
} });
|
|
1071
|
+
Object.defineProperty(exports, "usableCatalogText", { enumerable: true, get: function() {
|
|
1072
|
+
return catalog_text_js_1.usableCatalogText;
|
|
1073
|
+
} });
|
|
1074
|
+
var skill_source_redaction_js_1 = require_skill_source_redaction();
|
|
1075
|
+
Object.defineProperty(exports, "COMPONENT_INSPECTION_TEXT_MAX_BYTES", { enumerable: true, get: function() {
|
|
1076
|
+
return skill_source_redaction_js_1.COMPONENT_INSPECTION_TEXT_MAX_BYTES;
|
|
1077
|
+
} });
|
|
1078
|
+
Object.defineProperty(exports, "COMPONENT_SOURCE_REDACTION_PLACEHOLDER", { enumerable: true, get: function() {
|
|
1079
|
+
return skill_source_redaction_js_1.COMPONENT_SOURCE_REDACTION_PLACEHOLDER;
|
|
1080
|
+
} });
|
|
1081
|
+
Object.defineProperty(exports, "SNAPSHOT_INSPECTION_TEXT_MAX_BYTES", { enumerable: true, get: function() {
|
|
1082
|
+
return skill_source_redaction_js_1.SNAPSHOT_INSPECTION_TEXT_MAX_BYTES;
|
|
1083
|
+
} });
|
|
1084
|
+
Object.defineProperty(exports, "capComponentTextBytes", { enumerable: true, get: function() {
|
|
1085
|
+
return skill_source_redaction_js_1.capComponentTextBytes;
|
|
1086
|
+
} });
|
|
1087
|
+
Object.defineProperty(exports, "componentSourceContainsRedactableSecret", { enumerable: true, get: function() {
|
|
1088
|
+
return skill_source_redaction_js_1.componentSourceContainsRedactableSecret;
|
|
1089
|
+
} });
|
|
1090
|
+
Object.defineProperty(exports, "fitSnapshotInspectionTextBudget", { enumerable: true, get: function() {
|
|
1091
|
+
return skill_source_redaction_js_1.fitSnapshotInspectionTextBudget;
|
|
1092
|
+
} });
|
|
1093
|
+
Object.defineProperty(exports, "prepareComponentInspectionText", { enumerable: true, get: function() {
|
|
1094
|
+
return skill_source_redaction_js_1.prepareComponentInspectionText;
|
|
1095
|
+
} });
|
|
1096
|
+
Object.defineProperty(exports, "redactComponentSource", { enumerable: true, get: function() {
|
|
1097
|
+
return skill_source_redaction_js_1.redactComponentSource;
|
|
1098
|
+
} });
|
|
1099
|
+
}
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1
1102
|
// src/launcher/constants.ts
|
|
2
1103
|
var READY_BYTE = Buffer.from([1]);
|
|
3
1104
|
var STDIN_BACKLOG_MAX = 1024 * 1024;
|
|
@@ -16,6 +1117,196 @@ function buildCollectorUrl(orgToken, baseUrl = DEFAULT_COLLECTOR_BASE_URL) {
|
|
|
16
1117
|
return `${normalizedBase}/${token}/hook`;
|
|
17
1118
|
}
|
|
18
1119
|
|
|
1120
|
+
// src/collectors/userSpec/layout.ts
|
|
1121
|
+
var RUNNER_LAYOUT = {
|
|
1122
|
+
claude: {
|
|
1123
|
+
shared: {
|
|
1124
|
+
skillRoots: [".claude/skills"],
|
|
1125
|
+
dirs: [
|
|
1126
|
+
{ dir: ".claude/agents", kind: "SUBAGENT", extensions: [".md"] },
|
|
1127
|
+
{ dir: ".claude/commands", kind: "COMMAND", extensions: [".md"] },
|
|
1128
|
+
{ dir: ".claude/rules", kind: "RULE", extensions: [".mdc", ".md"] }
|
|
1129
|
+
],
|
|
1130
|
+
// Claude's memory walk runs to the filesystem root, so a `~/CLAUDE.md`
|
|
1131
|
+
// covering every tree under home is in context and no project anchor
|
|
1132
|
+
// collects it (the parent walk stops before home).
|
|
1133
|
+
memory: [["CLAUDE.md"], ["CLAUDE.local.md"], [".claude/CLAUDE.md"]],
|
|
1134
|
+
// `remote-settings.json` is deliberately absent: it is the cached
|
|
1135
|
+
// server-managed payload, so it belongs to `managed` (which probes and
|
|
1136
|
+
// parses it) rather than to the operator's own settings.
|
|
1137
|
+
settings: [".claude/settings.json", ".claude/settings.local.json", ".claude/hooks.json"]
|
|
1138
|
+
},
|
|
1139
|
+
// The only field where the two scopes name different files rather than one
|
|
1140
|
+
// scope adding to the other: user MCP servers live in `~/.claude.json`,
|
|
1141
|
+
// project ones in a checked-in `.mcp.json` at the tree root.
|
|
1142
|
+
homeOnly: { mcpJson: [".claude.json"], plugins: "claude", managed: "claude" },
|
|
1143
|
+
projectOnly: { mcpJson: [".mcp.json", "mcp.json"] }
|
|
1144
|
+
},
|
|
1145
|
+
cursor: {
|
|
1146
|
+
shared: {
|
|
1147
|
+
skillRoots: [".cursor/skills"],
|
|
1148
|
+
dirs: [
|
|
1149
|
+
{ dir: ".cursor/agents", kind: "SUBAGENT", extensions: [".md"] },
|
|
1150
|
+
{ dir: ".cursor/commands", kind: "COMMAND", extensions: [".md"] },
|
|
1151
|
+
{ dir: ".cursor/rules", kind: "RULE", extensions: [".mdc", ".md"] }
|
|
1152
|
+
],
|
|
1153
|
+
memory: [["AGENTS.md"]],
|
|
1154
|
+
// Dedicated hooks file plus sandbox / permissions posture. CLI permissions
|
|
1155
|
+
// live in `cli-config.json` at home and `cli.json` at a project anchor —
|
|
1156
|
+
// see the scope deltas; Cursor never reads `cli-config.json` at project
|
|
1157
|
+
// scope.
|
|
1158
|
+
settings: [".cursor/hooks.json", ".cursor/sandbox.json", ".cursor/permissions.json"],
|
|
1159
|
+
mcpJson: [".cursor/mcp.json"]
|
|
1160
|
+
},
|
|
1161
|
+
// `skills-cursor` is the IDE-managed product-internal skills dir and never
|
|
1162
|
+
// appears in a repo; `.cursor/AGENTS.md` is a home-only memory location.
|
|
1163
|
+
homeOnly: {
|
|
1164
|
+
skillRoots: [".cursor/skills-cursor"],
|
|
1165
|
+
memory: [[".cursor/AGENTS.md"]],
|
|
1166
|
+
settings: [".cursor/cli-config.json"],
|
|
1167
|
+
plugins: "cursor",
|
|
1168
|
+
managed: "cursor"
|
|
1169
|
+
},
|
|
1170
|
+
projectOnly: { skillRoots: [".agents/skills"], settings: [".cursor/cli.json"] }
|
|
1171
|
+
},
|
|
1172
|
+
codex: {
|
|
1173
|
+
shared: {
|
|
1174
|
+
skillRoots: [".agents/skills", ".codex/skills"],
|
|
1175
|
+
dirs: [
|
|
1176
|
+
{ dir: ".codex/agents", kind: "SUBAGENT", extensions: [".toml", ".md"] },
|
|
1177
|
+
{ dir: ".codex/prompts", kind: "COMMAND", extensions: [".md"] },
|
|
1178
|
+
{ dir: ".codex/rules", kind: "RULE", extensions: [".md", ".rules"] }
|
|
1179
|
+
],
|
|
1180
|
+
memory: [["AGENTS.override.md", "AGENTS.md"]],
|
|
1181
|
+
// `managed_config.toml` is deliberately absent: it carries org defaults,
|
|
1182
|
+
// so it is probed by `managed` rather than counted as user settings.
|
|
1183
|
+
settings: [".codex/hooks.json", ".codex/config.toml"],
|
|
1184
|
+
mcpToml: [".codex/config.toml"]
|
|
1185
|
+
},
|
|
1186
|
+
homeOnly: { memory: [[".codex/AGENTS.override.md", ".codex/AGENTS.md"]], managed: "codex" }
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
function concatOptional(shared, delta) {
|
|
1190
|
+
if (!shared && !delta) {
|
|
1191
|
+
return void 0;
|
|
1192
|
+
}
|
|
1193
|
+
return [...shared ?? [], ...delta ?? []];
|
|
1194
|
+
}
|
|
1195
|
+
function layoutForScope(runner, delta = {}) {
|
|
1196
|
+
const { shared } = runner;
|
|
1197
|
+
return {
|
|
1198
|
+
skillRoots: [...shared.skillRoots, ...delta.skillRoots ?? []],
|
|
1199
|
+
dirs: shared.dirs,
|
|
1200
|
+
memory: [...shared.memory, ...delta.memory ?? []],
|
|
1201
|
+
settings: [...shared.settings, ...delta.settings ?? []],
|
|
1202
|
+
mcpJson: concatOptional(shared.mcpJson, delta.mcpJson),
|
|
1203
|
+
mcpToml: concatOptional(shared.mcpToml, delta.mcpToml),
|
|
1204
|
+
plugins: delta.plugins ?? shared.plugins,
|
|
1205
|
+
managed: delta.managed ?? shared.managed
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
function layoutsForScope(scope) {
|
|
1209
|
+
return Object.fromEntries(
|
|
1210
|
+
Object.entries(RUNNER_LAYOUT).map(([runner, entry]) => [
|
|
1211
|
+
runner,
|
|
1212
|
+
layoutForScope(entry, entry[scope])
|
|
1213
|
+
])
|
|
1214
|
+
);
|
|
1215
|
+
}
|
|
1216
|
+
var PLATFORM_USER_LAYOUT = layoutsForScope("homeOnly");
|
|
1217
|
+
var PLATFORM_PROJECT_LAYOUT = layoutsForScope("projectOnly");
|
|
1218
|
+
function uniqueRels(rels) {
|
|
1219
|
+
return [...new Set(rels)];
|
|
1220
|
+
}
|
|
1221
|
+
function userScopePathsFromLayouts(layouts) {
|
|
1222
|
+
const skills = [];
|
|
1223
|
+
const subagents = [];
|
|
1224
|
+
const commands = [];
|
|
1225
|
+
const rules = [];
|
|
1226
|
+
const memory = [];
|
|
1227
|
+
const settings = [];
|
|
1228
|
+
const mcp = [];
|
|
1229
|
+
for (const layout of layouts) {
|
|
1230
|
+
skills.push(...layout.skillRoots);
|
|
1231
|
+
for (const entry of layout.dirs) {
|
|
1232
|
+
if (entry.kind === "SUBAGENT") {
|
|
1233
|
+
subagents.push(entry.dir);
|
|
1234
|
+
} else if (entry.kind === "COMMAND") {
|
|
1235
|
+
commands.push(entry.dir);
|
|
1236
|
+
} else {
|
|
1237
|
+
rules.push(entry.dir);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
memory.push(...layout.memory.flat());
|
|
1241
|
+
settings.push(...layout.settings);
|
|
1242
|
+
mcp.push(...layout.mcpJson ?? [], ...layout.mcpToml ?? []);
|
|
1243
|
+
}
|
|
1244
|
+
return {
|
|
1245
|
+
skills: uniqueRels(skills),
|
|
1246
|
+
subagents: uniqueRels(subagents),
|
|
1247
|
+
commands: uniqueRels(commands),
|
|
1248
|
+
rules: uniqueRels(rules),
|
|
1249
|
+
memory: uniqueRels(memory),
|
|
1250
|
+
settings: uniqueRels(settings),
|
|
1251
|
+
mcp: uniqueRels(mcp)
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
var USER_SCOPE_PATHS = userScopePathsFromLayouts(
|
|
1255
|
+
Object.values(PLATFORM_USER_LAYOUT)
|
|
1256
|
+
);
|
|
1257
|
+
|
|
1258
|
+
// src/extract/layout-resolve.ts
|
|
1259
|
+
function uniqueOrderedRoots(preferred, available) {
|
|
1260
|
+
const remaining = new Set(available);
|
|
1261
|
+
const ordered = [];
|
|
1262
|
+
for (const root of preferred) {
|
|
1263
|
+
if (remaining.delete(root)) {
|
|
1264
|
+
ordered.push(root);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
for (const root of [...remaining].sort()) {
|
|
1268
|
+
ordered.push(root);
|
|
1269
|
+
}
|
|
1270
|
+
return ordered;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// src/extract/skill-extract.ts
|
|
1274
|
+
var PROJECT_SKILL_ROOT_ORDER = [".cursor/skills", ".claude/skills", ".agents/skills"];
|
|
1275
|
+
var USER_SKILL_ROOT_ORDER = [
|
|
1276
|
+
".cursor/skills",
|
|
1277
|
+
".cursor/skills-cursor",
|
|
1278
|
+
".claude/skills",
|
|
1279
|
+
".agents/skills"
|
|
1280
|
+
];
|
|
1281
|
+
var PROJECT_SKILL_ROOTS = uniqueOrderedRoots(
|
|
1282
|
+
PROJECT_SKILL_ROOT_ORDER,
|
|
1283
|
+
userScopePathsFromLayouts(Object.values(PLATFORM_PROJECT_LAYOUT)).skills
|
|
1284
|
+
);
|
|
1285
|
+
var USER_SKILL_ROOTS = uniqueOrderedRoots(
|
|
1286
|
+
USER_SKILL_ROOT_ORDER,
|
|
1287
|
+
userScopePathsFromLayouts(Object.values(PLATFORM_USER_LAYOUT)).skills
|
|
1288
|
+
);
|
|
1289
|
+
|
|
1290
|
+
// src/extract/rule-extract.ts
|
|
1291
|
+
var import_composition_identity = __toESM(require_dist(), 1);
|
|
1292
|
+
var RULE_LAYOUT_ROOTS = userScopePathsFromLayouts(Object.values(PLATFORM_PROJECT_LAYOUT)).rules;
|
|
1293
|
+
|
|
1294
|
+
// src/extract/command-extract.ts
|
|
1295
|
+
var import_composition_identity2 = __toESM(require_dist(), 1);
|
|
1296
|
+
var COMMAND_LAYOUT_ROOTS = userScopePathsFromLayouts(
|
|
1297
|
+
Object.values(PLATFORM_PROJECT_LAYOUT)
|
|
1298
|
+
).commands;
|
|
1299
|
+
|
|
1300
|
+
// src/hook/runner.ts
|
|
1301
|
+
var import_composition_identity3 = __toESM(require_dist(), 1);
|
|
1302
|
+
function isInProcessEvent(runnerEvent, platform) {
|
|
1303
|
+
const lower = runnerEvent.toLowerCase();
|
|
1304
|
+
if (lower === "sessionend" || lower === "stopfailure" || lower === "subagentstop") {
|
|
1305
|
+
return true;
|
|
1306
|
+
}
|
|
1307
|
+
return lower === "stop" && platform === "codex";
|
|
1308
|
+
}
|
|
1309
|
+
|
|
19
1310
|
// src/shared/constants.ts
|
|
20
1311
|
var HOOK_BINARY_NAME = "ev-ai-agent-hook";
|
|
21
1312
|
var HOOK_CHECKSUMS_FILE = "SHA256SUMS";
|
|
@@ -25,10 +1316,15 @@ var HOOK_INPUT_ALLOWLIST_MAX_BYTES = 4 * 1024;
|
|
|
25
1316
|
var HOOK_INPUT_FULL_MAX_BYTES = 256 * 1024;
|
|
26
1317
|
var HOOK_INPUT_MCP_MAX_BYTES = 4 * 1024;
|
|
27
1318
|
var GZIP_MIN_BYTES = 32 * 1024;
|
|
28
|
-
var PACKAGE_VERSION = "1.3.
|
|
1319
|
+
var PACKAGE_VERSION = "1.3.2";
|
|
29
1320
|
var NPX_PACKAGE_SPEC = `@ev-ai/agent-hook@${PACKAGE_VERSION}`;
|
|
30
1321
|
var HOOK_STATUS_MESSAGE = "ev-ai runtime report";
|
|
31
1322
|
|
|
1323
|
+
// src/config/hook-config.ts
|
|
1324
|
+
var HOOK_CONFIG_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
1325
|
+
var HOOK_CONFIG_FETCHED_AT_BUMP_MS = 24 * 60 * 60 * 1e3;
|
|
1326
|
+
var HOOK_CONFIG_FILE_MAX_BYTES = 1024 * 1024;
|
|
1327
|
+
|
|
32
1328
|
// src/install/install.ts
|
|
33
1329
|
function isSessionStartEvent(eventName) {
|
|
34
1330
|
return eventName === "SessionStart" || eventName === "sessionStart";
|
|
@@ -148,12 +1444,30 @@ var PLUGIN_PAYLOAD_FILES = [
|
|
|
148
1444
|
];
|
|
149
1445
|
|
|
150
1446
|
// src/install/managed-hooks-snippet.ts
|
|
1447
|
+
var CLAUDE_MANAGED_HOOK_TIMEOUT_SECONDS = 5;
|
|
1448
|
+
var CLAUDE_MANAGED_SESSION_START_TIMEOUT_SECONDS = 10;
|
|
1449
|
+
function withClaudeManagedHookLimits(doc) {
|
|
1450
|
+
const hooks = {};
|
|
1451
|
+
for (const [eventName, groups] of Object.entries(doc.hooks)) {
|
|
1452
|
+
const timeout = isSessionStartEvent(eventName) ? CLAUDE_MANAGED_SESSION_START_TIMEOUT_SECONDS : CLAUDE_MANAGED_HOOK_TIMEOUT_SECONDS;
|
|
1453
|
+
const limits = isInProcessEvent(eventName, "claude") ? { timeout } : { timeout, async: true };
|
|
1454
|
+
hooks[eventName] = groups.map(
|
|
1455
|
+
(group) => ({
|
|
1456
|
+
...group,
|
|
1457
|
+
hooks: (group.hooks ?? []).map((entry) => ({ ...entry, ...limits }))
|
|
1458
|
+
})
|
|
1459
|
+
);
|
|
1460
|
+
}
|
|
1461
|
+
return { hooks };
|
|
1462
|
+
}
|
|
151
1463
|
function managedHooksSnippet(runner, collectorUrl) {
|
|
152
1464
|
const command = withUrlFlag(withRunnerFlag(npxHookCommand(), runner), collectorUrl);
|
|
153
|
-
const doc = runner === "cursor" ? { version: 1, ...buildCursorPluginHooks(command) } : runner === "claude" ? buildClaudePluginHooks(command) : buildCodexPluginHooks(command);
|
|
1465
|
+
const doc = runner === "cursor" ? { version: 1, ...buildCursorPluginHooks(command) } : runner === "claude" ? withClaudeManagedHookLimits(buildClaudePluginHooks(command)) : buildCodexPluginHooks(command);
|
|
154
1466
|
return JSON.stringify(doc, null, 2);
|
|
155
1467
|
}
|
|
156
1468
|
export {
|
|
1469
|
+
CLAUDE_MANAGED_HOOK_TIMEOUT_SECONDS,
|
|
1470
|
+
CLAUDE_MANAGED_SESSION_START_TIMEOUT_SECONDS,
|
|
157
1471
|
buildCollectorUrl,
|
|
158
1472
|
managedHooksSnippet
|
|
159
1473
|
};
|