@capybara-hq/plugin-sdk 0.1.0-rc.26 → 0.1.0-rc.27

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 (48) hide show
  1. package/agent-docs/extension-points/model-provider.md +1 -1
  2. package/dist/cards.d.ts +17 -8
  3. package/dist/cards.js +21 -10
  4. package/dist/channel.d.ts +91 -47
  5. package/dist/channel.js +10 -5
  6. package/dist/connector-auth.d.ts +5 -2
  7. package/dist/connector-auth.js +14 -8
  8. package/dist/connector.d.ts +67 -32
  9. package/dist/ctx.d.ts +41 -23
  10. package/dist/define-extension.d.ts +21 -11
  11. package/dist/define-extension.js +10 -4
  12. package/dist/device-protocol.d.ts +2 -1
  13. package/dist/extension-point.js +1 -1
  14. package/dist/identity.d.ts +22 -9
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/model-params.d.ts +41 -22
  18. package/dist/model-params.js +28 -15
  19. package/dist/model.d.ts +96 -64
  20. package/dist/model.js +25 -14
  21. package/dist/permissions.d.ts +6 -6
  22. package/dist/permissions.js +8 -32
  23. package/dist/plugin-package.d.ts +79 -38
  24. package/dist/plugin-package.js +57 -29
  25. package/dist/sandbox-linux-runtime-source.d.ts +15 -0
  26. package/dist/sandbox-linux-runtime-source.js +1412 -0
  27. package/dist/sandbox-runtime-source.d.ts +9 -3
  28. package/dist/sandbox-runtime-source.js +16 -4
  29. package/dist/sandbox.d.ts +4 -1
  30. package/dist/sandbox.js +7 -3
  31. package/dist/secret.d.ts +4 -1
  32. package/dist/secret.js +4 -1
  33. package/dist/setup-guide.d.ts +1 -1
  34. package/dist/setup-guide.js +1 -1
  35. package/dist/skill.d.ts +27 -17
  36. package/dist/skill.js +39 -25
  37. package/dist/storage.d.ts +45 -25
  38. package/dist/tool.d.ts +51 -23
  39. package/dist/tool.js +21 -9
  40. package/dist/ui-resolve.d.ts +2 -7
  41. package/dist/ui-resolve.js +7 -19
  42. package/dist/ui-slots.d.ts +1 -3
  43. package/dist/ui-slots.js +0 -9
  44. package/dist/ui.d.ts +63 -49
  45. package/dist/ui.js +36 -22
  46. package/dist/url.d.ts +4 -1
  47. package/dist/url.js +4 -1
  48. package/package.json +1 -1
