@capybara-hq/plugin-sdk 0.1.0-rc.4 → 0.1.0-rc.41

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 (133) hide show
  1. package/agent-docs/agent-templates.md +15 -3
  2. package/agent-docs/concepts.md +13 -3
  3. package/agent-docs/connector-templates.md +2 -1
  4. package/agent-docs/extension-points/channel.md +2 -2
  5. package/agent-docs/extension-points/config-source.md +1 -1
  6. package/agent-docs/extension-points/connector.md +1 -1
  7. package/agent-docs/extension-points/context.md +15 -0
  8. package/agent-docs/extension-points/counter.md +1 -1
  9. package/agent-docs/extension-points/directory.md +1 -1
  10. package/agent-docs/extension-points/file-preview.md +3 -1
  11. package/agent-docs/extension-points/identity-source.md +1 -1
  12. package/agent-docs/extension-points/model-provider.md +4 -2
  13. package/agent-docs/extension-points/object-store.md +3 -1
  14. package/agent-docs/extension-points/sandbox.md +3 -3
  15. package/agent-docs/extension-points/secret-store.md +1 -1
  16. package/agent-docs/extension-points/web-fetch.md +1 -1
  17. package/agent-docs/extension-points/web-search.md +1 -1
  18. package/agent-docs/extensions.md +29 -4
  19. package/agent-docs/plugin-format.md +43 -3
  20. package/agent-docs/setup.md +46 -0
  21. package/agent-docs/skills.md +1 -1
  22. package/agent-docs/tool-naming.md +1 -1
  23. package/dist/agent-template.d.ts +15 -6
  24. package/dist/agent-template.js +32 -13
  25. package/dist/bootstrap.d.ts +15 -1
  26. package/dist/bootstrap.js +17 -1
  27. package/dist/cards.d.ts +67 -13
  28. package/dist/cards.js +91 -21
  29. package/dist/channel.d.ts +148 -48
  30. package/dist/channel.js +10 -5
  31. package/dist/client-css.d.ts +36 -0
  32. package/dist/client-css.js +326 -0
  33. package/dist/client-section.d.ts +35 -0
  34. package/dist/client-section.js +133 -0
  35. package/dist/config-ui.d.ts +22 -0
  36. package/dist/config-ui.js +64 -4
  37. package/dist/connector-auth.d.ts +7 -2
  38. package/dist/connector-auth.js +29 -8
  39. package/dist/connector.d.ts +74 -32
  40. package/dist/context.d.ts +40 -0
  41. package/dist/context.js +2 -0
  42. package/dist/ctx.d.ts +120 -29
  43. package/dist/define-extension.d.ts +26 -12
  44. package/dist/define-extension.js +11 -4
  45. package/dist/device-denied-paths.d.ts +14 -0
  46. package/dist/device-denied-paths.js +41 -0
  47. package/dist/device-protocol.d.ts +481 -0
  48. package/dist/device-protocol.js +1113 -0
  49. package/dist/extension-point.d.ts +2 -0
  50. package/dist/extension-point.js +5 -2
  51. package/dist/file-preview.d.ts +23 -6
  52. package/dist/git-hosts.d.ts +44 -0
  53. package/dist/git-hosts.js +81 -0
  54. package/dist/hooks.d.ts +125 -20
  55. package/dist/hooks.js +5 -0
  56. package/dist/http-access.d.ts +62 -0
  57. package/dist/http-access.js +12 -0
  58. package/dist/identity.d.ts +22 -9
  59. package/dist/index.d.ts +26 -1
  60. package/dist/index.js +26 -1
  61. package/dist/marketplace.d.ts +26 -0
  62. package/dist/marketplace.js +43 -1
  63. package/dist/model-params.d.ts +41 -22
  64. package/dist/model-params.js +28 -15
  65. package/dist/model.d.ts +206 -71
  66. package/dist/model.js +152 -19
  67. package/dist/net.d.ts +52 -0
  68. package/dist/net.js +34 -0
  69. package/dist/network-classes.d.ts +98 -0
  70. package/dist/network-classes.js +291 -0
  71. package/dist/permissions.d.ts +41 -21
  72. package/dist/permissions.js +101 -42
  73. package/dist/plugin-manifest.d.ts +45 -5
  74. package/dist/plugin-manifest.js +169 -6
  75. package/dist/plugin-package.d.ts +82 -38
  76. package/dist/plugin-package.js +61 -29
  77. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  78. package/dist/sandbox-linux-runtime-source.js +2318 -0
  79. package/dist/sandbox-native-runtime-source.d.ts +8 -0
  80. package/dist/sandbox-native-runtime-source.js +465 -0
  81. package/dist/sandbox-operation.d.ts +284 -0
  82. package/dist/sandbox-operation.js +262 -0
  83. package/dist/sandbox-runtime-source.d.ts +19 -0
  84. package/dist/sandbox-runtime-source.js +28 -0
  85. package/dist/sandbox-write-denies.d.ts +139 -0
  86. package/dist/sandbox-write-denies.js +869 -0
  87. package/dist/sandbox.d.ts +190 -16
  88. package/dist/sandbox.js +89 -14
  89. package/dist/secret.d.ts +4 -1
  90. package/dist/secret.js +4 -1
  91. package/dist/setup-check.d.ts +115 -0
  92. package/dist/setup-check.js +142 -0
  93. package/dist/setup-guide-parse.d.ts +121 -0
  94. package/dist/setup-guide-parse.js +350 -0
  95. package/dist/setup-guide-render.d.ts +45 -0
  96. package/dist/setup-guide-render.js +351 -0
  97. package/dist/setup-guide.d.ts +94 -0
  98. package/dist/setup-guide.js +336 -0
  99. package/dist/shell-capabilities.d.ts +88 -0
  100. package/dist/shell-capabilities.js +13 -0
  101. package/dist/shell-environment.d.ts +57 -0
  102. package/dist/shell-environment.js +16 -0
  103. package/dist/skill-invocation.d.ts +4 -3
  104. package/dist/skill-invocation.js +5 -4
  105. package/dist/skill.d.ts +34 -21
  106. package/dist/skill.js +48 -31
  107. package/dist/storage.d.ts +52 -25
  108. package/dist/theme-assets.d.ts +39 -0
  109. package/dist/theme-assets.js +449 -0
  110. package/dist/theme-readability.d.ts +37 -0
  111. package/dist/theme-readability.js +145 -0
  112. package/dist/theme-tokens.generated.d.ts +287 -0
  113. package/dist/theme-tokens.generated.js +176 -0
  114. package/dist/theme.d.ts +152 -0
  115. package/dist/theme.js +392 -0
  116. package/dist/tool.d.ts +69 -26
  117. package/dist/tool.js +29 -9
  118. package/dist/ui-parts.d.ts +23 -0
  119. package/dist/ui-parts.js +348 -0
  120. package/dist/ui-resolve.d.ts +35 -0
  121. package/dist/ui-resolve.js +42 -0
  122. package/dist/ui-slots.d.ts +65 -0
  123. package/dist/ui-slots.js +261 -0
  124. package/dist/ui.d.ts +212 -76
  125. package/dist/ui.js +101 -27
  126. package/dist/url.d.ts +4 -1
  127. package/dist/url.js +4 -1
  128. package/package.json +8 -1
  129. package/schemas/bootstrap.v1.schema.json +6 -0
  130. package/schemas/connector-template.v1.schema.json +35 -0
  131. package/schemas/marketplace.v1.schema.json +14 -0
  132. package/schemas/plugin.v1.schema.json +115 -3
  133. package/schemas/theme.v1.schema.json +225 -0
