@toolpal/manifest 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE +85 -0
  2. package/README.md +4 -2
  3. package/dist/constants.d.ts +34 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/constants.js +28 -0
  6. package/dist/constants.js.map +1 -0
  7. package/dist/files.d.ts +21 -0
  8. package/dist/files.d.ts.map +1 -0
  9. package/dist/files.js +62 -0
  10. package/dist/files.js.map +1 -0
  11. package/dist/hash.d.ts +14 -0
  12. package/dist/hash.d.ts.map +1 -0
  13. package/dist/hash.js +50 -0
  14. package/dist/hash.js.map +1 -0
  15. package/dist/index.d.ts +12 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +12 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/lint.d.ts +18 -0
  20. package/dist/lint.d.ts.map +1 -0
  21. package/dist/lint.js +100 -0
  22. package/dist/lint.js.map +1 -0
  23. package/dist/manifest.d.ts +94 -0
  24. package/dist/manifest.d.ts.map +1 -0
  25. package/dist/manifest.js +34 -0
  26. package/dist/manifest.js.map +1 -0
  27. package/dist/names.d.ts +24 -0
  28. package/dist/names.d.ts.map +1 -0
  29. package/dist/names.js +47 -0
  30. package/dist/names.js.map +1 -0
  31. package/dist/permissions.d.ts +21 -0
  32. package/dist/permissions.d.ts.map +1 -0
  33. package/dist/permissions.js +86 -0
  34. package/dist/permissions.js.map +1 -0
  35. package/dist/schemas.d.ts +274 -0
  36. package/dist/schemas.d.ts.map +1 -0
  37. package/dist/schemas.js +168 -0
  38. package/dist/schemas.js.map +1 -0
  39. package/dist/signing.d.ts +25 -0
  40. package/dist/signing.d.ts.map +1 -0
  41. package/dist/signing.js +53 -0
  42. package/dist/signing.js.map +1 -0
  43. package/dist/tarball.d.ts +23 -0
  44. package/dist/tarball.d.ts.map +1 -0
  45. package/dist/tarball.js +199 -0
  46. package/dist/tarball.js.map +1 -0
  47. package/dist/versions.d.ts +19 -0
  48. package/dist/versions.d.ts.map +1 -0
  49. package/dist/versions.js +62 -0
  50. package/dist/versions.js.map +1 -0
  51. package/package.json +34 -3
