@capybara-hq/plugin-sdk 0.1.0-rc.26 → 0.1.0-rc.28
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/agent-docs/extension-points/model-provider.md +1 -1
- package/dist/cards.d.ts +17 -8
- package/dist/cards.js +21 -10
- package/dist/channel.d.ts +91 -47
- package/dist/channel.js +10 -5
- package/dist/connector-auth.d.ts +5 -2
- package/dist/connector-auth.js +14 -8
- package/dist/connector.d.ts +67 -32
- package/dist/ctx.d.ts +41 -23
- package/dist/define-extension.d.ts +21 -11
- package/dist/define-extension.js +10 -4
- package/dist/device-protocol.d.ts +2 -1
- package/dist/extension-point.js +1 -1
- package/dist/identity.d.ts +22 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +96 -64
- package/dist/model.js +25 -14
- package/dist/permissions.d.ts +6 -6
- package/dist/permissions.js +8 -32
- package/dist/plugin-package.d.ts +79 -38
- package/dist/plugin-package.js +57 -29
- package/dist/sandbox-linux-runtime-source.d.ts +15 -0
- package/dist/sandbox-linux-runtime-source.js +1421 -0
- package/dist/sandbox-runtime-source.d.ts +9 -3
- package/dist/sandbox-runtime-source.js +16 -4
- package/dist/sandbox.d.ts +4 -1
- package/dist/sandbox.js +7 -3
- package/dist/secret.d.ts +4 -1
- package/dist/secret.js +4 -1
- package/dist/setup-guide.d.ts +1 -1
- package/dist/setup-guide.js +1 -1
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +39 -25
- package/dist/storage.d.ts +45 -25
- package/dist/tool.d.ts +51 -23
- package/dist/tool.js +21 -9
- package/dist/ui-resolve.d.ts +2 -7
- package/dist/ui-resolve.js +7 -19
- package/dist/ui-slots.d.ts +1 -3
- package/dist/ui-slots.js +0 -9
- package/dist/ui.d.ts +63 -49
- package/dist/ui.js +36 -22
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/package.json +1 -1
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Immutable
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Immutable runtime bytes for trusted consumer staging (requires Python 3). Consumers verify every
|
|
3
|
+
* hash before use, stage the files together in a directory the operation user cannot write, and
|
|
4
|
+
* supply pinned, already-authorized root descriptors.
|
|
5
|
+
*
|
|
6
|
+
* - `native-files.py`: the portable native helper (descriptor-relative file access).
|
|
7
|
+
* - `linux-sandbox.py`: the restricted Linux launcher and syscall broker (Landlock plus a seccomp
|
|
8
|
+
* notification broker). It decides nothing about authority; its `probe` reports whether the
|
|
9
|
+
* running kernel, architecture and container policy support restricted execution, and every
|
|
10
|
+
* unsupported case reports unavailable. Shipping these bytes is not a provider support claim.
|
|
5
11
|
*/
|
|
6
12
|
export declare const SANDBOX_RUNTIME_SOURCE: {
|
|
7
13
|
readonly version: number;
|
|
@@ -1,16 +1,28 @@
|
|
|
1
|
+
import { LINUX_SANDBOX_SOURCE } from "./sandbox-linux-runtime-source.js";
|
|
1
2
|
import { NATIVE_FILES_SOURCE } from "./sandbox-native-runtime-source.js";
|
|
2
3
|
/**
|
|
3
|
-
* Immutable
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Immutable runtime bytes for trusted consumer staging (requires Python 3). Consumers verify every
|
|
5
|
+
* hash before use, stage the files together in a directory the operation user cannot write, and
|
|
6
|
+
* supply pinned, already-authorized root descriptors.
|
|
7
|
+
*
|
|
8
|
+
* - `native-files.py`: the portable native helper (descriptor-relative file access).
|
|
9
|
+
* - `linux-sandbox.py`: the restricted Linux launcher and syscall broker (Landlock plus a seccomp
|
|
10
|
+
* notification broker). It decides nothing about authority; its `probe` reports whether the
|
|
11
|
+
* running kernel, architecture and container policy support restricted execution, and every
|
|
12
|
+
* unsupported case reports unavailable. Shipping these bytes is not a provider support claim.
|
|
6
13
|
*/
|
|
7
14
|
export const SANDBOX_RUNTIME_SOURCE = Object.freeze({
|
|
8
|
-
version:
|
|
15
|
+
version: 2,
|
|
9
16
|
files: Object.freeze([
|
|
10
17
|
Object.freeze({
|
|
11
18
|
name: "native-files.py",
|
|
12
19
|
source: NATIVE_FILES_SOURCE,
|
|
13
20
|
sha256: "601f51c1c46bedac5ab56f7ca38d7c15fdea8481efc6476d5a5b3243318ef79b",
|
|
14
21
|
}),
|
|
22
|
+
Object.freeze({
|
|
23
|
+
name: "linux-sandbox.py",
|
|
24
|
+
source: LINUX_SANDBOX_SOURCE,
|
|
25
|
+
sha256: "f27ab699dbb5f7fc0ea9eb02cfa2257a405e5ccf3b8c3e011df29ab54bc3d599",
|
|
26
|
+
}),
|
|
15
27
|
]),
|
|
16
28
|
});
|
package/dist/sandbox.d.ts
CHANGED
|
@@ -410,5 +410,8 @@ export declare function validateSandboxPathShape(p: string): string[];
|
|
|
410
410
|
* ({@link rootsOf}); absent means {@link SANDBOX_ROOTS}. The path must be one of them or under one.
|
|
411
411
|
*/
|
|
412
412
|
export declare function validateSandboxPath(p: string, roots?: SandboxRoots): string[];
|
|
413
|
-
/**
|
|
413
|
+
/**
|
|
414
|
+
* Validates an outbound allowlist host name: lowercase, no protocol or port, optional leading `*.`,
|
|
415
|
+
* IDN accepted only as punycode.
|
|
416
|
+
*/
|
|
414
417
|
export declare function validateAllowHost(h: string): string[];
|
package/dist/sandbox.js
CHANGED
|
@@ -66,7 +66,7 @@ export function isFileSystemGoneError(e) {
|
|
|
66
66
|
* kill pattern.
|
|
67
67
|
*/
|
|
68
68
|
export const SANDBOX_TAG_RE = /^[a-z0-9-]{1,64}$/;
|
|
69
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex:
|
|
69
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are exactly what must be blocked
|
|
70
70
|
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
71
71
|
/** The longest project name, in UTF-16 code units. */
|
|
72
72
|
export const MAX_DEVICE_PROJECT_NAME_LENGTH = 64;
|
|
@@ -163,7 +163,10 @@ export function validateSandboxPath(p, roots) {
|
|
|
163
163
|
return errors;
|
|
164
164
|
}
|
|
165
165
|
const LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
166
|
-
/**
|
|
166
|
+
/**
|
|
167
|
+
* Validates an outbound allowlist host name: lowercase, no protocol or port, optional leading `*.`,
|
|
168
|
+
* IDN accepted only as punycode.
|
|
169
|
+
*/
|
|
167
170
|
export function validateAllowHost(h) {
|
|
168
171
|
if (typeof h !== "string" || h.length === 0)
|
|
169
172
|
return ["host must be a non-empty string"];
|
|
@@ -177,7 +180,8 @@ export function validateAllowHost(h) {
|
|
|
177
180
|
const tld = labels[labels.length - 1];
|
|
178
181
|
if (labels.length < 2)
|
|
179
182
|
return ["host must have at least two labels (no single-label names)"];
|
|
180
|
-
//
|
|
183
|
+
// The last label must start with a letter: this blocks the decimal / octal / hexadecimal
|
|
184
|
+
// spellings of IPv4
|
|
181
185
|
if (!/^[a-z]/.test(tld))
|
|
182
186
|
return ["host must not be an IP address literal"];
|
|
183
187
|
if (["local", "internal", "localhost"].includes(tld)) {
|
package/dist/secret.d.ts
CHANGED
|
@@ -4,5 +4,8 @@ import type { z } from "zod";
|
|
|
4
4
|
* (`ui` hints, `hot`), so `secret(ui(x, …))` and `ui(secret(x), …)` are the same.
|
|
5
5
|
*/
|
|
6
6
|
export declare function secret<T extends z.ZodTypeAny>(schema: T): T;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Reads the schema's meta to tell whether it is sensitive; the kernel's `meta({secret:true})` is
|
|
9
|
+
* recognized the same way.
|
|
10
|
+
*/
|
|
8
11
|
export declare function isSecret(schema: z.ZodTypeAny): boolean;
|
package/dist/secret.js
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
export function secret(schema) {
|
|
6
6
|
return schema.meta({ ...(schema.meta() ?? {}), secret: true });
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Reads the schema's meta to tell whether it is sensitive; the kernel's `meta({secret:true})` is
|
|
10
|
+
* recognized the same way.
|
|
11
|
+
*/
|
|
9
12
|
export function isSecret(schema) {
|
|
10
13
|
return schema.meta()?.secret === true;
|
|
11
14
|
}
|
package/dist/setup-guide.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Where a guide is shown. `channel-connection`:
|
|
2
|
+
* Where a guide is shown. `channel-connection`: "New channel" and the channel detail page;
|
|
3
3
|
* `connector-template`: the pages of a connector template and the connectors made from it.
|
|
4
4
|
*/
|
|
5
5
|
export declare const SETUP_GUIDE_PLACES: readonly ["channel-connection", "connector-template"];
|
package/dist/setup-guide.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import { createHash } from "node:crypto";
|
|
13
13
|
import { analyzeSetupGuide, checkMarkerIndex, ENCODED_SENTINEL_RE, lineSelected, normalizeGuideSource, parseGuideMarkdown, preparedGuideText, SENTINEL_RE, scanGuide, visitGuide, } from "./setup-guide-parse.js";
|
|
14
14
|
/**
|
|
15
|
-
* Where a guide is shown. `channel-connection`:
|
|
15
|
+
* Where a guide is shown. `channel-connection`: "New channel" and the channel detail page;
|
|
16
16
|
* `connector-template`: the pages of a connector template and the connectors made from it.
|
|
17
17
|
*/
|
|
18
18
|
export const SETUP_GUIDE_PLACES = ["channel-connection", "connector-template"];
|
package/dist/skill.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Limits of a skill package. */
|
|
2
2
|
export declare const SKILL_LIMITS: {
|
|
3
3
|
readonly nameMaxChars: 64;
|
|
4
4
|
readonly descriptionMaxChars: 1024;
|
|
5
5
|
readonly compatibilityMaxChars: 500;
|
|
6
|
-
/**
|
|
6
|
+
/** Upper bound of a single file after extraction (bytes). */
|
|
7
7
|
readonly fileBytes: number;
|
|
8
|
-
/**
|
|
8
|
+
/** Upper bound of the total of all files after extraction (bytes). */
|
|
9
9
|
readonly totalBytes: number;
|
|
10
|
-
/**
|
|
10
|
+
/** Upper bound on the number of files. */
|
|
11
11
|
readonly maxFiles: 1000;
|
|
12
|
-
/**
|
|
12
|
+
/** Upper bound on the length of a relative path inside the package (characters). */
|
|
13
13
|
readonly pathMaxChars: 512;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Upper bound on the length of the frontmatter (between the two `---` lines) in characters; above
|
|
16
|
+
* it no YAML parsing is done.
|
|
17
|
+
*/
|
|
15
18
|
readonly frontmatterMaxChars: number;
|
|
16
19
|
};
|
|
17
20
|
/** Limits of the invocation keys of a SKILL.md (see `SkillInvocation`). */
|
|
@@ -28,14 +31,14 @@ export declare const SKILL_INVOCATION_LIMITS: {
|
|
|
28
31
|
*/
|
|
29
32
|
readonly renderedMaxChars: 200000;
|
|
30
33
|
};
|
|
31
|
-
/**
|
|
34
|
+
/** The skill entry file (package root, case-sensitive). */
|
|
32
35
|
export declare const SKILL_ENTRY_FILE = "SKILL.md";
|
|
33
36
|
/**
|
|
34
37
|
* The sandbox root for skills: each skill version is copied (read-only to commands) to
|
|
35
38
|
* `/skills/<name>@<digest>/` ({@link skillSandboxDir}).
|
|
36
39
|
*/
|
|
37
40
|
export declare const SKILLS_SANDBOX_ROOT = "/skills";
|
|
38
|
-
/**
|
|
41
|
+
/** Whether it is a valid skill name (see the specification at the top of the file). */
|
|
39
42
|
export declare function isSkillName(s: unknown): s is string;
|
|
40
43
|
/**
|
|
41
44
|
* The digest of a skill version's file manifest: the first 12 hex digits of the sha256 of its
|
|
@@ -56,12 +59,12 @@ export declare function skillDigest(files: {
|
|
|
56
59
|
export declare function skillSandboxDir(name: string, digest: string, root?: string): string;
|
|
57
60
|
/** A skill file's path in the sandbox: `<root>/<name>@<digest>/<path>` ({@link skillSandboxDir}). */
|
|
58
61
|
export declare function skillSandboxPath(name: string, digest: string, path: string, root?: string): string;
|
|
59
|
-
/** {@link parseSkillMd}
|
|
62
|
+
/** The result of a successful {@link parseSkillMd}. */
|
|
60
63
|
export interface ParsedSkillMd {
|
|
61
64
|
name: string;
|
|
62
|
-
/**
|
|
65
|
+
/** Trimmed of leading and trailing whitespace. */
|
|
63
66
|
description: string;
|
|
64
|
-
/**
|
|
67
|
+
/** The Markdown body after the frontmatter. */
|
|
65
68
|
body: string;
|
|
66
69
|
/**
|
|
67
70
|
* The parsed YAML frontmatter mapping: every key, values unchanged (e.g. Claude Code's
|
|
@@ -79,17 +82,24 @@ export interface ParseSkillMdOptions {
|
|
|
79
82
|
invocationKeys?: boolean;
|
|
80
83
|
}
|
|
81
84
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
85
|
+
* Parses SKILL.md: it starts with YAML frontmatter wrapped in `---` lines, followed by the body.
|
|
86
|
+
* Tolerates BOM and CRLF (CRLF in the body becomes LF).
|
|
87
|
+
* Returns name / description / body, or all problems (in English, directly showable to a model or
|
|
88
|
+
* an admin).
|
|
84
89
|
*/
|
|
85
90
|
export declare function parseSkillMd(text: string, options?: ParseSkillMdOptions): ParsedSkillMd | {
|
|
86
91
|
errors: string[];
|
|
87
92
|
};
|
|
88
93
|
/**
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
94
|
+
* Validates a skill package's file list (paths relative to the package root, files only, no
|
|
95
|
+
* directory entries):
|
|
96
|
+
* the root must have `SKILL.md`; single file ≤ {@link SKILL_LIMITS.fileBytes}; total ≤ {@link
|
|
97
|
+
* SKILL_LIMITS.totalBytes};
|
|
98
|
+
* file count ≤ {@link SKILL_LIMITS.maxFiles}; paths must not escape (absolute paths, `..`,
|
|
99
|
+
* backslashes, drive letters, control characters), must not repeat
|
|
100
|
+
* (differing only in case also counts as repeating: they would overwrite each other on
|
|
101
|
+
* case-insensitive file systems), and a file must not share a name with a directory. Returns the
|
|
102
|
+
* list of problems; an empty array means valid.
|
|
93
103
|
*/
|
|
94
104
|
export declare function validateSkillPackage(files: {
|
|
95
105
|
path: string;
|
package/dist/skill.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Pure parsing and validation functions for skills (Agent Skills format): used when the kernel
|
|
3
|
+
* uploads a skill package and when an agent proposes a skill change.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* - Agent Skills
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* `
|
|
10
|
-
*
|
|
5
|
+
* Format sources (verified 2026-10-21):
|
|
6
|
+
* - Agent Skills specification https://agentskills.io/specification : `name` is required, 1–64
|
|
7
|
+
* characters, only lowercase letters, digits and
|
|
8
|
+
* hyphens, must not start or end with a hyphen, no consecutive hyphens, and must match its
|
|
9
|
+
* directory name; `description` is required, 1–1024 characters;
|
|
10
|
+
* optional `license`, `compatibility` (1–500 characters), `metadata`, `allowed-tools`.
|
|
11
|
+
* - Anthropic docs https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview :
|
|
12
|
+
* `name` and `description` must not contain XML tags (there are also reserved words "anthropic" /
|
|
13
|
+
* "claude", which are Anthropic's own platform rules and
|
|
14
|
+
* are not adopted here).
|
|
11
15
|
*
|
|
12
16
|
* Choices: the description goes into the model's system prompt, so XML tags are refused as Anthropic
|
|
13
17
|
* does (no forged prompt structure). Keys outside the specification are allowed and ignored, so
|
|
@@ -23,20 +27,23 @@ import { readFrontmatter } from "./frontmatter.js";
|
|
|
23
27
|
import { hasControlChars } from "./model.js";
|
|
24
28
|
import { validateSandboxPath } from "./sandbox.js";
|
|
25
29
|
import { argumentHintText, SKILL_ARGUMENT_NAME_RE } from "./skill-keys.js";
|
|
26
|
-
/**
|
|
30
|
+
/** Limits of a skill package. */
|
|
27
31
|
export const SKILL_LIMITS = {
|
|
28
32
|
nameMaxChars: 64,
|
|
29
33
|
descriptionMaxChars: 1024,
|
|
30
34
|
compatibilityMaxChars: 500,
|
|
31
|
-
/**
|
|
35
|
+
/** Upper bound of a single file after extraction (bytes). */
|
|
32
36
|
fileBytes: 10 * 1024 * 1024,
|
|
33
|
-
/**
|
|
37
|
+
/** Upper bound of the total of all files after extraction (bytes). */
|
|
34
38
|
totalBytes: 50 * 1024 * 1024,
|
|
35
|
-
/**
|
|
39
|
+
/** Upper bound on the number of files. */
|
|
36
40
|
maxFiles: 1000,
|
|
37
|
-
/**
|
|
41
|
+
/** Upper bound on the length of a relative path inside the package (characters). */
|
|
38
42
|
pathMaxChars: 512,
|
|
39
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Upper bound on the length of the frontmatter (between the two `---` lines) in characters; above
|
|
45
|
+
* it no YAML parsing is done.
|
|
46
|
+
*/
|
|
40
47
|
frontmatterMaxChars: 64 * 1024,
|
|
41
48
|
};
|
|
42
49
|
/** Limits of the invocation keys of a SKILL.md (see `SkillInvocation`). */
|
|
@@ -53,7 +60,7 @@ export const SKILL_INVOCATION_LIMITS = {
|
|
|
53
60
|
*/
|
|
54
61
|
renderedMaxChars: 200_000,
|
|
55
62
|
};
|
|
56
|
-
/**
|
|
63
|
+
/** The skill entry file (package root, case-sensitive). */
|
|
57
64
|
export const SKILL_ENTRY_FILE = "SKILL.md";
|
|
58
65
|
/**
|
|
59
66
|
* The sandbox root for skills: each skill version is copied (read-only to commands) to
|
|
@@ -63,7 +70,7 @@ export const SKILLS_SANDBOX_ROOT = "/skills";
|
|
|
63
70
|
const NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
64
71
|
const XML_TAG_RE = /<\/?[A-Za-z][^<>]*>/;
|
|
65
72
|
const DRIVE_RE = /^[A-Za-z]:/;
|
|
66
|
-
/**
|
|
73
|
+
/** Whether it is a valid skill name (see the specification at the top of the file). */
|
|
67
74
|
export function isSkillName(s) {
|
|
68
75
|
return typeof s === "string" && s.length <= SKILL_LIMITS.nameMaxChars && NAME_RE.test(s);
|
|
69
76
|
}
|
|
@@ -94,8 +101,10 @@ export function skillSandboxPath(name, digest, path, root = SKILLS_SANDBOX_ROOT)
|
|
|
94
101
|
}
|
|
95
102
|
const chars = (s) => [...s].length;
|
|
96
103
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
104
|
+
* Parses SKILL.md: it starts with YAML frontmatter wrapped in `---` lines, followed by the body.
|
|
105
|
+
* Tolerates BOM and CRLF (CRLF in the body becomes LF).
|
|
106
|
+
* Returns name / description / body, or all problems (in English, directly showable to a model or
|
|
107
|
+
* an admin).
|
|
99
108
|
*/
|
|
100
109
|
export function parseSkillMd(text, options = {}) {
|
|
101
110
|
const read = readFrontmatter(text, "SKILL.md", SKILL_LIMITS.frontmatterMaxChars);
|
|
@@ -178,9 +187,9 @@ function invocationKeyErrors(fm) {
|
|
|
178
187
|
}
|
|
179
188
|
return errors;
|
|
180
189
|
}
|
|
181
|
-
/**
|
|
190
|
+
/** A path for humans to read: JSON-escaped when it contains control characters. */
|
|
182
191
|
const show = (p) => (hasControlChars(p) || p === "" ? JSON.stringify(p) : p);
|
|
183
|
-
/**
|
|
192
|
+
/** The problem of a single relative path (the first one), null when valid. */
|
|
184
193
|
function pathProblem(p) {
|
|
185
194
|
if (typeof p !== "string" || p === "")
|
|
186
195
|
return "path must be a non-empty string";
|
|
@@ -203,15 +212,20 @@ function pathProblem(p) {
|
|
|
203
212
|
if (seg === "." || seg === "..")
|
|
204
213
|
return "path must not contain '.' or '..' segments";
|
|
205
214
|
}
|
|
206
|
-
//
|
|
215
|
+
// Then check again against the sandbox path rules (percent-encoded `..` etc.)
|
|
207
216
|
const errs = validateSandboxPath(skillSandboxPath("skill", "000000000000", p));
|
|
208
217
|
return errs[0] ?? null;
|
|
209
218
|
}
|
|
210
219
|
/**
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
220
|
+
* Validates a skill package's file list (paths relative to the package root, files only, no
|
|
221
|
+
* directory entries):
|
|
222
|
+
* the root must have `SKILL.md`; single file ≤ {@link SKILL_LIMITS.fileBytes}; total ≤ {@link
|
|
223
|
+
* SKILL_LIMITS.totalBytes};
|
|
224
|
+
* file count ≤ {@link SKILL_LIMITS.maxFiles}; paths must not escape (absolute paths, `..`,
|
|
225
|
+
* backslashes, drive letters, control characters), must not repeat
|
|
226
|
+
* (differing only in case also counts as repeating: they would overwrite each other on
|
|
227
|
+
* case-insensitive file systems), and a file must not share a name with a directory. Returns the
|
|
228
|
+
* list of problems; an empty array means valid.
|
|
215
229
|
*/
|
|
216
230
|
export function validateSkillPackage(files) {
|
|
217
231
|
if (files.length > SKILL_LIMITS.maxFiles) {
|
package/dist/storage.d.ts
CHANGED
|
@@ -7,27 +7,34 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/** Object storage extension point ref. */
|
|
9
9
|
export declare const OBJECT_STORE_EXTENSION_POINT = "object-store@1";
|
|
10
|
-
/**
|
|
10
|
+
/** Metadata of an object. */
|
|
11
11
|
export interface ObjectHead {
|
|
12
12
|
key: string;
|
|
13
|
-
/**
|
|
13
|
+
/** Size in bytes. */
|
|
14
14
|
size: number;
|
|
15
15
|
contentType: string;
|
|
16
16
|
etag?: string;
|
|
17
|
-
/** ISO 8601
|
|
17
|
+
/** ISO 8601 time. */
|
|
18
18
|
lastModified?: string;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* The `object-store@1` implementation (provided by an object-store plugin, e.g. S3-compatible
|
|
22
|
+
* storage).
|
|
23
|
+
*/
|
|
21
24
|
export interface ObjectStore {
|
|
22
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Writes (overwriting a key of the same name); give `size` when `body` is a stream if possible.
|
|
27
|
+
*/
|
|
23
28
|
put(key: string, body: Uint8Array | ReadableStream<Uint8Array>, opts: {
|
|
24
29
|
contentType: string;
|
|
25
30
|
size?: number;
|
|
26
31
|
signal?: AbortSignal;
|
|
27
32
|
}): Promise<ObjectHead>;
|
|
28
33
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
34
|
+
* Reads; returns null when missing. `range` is a closed byte range; an omitted `end` means read
|
|
35
|
+
* to the end.
|
|
36
|
+
* With `range`, `head.size` is still the size of the whole object; when the store ignores Range,
|
|
37
|
+
* body may be the whole object.
|
|
31
38
|
*/
|
|
32
39
|
get(key: string, opts?: {
|
|
33
40
|
signal?: AbortSignal;
|
|
@@ -39,15 +46,18 @@ export interface ObjectStore {
|
|
|
39
46
|
head: ObjectHead;
|
|
40
47
|
body: ReadableStream<Uint8Array>;
|
|
41
48
|
} | null>;
|
|
42
|
-
/**
|
|
49
|
+
/** Returns null when missing. */
|
|
43
50
|
head(key: string): Promise<ObjectHead | null>;
|
|
44
|
-
/**
|
|
51
|
+
/** Deletes; a missing key also counts as success. */
|
|
45
52
|
delete(key: string): Promise<void>;
|
|
46
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Deletes all objects under a prefix and returns the number deleted (used for org data deletion).
|
|
55
|
+
*/
|
|
47
56
|
deletePrefix(prefix: string): Promise<number>;
|
|
48
57
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
58
|
+
* Lists objects under a prefix with pagination; an omitted `cursor` in the result means there is
|
|
59
|
+
* no next page. When the listing carries no type, `contentType` is an empty string
|
|
60
|
+
* (use `head` to get it when needed).
|
|
51
61
|
*/
|
|
52
62
|
list(prefix: string, opts?: {
|
|
53
63
|
cursor?: string;
|
|
@@ -56,11 +66,13 @@ export interface ObjectStore {
|
|
|
56
66
|
items: ObjectHead[];
|
|
57
67
|
cursor?: string;
|
|
58
68
|
}>;
|
|
59
|
-
/**
|
|
69
|
+
/** Presigned download URL (options in {@link PresignGetOptions}). */
|
|
60
70
|
presignGet(key: string, opts: PresignGetOptions): Promise<string>;
|
|
61
71
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
72
|
+
* Presigned upload: the browser uploads straight to storage following the returned {@link
|
|
73
|
+
* PresignedUpload}. An upload over `maxSize` must be rejected by the **store side**
|
|
74
|
+
* (a presigned PUT cannot limit the size, so S3-compatible implementations use a POST policy with
|
|
75
|
+
* a `content-length-range` condition).
|
|
64
76
|
*/
|
|
65
77
|
presignPut(key: string, opts: {
|
|
66
78
|
contentType: string;
|
|
@@ -75,29 +87,37 @@ export interface ObjectStore {
|
|
|
75
87
|
*/
|
|
76
88
|
uri?(key: string): string;
|
|
77
89
|
}
|
|
78
|
-
/**
|
|
90
|
+
/** Options of a presigned download. */
|
|
79
91
|
export interface PresignGetOptions {
|
|
80
92
|
ttlSeconds: number;
|
|
81
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Download file name, goes into `Content-Disposition` (RFC 6266; non-ASCII uses
|
|
95
|
+
* `filename*=UTF-8''…`).
|
|
96
|
+
*/
|
|
82
97
|
downloadName?: string;
|
|
83
98
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
99
|
+
* How the browser opens it: `attachment` (default, download) or `inline` (display in the page).
|
|
100
|
+
* User-uploaded content should use `inline` only for types
|
|
101
|
+
* that do not execute scripts (images, PDF).
|
|
86
102
|
*/
|
|
87
103
|
disposition?: "attachment" | "inline";
|
|
88
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* Overrides the response `Content-Type` (e.g. return the verified type rather than the type
|
|
106
|
+
* recorded in storage).
|
|
107
|
+
*/
|
|
89
108
|
responseContentType?: string;
|
|
90
109
|
}
|
|
91
110
|
/**
|
|
92
|
-
*
|
|
93
|
-
* - `PUT
|
|
94
|
-
* - `POST
|
|
95
|
-
*
|
|
111
|
+
* The request method of a presigned upload:
|
|
112
|
+
* - `PUT`: the request body is the file bytes, and the request carries `headers`;
|
|
113
|
+
* - `POST`: a `multipart/form-data` form; first put every item of `fields` in as is, and put the
|
|
114
|
+
* file field `file` **last**;
|
|
115
|
+
* the request carries `headers` (usually empty).
|
|
96
116
|
*/
|
|
97
117
|
export interface PresignedUpload {
|
|
98
118
|
method: "PUT" | "POST";
|
|
99
119
|
url: string;
|
|
100
120
|
headers: Record<string, string>;
|
|
101
|
-
/** `POST
|
|
121
|
+
/** Always present for `POST`: the form fields (including policy and signature). */
|
|
102
122
|
fields?: Record<string, string>;
|
|
103
123
|
}
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ParamSchema } from "./model-params.js";
|
|
2
|
-
/**
|
|
2
|
+
/** Tool annotations (hints aligned with MCP, used to derive the default policy). */
|
|
3
3
|
export interface ToolAnnotations {
|
|
4
4
|
readOnlyHint?: boolean;
|
|
5
5
|
destructiveHint?: boolean;
|
|
@@ -16,12 +16,17 @@ export interface ToolSpec {
|
|
|
16
16
|
description: string;
|
|
17
17
|
inputSchema: Record<string, unknown>;
|
|
18
18
|
annotations?: ToolAnnotations;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Only plugin / builtin tools may declare it; when omitted it is derived from the annotations.
|
|
21
|
+
*/
|
|
20
22
|
defaultPolicy?: "allow" | "ask";
|
|
21
23
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* Connector tools only: the connector's own opaque data (e.g. OpenAPI's method, path template,
|
|
25
|
+
* parameter locations, server address), JSON-serializable.
|
|
26
|
+
* The kernel stores it with the definition in the snapshot and counts it in the fingerprint (a
|
|
27
|
+
* change means drift and needs review), and hands it back unchanged via `ctx.spec` of `callTool`
|
|
28
|
+
* on a call;
|
|
29
|
+
* never sent to the model.
|
|
25
30
|
*/
|
|
26
31
|
connectorData?: Record<string, unknown>;
|
|
27
32
|
/**
|
|
@@ -67,7 +72,10 @@ export type ToolContent = {
|
|
|
67
72
|
name?: string;
|
|
68
73
|
mimeType?: string;
|
|
69
74
|
};
|
|
70
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* A one-sentence description of a tool call, shown in the UI (Chinese and English each ≤ 200
|
|
77
|
+
* characters); does not enter the model context.
|
|
78
|
+
*/
|
|
71
79
|
export interface ToolDisplay {
|
|
72
80
|
summary: {
|
|
73
81
|
zh: string;
|
|
@@ -77,7 +85,7 @@ export interface ToolDisplay {
|
|
|
77
85
|
export interface ToolResult {
|
|
78
86
|
content: ToolContent[];
|
|
79
87
|
isError?: boolean;
|
|
80
|
-
/**
|
|
88
|
+
/** Optional: show this description in the conversation stream in place of the raw input JSON. */
|
|
81
89
|
display?: ToolDisplay;
|
|
82
90
|
/**
|
|
83
91
|
* Optional: an inline card under this call in the conversation: `view` is a ui contribution of
|
|
@@ -90,20 +98,31 @@ export interface ToolResult {
|
|
|
90
98
|
key?: string;
|
|
91
99
|
};
|
|
92
100
|
}
|
|
93
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Validates a {@link ToolDisplay} and returns the list of problems (empty = valid); length is
|
|
103
|
+
* counted in Unicode code points.
|
|
104
|
+
*/
|
|
94
105
|
export declare function validateToolDisplay(d: unknown): string[];
|
|
95
106
|
/** Text shown to people: bilingual (`zh` / `en`) or a single string shown as is. */
|
|
96
107
|
export type LocalizedText = {
|
|
97
108
|
zh: string;
|
|
98
109
|
en: string;
|
|
99
110
|
} | string;
|
|
100
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Interactive form: field schemas use only the ParamSchema subset of M2; enum fields may set
|
|
113
|
+
* multiSelect and allowOther.
|
|
114
|
+
*/
|
|
101
115
|
export interface InputForm {
|
|
102
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* A plugin may give both languages; builtin kernel tools give English (model-generated questions
|
|
118
|
+
* are displayed as is).
|
|
119
|
+
*/
|
|
103
120
|
title: LocalizedText;
|
|
104
121
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
122
|
+
* Optional: an external page the user must open in a browser (e.g. an MCP URL-mode elicitation:
|
|
123
|
+
* go to the other party's page to authorize / pay / enter sensitive information).
|
|
124
|
+
* The UI shows it as a link (the full address visible); only absolute http(s) addresses, ≤ 2000
|
|
125
|
+
* characters, are accepted.
|
|
107
126
|
*/
|
|
108
127
|
url?: string;
|
|
109
128
|
fields: {
|
|
@@ -117,8 +136,9 @@ export interface InputForm {
|
|
|
117
136
|
}[];
|
|
118
137
|
}
|
|
119
138
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
139
|
+
* The tool needs user input: the kernel pauses the run and renders a form; after the user submits,
|
|
140
|
+
* the tool is called again with the same input,
|
|
141
|
+
* and state and answer are brought back in ctx.resume. state ≤ 16 KB, JSON-serializable.
|
|
122
142
|
*/
|
|
123
143
|
export interface InputRequired {
|
|
124
144
|
kind: "input_required";
|
|
@@ -133,7 +153,7 @@ export interface ToolCallContext {
|
|
|
133
153
|
conversationId: string;
|
|
134
154
|
callId: string;
|
|
135
155
|
signal: AbortSignal;
|
|
136
|
-
/** null =
|
|
156
|
+
/** null = the user cancelled or it timed out. */
|
|
137
157
|
resume?: {
|
|
138
158
|
state: unknown;
|
|
139
159
|
answer: FormAnswer | null;
|
|
@@ -155,23 +175,31 @@ export interface ToolCallContext {
|
|
|
155
175
|
}
|
|
156
176
|
export type ToolHandler = (input: unknown, ctx: ToolCallContext) => Promise<ToolResult | InputRequired>;
|
|
157
177
|
/**
|
|
158
|
-
*
|
|
159
|
-
* - `error
|
|
160
|
-
*
|
|
178
|
+
* Tool error categories:
|
|
179
|
+
* - `error` (default): the remote is available but this call failed (bad parameters, business
|
|
180
|
+
* error, auth failure, etc.), not counted toward the connector circuit breaker;
|
|
181
|
+
* - `unavailable`: the remote is unavailable (connection / transport error, timeout, HTTP 5xx),
|
|
182
|
+
* counted toward the connector circuit breaker (connectors use it to tell the kernel).
|
|
161
183
|
*/
|
|
162
184
|
export type ToolErrorKind = "error" | "unavailable";
|
|
163
|
-
/**
|
|
185
|
+
/** A tool execution failure: message is for the model and must be in English and actionable. */
|
|
164
186
|
export declare class ToolError extends Error {
|
|
165
187
|
readonly kind: ToolErrorKind;
|
|
166
188
|
constructor(message: string, opts?: {
|
|
167
189
|
kind?: ToolErrorKind;
|
|
168
190
|
});
|
|
169
191
|
}
|
|
170
|
-
/**
|
|
192
|
+
/** Plugin tool name rule. */
|
|
171
193
|
export declare const EXTENSION_TOOL_NAME: RegExp;
|
|
172
|
-
/**
|
|
194
|
+
/**
|
|
195
|
+
* Validates the tool declarations a plugin registers and returns the list of problems (empty =
|
|
196
|
+
* valid).
|
|
197
|
+
*/
|
|
173
198
|
export declare function validateToolSpec(spec: ToolSpec): string[];
|
|
174
|
-
/**
|
|
199
|
+
/** Validates an interactive form declaration and returns the list of problems (empty = valid). */
|
|
175
200
|
export declare function validateInputForm(form: InputForm): string[];
|
|
176
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* Validates whether the answer a user submitted conforms to the form and returns the list of
|
|
203
|
+
* problems (empty = valid).
|
|
204
|
+
*/
|
|
177
205
|
export declare function validateAnswer(form: InputForm, answer: FormAnswer): string[];
|