@agntn/registries 0.3.0 → 0.3.1
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/README.md +26 -3
- package/dist/THIRD-PARTY-LICENSES.md +36 -0
- package/dist/_chunks/cache.mjs +15 -0
- package/dist/{cache/index.mjs.map → _chunks/cache.mjs.map} +1 -1
- package/dist/{commands/cache.mjs → _chunks/cache2.mjs} +6 -8
- package/dist/_chunks/cache2.mjs.map +1 -0
- package/dist/{cache → _chunks}/cached-registry.mjs +12 -8
- package/dist/_chunks/cached-registry.mjs.map +1 -0
- package/dist/{commands → _chunks}/deps.mjs +19 -13
- package/dist/_chunks/deps.mjs.map +1 -0
- package/dist/_chunks/helpers.mjs +53 -19
- package/dist/_chunks/helpers.mjs.map +1 -1
- package/dist/_chunks/index.d.mts +9 -23
- package/dist/_chunks/index.d.mts.map +1 -1
- package/dist/_chunks/index2.d.mts +181 -0
- package/dist/_chunks/index2.d.mts.map +1 -0
- package/dist/_chunks/index3.d.mts +188 -0
- package/dist/_chunks/index3.d.mts.map +1 -0
- package/dist/_chunks/info.mjs +105 -0
- package/dist/_chunks/info.mjs.map +1 -0
- package/dist/_chunks/libs/typebox.mjs +278 -0
- package/dist/_chunks/libs/typebox.mjs.map +1 -0
- package/dist/_chunks/lockfile.mjs +183 -0
- package/dist/_chunks/lockfile.mjs.map +1 -0
- package/dist/_chunks/maintainers.mjs +53 -0
- package/dist/_chunks/maintainers.mjs.map +1 -0
- package/dist/_chunks/mcp.mjs +15 -0
- package/dist/_chunks/mcp.mjs.map +1 -0
- package/dist/_chunks/registries.mjs +514 -245
- package/dist/_chunks/registries.mjs.map +1 -1
- package/dist/_chunks/registry.d.mts +121 -10
- package/dist/_chunks/registry.d.mts.map +1 -1
- package/dist/_chunks/registry.mjs +121 -31
- package/dist/_chunks/registry.mjs.map +1 -1
- package/dist/{commands → _chunks}/shared.mjs +15 -8
- package/dist/_chunks/shared.mjs.map +1 -0
- package/dist/_chunks/tool-operations.mjs +63 -0
- package/dist/_chunks/tool-operations.mjs.map +1 -0
- package/dist/_chunks/version.mjs +4 -0
- package/dist/_chunks/version.mjs.map +1 -0
- package/dist/{commands → _chunks}/versions.mjs +10 -9
- package/dist/_chunks/versions.mjs.map +1 -0
- package/dist/ai.d.mts +4 -4
- package/dist/ai.mjs +0 -1
- package/dist/ai.mjs.map +1 -1
- package/dist/cache/index.d.mts +3 -23
- package/dist/cache/index.mjs +4 -11
- package/dist/cli.mjs +9 -7
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +4 -56
- package/dist/index.mjs +4 -7
- package/dist/mcp.d.mts +7 -0
- package/dist/mcp.d.mts.map +1 -0
- package/dist/mcp.mjs +155 -0
- package/dist/mcp.mjs.map +1 -0
- package/dist/registries/index.d.mts +0 -1
- package/dist/registries/index.mjs +0 -1
- package/dist/tool-operations.d.mts +36 -0
- package/dist/tool-operations.d.mts.map +1 -0
- package/dist/tool-operations.mjs +5 -0
- package/package.json +55 -9
- package/packages/omp/extensions/registries.ts +112 -0
- package/packages/pi/extensions/registries.ts +125 -0
- package/dist/_chunks/errors.d.mts +0 -90
- package/dist/_chunks/errors.d.mts.map +0 -1
- package/dist/_chunks/purl.mjs +0 -200
- package/dist/_chunks/purl.mjs.map +0 -1
- package/dist/_chunks/types.d.mts +0 -73
- package/dist/_chunks/types.d.mts.map +0 -1
- package/dist/cache/cached-registry.d.mts +0 -35
- package/dist/cache/cached-registry.d.mts.map +0 -1
- package/dist/cache/cached-registry.mjs.map +0 -1
- package/dist/cache/index.d.mts.map +0 -1
- package/dist/cache/lockfile.d.mts +0 -50
- package/dist/cache/lockfile.d.mts.map +0 -1
- package/dist/cache/lockfile.mjs +0 -68
- package/dist/cache/lockfile.mjs.map +0 -1
- package/dist/cache/paths.d.mts +0 -11
- package/dist/cache/paths.d.mts.map +0 -1
- package/dist/cache/paths.mjs +0 -26
- package/dist/cache/paths.mjs.map +0 -1
- package/dist/cache/storage.d.mts +0 -22
- package/dist/cache/storage.d.mts.map +0 -1
- package/dist/cache/storage.mjs +0 -40
- package/dist/cache/storage.mjs.map +0 -1
- package/dist/commands/cache.d.mts +0 -7
- package/dist/commands/cache.d.mts.map +0 -1
- package/dist/commands/cache.mjs.map +0 -1
- package/dist/commands/deps.d.mts +0 -23
- package/dist/commands/deps.d.mts.map +0 -1
- package/dist/commands/deps.mjs.map +0 -1
- package/dist/commands/info.d.mts +0 -26
- package/dist/commands/info.d.mts.map +0 -1
- package/dist/commands/info.mjs +0 -54
- package/dist/commands/info.mjs.map +0 -1
- package/dist/commands/maintainers.d.mts +0 -23
- package/dist/commands/maintainers.d.mts.map +0 -1
- package/dist/commands/maintainers.mjs +0 -46
- package/dist/commands/maintainers.mjs.map +0 -1
- package/dist/commands/shared.d.mts +0 -27
- package/dist/commands/shared.d.mts.map +0 -1
- package/dist/commands/shared.mjs.map +0 -1
- package/dist/commands/versions.d.mts +0 -31
- package/dist/commands/versions.d.mts.map +0 -1
- package/dist/commands/versions.mjs.map +0 -1
- package/dist/core/index.d.mts +0 -4
- package/dist/core/index.mjs +0 -3
- package/dist/index.d.mts.map +0 -1
- package/dist/types.d.mts +0 -3
- package/dist/types.mjs +0 -1
package/dist/ai.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./_chunks/registry.mjs";
|
|
3
|
-
import "./types.mjs";
|
|
1
|
+
import { d as Package, g as Version, l as Dependency, u as Maintainer } from "./_chunks/registry.mjs";
|
|
4
2
|
import "./_chunks/index.mjs";
|
|
3
|
+
import "./_chunks/index2.mjs";
|
|
4
|
+
import "./_chunks/index3.mjs";
|
|
5
5
|
import * as ai from "ai";
|
|
6
6
|
|
|
7
7
|
//#region src/ai.d.ts
|
|
@@ -21,7 +21,7 @@ declare const packageTool: ai.Tool<{
|
|
|
21
21
|
operation: "bulk-packages";
|
|
22
22
|
purls: string[];
|
|
23
23
|
concurrency?: number | undefined;
|
|
24
|
-
},
|
|
24
|
+
}, Version[] | Dependency[] | Maintainer[] | Package | {
|
|
25
25
|
[k: string]: Package;
|
|
26
26
|
}>;
|
|
27
27
|
//#endregion
|
package/dist/ai.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "./_chunks/registry.mjs";
|
|
2
|
-
import "./_chunks/purl.mjs";
|
|
3
2
|
import "./_chunks/registries.mjs";
|
|
4
3
|
import { a as fetchVersionsFromPURL, i as fetchPackageFromPURL, n as fetchDependenciesFromPURL, r as fetchMaintainersFromPURL, t as bulkFetchPackages } from "./_chunks/helpers.mjs";
|
|
5
4
|
import { tool } from "ai";
|
package/dist/ai.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.mjs","names":[],"sources":["../src/ai.ts"],"sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport {\n bulkFetchPackages,\n fetchDependenciesFromPURL,\n fetchMaintainersFromPURL,\n fetchPackageFromPURL,\n fetchVersionsFromPURL,\n} from \"./helpers.ts\";\nimport \"./registries/index.ts\";\n\nexport const packageTool = tool({\n description:\n \"Query package metadata from npm, PyPI, crates.io, RubyGems, Packagist, and Arch Linux using PURLs. Supports package info, versions, dependencies, maintainers, and bulk package metadata lookups.\",\n inputSchema: z.discriminatedUnion(\"operation\", [\n z.object({\n operation: z.literal(\"package\"),\n purl: z.string().describe(\"Package PURL, for example pkg:npm/lodash or pkg:cargo/serde\"),\n }),\n z.object({\n operation: z.literal(\"versions\"),\n purl: z.string().describe(\"Package PURL, for example pkg:npm/lodash or pkg:cargo/serde\"),\n }),\n z.object({\n operation: z.literal(\"dependencies\"),\n purl: z\n .string()\n .describe(\"Package PURL including a version, for example pkg:pypi/flask@3.1.1\"),\n }),\n z.object({\n operation: z.literal(\"maintainers\"),\n purl: z\n .string()\n .describe(\"Package PURL, for example pkg:gem/rails or pkg:composer/laravel/framework\"),\n }),\n z.object({\n operation: z.literal(\"bulk-packages\"),\n purls: z.array(z.string()).min(1).max(50).describe(\"List of package PURLs to fetch in bulk.\"),\n concurrency: z\n .number()\n .int()\n .min(1)\n .max(50)\n .optional()\n .describe(\"Maximum concurrent lookups. Defaults to 15.\"),\n }),\n ]),\n execute: async (input, { abortSignal }) => {\n switch (input.operation) {\n case \"package\":\n return fetchPackageFromPURL(input.purl, abortSignal);\n case \"versions\":\n return fetchVersionsFromPURL(input.purl, abortSignal);\n case \"dependencies\":\n return fetchDependenciesFromPURL(input.purl, abortSignal);\n case \"maintainers\":\n return fetchMaintainersFromPURL(input.purl, abortSignal);\n case \"bulk-packages\": {\n const results = await bulkFetchPackages(input.purls, {\n concurrency: input.concurrency,\n signal: abortSignal,\n });\n return Object.fromEntries(results);\n }\n }\n },\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ai.mjs","names":[],"sources":["../src/ai.ts"],"sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport {\n bulkFetchPackages,\n fetchDependenciesFromPURL,\n fetchMaintainersFromPURL,\n fetchPackageFromPURL,\n fetchVersionsFromPURL,\n} from \"./helpers.ts\";\nimport \"./registries/index.ts\";\n\nexport const packageTool = tool({\n description:\n \"Query package metadata from npm, PyPI, crates.io, RubyGems, Packagist, and Arch Linux using PURLs. Supports package info, versions, dependencies, maintainers, and bulk package metadata lookups.\",\n inputSchema: z.discriminatedUnion(\"operation\", [\n z.object({\n operation: z.literal(\"package\"),\n purl: z.string().describe(\"Package PURL, for example pkg:npm/lodash or pkg:cargo/serde\"),\n }),\n z.object({\n operation: z.literal(\"versions\"),\n purl: z.string().describe(\"Package PURL, for example pkg:npm/lodash or pkg:cargo/serde\"),\n }),\n z.object({\n operation: z.literal(\"dependencies\"),\n purl: z\n .string()\n .describe(\"Package PURL including a version, for example pkg:pypi/flask@3.1.1\"),\n }),\n z.object({\n operation: z.literal(\"maintainers\"),\n purl: z\n .string()\n .describe(\"Package PURL, for example pkg:gem/rails or pkg:composer/laravel/framework\"),\n }),\n z.object({\n operation: z.literal(\"bulk-packages\"),\n purls: z.array(z.string()).min(1).max(50).describe(\"List of package PURLs to fetch in bulk.\"),\n concurrency: z\n .number()\n .int()\n .min(1)\n .max(50)\n .optional()\n .describe(\"Maximum concurrent lookups. Defaults to 15.\"),\n }),\n ]),\n execute: async (input, { abortSignal }) => {\n switch (input.operation) {\n case \"package\":\n return fetchPackageFromPURL(input.purl, abortSignal);\n case \"versions\":\n return fetchVersionsFromPURL(input.purl, abortSignal);\n case \"dependencies\":\n return fetchDependenciesFromPURL(input.purl, abortSignal);\n case \"maintainers\":\n return fetchMaintainersFromPURL(input.purl, abortSignal);\n case \"bulk-packages\": {\n const results = await bulkFetchPackages(input.purls, {\n concurrency: input.concurrency,\n signal: abortSignal,\n });\n return Object.fromEntries(results);\n }\n }\n },\n});\n"],"mappings":";;;;;AAWA,MAAa,cAAc,KAAK;CAC9B,aACE;CACF,aAAa,EAAE,mBAAmB,aAAa;EAC7C,EAAE,OAAO;GACP,WAAW,EAAE,QAAQ,UAAU;GAC/B,MAAM,EAAE,QAAQ,CAAC,SAAS,8DAAA;GAC3B,CAAC;EACF,EAAE,OAAO;GACP,WAAW,EAAE,QAAQ,WAAW;GAChC,MAAM,EAAE,QAAQ,CAAC,SAAS,8DAAA;GAC3B,CAAC;EACF,EAAE,OAAO;GACP,WAAW,EAAE,QAAQ,eAAe;GACpC,MAAM,EACH,QAAQ,CACR,SAAS,qEAAA;GACb,CAAC;EACF,EAAE,OAAO;GACP,WAAW,EAAE,QAAQ,cAAc;GACnC,MAAM,EACH,QAAQ,CACR,SAAS,4EAAA;GACb,CAAC;EACF,EAAE,OAAO;GACP,WAAW,EAAE,QAAQ,gBAAgB;GACrC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,SAAS,0CAA0C;GAC7F,aAAa,EACV,QAAQ,CACR,KAAK,CACL,IAAI,EAAE,CACN,IAAI,GAAG,CACP,UAAU,CACV,SAAS,8CAAA;GACb,CAAA;EACF,CAAC;CACF,SAAS,OAAO,OAAO,EAAE,kBAAkB;AACzC,UAAQ,MAAM,WAAd;GACE,KAAK,UACH,QAAO,qBAAqB,MAAM,MAAM,YAAY;GACtD,KAAK,WACH,QAAO,sBAAsB,MAAM,MAAM,YAAY;GACvD,KAAK,eACH,QAAO,0BAA0B,MAAM,MAAM,YAAY;GAC3D,KAAK,cACH,QAAO,yBAAyB,MAAM,MAAM,YAAY;GAC1D,KAAK,iBAAiB;IACpB,MAAM,UAAU,MAAM,kBAAkB,MAAM,OAAO;KACnD,aAAa,MAAM;KACnB,QAAQ;KACT,CAAC;AACF,WAAO,OAAO,YAAY,QAAQ;;;;CAIzC,CAAC"}
|
package/dist/cache/index.d.mts
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
import "../_chunks/
|
|
2
|
-
import { o as
|
|
3
|
-
|
|
4
|
-
import { getCacheDir } from "./paths.mjs";
|
|
5
|
-
import { clearStorage, computeIntegrity, configureStorage, disposeStorage, getEcosystemStorage, getStorage } from "./storage.mjs";
|
|
6
|
-
import { DEFAULT_TTL, EntryType, Lockfile, LockfileEntry, cacheKey, getFreshEntry, isFresh, pruneStale, readLockfile, removeEntry, setEntry, writeLockfile } from "./lockfile.mjs";
|
|
7
|
-
import { Storage } from "unstorage";
|
|
8
|
-
|
|
9
|
-
//#region src/cache/index.d.ts
|
|
10
|
-
/** Options for creating a cached registry. */
|
|
11
|
-
interface CreateCachedOptions {
|
|
12
|
-
/** Custom base URL for the registry API. */
|
|
13
|
-
baseURL?: string;
|
|
14
|
-
/** Custom HTTP client. */
|
|
15
|
-
client?: Client;
|
|
16
|
-
/** Custom unstorage instance. Overrides the globally configured storage. */
|
|
17
|
-
storage?: Storage;
|
|
18
|
-
}
|
|
19
|
-
/** Create a registry instance with caching + lockfile tracking. */
|
|
20
|
-
declare function createCached(ecosystem: string, options?: CreateCachedOptions): Registry;
|
|
21
|
-
//#endregion
|
|
22
|
-
export { CachedRegistry, CreateCachedOptions, DEFAULT_TTL, type EntryType, type Lockfile, type LockfileEntry, cacheKey, clearStorage, computeIntegrity, configureStorage, createCached, disposeStorage, getCacheDir, getEcosystemStorage, getFreshEntry, getStorage, isFresh, pruneStale, readLockfile, removeEntry, setEntry, writeLockfile };
|
|
23
|
-
//# sourceMappingURL=index.d.mts.map
|
|
1
|
+
import "../_chunks/registry.mjs";
|
|
2
|
+
import { S as getCacheDir, _ as computeIntegrity, a as Lockfile, b as getEcosystemStorage, c as getFreshEntry, d as readLockfile, f as removeEntry, g as clearStorage, h as CachedRegistry, i as EntryType, l as isFresh, m as writeLockfile, n as createCached, o as LockfileEntry, p as setEntry, r as DEFAULT_TTL, s as cacheKey, t as CreateCachedOptions, u as pruneStale, v as configureStorage, x as getStorage, y as disposeStorage } from "../_chunks/index3.mjs";
|
|
3
|
+
export { CachedRegistry, CreateCachedOptions, DEFAULT_TTL, EntryType, Lockfile, LockfileEntry, cacheKey, clearStorage, computeIntegrity, configureStorage, createCached, disposeStorage, getCacheDir, getEcosystemStorage, getFreshEntry, getStorage, isFresh, pruneStale, readLockfile, removeEntry, setEntry, writeLockfile };
|
package/dist/cache/index.mjs
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getCacheDir } from "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { CachedRegistry } from "./cached-registry.mjs";
|
|
6
|
-
/** Create a registry instance with caching + lockfile tracking. */
|
|
7
|
-
function createCached(ecosystem, options) {
|
|
8
|
-
return new CachedRegistry(create(ecosystem, options?.baseURL, options?.client), options?.storage);
|
|
9
|
-
}
|
|
1
|
+
import "../_chunks/registry.mjs";
|
|
2
|
+
import { a as pruneStale, c as setEntry, d as computeIntegrity, f as configureStorage, g as getCacheDir, h as getStorage, i as isFresh, l as writeLockfile, m as getEcosystemStorage, n as cacheKey, o as readLockfile, p as disposeStorage, r as getFreshEntry, s as removeEntry, t as DEFAULT_TTL, u as clearStorage } from "../_chunks/lockfile.mjs";
|
|
3
|
+
import { t as CachedRegistry } from "../_chunks/cached-registry.mjs";
|
|
4
|
+
import { t as createCached } from "../_chunks/cache.mjs";
|
|
10
5
|
export { CachedRegistry, DEFAULT_TTL, cacheKey, clearStorage, computeIntegrity, configureStorage, createCached, disposeStorage, getCacheDir, getEcosystemStorage, getFreshEntry, getStorage, isFresh, pruneStale, readLockfile, removeEntry, setEntry, writeLockfile };
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/cli.mjs
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { t as version } from "./_chunks/version.mjs";
|
|
2
3
|
import { defineCommand, runMain } from "citty";
|
|
3
|
-
runMain(defineCommand({
|
|
4
|
+
await runMain(defineCommand({
|
|
4
5
|
meta: {
|
|
5
6
|
name: "registries",
|
|
6
|
-
version
|
|
7
|
+
version,
|
|
7
8
|
description: "Universal package registry client — query npm, PyPI, crates.io, RubyGems, Packagist with a single PURL-native API."
|
|
8
9
|
},
|
|
9
10
|
subCommands: {
|
|
10
|
-
info: () => import("./
|
|
11
|
-
versions: () => import("./
|
|
12
|
-
deps: () => import("./
|
|
13
|
-
maintainers: () => import("./
|
|
14
|
-
cache: () => import("./
|
|
11
|
+
info: () => import("./_chunks/info.mjs").then((m) => m.default),
|
|
12
|
+
versions: () => import("./_chunks/versions.mjs").then((m) => m.default),
|
|
13
|
+
deps: () => import("./_chunks/deps.mjs").then((m) => m.default),
|
|
14
|
+
maintainers: () => import("./_chunks/maintainers.mjs").then((m) => m.default),
|
|
15
|
+
cache: () => import("./_chunks/cache2.mjs").then((m) => m.default),
|
|
16
|
+
mcp: () => import("./_chunks/mcp.mjs").then((m) => m.default)
|
|
15
17
|
}
|
|
16
18
|
}));
|
|
17
19
|
export {};
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { defineCommand, runMain } from \"citty\";\n\nconst main = defineCommand({\n meta: {\n name: \"registries\",\n version
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { defineCommand, runMain } from \"citty\";\nimport { version } from \"./version.ts\";\n\nconst main = defineCommand({\n meta: {\n name: \"registries\",\n version,\n description:\n \"Universal package registry client — query npm, PyPI, crates.io, RubyGems, Packagist with a single PURL-native API.\",\n },\n subCommands: {\n info: () => import(\"./commands/info.ts\").then((m) => m.default),\n versions: () => import(\"./commands/versions.ts\").then((m) => m.default),\n deps: () => import(\"./commands/deps.ts\").then((m) => m.default),\n maintainers: () => import(\"./commands/maintainers.ts\").then((m) => m.default),\n cache: () => import(\"./commands/cache.ts\").then((m) => m.default),\n mcp: () => import(\"./commands/mcp.ts\").then((m) => m.default),\n },\n});\n\nawait runMain(main);\n"],"mappings":";;;AAqBA,MAAM,QAjBO,cAAc;CACzB,MAAM;EACJ,MAAM;EACN;EACA,aACE;EACH;CACD,aAAa;EACX,YAAY,OAAO,sBAAsB,MAAM,MAAM,EAAE,QAAQ;EAC/D,gBAAgB,OAAO,0BAA0B,MAAM,MAAM,EAAE,QAAQ;EACvE,YAAY,OAAO,sBAAsB,MAAM,MAAM,EAAE,QAAQ;EAC/D,mBAAmB,OAAO,6BAA6B,MAAM,MAAM,EAAE,QAAQ;EAC7E,aAAa,OAAO,wBAAuB,MAAM,MAAM,EAAE,QAAQ;EACjE,WAAW,OAAO,qBAAqB,MAAM,MAAM,EAAE,QAAA;;CAExD,CAAC,CAEiB"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,57 +1,5 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as register, i as has, n as create, o as Client, r as ecosystems, s as defaultClient, t as Registry } from "./_chunks/registry.mjs";
|
|
1
|
+
import { _ as VersionStatus, a as register, c as ClientOptions, d as Package, f as ParsedPURL, g as Version, h as URLBuilder, i as has, l as Dependency, m as Scope, n as create, o as Client, p as RateLimiter, r as ecosystems, s as defaultClient, t as Registry, u as Maintainer } from "./_chunks/registry.mjs";
|
|
3
2
|
import { a as CargoRegistry, i as PyPIRegistry, n as PackagistRegistry, o as NpmRegistry, r as RubyGemsRegistry, t as AlpmRegistry } from "./_chunks/index.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { getCacheDir } from "./
|
|
6
|
-
|
|
7
|
-
import { DEFAULT_TTL, EntryType, Lockfile, LockfileEntry, cacheKey, getFreshEntry, isFresh, pruneStale, readLockfile, removeEntry, setEntry, writeLockfile } from "./cache/lockfile.mjs";
|
|
8
|
-
import { CreateCachedOptions, createCached } from "./cache/index.mjs";
|
|
9
|
-
import { a as RateLimitError, c as combineLicenses, d as createFromPURL, f as fullName, i as PkioError, l as normalizeLicense, n as InvalidPURLError, o as UnknownEcosystemError, p as parsePURL, r as NotFoundError, s as normalizeRepositoryURL, t as HTTPError, u as buildPURL } from "./_chunks/errors.mjs";
|
|
10
|
-
|
|
11
|
-
//#region src/helpers.d.ts
|
|
12
|
-
/** Fetch normalized package metadata from a PURL. */
|
|
13
|
-
declare function fetchPackageFromPURL(purl: string, signal?: AbortSignal, client?: Client): Promise<Package>;
|
|
14
|
-
/** Fetch all versions from a PURL. */
|
|
15
|
-
declare function fetchVersionsFromPURL(purl: string, signal?: AbortSignal, client?: Client): Promise<Version[]>;
|
|
16
|
-
/** Fetch dependencies for a specific version from a PURL. */
|
|
17
|
-
declare function fetchDependenciesFromPURL(purl: string, signal?: AbortSignal, client?: Client): Promise<Dependency[]>;
|
|
18
|
-
/** Fetch maintainers from a PURL. */
|
|
19
|
-
declare function fetchMaintainersFromPURL(purl: string, signal?: AbortSignal, client?: Client): Promise<Maintainer[]>;
|
|
20
|
-
/** Bulk fetch packages from multiple PURLs, with concurrency limit. */
|
|
21
|
-
declare function bulkFetchPackages(purls: string[], options?: {
|
|
22
|
-
concurrency?: number;
|
|
23
|
-
signal?: AbortSignal;
|
|
24
|
-
client?: Client;
|
|
25
|
-
}): Promise<Map<string, Package>>;
|
|
26
|
-
/**
|
|
27
|
-
* Select the best matching version from a list.
|
|
28
|
-
*
|
|
29
|
-
* Resolution order:
|
|
30
|
-
* 1. Exact match for `requested` (non-yanked/deprecated/retracted)
|
|
31
|
-
* 2. Exact match for `latest` (non-yanked/deprecated/retracted)
|
|
32
|
-
* 3. Newest available version with no negative status (by publishedAt)
|
|
33
|
-
*
|
|
34
|
-
* Returns `null` when no usable version exists.
|
|
35
|
-
*/
|
|
36
|
-
declare function selectVersion(versions: Version[], options?: {
|
|
37
|
-
requested?: string;
|
|
38
|
-
latest?: string;
|
|
39
|
-
}): Version | null;
|
|
40
|
-
/**
|
|
41
|
-
* Resolve the best documentation URL for a package.
|
|
42
|
-
*
|
|
43
|
-
* Fallback chain:
|
|
44
|
-
* 1. `package.documentation` (explicit docs URL from registry)
|
|
45
|
-
* 2. `package.homepage` (project homepage)
|
|
46
|
-
* 3. `urls.documentation()` (ecosystem default, e.g. docs.rs, rubydoc.info)
|
|
47
|
-
*/
|
|
48
|
-
declare function resolveDocsUrl(pkg: Package, urls: URLBuilder, version?: string): string;
|
|
49
|
-
/**
|
|
50
|
-
* Resolve the best README URL for a package.
|
|
51
|
-
*
|
|
52
|
-
* Returns the ecosystem-specific URL where the package README can be fetched.
|
|
53
|
-
*/
|
|
54
|
-
declare function resolveReadmeUrl(pkg: Package, urls: URLBuilder, version?: string): string;
|
|
55
|
-
//#endregion
|
|
56
|
-
export { AlpmRegistry, CachedRegistry, CargoRegistry, Client, type ClientOptions, type CreateCachedOptions, DEFAULT_TTL, type Dependency, type EntryType, HTTPError, InvalidPURLError, type Lockfile, type LockfileEntry, type Maintainer, NotFoundError, NpmRegistry, type Package, PackagistRegistry, type ParsedPURL, PkioError, PyPIRegistry, RateLimitError, type RateLimiter, Registry, RubyGemsRegistry, type Scope, type URLBuilder, UnknownEcosystemError, type Version, type VersionStatus, buildPURL, bulkFetchPackages, cacheKey, clearStorage, combineLicenses, computeIntegrity, configureStorage, create, createCached, createFromPURL, defaultClient, disposeStorage, ecosystems, fetchDependenciesFromPURL, fetchMaintainersFromPURL, fetchPackageFromPURL, fetchVersionsFromPURL, fullName, getCacheDir, getEcosystemStorage, getFreshEntry, getStorage, has, isFresh, normalizeLicense, normalizeRepositoryURL, parsePURL, pruneStale, readLockfile, register, removeEntry, resolveDocsUrl, resolveReadmeUrl, selectVersion, setEntry, writeLockfile };
|
|
57
|
-
//# sourceMappingURL=index.d.mts.map
|
|
3
|
+
import { _ as normalizeLicense, a as fetchVersionsFromPURL, b as fullName, c as selectVersion, d as NotFoundError, f as PkioError, g as combineLicenses, h as normalizeRepositoryURL, i as fetchPackageFromPURL, l as HTTPError, m as UnknownEcosystemError, n as fetchDependenciesFromPURL, o as resolveDocsUrl, p as RateLimitError, r as fetchMaintainersFromPURL, s as resolveReadmeUrl, t as bulkFetchPackages, u as InvalidPURLError, v as buildPURL, x as parsePURL, y as createFromPURL } from "./_chunks/index2.mjs";
|
|
4
|
+
import { S as getCacheDir, _ as computeIntegrity, a as Lockfile, b as getEcosystemStorage, c as getFreshEntry, d as readLockfile, f as removeEntry, g as clearStorage, h as CachedRegistry, i as EntryType, l as isFresh, m as writeLockfile, n as createCached, o as LockfileEntry, p as setEntry, r as DEFAULT_TTL, s as cacheKey, t as CreateCachedOptions, u as pruneStale, v as configureStorage, x as getStorage, y as disposeStorage } from "./_chunks/index3.mjs";
|
|
5
|
+
export { AlpmRegistry, CachedRegistry, CargoRegistry, Client, ClientOptions, CreateCachedOptions, DEFAULT_TTL, Dependency, EntryType, HTTPError, InvalidPURLError, Lockfile, LockfileEntry, Maintainer, NotFoundError, NpmRegistry, Package, PackagistRegistry, ParsedPURL, PkioError, PyPIRegistry, RateLimitError, RateLimiter, Registry, RubyGemsRegistry, Scope, URLBuilder, UnknownEcosystemError, Version, VersionStatus, buildPURL, bulkFetchPackages, cacheKey, clearStorage, combineLicenses, computeIntegrity, configureStorage, create, createCached, createFromPURL, defaultClient, disposeStorage, ecosystems, fetchDependenciesFromPURL, fetchMaintainersFromPURL, fetchPackageFromPURL, fetchVersionsFromPURL, fullName, getCacheDir, getEcosystemStorage, getFreshEntry, getStorage, has, isFresh, normalizeLicense, normalizeRepositoryURL, parsePURL, pruneStale, readLockfile, register, removeEntry, resolveDocsUrl, resolveReadmeUrl, selectVersion, setEntry, writeLockfile };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { a as register, c as HTTPError, d as PkioError, f as RateLimitError, i as has, l as InvalidPURLError, n as create, o as Client, p as UnknownEcosystemError, r as ecosystems, s as defaultClient, t as Registry, u as NotFoundError } from "./_chunks/registry.mjs";
|
|
2
|
-
import { a as normalizeRepositoryURL, i as
|
|
3
|
-
import { a as CargoRegistry, i as PyPIRegistry, n as PackagistRegistry, o as NpmRegistry, r as RubyGemsRegistry, t as AlpmRegistry } from "./_chunks/registries.mjs";
|
|
2
|
+
import { a as CargoRegistry, c as createFromPURL, d as normalizeRepositoryURL, f as combineLicenses, i as PyPIRegistry, l as fullName, n as PackagistRegistry, o as NpmRegistry, p as normalizeLicense, r as RubyGemsRegistry, s as buildPURL, t as AlpmRegistry, u as parsePURL } from "./_chunks/registries.mjs";
|
|
4
3
|
import { a as fetchVersionsFromPURL, c as selectVersion, i as fetchPackageFromPURL, n as fetchDependenciesFromPURL, o as resolveDocsUrl, r as fetchMaintainersFromPURL, s as resolveReadmeUrl, t as bulkFetchPackages } from "./_chunks/helpers.mjs";
|
|
5
|
-
import { getCacheDir } from "./
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { CachedRegistry } from "./cache/cached-registry.mjs";
|
|
9
|
-
import { createCached } from "./cache/index.mjs";
|
|
4
|
+
import { a as pruneStale, c as setEntry, d as computeIntegrity, f as configureStorage, g as getCacheDir, h as getStorage, i as isFresh, l as writeLockfile, m as getEcosystemStorage, n as cacheKey, o as readLockfile, p as disposeStorage, r as getFreshEntry, s as removeEntry, t as DEFAULT_TTL, u as clearStorage } from "./_chunks/lockfile.mjs";
|
|
5
|
+
import { t as CachedRegistry } from "./_chunks/cached-registry.mjs";
|
|
6
|
+
import { t as createCached } from "./_chunks/cache.mjs";
|
|
10
7
|
export { AlpmRegistry, CachedRegistry, CargoRegistry, Client, DEFAULT_TTL, HTTPError, InvalidPURLError, NotFoundError, NpmRegistry, PackagistRegistry, PkioError, PyPIRegistry, RateLimitError, Registry, RubyGemsRegistry, UnknownEcosystemError, buildPURL, bulkFetchPackages, cacheKey, clearStorage, combineLicenses, computeIntegrity, configureStorage, create, createCached, createFromPURL, defaultClient, disposeStorage, ecosystems, fetchDependenciesFromPURL, fetchMaintainersFromPURL, fetchPackageFromPURL, fetchVersionsFromPURL, fullName, getCacheDir, getEcosystemStorage, getFreshEntry, getStorage, has, isFresh, normalizeLicense, normalizeRepositoryURL, parsePURL, pruneStale, readLockfile, register, removeEntry, resolveDocsUrl, resolveReadmeUrl, selectVersion, setEntry, writeLockfile };
|
package/dist/mcp.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../src/mcp.ts"],"mappings":";;;iBAqJgB,eAAA,CAAA,GAAmB,MAAA"}
|
package/dist/mcp.mjs
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import "./_chunks/registry.mjs";
|
|
2
|
+
import "./_chunks/registries.mjs";
|
|
3
|
+
import "./_chunks/helpers.mjs";
|
|
4
|
+
import { t as version } from "./_chunks/version.mjs";
|
|
5
|
+
import { a as _Array_, i as Optional, n as Integer, r as _Object_, t as String$1 } from "./_chunks/libs/typebox.mjs";
|
|
6
|
+
import { a as bulkPackagesOperation, c as maintainersOperation, i as MAX_PURL_LENGTH, l as packageOperation, n as MAX_BULK_CONCURRENCY, o as dependenciesOperation, r as MAX_BULK_PACKAGES, s as ecosystemsOperation, u as versionsOperation } from "./_chunks/tool-operations.mjs";
|
|
7
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
8
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
9
|
+
const PURL = String$1({
|
|
10
|
+
minLength: 1,
|
|
11
|
+
maxLength: MAX_PURL_LENGTH,
|
|
12
|
+
description: "Package URL, for example pkg:npm/lodash or pkg:pypi/requests@2.32.3"
|
|
13
|
+
});
|
|
14
|
+
const PURLParams = _Object_({ purl: PURL }, { additionalProperties: false });
|
|
15
|
+
const BulkPackagesParams = _Object_({
|
|
16
|
+
purls: _Array_(PURL, {
|
|
17
|
+
minItems: 1,
|
|
18
|
+
maxItems: MAX_BULK_PACKAGES
|
|
19
|
+
}),
|
|
20
|
+
concurrency: Optional(Integer({
|
|
21
|
+
minimum: 1,
|
|
22
|
+
maximum: MAX_BULK_CONCURRENCY
|
|
23
|
+
}))
|
|
24
|
+
}, { additionalProperties: false });
|
|
25
|
+
const EmptyParams = _Object_({}, { additionalProperties: false });
|
|
26
|
+
const REMOTE_READ = {
|
|
27
|
+
readOnlyHint: true,
|
|
28
|
+
destructiveHint: false,
|
|
29
|
+
idempotentHint: false,
|
|
30
|
+
openWorldHint: true
|
|
31
|
+
};
|
|
32
|
+
const LOCAL_READ = {
|
|
33
|
+
readOnlyHint: true,
|
|
34
|
+
destructiveHint: false,
|
|
35
|
+
idempotentHint: true,
|
|
36
|
+
openWorldHint: false
|
|
37
|
+
};
|
|
38
|
+
function defineTool(tool) {
|
|
39
|
+
return tool;
|
|
40
|
+
}
|
|
41
|
+
const tools = [
|
|
42
|
+
defineTool({
|
|
43
|
+
name: "registries_package",
|
|
44
|
+
title: "Get package metadata",
|
|
45
|
+
description: "Fetch normalized metadata for one package URL.",
|
|
46
|
+
inputSchema: PURLParams,
|
|
47
|
+
annotations: REMOTE_READ,
|
|
48
|
+
execute: packageOperation
|
|
49
|
+
}),
|
|
50
|
+
defineTool({
|
|
51
|
+
name: "registries_versions",
|
|
52
|
+
title: "List package versions",
|
|
53
|
+
description: "List normalized versions for one package URL.",
|
|
54
|
+
inputSchema: PURLParams,
|
|
55
|
+
annotations: REMOTE_READ,
|
|
56
|
+
execute: versionsOperation
|
|
57
|
+
}),
|
|
58
|
+
defineTool({
|
|
59
|
+
name: "registries_dependencies",
|
|
60
|
+
title: "List package dependencies",
|
|
61
|
+
description: "List dependencies for a versioned package URL.",
|
|
62
|
+
inputSchema: PURLParams,
|
|
63
|
+
annotations: REMOTE_READ,
|
|
64
|
+
execute: dependenciesOperation
|
|
65
|
+
}),
|
|
66
|
+
defineTool({
|
|
67
|
+
name: "registries_maintainers",
|
|
68
|
+
title: "List package maintainers",
|
|
69
|
+
description: "List normalized maintainers for one package URL.",
|
|
70
|
+
inputSchema: PURLParams,
|
|
71
|
+
annotations: REMOTE_READ,
|
|
72
|
+
execute: maintainersOperation
|
|
73
|
+
}),
|
|
74
|
+
defineTool({
|
|
75
|
+
name: "registries_bulk_packages",
|
|
76
|
+
title: "Get package metadata in bulk",
|
|
77
|
+
description: "Fetch normalized package metadata for up to 50 package URLs.",
|
|
78
|
+
inputSchema: BulkPackagesParams,
|
|
79
|
+
annotations: REMOTE_READ,
|
|
80
|
+
execute: bulkPackagesOperation
|
|
81
|
+
}),
|
|
82
|
+
defineTool({
|
|
83
|
+
name: "registries_ecosystems",
|
|
84
|
+
title: "List registry ecosystems",
|
|
85
|
+
description: "List package ecosystems registered by this package.",
|
|
86
|
+
inputSchema: EmptyParams,
|
|
87
|
+
annotations: LOCAL_READ,
|
|
88
|
+
execute: ecosystemsOperation
|
|
89
|
+
})
|
|
90
|
+
];
|
|
91
|
+
function errorMessage(error) {
|
|
92
|
+
return error instanceof Error ? error.message : String(error);
|
|
93
|
+
}
|
|
94
|
+
function sanitizeField(value) {
|
|
95
|
+
return Array.from(value).map((character) => {
|
|
96
|
+
const code = character.codePointAt(0) ?? 0;
|
|
97
|
+
return code <= 31 || code >= 127 && code <= 159 ? " " : character;
|
|
98
|
+
}).join("");
|
|
99
|
+
}
|
|
100
|
+
function errorResult(text) {
|
|
101
|
+
return {
|
|
102
|
+
content: [{
|
|
103
|
+
type: "text",
|
|
104
|
+
text: sanitizeField(text)
|
|
105
|
+
}],
|
|
106
|
+
isError: true
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function toCallToolResult(result) {
|
|
110
|
+
return {
|
|
111
|
+
content: result.content,
|
|
112
|
+
...result.isError ? { isError: true } : {}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* SAFETY: TypeBox schemas conform to the JSON Schema object accepted by MCP.
|
|
117
|
+
*
|
|
118
|
+
* @param schema - TypeBox schema to expose through MCP.
|
|
119
|
+
* @returns {Tool["inputSchema"]} The same schema under the MCP SDK type.
|
|
120
|
+
*/
|
|
121
|
+
function toMcpSchema(schema) {
|
|
122
|
+
return schema;
|
|
123
|
+
}
|
|
124
|
+
function createMcpServer() {
|
|
125
|
+
const toolsByName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
126
|
+
const server = new Server({
|
|
127
|
+
name: "registries",
|
|
128
|
+
version
|
|
129
|
+
}, { capabilities: { tools: {} } });
|
|
130
|
+
server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: tools.map((tool) => ({
|
|
131
|
+
name: tool.name,
|
|
132
|
+
title: tool.title,
|
|
133
|
+
description: tool.description,
|
|
134
|
+
inputSchema: toMcpSchema(tool.inputSchema),
|
|
135
|
+
annotations: tool.annotations
|
|
136
|
+
})) }));
|
|
137
|
+
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
138
|
+
const tool = toolsByName.get(request.params.name);
|
|
139
|
+
if (!tool) return errorResult(`Unknown registries tool: ${request.params.name}`);
|
|
140
|
+
const args = request.params.arguments ?? {};
|
|
141
|
+
const { Value } = await import("typebox/value");
|
|
142
|
+
if (!Value.Check(tool.inputSchema, args)) return errorResult(`Invalid arguments for ${tool.name}`);
|
|
143
|
+
try {
|
|
144
|
+
/** SAFETY: Value.Check validated args against the selected tool's schema. */
|
|
145
|
+
const validatedArgs = args;
|
|
146
|
+
return toCallToolResult(await tool.execute(validatedArgs, extra.signal));
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return errorResult(`${tool.name} failed: ${errorMessage(error)}`);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return server;
|
|
152
|
+
}
|
|
153
|
+
export { createMcpServer };
|
|
154
|
+
|
|
155
|
+
//# sourceMappingURL=mcp.mjs.map
|
package/dist/mcp.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.mjs","names":["Type.String","Type.Object","Type.Array","Type.Optional","Type.Integer"],"sources":["../src/mcp.ts"],"sourcesContent":["import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n type CallToolResult,\n type Tool,\n type ToolAnnotations,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { Type, type Static, type TSchema } from \"typebox\";\nimport {\n bulkPackagesOperation,\n dependenciesOperation,\n ecosystemsOperation,\n maintainersOperation,\n MAX_BULK_CONCURRENCY,\n MAX_BULK_PACKAGES,\n MAX_PURL_LENGTH,\n packageOperation,\n type ToolResult,\n versionsOperation,\n} from \"./tool-operations.ts\";\nimport { version } from \"./version.ts\";\n\nconst PURL = Type.String({\n minLength: 1,\n maxLength: MAX_PURL_LENGTH,\n description: \"Package URL, for example pkg:npm/lodash or pkg:pypi/requests@2.32.3\",\n});\n\nconst PURLParams = Type.Object({ purl: PURL }, { additionalProperties: false });\nconst BulkPackagesParams = Type.Object(\n {\n purls: Type.Array(PURL, { minItems: 1, maxItems: MAX_BULK_PACKAGES }),\n concurrency: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_BULK_CONCURRENCY })),\n },\n { additionalProperties: false },\n);\nconst EmptyParams = Type.Object({}, { additionalProperties: false });\n\nconst REMOTE_READ: ToolAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n};\nconst LOCAL_READ: ToolAnnotations = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n};\n\ninterface RegistryTool<S extends TSchema> {\n readonly name: string;\n readonly title: string;\n readonly description: string;\n readonly inputSchema: S;\n readonly annotations: ToolAnnotations;\n execute(params: Readonly<Static<S>>, signal?: AbortSignal): Promise<ToolResult<unknown>>;\n}\n\nfunction defineTool<S extends TSchema>(tool: Readonly<RegistryTool<S>>): RegistryTool<S> {\n return tool;\n}\n\nconst tools = [\n defineTool({\n name: \"registries_package\",\n title: \"Get package metadata\",\n description: \"Fetch normalized metadata for one package URL.\",\n inputSchema: PURLParams,\n annotations: REMOTE_READ,\n execute: packageOperation,\n }),\n defineTool({\n name: \"registries_versions\",\n title: \"List package versions\",\n description: \"List normalized versions for one package URL.\",\n inputSchema: PURLParams,\n annotations: REMOTE_READ,\n execute: versionsOperation,\n }),\n defineTool({\n name: \"registries_dependencies\",\n title: \"List package dependencies\",\n description: \"List dependencies for a versioned package URL.\",\n inputSchema: PURLParams,\n annotations: REMOTE_READ,\n execute: dependenciesOperation,\n }),\n defineTool({\n name: \"registries_maintainers\",\n title: \"List package maintainers\",\n description: \"List normalized maintainers for one package URL.\",\n inputSchema: PURLParams,\n annotations: REMOTE_READ,\n execute: maintainersOperation,\n }),\n defineTool({\n name: \"registries_bulk_packages\",\n title: \"Get package metadata in bulk\",\n description: \"Fetch normalized package metadata for up to 50 package URLs.\",\n inputSchema: BulkPackagesParams,\n annotations: REMOTE_READ,\n execute: bulkPackagesOperation,\n }),\n defineTool({\n name: \"registries_ecosystems\",\n title: \"List registry ecosystems\",\n description: \"List package ecosystems registered by this package.\",\n inputSchema: EmptyParams,\n annotations: LOCAL_READ,\n execute: ecosystemsOperation,\n }),\n] as const;\n\ntype AnyRegistryTool = (typeof tools)[number];\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction sanitizeField(value: string): string {\n return Array.from(value)\n .map((character) => {\n const code = character.codePointAt(0) ?? 0;\n return code <= 31 || (code >= 127 && code <= 159) ? \" \" : character;\n })\n .join(\"\");\n}\n\nfunction errorResult(text: string): CallToolResult {\n return { content: [{ type: \"text\", text: sanitizeField(text) }], isError: true };\n}\n\nfunction toCallToolResult(result: ToolResult<unknown>): CallToolResult {\n return { content: result.content, ...(result.isError ? { isError: true } : {}) };\n}\n\n/**\n * SAFETY: TypeBox schemas conform to the JSON Schema object accepted by MCP.\n *\n * @param schema - TypeBox schema to expose through MCP.\n * @returns {Tool[\"inputSchema\"]} The same schema under the MCP SDK type.\n */\nfunction toMcpSchema(schema: TSchema): Tool[\"inputSchema\"] {\n return schema as unknown as Tool[\"inputSchema\"];\n}\n\nexport function createMcpServer(): Server {\n const toolsByName = new Map<string, AnyRegistryTool>(tools.map((tool) => [tool.name, tool]));\n const server = new Server({ name: \"registries\", version }, { capabilities: { tools: {} } });\n\n server.setRequestHandler(ListToolsRequestSchema, () => ({\n tools: tools.map((tool): Tool => ({\n name: tool.name,\n title: tool.title,\n description: tool.description,\n inputSchema: toMcpSchema(tool.inputSchema),\n annotations: tool.annotations,\n })),\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {\n const tool = toolsByName.get(request.params.name);\n if (!tool) return errorResult(`Unknown registries tool: ${request.params.name}`);\n\n const args = request.params.arguments ?? {};\n const { Value } = await import(\"typebox/value\");\n if (!Value.Check(tool.inputSchema, args)) {\n return errorResult(`Invalid arguments for ${tool.name}`);\n }\n\n try {\n /** SAFETY: Value.Check validated args against the selected tool's schema. */\n const validatedArgs = args as never;\n return toCallToolResult(await tool.execute(validatedArgs, extra.signal));\n } catch (error) {\n return errorResult(`${tool.name} failed: ${errorMessage(error)}`);\n }\n });\n\n return server;\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../_chunks/types.mjs";
|
|
2
1
|
import "../_chunks/registry.mjs";
|
|
3
2
|
import { a as CargoRegistry, i as PyPIRegistry, n as PackagistRegistry, o as NpmRegistry, r as RubyGemsRegistry, t as AlpmRegistry } from "../_chunks/index.mjs";
|
|
4
3
|
export { AlpmRegistry, CargoRegistry, NpmRegistry, PackagistRegistry, PyPIRegistry, RubyGemsRegistry };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import "../_chunks/registry.mjs";
|
|
2
|
-
import "../_chunks/purl.mjs";
|
|
3
2
|
import { a as CargoRegistry, i as PyPIRegistry, n as PackagistRegistry, o as NpmRegistry, r as RubyGemsRegistry, t as AlpmRegistry } from "../_chunks/registries.mjs";
|
|
4
3
|
export { AlpmRegistry, CargoRegistry, NpmRegistry, PackagistRegistry, PyPIRegistry, RubyGemsRegistry };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { d as Package, g as Version, l as Dependency, o as Client, u as Maintainer } from "./_chunks/registry.mjs";
|
|
2
|
+
import "./_chunks/index.mjs";
|
|
3
|
+
import "./_chunks/index2.mjs";
|
|
4
|
+
import "./_chunks/index3.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/tool-operations.d.ts
|
|
7
|
+
declare const MAX_PURL_LENGTH = 2048;
|
|
8
|
+
declare const MAX_BULK_PACKAGES = 50;
|
|
9
|
+
declare const DEFAULT_BULK_CONCURRENCY = 15;
|
|
10
|
+
declare const MAX_BULK_CONCURRENCY = 50;
|
|
11
|
+
interface ToolResult<T> {
|
|
12
|
+
content: Array<{
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
}>;
|
|
16
|
+
details: T;
|
|
17
|
+
isError?: boolean;
|
|
18
|
+
}
|
|
19
|
+
interface PURLParams {
|
|
20
|
+
readonly purl: string;
|
|
21
|
+
}
|
|
22
|
+
interface BulkPackagesParams {
|
|
23
|
+
readonly purls: readonly string[];
|
|
24
|
+
readonly concurrency?: number;
|
|
25
|
+
}
|
|
26
|
+
declare function packageOperation(params: Readonly<PURLParams>, signal?: AbortSignal, client?: Client): Promise<ToolResult<Package>>;
|
|
27
|
+
declare function versionsOperation(params: Readonly<PURLParams>, signal?: AbortSignal, client?: Client): Promise<ToolResult<Version[]>>;
|
|
28
|
+
declare function dependenciesOperation(params: Readonly<PURLParams>, signal?: AbortSignal, client?: Client): Promise<ToolResult<Dependency[]>>;
|
|
29
|
+
declare function maintainersOperation(params: Readonly<PURLParams>, signal?: AbortSignal, client?: Client): Promise<ToolResult<Maintainer[]>>;
|
|
30
|
+
declare function bulkPackagesOperation(params: Readonly<BulkPackagesParams>, signal?: AbortSignal, client?: Client): Promise<ToolResult<Record<string, Package>>>;
|
|
31
|
+
declare function ecosystemsOperation(): Promise<ToolResult<{
|
|
32
|
+
ecosystems: string[];
|
|
33
|
+
}>>;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { BulkPackagesParams, DEFAULT_BULK_CONCURRENCY, MAX_BULK_CONCURRENCY, MAX_BULK_PACKAGES, MAX_PURL_LENGTH, PURLParams, ToolResult, bulkPackagesOperation, dependenciesOperation, ecosystemsOperation, maintainersOperation, packageOperation, versionsOperation };
|
|
36
|
+
//# sourceMappingURL=tool-operations.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-operations.d.mts","names":[],"sources":["../src/tool-operations.ts"],"mappings":";;;;;;cAca,eAAA;AAAA,cACA,iBAAA;AAAA,cACA,wBAAA;AAAA,cACA,oBAAA;AAAA,UAEI,UAAA;EACf,OAAA,EAAS,KAAA;IAAQ,IAAA;IAAc,IAAA;EAAA;EAC/B,OAAA,EAAS,CAAA;EACT,OAAA;AAAA;AAAA,UAGe,UAAA;EAAA,SACN,IAAA;AAAA;AAAA,UAGM,kBAAA;EAAA,SACN,KAAA;EAAA,SACA,WAAA;AAAA;AAAA,iBA8CW,gBAAA,CACpB,MAAA,EAAQ,QAAA,CAAS,UAAA,GACjB,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GACR,OAAA,CAAQ,UAAA,CAAW,OAAA;AAAA,iBAKA,iBAAA,CACpB,MAAA,EAAQ,QAAA,CAAS,UAAA,GACjB,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GAAM,OAAA,CAAA,UAAA,CAAA,OAAA;AAAA,iBAMK,qBAAA,CACpB,MAAA,EAAQ,QAAA,CAAS,UAAA,GACjB,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GAAM,OAAA,CAAA,UAAA,CAAA,UAAA;AAAA,iBAMK,oBAAA,CACpB,MAAA,EAAQ,QAAA,CAAS,UAAA,GACjB,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GAAM,OAAA,CAAA,UAAA,CAAA,UAAA;AAAA,iBAMK,qBAAA,CACpB,MAAA,EAAQ,QAAA,CAAS,kBAAA,GACjB,MAAA,GAAS,WAAA,EACT,MAAA,GAAS,MAAA,GACR,OAAA,CAAQ,UAAA,CAAW,MAAA,SAAe,OAAA;AAAA,iBAUf,mBAAA,CAAA,GAAuB,OAAA,CAAQ,UAAA;EAAa,UAAA;AAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import "./_chunks/registry.mjs";
|
|
2
|
+
import "./_chunks/registries.mjs";
|
|
3
|
+
import "./_chunks/helpers.mjs";
|
|
4
|
+
import { a as bulkPackagesOperation, c as maintainersOperation, i as MAX_PURL_LENGTH, l as packageOperation, n as MAX_BULK_CONCURRENCY, o as dependenciesOperation, r as MAX_BULK_PACKAGES, s as ecosystemsOperation, t as DEFAULT_BULK_CONCURRENCY, u as versionsOperation } from "./_chunks/tool-operations.mjs";
|
|
5
|
+
export { DEFAULT_BULK_CONCURRENCY, MAX_BULK_CONCURRENCY, MAX_BULK_PACKAGES, MAX_PURL_LENGTH, bulkPackagesOperation, dependenciesOperation, ecosystemsOperation, maintainersOperation, packageOperation, versionsOperation };
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agntn/registries",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Universal package registry client. Query npm, PyPI, crates.io, RubyGems, Packagist and more with a single PURL-native API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crates",
|
|
7
|
+
"mcp",
|
|
7
8
|
"metadata",
|
|
8
9
|
"npm",
|
|
9
10
|
"package-registry",
|
|
10
11
|
"packagist",
|
|
12
|
+
"pi-extension",
|
|
11
13
|
"purl",
|
|
12
14
|
"pypi",
|
|
13
15
|
"rubygems",
|
|
@@ -25,14 +27,17 @@
|
|
|
25
27
|
"registries": "./dist/cli.mjs"
|
|
26
28
|
},
|
|
27
29
|
"files": [
|
|
28
|
-
"dist"
|
|
30
|
+
"dist",
|
|
31
|
+
"packages/pi/extensions",
|
|
32
|
+
"packages/omp/extensions"
|
|
29
33
|
],
|
|
30
34
|
"type": "module",
|
|
31
35
|
"sideEffects": [
|
|
32
36
|
"./src/index.ts",
|
|
33
37
|
"./src/registries/index.ts",
|
|
34
38
|
"./dist/index.mjs",
|
|
35
|
-
"./dist/registries/index.mjs"
|
|
39
|
+
"./dist/registries/index.mjs",
|
|
40
|
+
"./dist/_chunks/*.mjs"
|
|
36
41
|
],
|
|
37
42
|
"main": "./dist/index.mjs",
|
|
38
43
|
"types": "./dist/index.d.mts",
|
|
@@ -45,6 +50,10 @@
|
|
|
45
50
|
"types": "./dist/ai.d.mts",
|
|
46
51
|
"import": "./dist/ai.mjs"
|
|
47
52
|
},
|
|
53
|
+
"./mcp": {
|
|
54
|
+
"types": "./dist/mcp.d.mts",
|
|
55
|
+
"import": "./dist/mcp.mjs"
|
|
56
|
+
},
|
|
48
57
|
"./registries": {
|
|
49
58
|
"types": "./dist/registries/index.d.mts",
|
|
50
59
|
"import": "./dist/registries/index.mjs"
|
|
@@ -58,27 +67,42 @@
|
|
|
58
67
|
"access": "public"
|
|
59
68
|
},
|
|
60
69
|
"dependencies": {
|
|
70
|
+
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
61
71
|
"citty": "^0.2.1",
|
|
62
72
|
"consola": "^3.4.2",
|
|
63
73
|
"ofetch": "^1.5.1",
|
|
74
|
+
"typebox": "^1.3.25",
|
|
64
75
|
"unstorage": "^1.17.4"
|
|
65
76
|
},
|
|
66
77
|
"devDependencies": {
|
|
78
|
+
"@agntn/ox": "^0.1.0",
|
|
79
|
+
"@earendil-works/pi-coding-agent": "0.84.2",
|
|
80
|
+
"@oh-my-pi/omptype": "18.0.0",
|
|
81
|
+
"@oh-my-pi/pi-coding-agent": "18.0.0",
|
|
67
82
|
"@types/node": "^25.3.0",
|
|
68
83
|
"ai": "^6.0.116",
|
|
69
84
|
"changelogen": "^0.6.2",
|
|
70
85
|
"obuild": "^0.4.31",
|
|
71
|
-
"oxfmt": "^0.
|
|
72
|
-
"oxlint": "^1.
|
|
86
|
+
"oxfmt": "^0.65.0",
|
|
87
|
+
"oxlint": "^1.80.0",
|
|
88
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
73
89
|
"typescript": "^5.8.3",
|
|
74
90
|
"vitest": "^4.0.0",
|
|
75
91
|
"zod": "^4.3.6"
|
|
76
92
|
},
|
|
77
93
|
"peerDependencies": {
|
|
94
|
+
"@earendil-works/pi-coding-agent": ">=0.84.2",
|
|
95
|
+
"@oh-my-pi/pi-coding-agent": ">=18.0.0",
|
|
78
96
|
"ai": "^6.0.116",
|
|
79
97
|
"zod": "^4.3.6"
|
|
80
98
|
},
|
|
81
99
|
"peerDependenciesMeta": {
|
|
100
|
+
"@earendil-works/pi-coding-agent": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
103
|
+
"@oh-my-pi/pi-coding-agent": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
82
106
|
"ai": {
|
|
83
107
|
"optional": true
|
|
84
108
|
},
|
|
@@ -89,14 +113,36 @@
|
|
|
89
113
|
"engines": {
|
|
90
114
|
"node": ">=22.6.0"
|
|
91
115
|
},
|
|
116
|
+
"mcpServers": {
|
|
117
|
+
"registries": {
|
|
118
|
+
"command": "node",
|
|
119
|
+
"args": [
|
|
120
|
+
"dist/cli.mjs",
|
|
121
|
+
"mcp"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"omp": {
|
|
126
|
+
"extensions": [
|
|
127
|
+
"./packages/omp/extensions/registries.ts"
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"pi": {
|
|
131
|
+
"extensions": [
|
|
132
|
+
"./packages/pi/extensions/registries.ts"
|
|
133
|
+
]
|
|
134
|
+
},
|
|
92
135
|
"scripts": {
|
|
93
136
|
"build": "obuild",
|
|
94
137
|
"dev:prepare": "obuild --stub",
|
|
95
|
-
"fmt": "
|
|
96
|
-
"lint": "oxlint . && oxfmt --check .",
|
|
97
|
-
"
|
|
138
|
+
"fmt": "pnpm lint:fix",
|
|
139
|
+
"lint": "pnpm build && oxlint . && oxfmt --check .",
|
|
140
|
+
"lint:fix": "oxlint . --fix && oxfmt .",
|
|
141
|
+
"typecheck": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit && pnpm build && tsc -p tsconfig.extensions.json --noEmit",
|
|
98
142
|
"test": "vitest",
|
|
99
143
|
"test:run": "vitest run",
|
|
100
|
-
"release": "pnpm test:run && pnpm build && changelogen --release --push"
|
|
144
|
+
"release": "pnpm test:run && pnpm build && changelogen --release --push",
|
|
145
|
+
"docs": "pnpm --dir docs dev",
|
|
146
|
+
"docs:build": "pnpm --dir docs build"
|
|
101
147
|
}
|
|
102
148
|
}
|