@@ -1,4 +1,5 @@
1
1
  import { type ExtensionManifest } from "./define-extension.js";
2
+ import { type GitSource } from "./git-hosts.js";
2
3
  import type { ExtensionPermissions } from "./permissions.js";
3
4
  import type { PluginManifest } from "./plugin-manifest.js";
4
5
  /**
@@ -10,17 +11,29 @@ import type { PluginManifest } from "./plugin-manifest.js";
10
11
  * entry is single-file ESM with third-party dependencies bundled; only {@link HOST_PROVIDED_PACKAGES}
11
12
  * come from the host.
12
13
  */
13
- /** 宿主提供的包(peerDependencies,安装时链接到宿主副本);其余三方依赖必须打进 entry。 */
14
+ /**
15
+ * Packages provided by the host (peerDependencies, linked to the host's copy on install); every
16
+ * other third-party dependency must be bundled into the entry.
17
+ */
14
18
  export declare const HOST_PROVIDED_PACKAGES: readonly ["@capybara-hq/plugin-sdk", "zod"];
15
- /** npm 安装时会自动执行的脚本:插件包一律不许有(安装不跑脚本,有也是误导)。 */
19
+ /**
20
+ * Scripts npm runs automatically on install: a plugin package must never have any (installs run no
21
+ * scripts, so having them would mislead).
22
+ */
16
23
  export declare const FORBIDDEN_INSTALL_SCRIPTS: readonly ["preinstall", "install", "postinstall", "prepare"];
