@capybara-hq/plugin-sdk 0.1.0-rc.6 → 0.1.0-rc.60

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 (136) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +7 -1
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +2 -0
  9. package/agent-docs/extension-points/model-provider.md +3 -1
  10. package/agent-docs/extension-points/object-store.md +2 -0
  11. package/agent-docs/extension-points/push-provider.md +17 -0
  12. package/agent-docs/extensions.md +29 -3
  13. package/agent-docs/plugin-format.md +52 -2
  14. package/agent-docs/setup.md +54 -0
  15. package/dist/agent-template.d.ts +15 -6
  16. package/dist/agent-template.js +32 -13
  17. package/dist/avatar-presets.d.ts +8 -0
  18. package/dist/avatar-presets.js +17 -0
  19. package/dist/bootstrap.d.ts +109 -1
  20. package/dist/bootstrap.js +185 -2
  21. package/dist/cards.d.ts +67 -13
  22. package/dist/cards.js +91 -21
  23. package/dist/channel.d.ts +148 -48
  24. package/dist/channel.js +10 -5
  25. package/dist/client-css.d.ts +36 -0
  26. package/dist/client-css.js +326 -0
  27. package/dist/client-section.d.ts +35 -0
  28. package/dist/client-section.js +133 -0
  29. package/dist/config-ui.d.ts +22 -0
  30. package/dist/config-ui.js +64 -4
  31. package/dist/connector-auth.d.ts +15 -2
  32. package/dist/connector-auth.js +97 -8
  33. package/dist/connector.d.ts +74 -32
  34. package/dist/context.d.ts +40 -0
  35. package/dist/context.js +2 -0
  36. package/dist/ctx.d.ts +132 -29
  37. package/dist/define-extension.d.ts +26 -12
  38. package/dist/define-extension.js +12 -5
  39. package/dist/device-denied-paths.d.ts +18 -0
  40. package/dist/device-denied-paths.js +84 -0
  41. package/dist/device-operation.d.ts +333 -0
  42. package/dist/device-operation.js +312 -0
  43. package/dist/device-protocol.d.ts +285 -50
  44. package/dist/device-protocol.js +755 -90
  45. package/dist/device-provider.d.ts +500 -0
  46. package/dist/device-provider.js +302 -0
  47. package/dist/dial-in.d.ts +176 -0
  48. package/dist/dial-in.js +115 -0
  49. package/dist/extension-point.d.ts +2 -0
  50. package/dist/extension-point.js +6 -2
  51. package/dist/file-preview.d.ts +23 -6
  52. package/dist/git-hosts.d.ts +53 -0
  53. package/dist/git-hosts.js +98 -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 +38 -9
  59. package/dist/identity.js +21 -1
  60. package/dist/index.d.ts +29 -3
  61. package/dist/index.js +29 -3
  62. package/dist/marketplace.d.ts +26 -0
  63. package/dist/marketplace.js +43 -1
  64. package/dist/model-params.d.ts +41 -22
  65. package/dist/model-params.js +28 -15
  66. package/dist/model.d.ts +206 -71
  67. package/dist/model.js +152 -19
  68. package/dist/net.d.ts +52 -0
  69. package/dist/net.js +34 -0
  70. package/dist/network-classes.d.ts +98 -0
  71. package/dist/network-classes.js +291 -0
  72. package/dist/permissions.d.ts +54 -22
  73. package/dist/permissions.js +119 -43
  74. package/dist/plugin-manifest.d.ts +45 -5
  75. package/dist/plugin-manifest.js +174 -6
  76. package/dist/plugin-package.d.ts +82 -38
  77. package/dist/plugin-package.js +61 -29
  78. package/dist/push.d.ts +75 -0
  79. package/dist/push.js +87 -0
  80. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  81. package/dist/sandbox-linux-runtime-source.js +2318 -0
  82. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  83. package/dist/sandbox-native-runtime-source.js +476 -0
  84. package/dist/sandbox-runtime-source.d.ts +19 -0
  85. package/dist/sandbox-runtime-source.js +28 -0
  86. package/dist/sandbox-write-denies.d.ts +139 -0
  87. package/dist/sandbox-write-denies.js +869 -0
  88. package/dist/secret.d.ts +4 -1
  89. package/dist/secret.js +4 -1
  90. package/dist/setup-check.d.ts +128 -0
  91. package/dist/setup-check.js +142 -0
  92. package/dist/setup-guide-parse.d.ts +121 -0
  93. package/dist/setup-guide-parse.js +356 -0
  94. package/dist/setup-guide-render.d.ts +45 -0
  95. package/dist/setup-guide-render.js +351 -0
  96. package/dist/setup-guide.d.ts +108 -0
  97. package/dist/setup-guide.js +367 -0
  98. package/dist/shell-capabilities.d.ts +211 -0
  99. package/dist/shell-capabilities.js +44 -0
  100. package/dist/shell-environment.d.ts +57 -0
  101. package/dist/shell-environment.js +21 -0
  102. package/dist/skill.d.ts +27 -17
  103. package/dist/skill.js +40 -26
  104. package/dist/storage.d.ts +52 -25
  105. package/dist/svg-viewbox.d.ts +10 -0
  106. package/dist/svg-viewbox.js +24 -0
  107. package/dist/theme-assets.d.ts +55 -0
  108. package/dist/theme-assets.js +489 -0
  109. package/dist/theme-readability.d.ts +37 -0
  110. package/dist/theme-readability.js +145 -0
  111. package/dist/theme-tokens.generated.d.ts +299 -0
  112. package/dist/theme-tokens.generated.js +184 -0
  113. package/dist/theme.d.ts +190 -0
  114. package/dist/theme.js +471 -0
  115. package/dist/tool.d.ts +99 -26
  116. package/dist/tool.js +29 -9
  117. package/dist/ui-parts.d.ts +23 -0
  118. package/dist/ui-parts.js +385 -0
  119. package/dist/ui-resolve.d.ts +35 -0
  120. package/dist/ui-resolve.js +42 -0
  121. package/dist/ui-slots.d.ts +65 -0
  122. package/dist/ui-slots.js +261 -0
  123. package/dist/ui.d.ts +212 -76
  124. package/dist/ui.js +101 -27
  125. package/dist/url.d.ts +4 -1
  126. package/dist/url.js +4 -1
  127. package/package.json +13 -1
  128. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  129. package/schemas/bootstrap.v1.schema.json +20 -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 +122 -3
  133. package/schemas/theme.v1.schema.json +302 -0
  134. package/agent-docs/extension-points/sandbox.md +0 -15
  135. package/dist/sandbox.d.ts +0 -254
  136. package/dist/sandbox.js +0 -153
