@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.
- package/LICENSE +85 -0
- package/README.md +4 -2
- package/dist/constants.d.ts +34 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +28 -0
- package/dist/constants.js.map +1 -0
- package/dist/files.d.ts +21 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +62 -0
- package/dist/files.js.map +1 -0
- package/dist/hash.d.ts +14 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +50 -0
- package/dist/hash.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lint.d.ts +18 -0
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +100 -0
- package/dist/lint.js.map +1 -0
- package/dist/manifest.d.ts +94 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +34 -0
- package/dist/manifest.js.map +1 -0
- package/dist/names.d.ts +24 -0
- package/dist/names.d.ts.map +1 -0
- package/dist/names.js +47 -0
- package/dist/names.js.map +1 -0
- package/dist/permissions.d.ts +21 -0
- package/dist/permissions.d.ts.map +1 -0
- package/dist/permissions.js +86 -0
- package/dist/permissions.js.map +1 -0
- package/dist/schemas.d.ts +274 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +168 -0
- package/dist/schemas.js.map +1 -0
- package/dist/signing.d.ts +25 -0
- package/dist/signing.d.ts.map +1 -0
- package/dist/signing.js +53 -0
- package/dist/signing.js.map +1 -0
- package/dist/tarball.d.ts +23 -0
- package/dist/tarball.d.ts.map +1 -0
- package/dist/tarball.js +199 -0
- package/dist/tarball.js.map +1 -0
- package/dist/versions.d.ts +19 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +62 -0
- package/dist/versions.js.map +1 -0
- package/package.json +34 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
Toolpal License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 the Toolpal authors. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This license covers the Toolpal client packages: toolpal, @toolpal/tool,
|
|
6
|
+
@toolpal/runtime, @toolpal/sandbox, @toolpal/manifest, @toolpal/analyzer and
|
|
7
|
+
@toolpal/builder (together, the "Software"). It does not cover any other
|
|
8
|
+
Toolpal software or service, such as the Toolpal registry or website.
|
|
9
|
+
The Toolpal authors are the "licensor"; "you" means the person or
|
|
10
|
+
organization using the Software.
|
|
11
|
+
|
|
12
|
+
1. Use
|
|
13
|
+
|
|
14
|
+
The licensor grants you a free, worldwide, non-exclusive, non-transferable
|
|
15
|
+
license to install, run and use the Software for any purpose, including
|
|
16
|
+
commercial purposes, subject to the terms below.
|
|
17
|
+
|
|
18
|
+
2. Tools you build
|
|
19
|
+
|
|
20
|
+
You may include @toolpal/tool, and any other code the Software adds to a
|
|
21
|
+
tool when it builds one, in tools you create. You may publish and
|
|
22
|
+
distribute those tools, through the Toolpal registry or otherwise, under
|
|
23
|
+
terms you choose for your own code. The parts of a tool that come from the
|
|
24
|
+
Software remain under this license.
|
|
25
|
+
|
|
26
|
+
3. Copies
|
|
27
|
+
|
|
28
|
+
You may make the copies of the Software you need to use it, including in
|
|
29
|
+
your own applications, container images, caches and deployments, as long
|
|
30
|
+
as each copy keeps this license and is unmodified apart from automated
|
|
31
|
+
bundling, compilation or minification.
|
|
32
|
+
|
|
33
|
+
4. Restrictions
|
|
34
|
+
|
|
35
|
+
You may not:
|
|
36
|
+
|
|
37
|
+
a. modify the Software or make derivative works of it, except as
|
|
38
|
+
sections 2 and 3 allow;
|
|
39
|
+
b. sell, rent, lease or sublicense the Software, or distribute it on its
|
|
40
|
+
own, except as sections 2 and 3 allow;
|
|
41
|
+
c. use the Software to offer a product or service that competes with
|
|
42
|
+
Toolpal, such as a tool registry or marketplace, without the
|
|
43
|
+
licensor's written permission;
|
|
44
|
+
d. remove or change any copyright, license or other notice in the
|
|
45
|
+
Software.
|
|
46
|
+
|
|
47
|
+
5. Third-party software
|
|
48
|
+
|
|
49
|
+
The Software uses open-source components that are licensed to you under
|
|
50
|
+
their own licenses. Nothing in this license limits your rights under
|
|
51
|
+
those licenses.
|
|
52
|
+
|
|
53
|
+
6. Ownership
|
|
54
|
+
|
|
55
|
+
The licensor keeps all rights in the Software that this license does not
|
|
56
|
+
expressly grant you. This license grants no rights to the Toolpal name or
|
|
57
|
+
logo.
|
|
58
|
+
|
|
59
|
+
7. Termination
|
|
60
|
+
|
|
61
|
+
This license ends automatically if you break any of its terms. You must
|
|
62
|
+
then stop using the Software and delete your copies of it. Tools you
|
|
63
|
+
distributed before then stay licensed under section 2 for the people who
|
|
64
|
+
received them.
|
|
65
|
+
|
|
66
|
+
8. No warranty
|
|
67
|
+
|
|
68
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
69
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
70
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
71
|
+
|
|
72
|
+
9. Limitation of liability
|
|
73
|
+
|
|
74
|
+
IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
75
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
76
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
77
|
+
DEALINGS IN THE SOFTWARE. THIS INCLUDES HARM CAUSED BY TOOLS YOU RUN WITH
|
|
78
|
+
THE SOFTWARE: ITS ISOLATION REDUCES RISK BUT IS NOT A GUARANTEE (SEE THE
|
|
79
|
+
SECURITY MODEL IN THE TOOLPAL DOCUMENTATION).
|
|
80
|
+
|
|
81
|
+
10. Future versions
|
|
82
|
+
|
|
83
|
+
The licensor may release future versions of the Software under different
|
|
84
|
+
terms. Each version of the Software is governed by the license included
|
|
85
|
+
with it.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @toolpal/manifest
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared manifest, lockfile, tarball, signing, and static-analysis report schemas for [Toolpal](https://toolpal.dev).
|
|
4
|
+
|
|
5
|
+
Most users should install the [`toolpal`](https://www.npmjs.com/package/toolpal) CLI/SDK or [`@toolpal/tool`](https://www.npmjs.com/package/@toolpal/tool) instead.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare const MANIFEST_VERSION: 1;
|
|
2
|
+
export declare const LOCKFILE_VERSION: 1;
|
|
3
|
+
/** Path of the executable bundle inside a built tool and inside its tarball's `package/` root. */
|
|
4
|
+
export declare const ENTRY_PATH = "dist/tool.mjs";
|
|
5
|
+
/** Path of the generated manifest inside the tarball's `package/` root. */
|
|
6
|
+
export declare const TARBALL_MANIFEST_PATH = "manifest.json";
|
|
7
|
+
/**
|
|
8
|
+
* The version in the manifest of a build that has not been published. Authors never
|
|
9
|
+
* choose versions: the registry numbers each publish (see `nextVersion`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const UNPUBLISHED_VERSION = "0.0";
|
|
12
|
+
export declare const MIN_NODE_VERSION = "22.15.0";
|
|
13
|
+
/** First Node major with `--allow-net`; below it network denial is the JS-level guard. */
|
|
14
|
+
export declare const NATIVE_NET_NODE_MAJOR = 25;
|
|
15
|
+
export declare const DEFAULT_LIMITS: {
|
|
16
|
+
readonly timeoutMs: 10000;
|
|
17
|
+
readonly memoryMb: 128;
|
|
18
|
+
};
|
|
19
|
+
export declare const MAX_LIMITS: {
|
|
20
|
+
readonly timeoutMs: 300000;
|
|
21
|
+
readonly memoryMb: 4096;
|
|
22
|
+
};
|
|
23
|
+
export declare const MAX_DESCRIPTION_CHARS = 1024;
|
|
24
|
+
export declare const MAX_SCHEMA_BYTES: number;
|
|
25
|
+
export declare const MAX_EXAMPLES = 5;
|
|
26
|
+
export declare const MAX_EXAMPLE_BYTES: number;
|
|
27
|
+
export declare const MAX_BUNDLE_BYTES: number;
|
|
28
|
+
export declare const MAX_TARBALL_BYTES: number;
|
|
29
|
+
export declare const MAX_TARBALL_FILES = 2000;
|
|
30
|
+
/** Files one call may hand to a tool, and files it may return. */
|
|
31
|
+
export declare const MAX_FILES_PER_CALL = 64;
|
|
32
|
+
/** Size limit of each file handed to a tool or returned by one. */
|
|
33
|
+
export declare const MAX_FILE_BYTES: number;
|
|
34
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAC3C,eAAO,MAAM,gBAAgB,EAAG,CAAU,CAAC;AAE3C,kGAAkG;AAClG,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAC1C,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AAErD;;;GAGG;AACH,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C,0FAA0F;AAC1F,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,eAAO,MAAM,cAAc;aAAK,SAAS,EAAE,KAAM;aAAE,QAAQ,EAAE,GAAG;CAAW,CAAC;AAC5E,eAAO,MAAM,UAAU;aAAK,SAAS,EAAE,MAAO;aAAE,QAAQ,EAAE,IAAI;CAAW,CAAC;AAE1E,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,gBAAgB,QAAY,CAAC;AAC1C,eAAO,MAAM,YAAY,IAAI,CAAC;AAC9B,eAAO,MAAM,iBAAiB,QAAY,CAAC;AAC3C,eAAO,MAAM,gBAAgB,QAAkB,CAAC;AAChD,eAAO,MAAM,iBAAiB,QAAmB,CAAC;AAClD,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,mEAAmE;AACnE,eAAO,MAAM,cAAc,QAAqB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const MANIFEST_VERSION = 1;
|
|
2
|
+
export const LOCKFILE_VERSION = 1;
|
|
3
|
+
/** Path of the executable bundle inside a built tool and inside its tarball's `package/` root. */
|
|
4
|
+
export const ENTRY_PATH = "dist/tool.mjs";
|
|
5
|
+
/** Path of the generated manifest inside the tarball's `package/` root. */
|
|
6
|
+
export const TARBALL_MANIFEST_PATH = "manifest.json";
|
|
7
|
+
/**
|
|
8
|
+
* The version in the manifest of a build that has not been published. Authors never
|
|
9
|
+
* choose versions: the registry numbers each publish (see `nextVersion`).
|
|
10
|
+
*/
|
|
11
|
+
export const UNPUBLISHED_VERSION = "0.0";
|
|
12
|
+
export const MIN_NODE_VERSION = "22.15.0";
|
|
13
|
+
/** First Node major with `--allow-net`; below it network denial is the JS-level guard. */
|
|
14
|
+
export const NATIVE_NET_NODE_MAJOR = 25;
|
|
15
|
+
export const DEFAULT_LIMITS = { timeoutMs: 10_000, memoryMb: 128 };
|
|
16
|
+
export const MAX_LIMITS = { timeoutMs: 300_000, memoryMb: 4096 };
|
|
17
|
+
export const MAX_DESCRIPTION_CHARS = 1024;
|
|
18
|
+
export const MAX_SCHEMA_BYTES = 64 * 1024;
|
|
19
|
+
export const MAX_EXAMPLES = 5;
|
|
20
|
+
export const MAX_EXAMPLE_BYTES = 32 * 1024;
|
|
21
|
+
export const MAX_BUNDLE_BYTES = 5 * 1024 * 1024;
|
|
22
|
+
export const MAX_TARBALL_BYTES = 10 * 1024 * 1024;
|
|
23
|
+
export const MAX_TARBALL_FILES = 2000;
|
|
24
|
+
/** Files one call may hand to a tool, and files it may return. */
|
|
25
|
+
export const MAX_FILES_PER_CALL = 64;
|
|
26
|
+
/** Size limit of each file handed to a tool or returned by one. */
|
|
27
|
+
export const MAX_FILE_BYTES = 1024 * 1024 * 1024;
|
|
28
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAU,CAAC;AAE3C,kGAAkG;AAClG,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;AAC1C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAC1C,0FAA0F;AAC1F,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAW,CAAC;AAC5E,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAW,CAAC;AAE1E,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AAC9B,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,CAAC;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAEtC,kEAAkE;AAClE,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,mEAAmE;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks a string in a tool's input or output schema as the path of a file
|
|
3
|
+
* (`FilePath()` in `@toolpal/tool` writes it). The host copies such files into
|
|
4
|
+
* and out of the tool's private directory; the tool never sees the caller's paths.
|
|
5
|
+
*/
|
|
6
|
+
export declare const FILE_KEYWORD = "x-toolpal-file";
|
|
7
|
+
export interface FileField {
|
|
8
|
+
/** The top-level property that holds the path. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** The property is an array of paths rather than one. */
|
|
11
|
+
many: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The file fields of an input or output schema. Only a top-level property, or the
|
|
15
|
+
* items of a top-level array, can be one: that is all the host looks at, so a
|
|
16
|
+
* marker anywhere else hands the tool nothing (see `misplacedFileFields`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function fileFields(schema: Record<string, unknown>): FileField[];
|
|
19
|
+
/** Paths (below `root`) of file markers that `fileFields` does not pick up. */
|
|
20
|
+
export declare function misplacedFileFields(root: string, schema: Record<string, unknown>): string[];
|
|
21
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAE7C,MAAM,WAAW,SAAS;IACxB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,IAAI,EAAE,OAAO,CAAC;CACf;AAmBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,CAUvE;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,EAAE,CAoB3F"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks a string in a tool's input or output schema as the path of a file
|
|
3
|
+
* (`FilePath()` in `@toolpal/tool` writes it). The host copies such files into
|
|
4
|
+
* and out of the tool's private directory; the tool never sees the caller's paths.
|
|
5
|
+
*/
|
|
6
|
+
export const FILE_KEYWORD = "x-toolpal-file";
|
|
7
|
+
/** Keywords whose value maps names to schemas, so its keys are not keywords themselves. */
|
|
8
|
+
const SCHEMA_MAPS = new Set([
|
|
9
|
+
"properties",
|
|
10
|
+
"patternProperties",
|
|
11
|
+
"$defs",
|
|
12
|
+
"definitions",
|
|
13
|
+
"dependentSchemas",
|
|
14
|
+
]);
|
|
15
|
+
function isRecord(value) {
|
|
16
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
function isFileSchema(node) {
|
|
19
|
+
return isRecord(node) && node.type === "string" && node[FILE_KEYWORD] === true;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The file fields of an input or output schema. Only a top-level property, or the
|
|
23
|
+
* items of a top-level array, can be one: that is all the host looks at, so a
|
|
24
|
+
* marker anywhere else hands the tool nothing (see `misplacedFileFields`).
|
|
25
|
+
*/
|
|
26
|
+
export function fileFields(schema) {
|
|
27
|
+
if (!isRecord(schema.properties))
|
|
28
|
+
return [];
|
|
29
|
+
const fields = [];
|
|
30
|
+
for (const [name, property] of Object.entries(schema.properties)) {
|
|
31
|
+
if (isFileSchema(property))
|
|
32
|
+
fields.push({ name, many: false });
|
|
33
|
+
else if (isRecord(property) && property.type === "array" && isFileSchema(property.items)) {
|
|
34
|
+
fields.push({ name, many: true });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return fields;
|
|
38
|
+
}
|
|
39
|
+
/** Paths (below `root`) of file markers that `fileFields` does not pick up. */
|
|
40
|
+
export function misplacedFileFields(root, schema) {
|
|
41
|
+
const allowed = new Set(fileFields(schema).map(({ name, many }) => `${root}.properties.${name}${many ? ".items" : ""}`));
|
|
42
|
+
const found = [];
|
|
43
|
+
const walk = (path, node, isMap) => {
|
|
44
|
+
if (Array.isArray(node)) {
|
|
45
|
+
node.forEach((child, i) => {
|
|
46
|
+
walk(`${path}[${i}]`, child, false);
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!isRecord(node))
|
|
51
|
+
return;
|
|
52
|
+
for (const [key, value] of Object.entries(node)) {
|
|
53
|
+
if (!isMap && key === FILE_KEYWORD)
|
|
54
|
+
found.push(path);
|
|
55
|
+
else
|
|
56
|
+
walk(`${path}.${key}`, value, !isMap && SCHEMA_MAPS.has(key));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
walk(root, schema, false);
|
|
60
|
+
return found.filter((path) => !allowed.has(path));
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAS7C,2FAA2F;AAC3F,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,YAAY;IACZ,mBAAmB;IACnB,OAAO;IACP,aAAa;IACb,kBAAkB;CACnB,CAAC,CAAC;AAEH,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAA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3B,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,IAAa,EAAE,KAAc,EAAQ,EAAE;QACjE,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;gBACxB,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,OAAO;QAC5B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,IAAI,CAAC,KAAK,IAAI,GAAG,KAAK,YAAY;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;gBAChD,IAAI,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACrE,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC1B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/hash.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type Algo = "sha256" | "sha512";
|
|
2
|
+
/** Subresource-Integrity style digest, e.g. `sha512-<base64>`. */
|
|
3
|
+
export declare function integrityOf(data: Uint8Array | string, algo?: Algo): string;
|
|
4
|
+
export declare function sha256Hex(data: Uint8Array | string): string;
|
|
5
|
+
export declare function verifyIntegrity(data: Uint8Array | string, integrity: string): boolean;
|
|
6
|
+
/** Integrity string → filesystem-safe hex (used for content-addressed store paths). */
|
|
7
|
+
export declare function integrityToHex(integrity: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Deterministic JSON: object keys sorted recursively, arrays kept in order,
|
|
10
|
+
* `undefined` properties dropped. Used for every hash and signature payload.
|
|
11
|
+
*/
|
|
12
|
+
export declare function canonicalJson(value: unknown): string;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAEA,KAAK,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAMhC,kEAAkE;AAClE,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,IAAI,GAAE,IAAe,GAAG,MAAM,CAEpF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAE3D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAOrF;AAED,uFAAuF;AACvF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD"}
|
package/dist/hash.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createHash, timingSafeEqual } from "node:crypto";
|
|
2
|
+
function digest(algo, data) {
|
|
3
|
+
return createHash(algo).update(data).digest();
|
|
4
|
+
}
|
|
5
|
+
/** Subresource-Integrity style digest, e.g. `sha512-<base64>`. */
|
|
6
|
+
export function integrityOf(data, algo = "sha512") {
|
|
7
|
+
return `${algo}-${digest(algo, data).toString("base64")}`;
|
|
8
|
+
}
|
|
9
|
+
export function sha256Hex(data) {
|
|
10
|
+
return digest("sha256", data).toString("hex");
|
|
11
|
+
}
|
|
12
|
+
export function verifyIntegrity(data, integrity) {
|
|
13
|
+
const dash = integrity.indexOf("-");
|
|
14
|
+
const algo = integrity.slice(0, dash);
|
|
15
|
+
if (dash === -1 || (algo !== "sha256" && algo !== "sha512"))
|
|
16
|
+
return false;
|
|
17
|
+
const expected = Buffer.from(integrity.slice(dash + 1), "base64");
|
|
18
|
+
const actual = digest(algo, data);
|
|
19
|
+
return expected.length === actual.length && timingSafeEqual(expected, actual);
|
|
20
|
+
}
|
|
21
|
+
/** Integrity string → filesystem-safe hex (used for content-addressed store paths). */
|
|
22
|
+
export function integrityToHex(integrity) {
|
|
23
|
+
const dash = integrity.indexOf("-");
|
|
24
|
+
return Buffer.from(integrity.slice(dash + 1), "base64").toString("hex");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Deterministic JSON: object keys sorted recursively, arrays kept in order,
|
|
28
|
+
* `undefined` properties dropped. Used for every hash and signature payload.
|
|
29
|
+
*/
|
|
30
|
+
export function canonicalJson(value) {
|
|
31
|
+
return JSON.stringify(sortValue(value));
|
|
32
|
+
}
|
|
33
|
+
function sortValue(value) {
|
|
34
|
+
if (Array.isArray(value))
|
|
35
|
+
return value.map(sortValue);
|
|
36
|
+
if (value !== null && typeof value === "object") {
|
|
37
|
+
const out = {};
|
|
38
|
+
for (const key of Object.keys(value).sort()) {
|
|
39
|
+
const v = value[key];
|
|
40
|
+
if (v !== undefined)
|
|
41
|
+
out[key] = sortValue(v);
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
if (typeof value === "number" && !Number.isFinite(value)) {
|
|
46
|
+
throw new Error("canonicalJson: non-finite number");
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=hash.js.map
|
package/dist/hash.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"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.js";
|
|
5
|
+
export * from "./manifest.js";
|
|
6
|
+
export * from "./names.js";
|
|
7
|
+
export * from "./permissions.js";
|
|
8
|
+
export * from "./schemas.js";
|
|
9
|
+
export * from "./signing.js";
|
|
10
|
+
export * from "./tarball.js";
|
|
11
|
+
export * from "./versions.js";
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./constants.js";
|
|
2
|
+
export * from "./files.js";
|
|
3
|
+
export * from "./hash.js";
|
|
4
|
+
export * from "./lint.js";
|
|
5
|
+
export * from "./manifest.js";
|
|
6
|
+
export * from "./names.js";
|
|
7
|
+
export * from "./permissions.js";
|
|
8
|
+
export * from "./schemas.js";
|
|
9
|
+
export * from "./signing.js";
|
|
10
|
+
export * from "./tarball.js";
|
|
11
|
+
export * from "./versions.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
|
package/dist/lint.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolManifest } from "./schemas.js";
|
|
2
|
+
export declare function containsInvisible(text: string): boolean;
|
|
3
|
+
export interface LintIssue {
|
|
4
|
+
path: string;
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Schema regexes run on the host (ajv validates every input and output), so a
|
|
9
|
+
* catastrophically backtracking pattern would stall the agent's event loop.
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkSchemaPattern(pattern: string): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Tool descriptions (including every `description`/`title` inside the schemas)
|
|
14
|
+
* are read by the model, so they are a prompt-injection surface ("tool poisoning").
|
|
15
|
+
* Schema regexes are checked for ReDoS because they execute on the host.
|
|
16
|
+
*/
|
|
17
|
+
export declare function lintManifest(manifest: ToolManifest): LintIssue[];
|
|
18
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAejD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOjE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,SAAS,EAAE,CAoBhE"}
|
package/dist/lint.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { safeRegex } from "safe-regex2";
|
|
2
|
+
import { MAX_DESCRIPTION_CHARS } from "./constants.js";
|
|
3
|
+
import { misplacedFileFields } from "./files.js";
|
|
4
|
+
/**
|
|
5
|
+
* Zero-width, bidi-override and Unicode tag characters used to hide instructions
|
|
6
|
+
* from humans. Built from escaped strings on purpose: a regex literal invites
|
|
7
|
+
* tools to "simplify" the escapes into the invisible characters themselves.
|
|
8
|
+
*/
|
|
9
|
+
const INVISIBLE_RE = new RegExp([
|
|
10
|
+
"[\\u00AD\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u2069\\uFEFF]",
|
|
11
|
+
"[\\u{E0000}-\\u{E007F}]",
|
|
12
|
+
].join("|"), "u");
|
|
13
|
+
export function containsInvisible(text) {
|
|
14
|
+
return INVISIBLE_RE.test(text);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Schema regexes run on the host (ajv validates every input and output), so a
|
|
18
|
+
* catastrophically backtracking pattern would stall the agent's event loop.
|
|
19
|
+
*/
|
|
20
|
+
export function checkSchemaPattern(pattern) {
|
|
21
|
+
try {
|
|
22
|
+
new RegExp(pattern, "u");
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return "is not a valid regular expression";
|
|
26
|
+
}
|
|
27
|
+
return safeRegex(pattern, { limit: 25 }) ? null : "may cause catastrophic backtracking";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tool descriptions (including every `description`/`title` inside the schemas)
|
|
31
|
+
* are read by the model, so they are a prompt-injection surface ("tool poisoning").
|
|
32
|
+
* Schema regexes are checked for ReDoS because they execute on the host.
|
|
33
|
+
*/
|
|
34
|
+
export function lintManifest(manifest) {
|
|
35
|
+
const issues = [];
|
|
36
|
+
checkText("description", manifest.description, issues);
|
|
37
|
+
walkSchema("inputSchema", manifest.inputSchema, issues);
|
|
38
|
+
walkSchema("outputSchema", manifest.outputSchema, issues);
|
|
39
|
+
manifest.examples?.forEach((ex, i) => {
|
|
40
|
+
if (ex.title)
|
|
41
|
+
checkText(`examples[${i}].title`, ex.title, issues);
|
|
42
|
+
if (ex.prompt)
|
|
43
|
+
checkText(`examples[${i}].prompt`, ex.prompt, issues);
|
|
44
|
+
});
|
|
45
|
+
// The host only hands over files it finds; anywhere else the tool would get a path it cannot read.
|
|
46
|
+
for (const path of [
|
|
47
|
+
...misplacedFileFields("inputSchema", manifest.inputSchema),
|
|
48
|
+
...misplacedFileFields("outputSchema", manifest.outputSchema),
|
|
49
|
+
]) {
|
|
50
|
+
issues.push({
|
|
51
|
+
path,
|
|
52
|
+
message: "FilePath() must be a top-level property, or the items of a top-level array",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return issues;
|
|
56
|
+
}
|
|
57
|
+
function checkText(path, text, issues) {
|
|
58
|
+
if (containsInvisible(text)) {
|
|
59
|
+
issues.push({ path, message: "contains invisible or bidirectional-override characters" });
|
|
60
|
+
}
|
|
61
|
+
if (text.length > MAX_DESCRIPTION_CHARS) {
|
|
62
|
+
issues.push({ path, message: `longer than ${MAX_DESCRIPTION_CHARS} characters` });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function walkSchema(path, node, issues) {
|
|
66
|
+
if (Array.isArray(node)) {
|
|
67
|
+
node.forEach((child, i) => {
|
|
68
|
+
walkSchema(`${path}[${i}]`, child, issues);
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (node === null || typeof node !== "object")
|
|
73
|
+
return;
|
|
74
|
+
for (const [key, value] of Object.entries(node)) {
|
|
75
|
+
const childPath = `${path}.${key}`;
|
|
76
|
+
if ((key === "description" || key === "title") && typeof value === "string") {
|
|
77
|
+
checkText(childPath, value, issues);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (key === "pattern" && typeof value === "string") {
|
|
81
|
+
const problem = checkSchemaPattern(value);
|
|
82
|
+
if (problem)
|
|
83
|
+
issues.push({ path: childPath, message: `regex ${problem}` });
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (key === "patternProperties" && value !== null && typeof value === "object") {
|
|
87
|
+
for (const pattern of Object.keys(value)) {
|
|
88
|
+
const problem = checkSchemaPattern(pattern);
|
|
89
|
+
if (problem) {
|
|
90
|
+
issues.push({
|
|
91
|
+
path: `${childPath}[${JSON.stringify(pattern)}]`,
|
|
92
|
+
message: `regex ${problem}`,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
walkSchema(childPath, value, issues);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=lint.js.map
|
package/dist/lint.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../src/lint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD;;;;GAIG;AACH,MAAM,YAAY,GAAG,IAAI,MAAM,CAC7B;IACE,qFAAqF;IACrF,yBAAyB;CAC1B,CAAC,IAAI,CAAC,GAAG,CAAC,EACX,GAAG,CACJ,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,IAAI,CAAC;QACH,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,mCAAmC,CAAC;IAC7C,CAAC;IACD,OAAO,SAAS,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,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IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/E,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACzC,MAAM,OAAO,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;gBAC5C,IAAI,OAAO,EAAE,CAAC;oBACZ,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,GAAG,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG;wBAChD,OAAO,EAAE,SAAS,OAAO,EAAE;qBAC5B,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QACD,UAAU,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type ToolManifest } from "./schemas.js";
|
|
2
|
+
export interface SchemaIssue {
|
|
3
|
+
path: string;
|
|
4
|
+
message: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ManifestError extends Error {
|
|
7
|
+
readonly issues: SchemaIssue[];
|
|
8
|
+
constructor(what: string, issues: SchemaIssue[]);
|
|
9
|
+
}
|
|
10
|
+
export declare const parseManifest: (value: unknown) => {
|
|
11
|
+
manifestVersion: 1;
|
|
12
|
+
name: string;
|
|
13
|
+
version: string;
|
|
14
|
+
description: string;
|
|
15
|
+
license?: string | undefined;
|
|
16
|
+
repository?: string | undefined;
|
|
17
|
+
keywords?: string[] | undefined;
|
|
18
|
+
entry: "dist/tool.mjs";
|
|
19
|
+
sdk: string;
|
|
20
|
+
engines: {
|
|
21
|
+
node: string;
|
|
22
|
+
};
|
|
23
|
+
inputSchema: Record<string, unknown>;
|
|
24
|
+
outputSchema: Record<string, unknown>;
|
|
25
|
+
examples?: {
|
|
26
|
+
title?: string | undefined;
|
|
27
|
+
prompt?: string | undefined;
|
|
28
|
+
input: Record<string, unknown>;
|
|
29
|
+
output?: Record<string, unknown> | undefined;
|
|
30
|
+
outputFiles?: Record<string, {
|
|
31
|
+
name: string;
|
|
32
|
+
size: number;
|
|
33
|
+
mediaType?: string | undefined;
|
|
34
|
+
}[] | {
|
|
35
|
+
name: string;
|
|
36
|
+
size: number;
|
|
37
|
+
mediaType?: string | undefined;
|
|
38
|
+
}> | undefined;
|
|
39
|
+
}[] | undefined;
|
|
40
|
+
permissions: {
|
|
41
|
+
net: boolean;
|
|
42
|
+
env: string[];
|
|
43
|
+
tmp: boolean;
|
|
44
|
+
};
|
|
45
|
+
limits: {
|
|
46
|
+
timeoutMs: number;
|
|
47
|
+
memoryMb: number;
|
|
48
|
+
};
|
|
49
|
+
build: {
|
|
50
|
+
toolpal: string;
|
|
51
|
+
esbuild: string;
|
|
52
|
+
options: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export declare const parseLockfile: (value: unknown) => {
|
|
56
|
+
lockfileVersion: 1;
|
|
57
|
+
tools: Record<string, {
|
|
58
|
+
version: string;
|
|
59
|
+
resolved: string;
|
|
60
|
+
integrity: string;
|
|
61
|
+
entryIntegrity: string;
|
|
62
|
+
manifestHash: string;
|
|
63
|
+
publishedAt: string;
|
|
64
|
+
signature: string;
|
|
65
|
+
keyId: string;
|
|
66
|
+
publisher?: string | undefined;
|
|
67
|
+
verified?: boolean | undefined;
|
|
68
|
+
permissions: {
|
|
69
|
+
net: boolean;
|
|
70
|
+
env: string[];
|
|
71
|
+
tmp: boolean;
|
|
72
|
+
};
|
|
73
|
+
flags: string[];
|
|
74
|
+
}>;
|
|
75
|
+
};
|
|
76
|
+
export declare const parseProjectConfig: (value: unknown) => {
|
|
77
|
+
$schema?: string | undefined;
|
|
78
|
+
registry?: string | undefined;
|
|
79
|
+
tools: Record<string, string>;
|
|
80
|
+
env: Record<string, Record<string, {
|
|
81
|
+
fromEnv: string;
|
|
82
|
+
}>>;
|
|
83
|
+
policy: {
|
|
84
|
+
maxTimeoutMs?: number | undefined;
|
|
85
|
+
maxMemoryMb?: number | undefined;
|
|
86
|
+
isolation?: "per-call" | "warm" | undefined;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Hash of everything a consumer implicitly accepts by running a tool: what the
|
|
91
|
+
* model is told (description + schemas) and what the tool may do (permissions).
|
|
92
|
+
*/
|
|
93
|
+
export declare function manifestHash(manifest: ToolManifest): string;
|
|
94
|
+
//# sourceMappingURL=manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC;IAC/B,YAAY,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,EAI9C;CACF;AAaD,eAAO,MAAM,aAAa,UAAW,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAiD,CAAC;AAC9F,eAAO,MAAM,aAAa,UAAW,OAAO;;;;;;;;;;;;;;;;;;;;CAAqD,CAAC;AAClG,eAAO,MAAM,kBAAkB,UAAW,OAAO;;;;;;;;;;;;CACM,CAAC;AAExD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,CAU3D"}
|
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { canonicalJson, integrityOf } from "./hash.js";
|
|
2
|
+
import { normalizePermissions } from "./permissions.js";
|
|
3
|
+
import { lockfileSchema, manifestSchema, projectConfigSchema, } from "./schemas.js";
|
|
4
|
+
export class ManifestError extends Error {
|
|
5
|
+
issues;
|
|
6
|
+
constructor(what, issues) {
|
|
7
|
+
super(`Invalid ${what}: ${issues.map((i) => `${i.path || "(root)"} ${i.message}`).join("; ")}`);
|
|
8
|
+
this.name = "ManifestError";
|
|
9
|
+
this.issues = issues;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function parseWith(schema, what, value) {
|
|
13
|
+
const result = schema.safeParse(value);
|
|
14
|
+
if (!result.success) {
|
|
15
|
+
throw new ManifestError(what, result.error.issues.map((i) => ({ path: i.path.join("."), message: i.message })));
|
|
16
|
+
}
|
|
17
|
+
return result.data;
|
|
18
|
+
}
|
|
19
|
+
export const parseManifest = (value) => parseWith(manifestSchema, "manifest", value);
|
|
20
|
+
export const parseLockfile = (value) => parseWith(lockfileSchema, "toolpal.lock", value);
|
|
21
|
+
export const parseProjectConfig = (value) => parseWith(projectConfigSchema, "toolpal.json", value);
|
|
22
|
+
/**
|
|
23
|
+
* Hash of everything a consumer implicitly accepts by running a tool: what the
|
|
24
|
+
* model is told (description + schemas) and what the tool may do (permissions).
|
|
25
|
+
*/
|
|
26
|
+
export function manifestHash(manifest) {
|
|
27
|
+
return integrityOf(canonicalJson({
|
|
28
|
+
description: manifest.description,
|
|
29
|
+
inputSchema: manifest.inputSchema,
|
|
30
|
+
outputSchema: manifest.outputSchema,
|
|
31
|
+
permissions: normalizePermissions(manifest.permissions),
|
|
32
|
+
}), "sha256");
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,GAEpB,MAAM,cAAc,CAAC;AAOtB,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,M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