17
- /** 静态清单里的一个配置字段(点路径,根即叶子时为空串)。 */
24
+ /**
25
+ * A config field in the static manifest (a dotted path; an empty string when the root is itself the
26
+ * leaf).
27
+ */
18
28
  export interface StaticConfigField {
19
29
  path: string;
20
30
  secret: boolean;
21
31
  hot: boolean;
22
32
  }
23
- /** 插件清单的静态部分(可 JSON 序列化;不含 setup、zod schema、migrations 路径)。 */
33
+ /**
34
+ * The static part of the plugin manifest (JSON-serializable; excludes setup, zod schemas and
35
+ * migration paths).
36
+ */
24
37
  export interface StaticExtensionManifest {
25
38
  name: string;
26
39
  version: string;
@@ -35,27 +48,38 @@ export interface StaticExtensionManifest {
35
48
  org: StaticConfigField[];
36
49
  };
37
50
  }
38
- /** 入口模块里的一个 import:`name` 是 specifier(非字面量的动态 import 时为空串)。 */
51
+ /**
52
+ * An import in the entry module: `name` is the specifier (an empty string for a dynamic import that
53
+ * is not a literal).
54
+ */
39
55
  export interface EntryImport {
40
56
  name: string;
41
57
  dynamic: boolean;
42
58
  literal: boolean;
43
59
  }
44
- /** npm 包名规则(简化):可带 scope,小写,≤ 214 字符(长度另行检查)。 */
60
+ /**
61
+ * npm package name rule (simplified): may carry a scope, lowercase, ≤ 214 characters (the length is
62
+ * checked separately).
63
+ */
45
64
  export declare const NPM_PACKAGE_NAME_RE: RegExp;
46
65
  /**
47
- * 包内相对路径是否安全:非空、不以 `/` 开头、不含 `\`、控制字符与盘符,没有空段、`.` 与 `..` 段,≤ 1024 字符。
66
+ * Whether a path relative to the package is safe: non-empty, not starting with `/`, no `\`, control
67
+ * characters or drive letters, no empty segments, `.` or `..` segments, ≤ 1024 characters.
48
68
  */
49
69
  export declare function isSafePackagePath(p: string): boolean;
50
70
  /**
51
- * 核对入口模块的 import(C11):静态与字面量动态 import 只许 `node:*`、{@link HOST_PROVIDED_PACKAGES}(含子路径)
52
- * 与包内相对路径(`./`、`../`;是否越出包外由调用方按文件位置判断);非字面量的动态 import 一律拒绝。
53
- * 返回问题列表(空表示合法)。
71
+ * Checks the entry module's imports (C11): static and literal dynamic imports may only be `node:*`,
72
+ * {@link HOST_PROVIDED_PACKAGES} (subpaths included)
73
+ * and in-package relative paths (`./`, `../`; whether they escape the package is judged by the
74
+ * caller from the file location); non-literal dynamic imports are always rejected.
75
+ * Returns the list of problems (empty means valid).
54
76
  */
55
77
  export declare function checkEntryImports(specifiers: EntryImport[]): string[];