@@ -1,13 +1,19 @@
1
1
  import semver from "semver";
2
2
  import { z } from "zod";
3
3
  import { AGENT_TEMPLATE_LIMITS } from "./agent-template.js";
4
+ import { validateClientSection } from "./client-section.js";
4
5
  import { CONFIG_UI_LIMITS } from "./config-ui.js";
5
6
  import { defineExtension, EXTENSION_NAME_RE } from "./define-extension.js";
7
+ import { GitSourceSchema } from "./git-hosts.js";
6
8
  import { CATALOG_ITEM_NAME_RE, CONNECTOR_TEMPLATE_LIMITS, isSafePackagePath, SEMVER_VERSION_RE, validateConnectorTemplate, } from "./plugin-package.js";
7
9
  import { hasUpperBound } from "./semver-range.js";
10
+ import { SETUP_GUIDE_LIMITS, SETUP_GUIDE_PLACES } from "./setup-guide.js";
11
+ import { THEME_LIMITS, themeIdOf } from "./theme.js";
12
+ import { parseSlotRef, uiSlot } from "./ui-slots.js";
8
13
  /**
9
14
  * The plugin manifest `.capybara-plugin/plugin.json` (package ecosystem spec §4.1). A plugin is a
10
- * bundle of at most one extension, skills and connector templates, packed as an npm-pack tgz:
15
+ * bundle of at most one extension, skills, connector templates, agent templates and themes, packed as
16
+ * an npm-pack tgz:
11
17
  *
12
18
  * ```
13
19
  * package/package.json npm metadata; version equals plugin.json version
@@ -15,13 +21,14 @@ import { hasUpperBound } from "./semver-range.js";
15
21
  * package/skills/<name>/SKILL.md skills
16
22
  * package/connectors/<id>.json connector templates ({@link ConnectorTemplateFile})
17
23
  * package/agents/<name>.md agent templates (parsed by `parseAgentTemplate`)
24
+ * package/themes/<id>.json themes (parsed by `parseThemeFile`)
18
25
  * package/dist/index.mjs extension entry (only with an extension)
19
26
  * package/migrations/*.sql, package/ui/**
20
27
  * ```
21
28
  *
22
29
  * Paths start with `./` and stay inside the plugin root. Omitting `skills` / `connectorTemplates`
23
- * / `agents` means "scan `skills/*\/SKILL.md` / `connectors/*.json` / `agents/*.md`" (done by the
24
- * kernel when it reads the package). `extension` is written by the packer, never by hand.
30
+ * / `agents` / `themes` means "scan `skills/*\/SKILL.md` / `connectors/*.json` / `agents/*.md` /
31
+ * `themes/*.json`" (done by the kernel when it reads the package). `extension` is written by the packer, never by hand.
25
32
  *
26
33
  * The committed JSON Schema (`schemas/plugin.v1.schema.json`) is generated from
27
34
  * {@link PluginManifestSchema} by `pnpm gen:package-schemas` and drift-checked by
@@ -43,10 +50,14 @@ export const PLUGIN_MANIFEST_LIMITS = {
43
50
  connectorTemplates: 20,
44
51
  /** Agent templates ({@link AGENT_TEMPLATE_LIMITS}`.perPlugin`). */