@@ -1,7 +1,13 @@
1
1
  /**
2
- * Immutable portable native helper bytes for trusted consumer staging (requires Python 3).
3
- * Consumers verify hashes before use and supply pinned, already-authorized root descriptors.
4
- * This bundle declares no restricted-runtime support; enforcement and launch belong to providers.
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 portable native helper bytes for trusted consumer staging (requires Python 3).
4
- * Consumers verify hashes before use and supply pinned, already-authorized root descriptors.
5
- * This bundle declares no restricted-runtime support; enforcement and launch belong to providers.
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: 1,
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: "64f0c6f3e5eedad63046058a1f0f60c6edbde3abe72e991daf881798927a49af",
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
- /** 校验出站白名单主机名:小写、无协议与端口、可选前导 `*.`、IDN 只认 punycode。 */
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
- /** 校验出站白名单主机名:小写、无协议与端口、可选前导 `*.`、IDN 只认 punycode。 */
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
- // 末段必须以字母开头:挡住 IPv4 的十进制 / 八进制 / 十六进制写法
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
- /** 读取 schema 的 meta,判断是否敏感;内核 `meta({secret:true})` 同样可识别。 */
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
- /** 读取 schema 的 meta,判断是否敏感;内核 `meta({secret:true})` 同样可识别。 */
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
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Where a guide is shown. `channel-connection`: 新建渠道 and the channel detail page;
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"];
@@ -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`: 新建渠道 and the channel detail page;
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
- /** frontmatter(两条 `---` 之间)的长度上限(字符),超过不做 YAML 解析。 */
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
- /** frontmatter 之后的 Markdown 正文。 */
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
- * 解析 SKILL.md:开头是 `---` 行包住的 YAML frontmatter,之后是正文。容忍 BOM 与 CRLF(正文里的 CRLF 换成 LF)。
83
- * 返回 name / description / 正文,或全部问题(英文,可直接给模型或管理员看)。
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
- * 根目录必须有 `SKILL.md`;单文件 ≤ {@link SKILL_LIMITS.fileBytes};总量 ≤ {@link SKILL_LIMITS.totalBytes};
91
- * 文件数 ≤ {@link SKILL_LIMITS.maxFiles};路径不能越界(绝对路径、`..`、反斜杠、盘符、控制字符),不能重复
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
- * 技能(Agent Skills 格式)的纯解析与校验函数:内核上传技能包、agent 提议技能改动时都用它们。
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
- * 格式依据(2026-10-21 核实):
5
- * - Agent Skills 规范 https://agentskills.io/specification :`name` 必填,1–64 个字符,只能是小写字母、数字与
6
- * 连字符,不能以连字符开头或结尾,不能有连续连字符,须与所在目录同名;`description` 必填,1–1024 个字符;
7
- * 可选 `license`、`compatibility`(1–500 个字符)、`metadata`、`allowed-tools`。
8
- * - Anthropic 文档 https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview :
9
- * `name` 与 `description` 不能含 XML 标签(另有保留词 "anthropic" / "claude",那是 Anthropic 平台自己的规则,
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
- /** frontmatter(两条 `---` 之间)的长度上限(字符),超过不做 YAML 解析。 */
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
- * 解析 SKILL.md:开头是 `---` 行包住的 YAML frontmatter,之后是正文。容忍 BOM 与 CRLF(正文里的 CRLF 换成 LF)。
98
- * 返回 name / description / 正文,或全部问题(英文,可直接给模型或管理员看)。
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
- /** 给人看的路径:含控制字符时用 JSON 转义。 */
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
- /** 单个相对路径的问题(第一个),合法时为 null。 */
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
- * 根目录必须有 `SKILL.md`;单文件 ≤ {@link SKILL_LIMITS.fileBytes};总量 ≤ {@link SKILL_LIMITS.totalBytes};
213
- * 文件数 ≤ {@link SKILL_LIMITS.maxFiles};路径不能越界(绝对路径、`..`、反斜杠、盘符、控制字符),不能重复
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
- /** `object-store@1` 的实现(由对象存储插件提供,如 S3 兼容存储)。 */
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
- /** 写入(覆盖同名键);`body` 是流时最好给出 `size`。 */
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
- * 读取;不存在返回 null。`range` 为闭区间字节范围,缺省 `end` 表示读到末尾。
30
- * 带 `range` 时 `head.size` 仍是整个对象的大小;存储忽略 Range 时 body 可能是整个对象。
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
- /** 不存在返回 null。 */
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
- * 分页列举前缀下的对象;返回的 `cursor` 缺省表示没有下一页。列举结果不带类型时 `contentType` 为空串
50
- * (需要时用 `head` 取)。
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
- /** 预签名下载 URL(选项见 {@link PresignGetOptions})。 */
69
+ /** Presigned download URL (options in {@link PresignGetOptions}). */
60
70
  presignGet(key: string, opts: PresignGetOptions): Promise<string>;
61
71
  /**
62
- * 预签名上传:浏览器按返回的 {@link PresignedUpload} 直传存储。超过 `maxSize` 的上传必须由**存储端**拒绝
63
- * (预签名 PUT 无法限制大小,所以 S3 兼容实现用带 `content-length-range` 条件的 POST 策略)。
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
- /** 下载文件名,进 `Content-Disposition`(RFC 6266,非 ASCII 用 `filename*=UTF-8''…`)。 */
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
- * 浏览器打开方式:`attachment`(缺省,下载)或 `inline`(在页面里显示)。用户上传的内容只应对
85
- * 不会执行脚本的类型(图片、PDF)用 `inline`。
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
- /** 覆盖响应的 `Content-Type`(如按核对过的类型返回,而不是存储里记的类型)。 */
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`:请求体就是文件字节,请求头带上 `headers`;
94
- * - `POST`:`multipart/form-data` 表单,先按原样放入 `fields` 的每一项,**最后**放文件字段 `file`;
95
- * 请求头带上 `headers`(通常为空)。
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
- /** 工具注解(与 MCP 对齐的提示,用于推导默认策略)。 */
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
- * 仅连接器工具:连接器自己的不透明数据(如 OpenAPI 的方法、路径模板、参数位置、服务器地址),可 JSON 序列化。
23
- * 内核把它与定义一起存进快照并计入指纹(变了即漂移、需复核),调用时经 `callTool` 的 `ctx.spec` 原样交回;
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
- /** 工具调用的一句话说明,给界面显示(中英文各 ≤ 200 字符);不进模型上下文。 */
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
- /** 可选:对话流里显示这句说明,代替原样的输入 JSON。 */
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
- /** 校验 {@link ToolDisplay},返回问题列表(空 = 合法);长度按 Unicode 码点计。 */
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
- /** 交互表单:字段的 schema 只用 M2 的 ParamSchema 子集;枚举字段可设 multiSelect 与 allowOther。 */
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
- * 可选:需要用户在浏览器里打开的外部页面(如 MCP URL 模式的 elicitation:去对方页面授权 / 付款 / 填敏感信息)。
106
- * 界面把它显示为链接(完整地址可见);只接受 http(s) 绝对地址、≤ 2000 字符。
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
- * 工具需要用户输入:内核暂停运行、渲染表单;用户提交后用同一 input 再次调用该工具,
121
- * 并在 ctx.resume 中带回 state 与 answer。state ≤ 16 KB,可 JSON 序列化。
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
- * - `unavailable`:远端不可用(连接 / 传输错误、超时、HTTP 5xx),计入连接器熔断(连接器用它告诉内核)。
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
- /** 工具执行失败:message 给模型看,须为英文且可操作。 */
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[];