56
78
  /**
57
- * 真实清单的静态部分:打包时写进 `capybara.manifest`,加载时与包内的比对(`manifest_mismatch`)。
58
- * 结果可 JSON 往返(undefined 字段去掉);配置字段按路径排序。
79
+ * The static part of the real manifest: written into `capybara.manifest` when packing, and compared
80
+ * with the in-package one at load time (`manifest_mismatch`).
81
+ * The result survives a JSON round trip (undefined fields removed); config fields are sorted by
82
+ * path.
59
83
  */
60
84
  export declare function staticManifestOf(m: ExtensionManifest): StaticExtensionManifest;
61
85
  /**
@@ -78,62 +102,82 @@ export declare function validatePluginPackageJsonFor(pkg: unknown, manifest: Plu
78
102
  */
79
103
  export declare function hostSdkProblem(sdk: string, hostSdkVersion: string): string | undefined;
80
104
  /**
81
- * 连接器模板(C30):连接器插件引用 + `Connector.kind` + 端点预设 + 组织可改的端点路径 + 认证预设(不含凭据)+
82
- * 默认 ownership + 各工具默认策略 + 图标。组织安装时只能填凭据、客户端 id / secret 与 `editableEndpoint` 里的字段。
105
+ * Connector template (C30): connector plugin reference + `Connector.kind` + endpoint preset +
106
+ * endpoint paths an org may change + auth preset (no credentials) +
107
+ * default ownership + default policy per tool + icon. When installing, an org may only fill in
108
+ * credentials, the client id / secret and the fields in `editableEndpoint`.
83
109
  */
84
110
  export interface ConnectorTemplateSpec {
85
- /** 连接器插件名(如 `connector-mcp`)。 */
111
+ /** Connector plugin name (e.g. `connector-mcp`). */
86
112
  plugin: string;
87
- /** 连接器插件的 semver 范围,可选。 */
113
+ /** Semver range of the connector plugin, optional. */
88
114
  pluginVersion?: string;
89
- /** `Connector.kind`(如 `"mcp"`)。 */
115
+ /** `Connector.kind` (e.g. `"mcp"`). */
90
116
  connector: string;
91
- /** 端点预设;导入时内核按该连接器的 `endpointSchema` 校验。 */
117
+ /**
118
+ * Endpoint preset; on import the kernel validates it against that connector's `endpointSchema`.
119
+ */
92
120
  endpoint: Record<string, unknown>;
93
- /** 组织安装时允许改的点路径(如 `"url"`);其余以模板为准。路径必须存在于连接器的端点 schema 中。 */
121
+ /**
122
+ * Dotted paths an org may change when installing (e.g. `"url"`); everything else follows the
123
+ * template. The paths must exist in the connector's endpoint schema.
124
+ */
94
125
  editableEndpoint?: string[];
95
- /** 与连接器安装接口的认证方式同形({@link ConnectorAuthSchema}),不含任何凭据。 */
126
+ /**
127
+ * The same shape as the auth method of the connector install API ({@link ConnectorAuthSchema}),
128
+ * carrying no credentials.
129
+ */
96
130
  auth: Record<string, unknown>;
97
- /** 缺省取 `auth.ownership`;给了就必须与之一致。 */
131
+ /** Defaults to `auth.ownership`; if given it must agree. */
98
132
  ownership?: "org" | "personal";
99
- /** 工具名 → 默认策略(安装后记 `policy_source 'template'`)。 */
133
+ /** Tool name -> default policy (recorded as `policy_source 'template'` after install). */
100
134
  defaultToolPolicies?: Record<string, "allow" | "ask" | "deny">;
101
- /** 包内路径,svg / png,≤ {@link CONNECTOR_TEMPLATE_LIMITS}`.iconBytes`。 */
135
+ /** Git hosts this connector's credential serves in sandboxes ({@link GitSource}). */
136
+ git?: GitSource;
137
+ /** In-package path, svg / png, ≤ {@link CONNECTOR_TEMPLATE_LIMITS}`.iconBytes`. */
102
138
  icon?: string;
103
139
  }
104
- /** 双语显示名。 */
140
+ /** Bilingual display name. */
105
141
  export interface LocalizedName {
106
142
  zh: string;
107
143
  en: string;
108
144
  }