45
52
  agents: AGENT_TEMPLATE_LIMITS.perPlugin,
53
+ /** Themes ({@link THEME_LIMITS}`.perPlugin`). */
54
+ themes: THEME_LIMITS.perPlugin,
46
55
  descriptionChars: 1024,
47
56
  publisherChars: 100,
48
57
  displayNameChars: 100,
49
58
  pathChars: 512,
59
+ /** Entries of `suggestedAppearance.replacements`. */
60
+ appearanceReplacements: 8,
50
61
  };
51
62
  /** A plugin description as `{ en, zh? }` (a plain string is the English text). */
52
63
  export function pluginDescription(d) {
@@ -55,6 +66,7 @@ export function pluginDescription(d) {
55
66
  const L = PLUGIN_MANIFEST_LIMITS;
56
67
  const MAX_ERRORS = 50;
57
68
  const ICON_RE = /\.(?:svg|png)$/i;
69
+ const COMPONENT_ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
58
70
  const HTTPS_URL_RE = /^https:\/\/\S+$/;
59
71
  const text = (max, what) => z
60
72
  .string()
@@ -97,6 +109,38 @@ const configSchemaJson = z
97
109
  .refine((v) => new TextEncoder().encode(JSON.stringify(v)).length <= CONFIG_UI_LIMITS.configSchemaBytes, {
98
110
  message: `must be at most ${CONFIG_UI_LIMITS.configSchemaBytes} bytes of JSON (${CONFIG_UI_LIMITS.configSchemaBytes / 1024} KiB)`,
99
111
  });
112
+ const setupGuide = z.strictObject({
113
+ id: z.string().regex(CATALOG_ITEM_NAME_RE, {
114
+ message: "id must match ^[a-z0-9][a-z0-9-]{0,63}$",
115
+ }),
116
+ place: z.enum(SETUP_GUIDE_PLACES),
117
+ templates: z
118
+ .array(z.string().regex(CATALOG_ITEM_NAME_RE, {
119
+ message: "a template must match ^[a-z0-9][a-z0-9-]{0,63}$",
120
+ }))
121
+ .min(1)
122
+ .max(SETUP_GUIDE_LIMITS.templatesPerGuide)
123
+ .optional(),
124
+ });
125
+ const clientSection = z
126
+ .strictObject({
127
+ entry: z.string().max(L.pathChars).optional(),
128
+ styles: z.array(z.string().max(L.pathChars)).max(64).optional(),
129
+ assets: z.array(z.string().max(L.pathChars)).max(256).optional(),
130
+ integrity: z.record(z.string().max(L.pathChars), z.string().max(128)),
131
+ apiVersion: z.number().int().min(1),
132
+ })
133
+ .superRefine((c, ctx) => {
134
+ for (const e of validateClientSection(c))
135
+ ctx.addIssue({ code: "custom", path: [], message: e });
136
+ });
137
+ const suggestedAppearance = z.strictObject({
138
+ theme: z
139
+ .string()
140
+ .regex(CATALOG_ITEM_NAME_RE, { message: "theme must match ^[a-z0-9][a-z0-9-]{0,63}$" })
141
+ .optional(),
142
+ replacements: z.record(z.string().max(100), z.string().max(100)).optional(),
143
+ });
100
144
  const extensionSection = z.strictObject({
101
145
  entry: dotPath("entry").refine((p) => p.endsWith(".mjs"), {
102
146
  message: "entry must be a .mjs file",
@@ -107,6 +151,7 @@ const extensionSection = z.strictObject({
107
151
  configSchemas: z
108
152
  .strictObject({ deployment: configSchemaJson.optional(), org: configSchemaJson.optional() })
109
153
  .optional(),
154
+ client: clientSection.optional(),
110
155
  });
111
156
  const schema = z
112
157
  .strictObject({
@@ -153,7 +198,7 @@ const schema = z
153
198
  .max(L.dependencies)
154
199
  .optional(),
155
200
  skills: z
156
- .array(z.strictObject({ path: dotPath("path"), pinned: z.boolean().optional() }))
201
+ .array(z.strictObject({ path: dotPath("path") }))
157
202
  .max(L.skills)
158
203
  .optional(),
159
204
  connectorTemplates: z
@@ -168,6 +213,14 @@ const schema = z
168
213
  }))
169
214
  .max(L.agents)
170
215
  .optional(),
216
+ themes: z
217
+ .array(z.strictObject({
218
+ path: dotPath("path").refine((p) => p.endsWith(".json") && CATALOG_ITEM_NAME_RE.test(themeIdOf(p)), { message: "path must be a <id>.json file with id matching ^[a-z0-9][a-z0-9-]{0,63}$" }),
219
+ }))
220
+ .max(L.themes)
221
+ .optional(),
222
+ setupGuides: z.array(setupGuide).max(SETUP_GUIDE_LIMITS.guides).optional(),
223
+ suggestedAppearance: suggestedAppearance.optional(),
171
224
  extension: extensionSection.optional(),
172
225
  })
173
226
  .superRefine((m, ctx) => {
@@ -206,16 +259,119 @@ const schema = z
206
259
  issue(["agents", i, "path"], `duplicate agent template path ${a.path}`);
207
260
  agentPaths.add(a.path);
208
261
  });
262
+ const themeIds = new Set();
263
+ m.themes?.forEach((t, i) => {
264
+ const id = themeIdOf(t.path);
265
+ if (themeIds.has(id))
266
+ issue(["themes", i, "path"], `duplicate theme id ${id}`);
267
+ themeIds.add(id);
268
+ });
269
+ const guideIds = new Set();
270
+ const guideTemplates = new Set();
271
+ let channelGuides = 0;
272
+ m.setupGuides?.forEach((g, i) => {
273
+ if (guideIds.has(g.id))
274
+ issue(["setupGuides", i, "id"], `duplicate setup guide id ${g.id}`);
275
+ guideIds.add(g.id);
276
+ if (g.place === "connector-template") {
277
+ if (g.templates === undefined) {
278
+ issue(["setupGuides", i, "templates"], "templates is required for a connector-template guide");
279
+ }
280
+ else {
281
+ g.templates.forEach((t, j) => {
282
+ if (m.connectorTemplates !== undefined && !ids.has(t)) {
283
+ issue(["setupGuides", i, "templates", j], `template ${t} is not one of the plugin's connector templates`);
284
+ }
285
+ if (guideTemplates.has(t)) {
286
+ issue(["setupGuides", i, "templates", j], `at most one setup guide per connector template (${t} is named twice)`);
287
+ }
288
+ guideTemplates.add(t);
289
+ });
290
+ }
291
+ }
292
+ else if (g.templates !== undefined) {
293
+ issue(["setupGuides", i, "templates"], "templates is only for connector-template guides");
294
+ }
295
+ if (g.place === "channel-connection") {
296
+ channelGuides++;
297
+ if (channelGuides === 2) {
298
+ issue(["setupGuides", i, "place"], "a plugin has at most one channel-connection guide");
299
+ }
300
+ }
301
+ if (g.place === "channel-connection" &&
302
+ m.extension !== undefined &&
303
+ !m.extension.manifest.provides.some((p) => p.startsWith("channel@"))) {
304
+ issue(["setupGuides", i, "place"], "a channel-connection guide needs the plugin's extension to provide channel@1");
305
+ }
306
+ });
307
+ const sa = m.suggestedAppearance;
308
+ if (sa !== undefined) {
309
+ const at = ["suggestedAppearance"];
310
+ if (sa.theme === undefined && sa.replacements === undefined) {
311
+ issue(at, "suggestedAppearance needs theme or replacements");
312
+ }
313
+ if (sa.theme !== undefined && m.themes !== undefined && !themeIds.has(sa.theme)) {
314
+ issue([...at, "theme"], `suggestedAppearance.theme names ${sa.theme}, which is not a theme of the plugin`);
315
+ }
316
+ if (sa.replacements !== undefined) {
317
+ const entries = Object.entries(sa.replacements);
318
+ if (m.extension === undefined) {
319
+ issue([...at, "replacements"], "suggestedAppearance.replacements needs an extension");
320
+ }
321
+ if (entries.length > L.appearanceReplacements) {
322
+ issue([...at, "replacements"], `suggestedAppearance.replacements has ${entries.length} entries; the limit is ${L.appearanceReplacements}`);
323
+ }
324
+ const seen = new Set();
325
+ for (const [slot, id] of entries) {
326
+ const ref = parseSlotRef(slot);
327
+ if (ref === null) {
328
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} is not a slot ref`);
329
+ continue;
330
+ }
331
+ if (seen.has(ref.id)) {
332
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names the slot ${ref.id} again; give each slot once`);
333
+ continue;
334
+ }
335
+ seen.add(ref.id);
336
+ if (!COMPONENT_ID_RE.test(id)) {
337
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names ${id}, which is not a contribution id`);
338
+ continue;
339
+ }
340
+ const known = uiSlot(ref.id);
341
+ if (known === undefined)
342
+ continue;
343
+ if (known.cardinality !== "single") {
344
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} is not a replaceable slot`);
345
+ continue;
346
+ }
347
+ const ok = (m.extension?.manifest.ui ?? []).some((u) => {
348
+ const us = typeof u.slot === "string" ? parseSlotRef(u.slot) : null;
349
+ return u.id === id && u.kind === "component" && us?.id === ref.id;
350
+ });
351
+ if (!ok) {
352
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names ${id}, which is not a component contribution in that slot`);
353
+ }
354
+ }
355
+ }
356
+ }
209
357
  if (m.extension === undefined &&
210
358
  m.skills?.length === 0 &&
211
359
  m.connectorTemplates?.length === 0 &&
212
- (m.agents === undefined || m.agents.length === 0)) {
213
- issue([], "a plugin must contain an extension, a skill, a connector template or an agent template");
360
+ (m.agents === undefined || m.agents.length === 0) &&
361
+ (m.themes === undefined || m.themes.length === 0)) {
362
+ issue([], "a plugin must contain an extension, a skill, a connector template, an agent template or a theme");
214
363
  }
215
364
  const ext = m.extension;
216
365
  if (ext === undefined)
217
366
  return;
218
367
  const em = ext.manifest;
368
+ const hasClientPermission = em.permissions.client === true;
369
+ if (ext.client !== undefined && !hasClientPermission) {
370
+ issue(["extension", "client"], "extension.client needs permissions.client: true");
371
+ }
372
+ if (ext.client === undefined && hasClientPermission) {
373
+ issue(["extension", "manifest", "permissions", "client"], "permissions.client is true but extension.client is missing (pack the plugin with its client code, or drop permissions.client)");
374
+ }
219
375
  if (!EXTENSION_NAME_RE.test(m.name)) {
220
376
  issue(["name"], `a plugin with an extension needs an extension name (${EXTENSION_NAME_RE})`);
221
377
  }
@@ -268,6 +424,7 @@ const template = z.strictObject({
268
424
  auth: z.record(z.string(), z.unknown()),
269
425
  ownership: z.enum(["org", "personal"]).optional(),
270
426
  defaultToolPolicies: z.record(z.string(), z.enum(["allow", "ask", "deny"])).optional(),
427
+ git: GitSourceSchema.optional(),
271
428
  icon: z.string().max(L.pathChars).optional(),
272
429
  });
273
430
  const templateFile = z
@@ -281,6 +438,7 @@ const templateFile = z
281
438
  message: "icon must be a relative .svg or .png path inside the plugin",
282
439
  })
283
440
  .optional(),
441
+ defaultEnabled: z.boolean().optional(),
284
442
  template,
285
443
  })
286
444
  // Field rules (no credentials, auth presets, editableEndpoint, ...) belong to validateConnectorTemplate.
@@ -339,3 +497,13 @@ export function parsePluginManifest(json) {
339
497
  export function parseConnectorTemplateFile(json) {
340
498
  return parseWith(ConnectorTemplateFileSchema, json, "connector template file");
341
499
  }
500
+ /**
501
+ * The theme check of `suggestedAppearance` after the themes are known (the manifest may omit
502
+ * `themes` and let the scan find them): shared by the packer and the kernel.
503
+ */
504
+ export function appearanceIssues(manifest, themeIds) {
505
+ const theme = manifest.suggestedAppearance?.theme;
506
+ if (theme === undefined || themeIds.includes(theme))
507
+ return [];
508
+ return [`suggestedAppearance.theme names ${theme}, which is not a theme of the plugin`];
509
+ }
@@ -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[];