@@ -0,0 +1,24 @@
1
+ export declare const TOOL_NAME_RE: RegExp;
2
+ export declare function isValidToolName(name: string): boolean;
3
+ export declare function splitToolName(name: string): {
4
+ scope: string;
5
+ name: string;
6
+ };
7
+ export type ToolRef = {
8
+ kind: "registry";
9
+ name: string;
10
+ range: string | undefined;
11
+ } | {
12
+ kind: "path";
13
+ path: string;
14
+ };
15
+ /**
16
+ * Parses what a caller passes as `tool`: `@scope/name`, `@scope/name@2` (also
17
+ * written `@2.0`), `@scope/name@latest`, or a local path. Any semver range is
18
+ * accepted, since tools published before versions were assigned in order can
19
+ * have versions like 1.2.3 (see `satisfiesVersion`).
20
+ */
21
+ export declare function parseToolRef(ref: string): ToolRef;
22
+ /** MCP tool names allow [a-zA-Z0-9_-]; `@acme/weather` becomes `acme__weather`. */
23
+ export declare function mcpToolName(name: string): string;
24
+ //# sourceMappingURL=names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../src/names.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,QAA4D,CAAC;AAEtF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAI3E;AAED,MAAM,MAAM,OAAO,GACf;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAYnC;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAejD;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGhD"}
package/dist/names.js ADDED
@@ -0,0 +1,47 @@
1
+ import semver from "semver";
2
+ // A scope is its owner's username (max 39 chars); names follow npm's lowercase rules.
3
+ export const TOOL_NAME_RE = /^@([a-z0-9][a-z0-9-]{0,38})\/([a-z0-9][a-z0-9-]{0,63})$/;
4
+ export function isValidToolName(name) {
5
+ return TOOL_NAME_RE.test(name);
6
+ }
7
+ export function splitToolName(name) {
8
+ const m = TOOL_NAME_RE.exec(name);
9
+ if (!m)
10
+ throw new Error(`Invalid tool name "${name}" (expected @scope/name)`);
11
+ return { scope: m[1], name: m[2] };
12
+ }
13
+ function looksLikePath(ref) {
14
+ return (ref.startsWith(".") ||
15
+ ref.startsWith("/") ||
16
+ ref.startsWith("\\") ||
17
+ ref.startsWith("file:") ||
18
+ /^[a-zA-Z]:[\\/]/.test(ref));
19
+ }
20
+ /**
21
+ * Parses what a caller passes as `tool`: `@scope/name`, `@scope/name@2` (also
22
+ * written `@2.0`), `@scope/name@latest`, or a local path. Any semver range is
23
+ * accepted, since tools published before versions were assigned in order can
24
+ * have versions like 1.2.3 (see `satisfiesVersion`).
25
+ */
26
+ export function parseToolRef(ref) {
27
+ const trimmed = ref.trim();
28
+ if (looksLikePath(trimmed)) {
29
+ return { kind: "path", path: trimmed.startsWith("file:") ? trimmed.slice(5) : trimmed };
30
+ }
31
+ const at = trimmed.indexOf("@", 1);
32
+ const name = at === -1 ? trimmed : trimmed.slice(0, at);
33
+ const range = at === -1 ? undefined : trimmed.slice(at + 1);
34
+ if (!isValidToolName(name)) {
35
+ throw new Error(`Invalid tool reference "${ref}" (expected @scope/name[@range] or a path)`);
36
+ }
37
+ if (range !== undefined && range !== "latest" && semver.validRange(range) === null) {
38
+ throw new Error(`Invalid version range "${range}" in "${ref}"`);
39
+ }
40
+ return { kind: "registry", name, range: range === "" ? undefined : range };
41
+ }
42
+ /** MCP tool names allow [a-zA-Z0-9_-]; `@acme/weather` becomes `acme__weather`. */
43
+ export function mcpToolName(name) {
44
+ const { scope, name: base } = splitToolName(name);
45
+ return `${scope}__${base}`;
46
+ }
47
+ //# sourceMappingURL=names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.js","sourceRoot":"","sources":["../src/names.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,sFAAsF;AACtF,MAAM,CAAC,MAAM,YAAY,GAAG,yDAAyD,CAAC;AAEtF,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,IAAI,0BAA0B,CAAC,CAAC;IAC9E,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAW,EAAE,CAAC;AACzD,CAAC;AAMD,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,CACL,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QACnB,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC;QACnB,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC;QACpB,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;QACvB,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC,CAC5B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAA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AAI,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { AnalysisReport, Finding, Permissions } from "./schemas.js";
2
+ export declare function normalizePermissions(p: Partial<Permissions> | undefined): Permissions;
3
+ export declare function mergePermissions(a: Partial<Permissions>, b: Partial<Permissions>): Permissions;
4
+ /** What the analyzer saw the code use, expressed as the permissions it needs. */
5
+ export declare function permissionsFromReport(report: AnalysisReport): Permissions;
6
+ /** Human-readable list of grants, e.g. for `toolpal info` and install summaries. */
7
+ export declare function describePermissions(p: Permissions): string[];
8
+ /** Permissions present in `next` but not in `prev`, as short labels (`net`, `tmp`, `env:X`). */
9
+ export declare function permissionsAdded(prev: Permissions, next: Permissions): string[];
10
+ export interface PermissionViolation {
11
+ permission: "net" | "env" | "tmp";
12
+ message: string;
13
+ findings: Finding[];
14
+ }
15
+ /**
16
+ * The publish gate: everything the code was seen to use must be declared.
17
+ * Declaring more than detected is allowed (dynamic code can hide usage) and only flagged.
18
+ */
19
+ export declare function checkDeclared(report: AnalysisReport, declared: Permissions): PermissionViolation[];
20
+ export declare function computeFlags(report: AnalysisReport, declared: Permissions): string[];
21
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzE,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,WAAW,CAMrF;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW,CAM9F;AAED,iFAAiF;AACjF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,CAEzE;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE,CAM5D;AAED,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,CAM/E;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,WAAW,GACpB,mBAAmB,EAAE,CA2BvB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM,EAAE,CAUpF"}
@@ -0,0 +1,86 @@
1
+ export function normalizePermissions(p) {
2
+ return {
3
+ net: p?.net === true,
4
+ env: [...new Set(p?.env ?? [])].sort(),
5
+ tmp: p?.tmp === true,
6
+ };
7
+ }
8
+ export function mergePermissions(a, b) {
9
+ return normalizePermissions({
10
+ net: a.net === true || b.net === true,
11
+ env: [...(a.env ?? []), ...(b.env ?? [])],
12
+ tmp: a.tmp === true || b.tmp === true,
13
+ });
14
+ }
15
+ /** What the analyzer saw the code use, expressed as the permissions it needs. */
16
+ export function permissionsFromReport(report) {
17
+ return normalizePermissions({ net: report.net.used, env: report.env.vars, tmp: report.fs.used });
18
+ }
19
+ /** Human-readable list of grants, e.g. for `toolpal info` and install summaries. */
20
+ export function describePermissions(p) {
21
+ const out = [];
22
+ if (p.net)
23
+ out.push("network: any host (including internal addresses)");
24
+ if (p.env.length > 0)
25
+ out.push(`env: ${p.env.join(", ")}`);
26
+ if (p.tmp)
27
+ out.push("temp files: private scratch directory");
28
+ return out.length > 0 ? out : ["none (pure compute)"];
29
+ }
30
+ /** Permissions present in `next` but not in `prev`, as short labels (`net`, `tmp`, `env:X`). */
31
+ export function permissionsAdded(prev, next) {
32
+ const added = [];
33
+ if (next.net && !prev.net)
34
+ added.push("net");
35
+ if (next.tmp && !prev.tmp)
36
+ added.push("tmp");
37
+ for (const v of next.env)
38
+ if (!prev.env.includes(v))
39
+ added.push(`env:${v}`);
40
+ return added;
41
+ }
42
+ /**
43
+ * The publish gate: everything the code was seen to use must be declared.
44
+ * Declaring more than detected is allowed (dynamic code can hide usage) and only flagged.
45
+ */
46
+ export function checkDeclared(report, declared) {
47
+ const violations = [];
48
+ const byCat = (cat) => report.findings.filter((f) => f.category === cat);
49
+ if (report.net.used && !declared.net) {
50
+ violations.push({
51
+ permission: "net",
52
+ message: "code uses the network but the manifest does not declare `net: true`",
53
+ findings: byCat("net"),
54
+ });
55
+ }
56
+ const missingEnv = report.env.vars.filter((v) => !declared.env.includes(v));
57
+ if (missingEnv.length > 0) {
58
+ violations.push({
59
+ permission: "env",
60
+ message: `code reads undeclared env vars: ${missingEnv.join(", ")}`,
61
+ findings: byCat("env").filter((f) => missingEnv.some((v) => f.detail.includes(v))),
62
+ });
63
+ }
64
+ if (report.fs.used && !declared.tmp) {
65
+ violations.push({
66
+ permission: "tmp",
67
+ message: "code imports the filesystem module but the manifest does not declare `tmp: true`",
68
+ findings: byCat("fs"),
69
+ });
70
+ }
71
+ return violations;
72
+ }
73
+ export function computeFlags(report, declared) {
74
+ const flags = [];
75
+ if (report.dynamicCode)
76
+ flags.push("dynamic-code");
77
+ if (report.blockedApis.length > 0)
78
+ flags.push("blocked-apis");
79
+ const unused = (declared.net && !report.net.used) ||
80
+ (declared.tmp && !report.fs.used) ||
81
+ (!report.env.dynamic && declared.env.some((v) => !report.env.vars.includes(v)));
82
+ if (unused)
83
+ flags.push("unused-permission");
84
+ return flags;
85
+ }
86
+ //# sourceMappingURL=permissions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,CAA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,CAAC;QAClC,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC;QACjC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,IAAI,MAAM;QAAE,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,274 @@
1
+ import { z } from "zod";
2
+ export declare const ENV_VAR_RE: RegExp;
3
+ /**
4
+ * Env vars a tool may never request: they change how Node or the dynamic linker
5
+ * start the child process (e.g. NODE_OPTIONS can re-grant permissions, LD_PRELOAD
6
+ * loads native code before the permission model exists).
7
+ */
8
+ export declare const RESERVED_ENV_RE: RegExp;
9
+ export declare const permissionsSchema: z.ZodObject<{
10
+ net: z.ZodDefault<z.ZodBoolean>;
11
+ env: z.ZodDefault<z.ZodArray<z.ZodString>>;
12
+ tmp: z.ZodDefault<z.ZodBoolean>;
13
+ }, z.core.$strict>;
14
+ export type Permissions = z.output<typeof permissionsSchema>;
15
+ export declare const limitsSchema: z.ZodObject<{
16
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
17
+ memoryMb: z.ZodDefault<z.ZodNumber>;
18
+ }, z.core.$strict>;
19
+ export type Limits = z.output<typeof limitsSchema>;
20
+ export declare const buildInfoSchema: z.ZodObject<{
21
+ toolpal: z.ZodString;
22
+ esbuild: z.ZodString;
23
+ options: z.ZodString;
24
+ }, z.core.$strict>;
25
+ export type BuildInfo = z.output<typeof buildInfoSchema>;
26
+ export declare const exampleFileSchema: z.ZodObject<{
27
+ name: z.ZodString;
28
+ size: z.ZodNumber;
29
+ mediaType: z.ZodOptional<z.ZodString>;
30
+ }, z.core.$strict>;
31
+ export type ExampleFile = z.output<typeof exampleFileSchema>;
32
+ export declare const manifestExampleSchema: z.ZodObject<{
33
+ title: z.ZodOptional<z.ZodString>;
34
+ prompt: z.ZodOptional<z.ZodString>;
35
+ input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
36
+ output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
37
+ outputFiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
38
+ name: z.ZodString;
39
+ size: z.ZodNumber;
40
+ mediaType: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strict>, z.ZodArray<z.ZodObject<{
42
+ name: z.ZodString;
43
+ size: z.ZodNumber;
44
+ mediaType: z.ZodOptional<z.ZodString>;
45
+ }, z.core.$strict>>]>>>;
46
+ }, z.core.$strict>;
47
+ export type ManifestExample = z.output<typeof manifestExampleSchema>;
48
+ export declare const manifestSchema: z.ZodObject<{
49
+ manifestVersion: z.ZodLiteral<1>;
50
+ name: z.ZodString;
51
+ version: z.ZodString;
52
+ description: z.ZodString;
53
+ license: z.ZodOptional<z.ZodString>;
54
+ repository: z.ZodOptional<z.ZodString>;
55
+ keywords: z.ZodOptional<z.ZodArray<z.ZodString>>;
56
+ entry: z.ZodLiteral<"dist/tool.mjs">;
57
+ sdk: z.ZodString;
58
+ engines: z.ZodObject<{
59
+ node: z.ZodString;
60
+ }, z.core.$strict>;
61
+ inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
62
+ outputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
63
+ examples: z.ZodOptional<z.ZodArray<z.ZodObject<{
64
+ title: z.ZodOptional<z.ZodString>;
65
+ prompt: z.ZodOptional<z.ZodString>;
66
+ input: z.ZodRecord<z.ZodString, z.ZodUnknown>;
67
+ output: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
68
+ outputFiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
69
+ name: z.ZodString;
70
+ size: z.ZodNumber;
71
+ mediaType: z.ZodOptional<z.ZodString>;
72
+ }, z.core.$strict>, z.ZodArray<z.ZodObject<{
73
+ name: z.ZodString;
74
+ size: z.ZodNumber;
75
+ mediaType: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strict>>]>>>;
77
+ }, z.core.$strict>>>;
78
+ permissions: z.ZodObject<{
79
+ net: z.ZodDefault<z.ZodBoolean>;
80
+ env: z.ZodDefault<z.ZodArray<z.ZodString>>;
81
+ tmp: z.ZodDefault<z.ZodBoolean>;
82
+ }, z.core.$strict>;
83
+ limits: z.ZodObject<{
84
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
85
+ memoryMb: z.ZodDefault<z.ZodNumber>;
86
+ }, z.core.$strict>;
87
+ build: z.ZodObject<{
88
+ toolpal: z.ZodString;
89
+ esbuild: z.ZodString;
90
+ options: z.ZodString;
91
+ }, z.core.$strict>;
92
+ }, z.core.$strict>;
93
+ export type ToolManifest = z.output<typeof manifestSchema>;
94
+ export declare const findingSchema: z.ZodObject<{
95
+ category: z.ZodEnum<{
96
+ blocked: "blocked";
97
+ dynamic: "dynamic";
98
+ env: "env";
99
+ fs: "fs";
100
+ net: "net";
101
+ }>;
102
+ detail: z.ZodString;
103
+ line: z.ZodNumber;
104
+ col: z.ZodNumber;
105
+ snippet: z.ZodString;
106
+ module: z.ZodOptional<z.ZodString>;
107
+ }, z.core.$strip>;
108
+ export type Finding = z.output<typeof findingSchema>;
109
+ export declare const analysisReportSchema: z.ZodObject<{
110
+ analyzerVersion: z.ZodString;
111
+ net: z.ZodObject<{
112
+ used: z.ZodBoolean;
113
+ hosts: z.ZodArray<z.ZodString>;
114
+ dynamicUrls: z.ZodBoolean;
115
+ }, z.core.$strip>;
116
+ env: z.ZodObject<{
117
+ vars: z.ZodArray<z.ZodString>;
118
+ dynamic: z.ZodBoolean;
119
+ }, z.core.$strip>;
120
+ fs: z.ZodObject<{
121
+ used: z.ZodBoolean;
122
+ }, z.core.$strip>;
123
+ blockedApis: z.ZodArray<z.ZodString>;
124
+ dynamicCode: z.ZodBoolean;
125
+ findings: z.ZodArray<z.ZodObject<{
126
+ category: z.ZodEnum<{
127
+ blocked: "blocked";
128
+ dynamic: "dynamic";
129
+ env: "env";
130
+ fs: "fs";
131
+ net: "net";
132
+ }>;
133
+ detail: z.ZodString;
134
+ line: z.ZodNumber;
135
+ col: z.ZodNumber;
136
+ snippet: z.ZodString;
137
+ module: z.ZodOptional<z.ZodString>;
138
+ }, z.core.$strip>>;
139
+ }, z.core.$strip>;
140
+ export type AnalysisReport = z.output<typeof analysisReportSchema>;
141
+ export declare const lockEntrySchema: z.ZodObject<{
142
+ version: z.ZodString;
143
+ resolved: z.ZodString;
144
+ integrity: z.ZodString;
145
+ entryIntegrity: z.ZodString;
146
+ manifestHash: z.ZodString;
147
+ publishedAt: z.ZodString;
148
+ signature: z.ZodString;
149
+ keyId: z.ZodString;
150
+ publisher: z.ZodOptional<z.ZodString>;
151
+ verified: z.ZodOptional<z.ZodBoolean>;
152
+ permissions: z.ZodObject<{
153
+ net: z.ZodDefault<z.ZodBoolean>;
154
+ env: z.ZodDefault<z.ZodArray<z.ZodString>>;
155
+ tmp: z.ZodDefault<z.ZodBoolean>;
156
+ }, z.core.$strict>;
157
+ flags: z.ZodDefault<z.ZodArray<z.ZodString>>;
158
+ }, z.core.$strict>;
159
+ export type LockEntry = z.output<typeof lockEntrySchema>;
160
+ export declare const lockfileSchema: z.ZodObject<{
161
+ lockfileVersion: z.ZodLiteral<1>;
162
+ tools: z.ZodRecord<z.ZodString, z.ZodObject<{
163
+ version: z.ZodString;
164
+ resolved: z.ZodString;
165
+ integrity: z.ZodString;
166
+ entryIntegrity: z.ZodString;
167
+ manifestHash: z.ZodString;
168
+ publishedAt: z.ZodString;
169
+ signature: z.ZodString;
170
+ keyId: z.ZodString;
171
+ publisher: z.ZodOptional<z.ZodString>;
172
+ verified: z.ZodOptional<z.ZodBoolean>;
173
+ permissions: z.ZodObject<{
174
+ net: z.ZodDefault<z.ZodBoolean>;
175
+ env: z.ZodDefault<z.ZodArray<z.ZodString>>;
176
+ tmp: z.ZodDefault<z.ZodBoolean>;
177
+ }, z.core.$strict>;
178
+ flags: z.ZodDefault<z.ZodArray<z.ZodString>>;
179
+ }, z.core.$strict>>;
180
+ }, z.core.$strict>;
181
+ export type Lockfile = z.output<typeof lockfileSchema>;
182
+ export declare const projectConfigSchema: z.ZodObject<{
183
+ $schema: z.ZodOptional<z.ZodString>;
184
+ registry: z.ZodOptional<z.ZodString>;
185
+ tools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
186
+ env: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodObject<{
187
+ fromEnv: z.ZodString;
188
+ }, z.core.$strict>>>>;
189
+ policy: z.ZodDefault<z.ZodObject<{
190
+ maxTimeoutMs: z.ZodOptional<z.ZodNumber>;
191
+ maxMemoryMb: z.ZodOptional<z.ZodNumber>;
192
+ isolation: z.ZodOptional<z.ZodEnum<{
193
+ "per-call": "per-call";
194
+ warm: "warm";
195
+ }>>;
196
+ }, z.core.$strict>>;
197
+ }, z.core.$strict>;
198
+ export type ProjectConfig = z.output<typeof projectConfigSchema>;
199
+ export declare const registryKeySchema: z.ZodObject<{
200
+ keyId: z.ZodString;
201
+ x: z.ZodString;
202
+ }, z.core.$strip>;
203
+ export type RegistryKey = z.output<typeof registryKeySchema>;
204
+ /** Who can see a tool on the registry: everyone, or only the owner of its scope. */
205
+ export declare const visibilitySchema: z.ZodEnum<{
206
+ private: "private";
207
+ public: "public";
208
+ }>;
209
+ export type Visibility = z.output<typeof visibilitySchema>;
210
+ export declare const packumentVersionSchema: z.ZodObject<{
211
+ version: z.ZodString;
212
+ integrity: z.ZodString;
213
+ entryIntegrity: z.ZodString;
214
+ manifestHash: z.ZodString;
215
+ publishedAt: z.ZodString;
216
+ signature: z.ZodString;
217
+ keyId: z.ZodString;
218
+ publisher: z.ZodString;
219
+ tarball: z.ZodString;
220
+ yanked: z.ZodBoolean;
221
+ quarantined: z.ZodDefault<z.ZodBoolean>;
222
+ permissions: z.ZodObject<{
223
+ net: z.ZodDefault<z.ZodBoolean>;
224
+ env: z.ZodDefault<z.ZodArray<z.ZodString>>;
225
+ tmp: z.ZodDefault<z.ZodBoolean>;
226
+ }, z.core.$strict>;
227
+ flags: z.ZodArray<z.ZodString>;
228
+ hosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
229
+ description: z.ZodString;
230
+ openIssues: z.ZodDefault<z.ZodNumber>;
231
+ openBroken: z.ZodDefault<z.ZodNumber>;
232
+ }, z.core.$strip>;
233
+ export type PackumentVersion = z.output<typeof packumentVersionSchema>;
234
+ export declare const packumentSchema: z.ZodObject<{
235
+ name: z.ZodString;
236
+ description: z.ZodString;
237
+ verified: z.ZodBoolean;
238
+ stars: z.ZodNumber;
239
+ downloads: z.ZodNumber;
240
+ openIssues: z.ZodDefault<z.ZodNumber>;
241
+ visibility: z.ZodDefault<z.ZodEnum<{
242
+ private: "private";
243
+ public: "public";
244
+ }>>;
245
+ distTags: z.ZodObject<{
246
+ latest: z.ZodString;
247
+ }, z.core.$strip>;
248
+ deprecated: z.ZodDefault<z.ZodNullable<z.ZodString>>;
249
+ versions: z.ZodRecord<z.ZodString, z.ZodObject<{
250
+ version: z.ZodString;
251
+ integrity: z.ZodString;
252
+ entryIntegrity: z.ZodString;
253
+ manifestHash: z.ZodString;
254
+ publishedAt: z.ZodString;
255
+ signature: z.ZodString;
256
+ keyId: z.ZodString;
257
+ publisher: z.ZodString;
258
+ tarball: z.ZodString;
259
+ yanked: z.ZodBoolean;
260
+ quarantined: z.ZodDefault<z.ZodBoolean>;
261
+ permissions: z.ZodObject<{
262
+ net: z.ZodDefault<z.ZodBoolean>;
263
+ env: z.ZodDefault<z.ZodArray<z.ZodString>>;
264
+ tmp: z.ZodDefault<z.ZodBoolean>;
265
+ }, z.core.$strict>;
266
+ flags: z.ZodArray<z.ZodString>;
267
+ hosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
268
+ description: z.ZodString;
269
+ openIssues: z.ZodDefault<z.ZodNumber>;
270
+ openBroken: z.ZodDefault<z.ZodNumber>;
271
+ }, z.core.$strip>>;
272
+ }, z.core.$strip>;
273
+ export type Packument = z.output<typeof packumentSchema>;
274
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,eAAO,MAAM,UAAU,QAAmC,CAAC;AAC3D;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAC8C,CAAC;AAE3E,eAAO,MAAM,iBAAiB;;;;kBAY5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE7D,eAAO,MAAM,YAAY;;;kBAGvB,CAAC;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,YAAY,CAAC,CAAC;AAUnD,eAAO,MAAM,eAAe;;;;kBAK1B,CAAC;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAEzD,eAAO,MAAM,iBAAiB;;;;kBAI5B,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE7D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;kBAa/B,CAAC;AACJ,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAErE,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAiBzB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,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AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -0,0 +1,168 @@
1
+ import { z } from "zod";
2
+ import { DEFAULT_LIMITS, ENTRY_PATH, LOCKFILE_VERSION, MANIFEST_VERSION, MAX_DESCRIPTION_CHARS, MAX_EXAMPLE_BYTES, MAX_EXAMPLES, MAX_LIMITS, MAX_SCHEMA_BYTES, } from "./constants.js";
3
+ import { TOOL_NAME_RE } from "./names.js";
4
+ import { isValidVersion } from "./versions.js";
5
+ export const ENV_VAR_RE = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
6
+ /**
7
+ * Env vars a tool may never request: they change how Node or the dynamic linker
8
+ * start the child process (e.g. NODE_OPTIONS can re-grant permissions, LD_PRELOAD
9
+ * loads native code before the permission model exists).
10
+ */
11
+ export const RESERVED_ENV_RE = /^(NODE_|NPM_|LD_|DYLD_|ELECTRON_)|^(PATH|PATHEXT|SYSTEMROOT|COMSPEC)$/i;
12
+ export const permissionsSchema = z.strictObject({
13
+ net: z.boolean().default(false),
14
+ env: z
15
+ .array(z
16
+ .string()
17
+ .regex(ENV_VAR_RE, "invalid environment variable name")
18
+ .refine((v) => !RESERVED_ENV_RE.test(v), "reserved environment variable"))
19
+ .max(64)
20
+ .default([]),
21
+ tmp: z.boolean().default(false),
22
+ });
23
+ export const limitsSchema = z.strictObject({
24
+ timeoutMs: z.number().int().min(100).max(MAX_LIMITS.timeoutMs).default(DEFAULT_LIMITS.timeoutMs),
25
+ memoryMb: z.number().int().min(16).max(MAX_LIMITS.memoryMb).default(DEFAULT_LIMITS.memoryMb),
26
+ });
27
+ const jsonSchemaObject = z
28
+ .record(z.string(), z.unknown())
29
+ .refine((s) => s.type === "object", 'must be an object schema ({ "type": "object", ... })')
30
+ .refine((s) => Buffer.byteLength(JSON.stringify(s)) <= MAX_SCHEMA_BYTES, `schema larger than ${MAX_SCHEMA_BYTES} bytes`);
31
+ export const buildInfoSchema = z.strictObject({
32
+ toolpal: z.string().max(32),
33
+ esbuild: z.string().max(32),
34
+ /** sha256 of the canonical esbuild options, so verify-build can detect option drift. */
35
+ options: z.string().max(80),
36
+ });
37
+ export const exampleFileSchema = z.strictObject({
38
+ name: z.string().min(1).max(255),
39
+ size: z.number().int().min(0),
40
+ mediaType: z.string().max(128).optional(),
41
+ });
42
+ export const manifestExampleSchema = z
43
+ .strictObject({
44
+ title: z.string().min(1).max(120).optional(),
45
+ prompt: z.string().min(1).max(300).optional(),
46
+ input: z.record(z.string(), z.unknown()),
47
+ output: z.record(z.string(), z.unknown()).optional(),
48
+ outputFiles: z
49
+ .record(z.string(), z.union([exampleFileSchema, z.array(exampleFileSchema)]))
50
+ .optional(),
51
+ })
52
+ .refine((ex) => Buffer.byteLength(JSON.stringify(ex)) <= MAX_EXAMPLE_BYTES, `example larger than ${MAX_EXAMPLE_BYTES} bytes`);
53
+ export const manifestSchema = z.strictObject({
54
+ manifestVersion: z.literal(MANIFEST_VERSION),
55
+ name: z.string().regex(TOOL_NAME_RE, "must be @scope/name (lowercase letters, digits, -)"),
56
+ version: z.string().refine(isValidVersion, "must be a version like 2.0"),
57
+ description: z.string().min(1).max(MAX_DESCRIPTION_CHARS),
58
+ license: z.string().max(128).optional(),
59
+ repository: z.string().max(512).optional(),
60
+ keywords: z.array(z.string().max(64)).max(20).optional(),
61
+ entry: z.literal(ENTRY_PATH),
62
+ sdk: z.string().max(32),
63
+ engines: z.strictObject({ node: z.string().max(64) }),
64
+ inputSchema: jsonSchemaObject,
65
+ outputSchema: jsonSchemaObject,
66
+ examples: z.array(manifestExampleSchema).max(MAX_EXAMPLES).optional(),
67
+ permissions: permissionsSchema,
68
+ limits: limitsSchema,
69
+ build: buildInfoSchema,
70
+ });
71
+ // ---------------------------------------------------------------------------
72
+ // Static analysis report
73
+ // ---------------------------------------------------------------------------
74
+ export const findingSchema = z.object({
75
+ category: z.enum(["net", "env", "fs", "blocked", "dynamic"]),
76
+ detail: z.string(),
77
+ line: z.number().int(),
78
+ col: z.number().int(),
79
+ snippet: z.string(),
80
+ /** Source module the finding came from, taken from esbuild's path comments (advisory). */
81
+ module: z.string().optional(),
82
+ });
83
+ export const analysisReportSchema = z.object({
84
+ analyzerVersion: z.string(),
85
+ net: z.object({ used: z.boolean(), hosts: z.array(z.string()), dynamicUrls: z.boolean() }),
86
+ env: z.object({ vars: z.array(z.string()), dynamic: z.boolean() }),
87
+ fs: z.object({ used: z.boolean() }),
88
+ blockedApis: z.array(z.string()),
89
+ dynamicCode: z.boolean(),
90
+ findings: z.array(findingSchema),
91
+ });
92
+ // ---------------------------------------------------------------------------
93
+ // Consumer project files: toolpal.json + toolpal.lock
94
+ // ---------------------------------------------------------------------------
95
+ export const lockEntrySchema = z.strictObject({
96
+ version: z.string(),
97
+ resolved: z.string(),
98
+ integrity: z.string(),
99
+ entryIntegrity: z.string(),
100
+ manifestHash: z.string(),
101
+ publishedAt: z.string(),
102
+ signature: z.string(),
103
+ keyId: z.string(),
104
+ publisher: z.string().optional(),
105
+ verified: z.boolean().optional(),
106
+ permissions: permissionsSchema,
107
+ flags: z.array(z.string()).default([]),
108
+ });
109
+ export const lockfileSchema = z.strictObject({
110
+ lockfileVersion: z.literal(LOCKFILE_VERSION),
111
+ tools: z.record(z.string(), lockEntrySchema),
112
+ });
113
+ export const projectConfigSchema = z.strictObject({
114
+ $schema: z.string().optional(),
115
+ registry: z.string().url().optional(),
116
+ tools: z.record(z.string(), z.string()).default({}),
117
+ env: z
118
+ .record(z.string(), z.record(z.string(), z.strictObject({ fromEnv: z.string() })))
119
+ .default({}),
120
+ policy: z
121
+ .strictObject({
122
+ maxTimeoutMs: z.number().int().positive().optional(),
123
+ maxMemoryMb: z.number().int().positive().optional(),
124
+ isolation: z.enum(["warm", "per-call"]).optional(),
125
+ })
126
+ .default({}),
127
+ });
128
+ // ---------------------------------------------------------------------------
129
+ // Registry API shapes (lenient objects so newer registries can add fields)
130
+ // ---------------------------------------------------------------------------
131
+ export const registryKeySchema = z.object({ keyId: z.string(), x: z.string() });
132
+ /** Who can see a tool on the registry: everyone, or only the owner of its scope. */
133
+ export const visibilitySchema = z.enum(["public", "private"]);
134
+ export const packumentVersionSchema = z.object({
135
+ version: z.string(),
136
+ integrity: z.string(),
137
+ entryIntegrity: z.string(),
138
+ manifestHash: z.string(),
139
+ publishedAt: z.string(),
140
+ signature: z.string(),
141
+ keyId: z.string(),
142
+ publisher: z.string(),
143
+ tarball: z.string(),
144
+ yanked: z.boolean(),
145
+ /** Withheld by registry moderators (also reported as yanked, for older clients). */
146
+ quarantined: z.boolean().default(false),
147
+ permissions: permissionsSchema,
148
+ flags: z.array(z.string()),
149
+ hosts: z.array(z.string()).default([]),
150
+ description: z.string(),
151
+ openIssues: z.number().int().min(0).default(0),
152
+ openBroken: z.number().int().min(0).default(0),
153
+ });
154
+ export const packumentSchema = z.object({
155
+ name: z.string(),
156
+ description: z.string(),
157
+ verified: z.boolean(),
158
+ stars: z.number(),
159
+ downloads: z.number(),
160
+ openIssues: z.number().int().min(0).default(0),
161
+ /** Registries from before private tools report nothing; everything on them is public. */
162
+ visibility: visibilitySchema.default("public"),
163
+ distTags: z.object({ latest: z.string() }),
164
+ /** Deprecation message set by the tool's maintainers, if any. */
165
+ deprecated: z.string().nullable().default(null),
166
+ versions: z.record(z.string(), packumentVersionSchema),
167
+ });
168
+ //# sourceMappingURL=schemas.js.map