109
- /** 连接器模板与目录段的上限。 */
145
+ /** Limits of connector templates and catalog segments. */
110
146
  export declare const CONNECTOR_TEMPLATE_LIMITS: {
111
- /** 图标字节数上限。 */
147
+ /** Upper bound on icon bytes. */
112
148
  readonly iconBytes: number;
113
- /** 端点预设 JSON 序列化后的字符数上限。 */
149
+ /** Upper bound on the characters of the endpoint preset after JSON serialization. */
114
150
  readonly endpointChars: number;
115
- /** `editableEndpoint` 条数上限。 */
151
+ /** Upper bound on the number of `editableEndpoint` entries. */
116
152
  readonly editablePaths: 50;
117
- /** `defaultToolPolicies` 条数上限。 */
153
+ /** Upper bound on the number of `defaultToolPolicies` entries. */
118
154
  readonly toolPolicies: 1000;
119
- /** publisher 字符数上限。 */
155
+ /** Upper bound on the characters of publisher. */
120
156
  readonly publisherChars: 100;
121
- /** description 字符数上限。 */
157
+ /** Upper bound on the characters of description. */
122
158
  readonly descriptionChars: 1024;
123
- /** displayName 每种语言的字符数上限。 */
159
+ /** Upper bound on the characters of displayName per language. */
124
160
  readonly displayNameChars: 100;
125
161
  };
126
- /** 目录条目名(与清单条目名同一规则):小写字母或数字开头,之后小写字母、数字、连字符,≤ 64。 */
162
+ /**
163
+ * Catalog entry name (the same rule as manifest entry names): starts with a lowercase letter or
164
+ * digit, then lowercase letters, digits and hyphens, ≤ 64.
165
+ */
127
166
  export declare const CATALOG_ITEM_NAME_RE: RegExp;
128
167
  /** An exact semver version (a regex JSON Schema can use). */
129
168
  export declare const SEMVER_VERSION_RE: RegExp;
130
169
  /** The sha512 SRI of an npm package tgz: `sha512-<86 base64 chars>==`. */
131
170
  export declare const SHA512_INTEGRITY_RE: RegExp;
132
171
  /**
133
- * 校验连接器模板({@link ConnectorTemplateSpec})的静态部分,返回问题列表(空表示合法;路径相对模板根,不回显值):
134
- * 字段齐全、无未知字段;`auth` 符合 {@link ConnectorAuthSchema}(strict:夹带 `token` 等多余字段即拒绝);
135
- * 端点预设里任何层级都不许有凭据样式的键;`editableEndpoint` 是不重复的点路径;`ownership` 与 `auth.ownership`
136
- * 一致;默认策略只许 allow / ask / deny;icon 是包内 .svg / .png 路径。
137
- * 端点是否符合连接器的 `endpointSchema`、`editableEndpoint` 是否存在于其中,由内核在导入时按已加载的连接器校验。
172
+ * Validates the static part of a connector template ({@link ConnectorTemplateSpec}) and returns the
173
+ * list of problems (empty means valid; paths are relative to the template root, values are not
174
+ * echoed):
175
+ * fields complete, no unknown fields; `auth` conforms to {@link ConnectorAuthSchema} (strict: extra
176
+ * fields such as `token` are rejected);
177
+ * no credential-style key at any level of the endpoint preset; `editableEndpoint` is a list of
178
+ * distinct dotted paths; `ownership` agrees with `auth.ownership`;
179
+ * default policies may only be allow / ask / deny; icon is an in-package .svg / .png path.
180
+ * Whether the endpoint conforms to the connector's `endpointSchema` and whether `editableEndpoint`
181
+ * exists in it is checked by the kernel on import against the loaded connector.
138
182
  */
139
183
  export declare function validateConnectorTemplate(t: unknown): string[];
@@ -1,6 +1,7 @@
1
1
  import semver from "semver";
2
2
  import { ConnectorAuthSchema } from "./connector-auth.js";
3
3
  import { EXTENSION_NAME_RE } from "./define-extension.js";
4
+ import { validateGitSource } from "./git-hosts.js";
4
5
  /**
5
6
  * Plugin package (npm-pack tgz) rules shared by the SDK, the packer and the kernel (spec §4.1). Pure
6
7
  * functions only: the kernel reads the tgz and scans imports, `packages/plugin-tools` packs it. The
@@ -10,16 +11,24 @@ import { EXTENSION_NAME_RE } from "./define-extension.js";
10
11
  * entry is single-file ESM with third-party dependencies bundled; only {@link HOST_PROVIDED_PACKAGES}
11
12
  * come from the host.
12
13
  */
13
- /** 宿主提供的包(peerDependencies,安装时链接到宿主副本);其余三方依赖必须打进 entry。 */
14
+ /**
15
+ * Packages provided by the host (peerDependencies, linked to the host's copy on install); every
16
+ * other third-party dependency must be bundled into the entry.
17
+ */
14
18
  export const HOST_PROVIDED_PACKAGES = ["@capybara-hq/plugin-sdk", "zod"];
15
- /** npm 安装时会自动执行的脚本:插件包一律不许有(安装不跑脚本,有也是误导)。 */
19
+ /**
20
+ * Scripts npm runs automatically on install: a plugin package must never have any (installs run no
21
+ * scripts, so having them would mislead).
22
+ */
16
23
  export const FORBIDDEN_INSTALL_SCRIPTS = [
17
24
  "preinstall",
18
25
  "install",
19
26
  "postinstall",
20
27
  "prepare",
21
28
  ];
22
- /** 不许出现的依赖字段:三方依赖必须打进 entry。 */
29
+ /**
30
+ * Dependency fields that must not appear: third-party dependencies must be bundled into the entry.
31
+ */
23
32
  const FORBIDDEN_DEP_FIELDS = [
24
33
  "dependencies",
25
34
  "optionalDependencies",
@@ -27,16 +36,20 @@ const FORBIDDEN_DEP_FIELDS = [
27
36
  "bundledDependencies",
28
37
  ];
29
38
  const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
30
- /** npm 包名规则(简化):可带 scope,小写,≤ 214 字符(长度另行检查)。 */
39
+ /**
40
+ * npm package name rule (simplified): may carry a scope, lowercase, ≤ 214 characters (the length is
41
+ * checked separately).
42
+ */
31
43
  export const NPM_PACKAGE_NAME_RE = /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/;
32
44
  const NPM_NAME_RE = NPM_PACKAGE_NAME_RE;
33
45
  /**
34
- * 包内相对路径是否安全:非空、不以 `/` 开头、不含 `\`、控制字符与盘符,没有空段、`.` 与 `..` 段,≤ 1024 字符。
46
+ * Whether a path relative to the package is safe: non-empty, not starting with `/`, no `\`, control
47
+ * characters or drive letters, no empty segments, `.` or `..` segments, ≤ 1024 characters.
35
48
  */
36
49
  export function isSafePackagePath(p) {
37
50
  if (typeof p !== "string" || p === "" || p.length > 1024)
38
51
  return false;
39
- // biome-ignore lint/suspicious/noControlCharactersInRegex: 正是要拒绝控制字符
52
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are exactly what must be rejected
40
53
  if (p.startsWith("/") || p.includes("\\") || /[\u0000-\u001f\u007f]/.test(p))
41
54
  return false;
42
55
  if (/^[A-Za-z]:/.test(p))
@@ -45,9 +58,11 @@ export function isSafePackagePath(p) {
45
58
  }
46
59
  const isHostPackage = (name) => HOST_PROVIDED_PACKAGES.some((h) => name === h || name.startsWith(`${h}/`));
47
60
  /**
48
- * 核对入口模块的 import(C11):静态与字面量动态 import 只许 `node:*`、{@link HOST_PROVIDED_PACKAGES}(含子路径)
49
- * 与包内相对路径(`./`、`../`;是否越出包外由调用方按文件位置判断);非字面量的动态 import 一律拒绝。
50
- * 返回问题列表(空表示合法)。
61
+ * Checks the entry module's imports (C11): static and literal dynamic imports may only be `node:*`,
62
+ * {@link HOST_PROVIDED_PACKAGES} (subpaths included)
63
+ * and in-package relative paths (`./`, `../`; whether they escape the package is judged by the
64
+ * caller from the file location); non-literal dynamic imports are always rejected.
65
+ * Returns the list of problems (empty means valid).
51
66
  */
52
67
  export function checkEntryImports(specifiers) {
53
68
  const out = [];
@@ -71,7 +86,10 @@ export function checkEntryImports(specifiers) {
71
86
  const WRAPPERS = new Set(["default", "prefault", "optional", "nullable", "readonly", "catch"]);
72
87
  const defOf = (s) => s._zod.def;
73
88
  const metaOf = (s) => s.meta();
74
- /** 与内核 `configFields` 相同的遍历:对象递归展开,default / optional 等包装剥掉,对象上的 secret 向下继承。 */
89
+ /**
90
+ * The same traversal as the kernel's `configFields`: objects are expanded recursively, wrappers
91
+ * such as default / optional are stripped, and a secret on an object is inherited downward.
92
+ */
75
93
  function configFieldsOf(schema, prefix = "", inheritedSecret = false) {
76
94
  if (!schema)
77
95
  return [];
@@ -91,8 +109,10 @@ function configFieldsOf(schema, prefix = "", inheritedSecret = false) {
91
109
  const byPath = (a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
92
110
  const jsonClone = (v) => JSON.parse(JSON.stringify(v));
93
111
  /**
94
- * 真实清单的静态部分:打包时写进 `capybara.manifest`,加载时与包内的比对(`manifest_mismatch`)。
95
- * 结果可 JSON 往返(undefined 字段去掉);配置字段按路径排序。
112
+ * The static part of the real manifest: written into `capybara.manifest` when packing, and compared
113
+ * with the in-package one at load time (`manifest_mismatch`).
114
+ * The result survives a JSON round trip (undefined fields removed); config fields are sorted by
115
+ * path.
96
116
  */
97
117
  export function staticManifestOf(m) {
98
118
  const out = {
@@ -253,24 +273,27 @@ export function hostSdkProblem(sdk, hostSdkVersion) {
253
273
  return undefined;
254
274
  return `extension.manifest.sdk "${sdk}" is not satisfied by the host SDK version ${hostSdkVersion}`;
255
275
  }
256
- /** 连接器模板与目录段的上限。 */
276
+ /** Limits of connector templates and catalog segments. */
257
277
  export const CONNECTOR_TEMPLATE_LIMITS = {
258
- /** 图标字节数上限。 */
278
+ /** Upper bound on icon bytes. */
259
279
  iconBytes: 64 * 1024,
260
- /** 端点预设 JSON 序列化后的字符数上限。 */
280
+ /** Upper bound on the characters of the endpoint preset after JSON serialization. */
261
281
  endpointChars: 16 * 1024,
262
- /** `editableEndpoint` 条数上限。 */
282
+ /** Upper bound on the number of `editableEndpoint` entries. */
263
283
  editablePaths: 50,
264
- /** `defaultToolPolicies` 条数上限。 */
284
+ /** Upper bound on the number of `defaultToolPolicies` entries. */
265
285
  toolPolicies: 1000,
266
- /** publisher 字符数上限。 */
286
+ /** Upper bound on the characters of publisher. */
267
287
  publisherChars: 100,
268
- /** description 字符数上限。 */
288
+ /** Upper bound on the characters of description. */
269
289
  descriptionChars: 1024,
270
- /** displayName 每种语言的字符数上限。 */
290
+ /** Upper bound on the characters of displayName per language. */
271
291
  displayNameChars: 100,
272
292
  };
273
- /** 目录条目名(与清单条目名同一规则):小写字母或数字开头,之后小写字母、数字、连字符,≤ 64。 */
293
+ /**
294
+ * Catalog entry name (the same rule as manifest entry names): starts with a lowercase letter or
295
+ * digit, then lowercase letters, digits and hyphens, ≤ 64.
296
+ */
274
297
  export const CATALOG_ITEM_NAME_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
275
298
  /** An exact semver version (a regex JSON Schema can use). */
276
299
  export const SEMVER_VERSION_RE = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
@@ -279,8 +302,9 @@ export const SHA512_INTEGRITY_RE = /^sha512-[A-Za-z0-9+/]{86}==$/;
279
302
  const PATH_SEG_RE = /^[A-Za-z0-9_-]{1,100}$/;
280
303
  const PROTO_KEYS = new Set(["__proto__", "prototype", "constructor"]);
281
304
  /**
282
- * 凭据样式的字段名(比较时转小写、去掉 `-` 与 `_`):模板会被所有组织看到,端点预设里出现这些键一律拒绝。
283
- * `authorization` / `cookie` 等头名同样在列(端点头里的凭据)。
305
+ * Credential-style field names (compared lowercased with `-` and `_` removed): templates are seen
306
+ * by every org, so endpoint presets containing these keys are always rejected.
307
+ * Header names such as `authorization` / `cookie` are listed too (credentials in endpoint headers).
284
308
  */
285
309
  const CREDENTIAL_KEYS = new Set([
286
310
  "token",
@@ -305,7 +329,7 @@ const CREDENTIAL_KEYS = new Set([
305
329
  "sessiontoken",
306
330
  ]);
307
331
  const normKey = (k) => k.toLowerCase().replace(/[-_]/g, "");
308
- /** 递归找出凭据样式的键(只报路径,不回显值)。 */
332
+ /** Recursively finds credential-style keys (reports only paths, never echoes values). */
309
333
  function credentialKeyPaths(v, at, out, depth = 0) {
310
334
  if (depth > 20)
311
335
  return;
@@ -333,14 +357,20 @@ const TEMPLATE_KEYS = new Set([
333
357
  "auth",
334
358
  "ownership",
335
359
  "defaultToolPolicies",
360
+ "git",
336
361
  "icon",
337
362
  ]);
338
363
  /**
339
- * 校验连接器模板({@link ConnectorTemplateSpec})的静态部分,返回问题列表(空表示合法;路径相对模板根,不回显值):
340
- * 字段齐全、无未知字段;`auth` 符合 {@link ConnectorAuthSchema}(strict:夹带 `token` 等多余字段即拒绝);
341
- * 端点预设里任何层级都不许有凭据样式的键;`editableEndpoint` 是不重复的点路径;`ownership` 与 `auth.ownership`
342
- * 一致;默认策略只许 allow / ask / deny;icon 是包内 .svg / .png 路径。
343
- * 端点是否符合连接器的 `endpointSchema`、`editableEndpoint` 是否存在于其中,由内核在导入时按已加载的连接器校验。
364
+ * Validates the static part of a connector template ({@link ConnectorTemplateSpec}) and returns the
365
+ * list of problems (empty means valid; paths are relative to the template root, values are not
366
+ * echoed):
367
+ * fields complete, no unknown fields; `auth` conforms to {@link ConnectorAuthSchema} (strict: extra
368
+ * fields such as `token` are rejected);
369
+ * no credential-style key at any level of the endpoint preset; `editableEndpoint` is a list of
370
+ * distinct dotted paths; `ownership` agrees with `auth.ownership`;
371
+ * default policies may only be allow / ask / deny; icon is an in-package .svg / .png path.
372
+ * Whether the endpoint conforms to the connector's `endpointSchema` and whether `editableEndpoint`
373
+ * exists in it is checked by the kernel on import against the loaded connector.
344
374
  */
345
375
  export function validateConnectorTemplate(t) {
346
376
  if (!isObj(t))
@@ -439,6 +469,8 @@ export function validateConnectorTemplate(t) {
439
469
  }
440
470
  }
441
471
  }
472
+ if (t.git !== undefined)
473
+ errs.push(...validateGitSource(t.git, "template.git"));
442
474
  if (t.icon !== undefined) {
443
475
  if (typeof t.icon !== "string" || !isSafePackagePath(t.icon) || !/\.(svg|png)$/i.test(t.icon)) {
444
476
  errs.push("template.icon must be a relative .svg or .png path inside the package");
@@ -0,0 +1 @@
1
+ export declare const LINUX_SANDBOX_SOURCE: string;