@capybara-hq/plugin-sdk 0.1.0-rc.3 → 0.1.0-rc.31

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 (127) hide show
  1. package/agent-docs/agent-templates.md +15 -3
  2. package/agent-docs/concepts.md +5 -0
  3. package/agent-docs/connector-templates.md +2 -1
  4. package/agent-docs/extension-points/channel.md +1 -1
  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 +1 -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 +56 -13
  28. package/dist/cards.js +90 -20
  29. package/dist/channel.d.ts +111 -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 +135 -26
  43. package/dist/define-extension.d.ts +26 -12
  44. package/dist/define-extension.js +11 -4
  45. package/dist/device-protocol-v3.d.ts +117 -0
  46. package/dist/device-protocol-v3.js +409 -0
  47. package/dist/device-protocol.d.ts +330 -0
  48. package/dist/device-protocol.js +567 -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 +1 -1
  52. package/dist/git-hosts.d.ts +44 -0
  53. package/dist/git-hosts.js +81 -0
  54. package/dist/hooks.d.ts +111 -21
  55. package/dist/hooks.js +5 -0
  56. package/dist/http-access.d.ts +52 -0
  57. package/dist/http-access.js +12 -0
  58. package/dist/identity.d.ts +22 -9
  59. package/dist/index.d.ts +23 -1
  60. package/dist/index.js +24 -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 +180 -71
  66. package/dist/model.js +71 -19
  67. package/dist/net.d.ts +52 -0
  68. package/dist/net.js +34 -0
  69. package/dist/permissions.d.ts +42 -20
  70. package/dist/permissions.js +97 -40
  71. package/dist/plugin-manifest.d.ts +45 -5
  72. package/dist/plugin-manifest.js +169 -6
  73. package/dist/plugin-package.d.ts +82 -38
  74. package/dist/plugin-package.js +61 -29
  75. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  76. package/dist/sandbox-linux-runtime-source.js +1886 -0
  77. package/dist/sandbox-native-runtime-source.d.ts +8 -0
  78. package/dist/sandbox-native-runtime-source.js +325 -0
  79. package/dist/sandbox-operation.d.ts +248 -0
  80. package/dist/sandbox-operation.js +245 -0
  81. package/dist/sandbox-runtime-source.d.ts +19 -0
  82. package/dist/sandbox-runtime-source.js +28 -0
  83. package/dist/sandbox-write-denies.d.ts +60 -0
  84. package/dist/sandbox-write-denies.js +630 -0
  85. package/dist/sandbox.d.ts +201 -16
  86. package/dist/sandbox.js +89 -14
  87. package/dist/secret.d.ts +4 -1
  88. package/dist/secret.js +4 -1
  89. package/dist/setup-check.d.ts +115 -0
  90. package/dist/setup-check.js +142 -0
  91. package/dist/setup-guide-parse.d.ts +121 -0
  92. package/dist/setup-guide-parse.js +350 -0
  93. package/dist/setup-guide-render.d.ts +45 -0
  94. package/dist/setup-guide-render.js +351 -0
  95. package/dist/setup-guide.d.ts +94 -0
  96. package/dist/setup-guide.js +336 -0
  97. package/dist/skill-invocation.d.ts +4 -3
  98. package/dist/skill-invocation.js +5 -4
  99. package/dist/skill.d.ts +34 -21
  100. package/dist/skill.js +48 -31
  101. package/dist/storage.d.ts +52 -25
  102. package/dist/theme-assets.d.ts +39 -0
  103. package/dist/theme-assets.js +449 -0
  104. package/dist/theme-readability.d.ts +37 -0
  105. package/dist/theme-readability.js +145 -0
  106. package/dist/theme-tokens.generated.d.ts +279 -0
  107. package/dist/theme-tokens.generated.js +174 -0
  108. package/dist/theme.d.ts +152 -0
  109. package/dist/theme.js +392 -0
  110. package/dist/tool.d.ts +69 -26
  111. package/dist/tool.js +29 -9
  112. package/dist/ui-parts.d.ts +23 -0
  113. package/dist/ui-parts.js +337 -0
  114. package/dist/ui-resolve.d.ts +35 -0
  115. package/dist/ui-resolve.js +42 -0
  116. package/dist/ui-slots.d.ts +53 -0
  117. package/dist/ui-slots.js +238 -0
  118. package/dist/ui.d.ts +191 -79
  119. package/dist/ui.js +101 -27
  120. package/dist/url.d.ts +4 -1
  121. package/dist/url.js +4 -1
  122. package/package.json +7 -1
  123. package/schemas/bootstrap.v1.schema.json +6 -0
  124. package/schemas/connector-template.v1.schema.json +35 -0
  125. package/schemas/marketplace.v1.schema.json +14 -0
  126. package/schemas/plugin.v1.schema.json +115 -3
  127. package/schemas/theme.v1.schema.json +225 -0
@@ -1,15 +1,12 @@
1
1
  import { type PolicyHook } from "./hooks.js";
2
+ import { type HttpPermission } from "./http-access.js";
2
3
  /** Extension permission manifest: governance, not a sandbox; using an undeclared platform API throws ExtensionPermissionError. */
3
4
  export interface ExtensionPermissions {
4
5
  /** ctx.secrets */
5
6
  secrets?: boolean;
6
- /** ctx.http.route 注册的路由(`public` 表示免登录)。 */
7
- http?: {
8
- method: "GET" | "POST" | "PUT" | "DELETE";
9
- path: string;
10
- public?: boolean;
11
- }[];
12
- /** ctx.tools.register 的工具名。 */
7
+ /** Routes registered with ctx.http.route; each declares who may call it (`access`). */
8
+ http?: HttpPermission[];
9
+ /** Tool names for ctx.tools.register. */
13
10
  tools?: string[];
14
11
  /**
15
12
  * Hook mount points (`ctx.hooks.on`). From M7, five mount points are registrable; see
@@ -22,7 +19,10 @@ export interface ExtensionPermissions {
22
19
  * on a replica, calls on these mount points fail closed there.
23
20
  */
24
21
  policyHooks?: PolicyHook[];
25
- /** 预留:模型用途,键须为 `<插件名>.<名称>`。 */
22
+ /**
23
+ * Model purposes (`ctx.models`): each key must be `<extension name>.<name>`; an org admin maps
24
+ * each to a model of its `kind`. `ctx.models.embed` / `describe` accept the `embedding` ones.
25
+ */
26
26
  models?: {
27
27
  purpose: string;
28
28
  kind: "chat" | "embedding";
@@ -31,22 +31,36 @@ export interface ExtensionPermissions {
31
31
  en: string;
32
32
  };
33
33
  }[];
34
- /** ctx.storage(对象存储,键限定在 `plugins/<插件名>/<orgId>/` 下)。 */
34
+ /** ctx.storage (object storage, keys confined under `plugins/<plugin name>/<orgId>/`). */
35
35
  storage?: boolean;
36
- /** 访问的域名,只展示不拦截。 */
36
+ /** Domains accessed; displayed only, not enforced. */
37
37
  network?: string[];
38
38
  /**
39
- * 界面贡献的 id(与清单 `ui` 一一对应):`views` 记入快照但不卡加载;
40
- * `embeds` 卡加载、需批准,并标为敏感项。
39
+ * Client code: the package's `client` section (a browser bundle the web app loads for the
40
+ * extension's orgs). Sensitive and blocking; required when `ui.components` lists anything.
41
+ */
42
+ client?: boolean;
43
+ /**
44
+ * The ids of the `ui` contributions, one list per kind (each id in exactly one list): `views`
45
+ * are recorded in the snapshot without blocking the load; `embeds` and `components` block the
46
+ * load until approved and are sensitive. `components` needs `client: true`.
41
47
  */
42
48
  ui?: {
43
49
  views?: string[];
44
50
  embeds?: string[];
51
+ components?: string[];
45
52
  };
53
+ /**
54
+ * Setup check ids registered with `ctx.setup.check` (each matches `SETUP_CHECK_ID_RE`, at most
55
+ * `SETUP_CHECK_LIMITS.idsPerExtension`). Recorded in the snapshot and shown at review as
56
+ * `setupCheck:<id>`, but never blocks loading: a check receives only data the extension already
57
+ * receives for the same target.
58
+ */
59
+ setupChecks?: string[];
46
60
  }
47
- /** hook 挂载点(封闭列表,见总设计 2.4)。 */
48
- export declare const HOOK_MOUNT_POINTS: readonly ["session.start", "session.end", "agent.preStep", "model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report"];
49
- /** hook 挂载点名。 */
61
+ /** Hook mount points (a closed list, see the overall design 2.4). */
62
+ export declare const HOOK_MOUNT_POINTS: readonly ["session.start", "session.end", "agent.preStep", "model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report", "org.member_removed", "agent.deleted", "org.deleted"];
63
+ /** A hook mount point name. */
50
64
  export type HookMountPoint = (typeof HOOK_MOUNT_POINTS)[number];
51
65
  /** A platform API not declared in the manifest was used. */
52
66
  export declare class ExtensionPermissionError extends Error {
@@ -56,12 +70,20 @@ export declare class ExtensionPermissionError extends Error {
56
70
  export declare class ExtensionPointUnavailableError extends Error {
57
71
  constructor(message: string);
58
72
  }
59
- /** 校验权限清单,返回错误列表(空表示合法)。 */
73
+ /** Validates the permission manifest and returns the list of errors (empty means valid). */
60
74
  export declare function validatePermissions(plugin: string, p: unknown): string[];
61
75
  /**
62
- * 校验清单 `ui` 并与权限清单交叉核对,返回错误列表(空表示合法):
63
- * 每个贡献的 id 恰好出现在 `permissions.ui.views`(kind view)或 `permissions.ui.embeds`(kind embed)里,
64
- * `permissions.ui` 里也不能有清单 `ui` 没有的 id;embed 的 path 以 `/ui/` 开头并在 `permissions.http` 中声明为 GET。
65
- * 假定 `permissions` 已经过 {@link validatePermissions}。
76
+ * Checks the structure of the manifest's `ui` and cross-checks it with the permission manifest;
77
+ * returns the problems (empty = valid). Only structural problems (UI slots spec §3.2, client
78
+ * extensions spec §5.1): each contribution's id is listed in the list of its kind,
79
+ * `permissions.ui.views` (view), `permissions.ui.embeds` (embed) or `permissions.ui.components`
80
+ * (component), an id is in at most one of the three, and `permissions.ui` lists no id the `ui`
81
+ * lacks; `permissions.ui.components` needs `permissions.client: true`; an embed's path starts with
82
+ * `/ui/` and is declared in `permissions.http` as GET, a view or component has no path; exactly one
83
+ * of `slot` (a well-formed slot reference) and `place` (a known place); for a slot the catalog
84
+ * knows at the version named, a kind it accepts and, unless an alias, the icon it requires. An
85
+ * unknown slot id or version is not a problem here: `resolveUiSlots` drops that contribution and
86
+ * the rest of the extension loads.
87
+ * Assumes `permissions` passed {@link validatePermissions}.
66
88
  */
67
89
  export declare function validateUiContributions(ui: unknown, permissions: unknown): string[];
@@ -1,6 +1,9 @@
1
1
  import { POLICY_HOOKS } from "./hooks.js";
2
+ import { HTTP_ACCESS } from "./http-access.js";
3
+ import { SETUP_CHECK_ID_RE, SETUP_CHECK_LIMITS } from "./setup-check.js";
2
4
  import { UI_ICONS } from "./ui.js";
3
- /** hook 挂载点(封闭列表,见总设计 2.4)。 */
5
+ import { parseSlotRef, uiSlot } from "./ui-slots.js";
6
+ /** Hook mount points (a closed list, see the overall design 2.4). */
4
7
  export const HOOK_MOUNT_POINTS = [
5
8
  "session.start",
6
9
  "session.end",
@@ -10,6 +13,9 @@ export const HOOK_MOUNT_POINTS = [
10
13
  "tool.preExecute",
11
14
  "tool.postExecute",
12
15
  "usage.report",
16
+ "org.member_removed",
17
+ "agent.deleted",
18
+ "org.deleted",
13
19
  ];
14
20
  const HOOKS = new Set(HOOK_MOUNT_POINTS);
15
21
  /** A platform API not declared in the manifest was used. */
@@ -36,6 +42,8 @@ const KEYS = new Set([
36
42
  "storage",
37
43
  "network",
38
44
  "ui",
45
+ "client",
46
+ "setupChecks",
39
47
  ]);
40
48
  const POLICY = new Set(POLICY_HOOKS);
41
49
  const METHODS = new Set(["GET", "POST", "PUT", "DELETE"]);
@@ -57,7 +65,7 @@ function strList(label, v, errs) {
57
65
  }
58
66
  return out;
59
67
  }
60
- /** 校验权限清单,返回错误列表(空表示合法)。 */
68
+ /** Validates the permission manifest and returns the list of errors (empty means valid). */
61
69
  export function validatePermissions(plugin, p) {
62
70
  if (p === undefined)
63
71
  return [];
@@ -68,7 +76,7 @@ export function validatePermissions(plugin, p) {
68
76
  if (!KEYS.has(k))
69
77
  errs.push(`unknown permissions key "${k}"`);
70
78
  }
71
- for (const k of ["secrets", "storage"]) {
79
+ for (const k of ["secrets", "storage", "client"]) {
72
80
  if (p[k] !== undefined && typeof p[k] !== "boolean") {
73
81
  errs.push(`permissions.${k} must be a boolean`);
74
82
  }
@@ -110,14 +118,27 @@ export function validatePermissions(plugin, p) {
110
118
  !METHODS.has(r.method) ||
111
119
  typeof r.path !== "string" ||
112
120
  !r.path.startsWith("/") ||
113
- (r.public !== undefined && typeof r.public !== "boolean")) {
114
- errs.push("permissions.http entries need method GET/POST/PUT/DELETE and a path starting with /");
121
+ typeof r.access !== "string" ||
122
+ !HTTP_ACCESS.includes(r.access)) {
123
+ errs.push("permissions.http entries need method GET/POST/PUT/DELETE, a path starting with /, and access public/embed/member/admin");
115
124
  continue;
116
125
  }
117
126
  const key = `${r.method} ${r.path}`;
118
127
  if (seen.has(key))
119
128
  errs.push(`permissions.http has duplicate route "${key}"`);
120
129
  seen.add(key);
130
+ if (r.path === "/orgs" || r.path.startsWith("/orgs/")) {
131
+ errs.push(`permissions.http route "${key}" must not start with /orgs/ (reserved for org routes)`);
132
+ }
133
+ if (r.access === "embed" && !r.path.startsWith(UI_EMBED_PREFIX)) {
134
+ errs.push(`permissions.http embed route "${key}" must be under ${UI_EMBED_PREFIX}`);
135
+ }
136
+ if ((r.access === "member" || r.access === "admin") &&
137
+ // anywhere, not only after a slash: find-my-way lets a later duplicate param win, so
138
+ // `/x-:orgId` would override the mount's `:orgId`
139
+ /:orgId(?![A-Za-z0-9_])/.test(r.path)) {
140
+ errs.push(`permissions.http route "${key}" must not contain :orgId (the org comes from the mount)`);
141
+ }
121
142
  }
122
143
  }
123
144
  }
@@ -126,9 +147,11 @@ export function validatePermissions(plugin, p) {
126
147
  errs.push("permissions.ui must be an object");
127
148
  else {
128
149
  for (const k of Object.keys(p.ui)) {
129
- if (k !== "views" && k !== "embeds")
150
+ if (k !== "views" && k !== "embeds" && k !== "components")
130
151
  errs.push(`unknown permissions.ui key "${k}"`);
131
152
  }
153
+ if (p.ui.components !== undefined)
154
+ strList("permissions.ui.components", p.ui.components, errs);
132
155
  const views = p.ui.views === undefined ? [] : strList("permissions.ui.views", p.ui.views, errs);
133
156
  const embeds = p.ui.embeds === undefined ? [] : strList("permissions.ui.embeds", p.ui.embeds, errs);
134
157
  for (const id of views) {
@@ -137,6 +160,17 @@ export function validatePermissions(plugin, p) {
137
160
  }
138
161
  }
139
162
  }
163
+ if (p.setupChecks !== undefined) {
164
+ const ids = strList("permissions.setupChecks", p.setupChecks, errs);
165
+ for (const id of ids) {
166
+ if (!SETUP_CHECK_ID_RE.test(id)) {
167
+ errs.push(`permissions.setupChecks id "${id}" must match ${SETUP_CHECK_ID_RE}`);
168
+ }
169
+ }
170
+ if (ids.length > SETUP_CHECK_LIMITS.idsPerExtension) {
171
+ errs.push(`permissions.setupChecks has more than ${SETUP_CHECK_LIMITS.idsPerExtension} ids`);
172
+ }
173
+ }
140
174
  if (p.models !== undefined) {
141
175
  if (!Array.isArray(p.models))
142
176
  errs.push("permissions.models must be an array");
@@ -168,20 +202,20 @@ export function validatePermissions(plugin, p) {
168
202
  }
169
203
  const UI_ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
170
204
  const UI_TITLE_MAX = 100;
171
- const UI_PLACES = [
172
- "conversation",
173
- "panel",
174
- "section",
175
- "inline",
176
- "page",
177
- "file-preview",
178
- ];
179
205
  const UI_EMBED_PREFIX = "/ui/";
180
206
  /**
181
- * 校验清单 `ui` 并与权限清单交叉核对,返回错误列表(空表示合法):
182
- * 每个贡献的 id 恰好出现在 `permissions.ui.views`(kind view)或 `permissions.ui.embeds`(kind embed)里,
183
- * `permissions.ui` 里也不能有清单 `ui` 没有的 id;embed 的 path 以 `/ui/` 开头并在 `permissions.http` 中声明为 GET。
184
- * 假定 `permissions` 已经过 {@link validatePermissions}。
207
+ * Checks the structure of the manifest's `ui` and cross-checks it with the permission manifest;
208
+ * returns the problems (empty = valid). Only structural problems (UI slots spec §3.2, client
209
+ * extensions spec §5.1): each contribution's id is listed in the list of its kind,
210
+ * `permissions.ui.views` (view), `permissions.ui.embeds` (embed) or `permissions.ui.components`
211
+ * (component), an id is in at most one of the three, and `permissions.ui` lists no id the `ui`
212
+ * lacks; `permissions.ui.components` needs `permissions.client: true`; an embed's path starts with
213
+ * `/ui/` and is declared in `permissions.http` as GET, a view or component has no path; exactly one
214
+ * of `slot` (a well-formed slot reference) and `place` (a known place); for a slot the catalog
215
+ * knows at the version named, a kind it accepts and, unless an alias, the icon it requires. An
216
+ * unknown slot id or version is not a problem here: `resolveUiSlots` drops that contribution and
217
+ * the rest of the extension loads.
218
+ * Assumes `permissions` passed {@link validatePermissions}.
185
219
  */
186
220
  export function validateUiContributions(ui, permissions) {
187
221
  const perms = isObj(permissions) ? permissions : {};
@@ -191,10 +225,21 @@ export function validateUiContributions(ui, permissions) {
191
225
  : [];
192
226
  const views = listed("views");
193
227
  const embeds = listed("embeds");
228
+ const components = listed("components");
229
+ // an id in more than one list is reported once, not again as a mismatch of each list
230
+ const multiListed = new Set();
231
+ for (const id of new Set([...views, ...embeds, ...components])) {
232
+ if ([views, embeds, components].filter((l) => l.includes(id)).length > 1)
233
+ multiListed.add(id);
234
+ }
194
235
  const gets = new Set((Array.isArray(perms.http) ? perms.http : [])
195
- .filter((r) => isObj(r) && r.method === "GET")
236
+ .filter((r) => isObj(r) && r.method === "GET" && r.access === "public")
196
237
  .map((r) => r.path));
197
238
  const errs = [];
239
+ for (const id of multiListed)
240
+ errs.push(`ui "${id}" is listed in more than one of permissions.ui.views / embeds / components`);
241
+ if (components.length > 0 && perms.client !== true)
242
+ errs.push("permissions.ui.components needs permissions.client: true");
198
243
  const contributions = [];
199
244
  if (ui !== undefined) {
200
245
  if (!Array.isArray(ui))
@@ -203,7 +248,6 @@ export function validateUiContributions(ui, permissions) {
203
248
  contributions.push(...ui);
204
249
  }
205
250
  const seen = new Map();
206
- const aliases = [];
207
251
  contributions.forEach((c, i) => {
208
252
  const at = `ui[${i}]`;
209
253
  if (!isObj(c)) {
@@ -219,53 +263,66 @@ export function validateUiContributions(ui, permissions) {
219
263
  if (!title ||
220
264
  [title.zh, title.en].some((t) => typeof t !== "string" || t === "" || t.length > UI_TITLE_MAX))
221
265
  errs.push(`ui "${id}" title needs non-empty zh and en of at most ${UI_TITLE_MAX} characters`);
222
- if (!UI_PLACES.includes(c.place))
223
- errs.push(`ui "${id}" place must be one of ${UI_PLACES.join(", ")}`);
224
- if (c.kind !== "view" && c.kind !== "embed") {
225
- errs.push(`ui "${id}" kind must be view or embed`);
266
+ // the slot it names, when it is well formed (known to the catalog or not)
267
+ const slotRef = typeof c.slot === "string" ? parseSlotRef(c.slot) : null;
268
+ if (slotRef === null)
269
+ errs.push(`ui "${id}" slot must be a slot reference like "org.page" or "org.page@1"`);
270
+ if (c.after !== undefined && typeof c.after !== "string")
271
+ errs.push(`ui "${id}" after must be a string`);
272
+ if (c.kind !== "view" && c.kind !== "embed" && c.kind !== "component") {
273
+ errs.push(`ui "${id}" kind must be view, embed or component`);
226
274
  return;
227
275
  }
228
276
  if (c.icon !== undefined && !UI_ICONS.includes(c.icon))
229
277
  errs.push(`ui "${id}" icon must be one of ${UI_ICONS.join(", ")}`);
230
- if (c.aliasOf !== undefined)
231
- aliases.push({ id, kind: c.kind, target: c.aliasOf });
278
+ // the slot checks describe only the catalog's version: another version is left to
279
+ // resolveUiSlots, which drops it (unsupported-version) without failing the extension
280
+ const known = slotRef === null ? undefined : uiSlot(slotRef.id);
281
+ const spec = known !== undefined && known.version === slotRef?.version ? known : undefined;
282
+ if (spec !== undefined) {
283
+ if (!spec.accepts.includes(c.kind))
284
+ errs.push(`ui "${id}" slot ${spec.id} does not accept kind ${c.kind}`);
285
+ if (spec.icon === "required" && c.icon === undefined)
286
+ errs.push(`ui "${id}" slot ${spec.id} needs an icon`);
287
+ }
232
288
  if (seen.has(id))
233
289
  errs.push(`ui has duplicate id "${id}"`);
234
290
  seen.set(id, c.kind);
235
291
  if (c.kind === "view") {
236
- if (c.place === "file-preview")
237
- errs.push(`ui "${id}" place file-preview is only allowed for kind embed`);
238
292
  if (c.path !== undefined)
239
293
  errs.push(`ui "${id}" path is only allowed for kind embed`);
240
- if (!views.includes(id))
294
+ if (!views.includes(id) && !multiListed.has(id))
241
295
  errs.push(`ui "${id}" (view) must be listed in permissions.ui.views`);
242
296
  return;
243
297
  }
244
- if (!embeds.includes(id))
298
+ if (c.kind === "component") {
299
+ if (c.path !== undefined)
300
+ errs.push(`ui "${id}" is a component and cannot have a path`);
301
+ if (!components.includes(id) && !multiListed.has(id))
302
+ errs.push(`ui "${id}" is a component; list it in permissions.ui.components`);
303
+ return;
304
+ }
305
+ if (!embeds.includes(id) && !multiListed.has(id))
245
306
  errs.push(`ui "${id}" (embed) must be listed in permissions.ui.embeds`);
246
307
  if (typeof c.path !== "string" || !c.path.startsWith(UI_EMBED_PREFIX)) {
247
308
  errs.push(`ui "${id}" (embed) path must start with "${UI_EMBED_PREFIX}"`);
248
309
  }
249
310
  else if (!gets.has(c.path)) {
250
- errs.push(`ui "${id}" (embed) path must be declared in permissions.http as "GET ${c.path}"`);
311
+ errs.push(`ui "${id}" embed path "${c.path}" must be declared in permissions.http as GET with access public`);
251
312
  }
252
313
  });
253
- const aliasIds = new Set(aliases.map((a) => a.id));
254
- for (const a of aliases) {
255
- if (typeof a.target !== "string" ||
256
- a.target === a.id ||
257
- aliasIds.has(a.target) ||
258
- seen.get(a.target) !== a.kind)
259
- errs.push(`ui "${a.id}" aliasOf must name another, non-alias ${a.kind} contribution`);
260
- }
261
314
  for (const [k, kind, ids] of [
262
315
  ["views", "view", views],
263
316
  ["embeds", "embed", embeds],
264
317
  ]) {
265
318
  for (const id of ids) {
266
- if (seen.get(id) !== kind)
319
+ if (seen.get(id) !== kind && !multiListed.has(id))
267
320
  errs.push(`permissions.ui.${k} entry "${id}" has no matching ${kind} contribution in ui`);
268
321
  }
269
322
  }
323
+ for (const id of components) {
324
+ if (seen.get(id) !== "component" && !multiListed.has(id))
325
+ errs.push(`permissions.ui.components lists "${id}", which is not a component contribution`);
326
+ }
270
327
  return errs;
271
328
  }
@@ -1,9 +1,13 @@
1
1
  import { z } from "zod";
2
+ import { type PluginClientSection } from "./client-section.js";
2
3
  import { type JsonSchema } from "./config-ui.js";
3
4
  import { type ConnectorTemplateSpec, type LocalizedName, type StaticExtensionManifest } from "./plugin-package.js";
5
+ import { type PluginSetupGuide } from "./setup-guide.js";
6
+ import { type PluginThemeRef } from "./theme.js";
4
7
  /**
5
8
  * The plugin manifest `.capybara-plugin/plugin.json` (package ecosystem spec §4.1). A plugin is a
6
- * bundle of at most one extension, skills and connector templates, packed as an npm-pack tgz:
9
+ * bundle of at most one extension, skills, connector templates, agent templates and themes, packed as
10
+ * an npm-pack tgz:
7
11
  *
8
12
  * ```
9
13
  * package/package.json npm metadata; version equals plugin.json version
@@ -11,13 +15,14 @@ import { type ConnectorTemplateSpec, type LocalizedName, type StaticExtensionMan
11
15
  * package/skills/<name>/SKILL.md skills
12
16
  * package/connectors/<id>.json connector templates ({@link ConnectorTemplateFile})
13
17
  * package/agents/<name>.md agent templates (parsed by `parseAgentTemplate`)
18
+ * package/themes/<id>.json themes (parsed by `parseThemeFile`)
14
19
  * package/dist/index.mjs extension entry (only with an extension)
15
20
  * package/migrations/*.sql, package/ui/**
16
21
  * ```
17
22
  *
18
23
  * Paths start with `./` and stay inside the plugin root. Omitting `skills` / `connectorTemplates`
19
- * / `agents` means "scan `skills/*\/SKILL.md` / `connectors/*.json` / `agents/*.md`" (done by the
20
- * kernel when it reads the package). `extension` is written by the packer, never by hand.
24
+ * / `agents` / `themes` means "scan `skills/*\/SKILL.md` / `connectors/*.json` / `agents/*.md` /
25
+ * `themes/*.json`" (done by the kernel when it reads the package). `extension` is written by the packer, never by hand.
21
26
  *
22
27
  * The committed JSON Schema (`schemas/plugin.v1.schema.json`) is generated from
23
28
  * {@link PluginManifestSchema} by `pnpm gen:package-schemas` and drift-checked by
@@ -39,10 +44,14 @@ export declare const PLUGIN_MANIFEST_LIMITS: {
39
44
  readonly connectorTemplates: 20;
40
45
  /** Agent templates ({@link AGENT_TEMPLATE_LIMITS}`.perPlugin`). */
41
46
  readonly agents: 64;
47
+ /** Themes ({@link THEME_LIMITS}`.perPlugin`). */
48
+ readonly themes: 10;
42
49
  readonly descriptionChars: 1024;
43
50
  readonly publisherChars: 100;
44
51
  readonly displayNameChars: 100;
45
52
  readonly pathChars: 512;
53
+ /** Entries of `suggestedAppearance.replacements`. */
54
+ readonly appearanceReplacements: 8;
46
55
  };
47
56
  /** A plugin this one depends on: a plugin name and a semver range. */
48
57
  export interface PluginDependency {
@@ -54,8 +63,6 @@ export interface PluginDependency {
54
63
  /** A skill of the plugin: a `./…` directory holding SKILL.md. */
55
64
  export interface PluginSkillRef {
56
65
  path: string;
57
- /** Suggested as pinned when an agent selects the skill (spec §9.1). */
58
- pinned?: boolean;
59
66
  }
60
67
  /** A connector template of the plugin: a `./…/<id>.json` file ({@link ConnectorTemplateFile}). */
61
68
  export interface PluginConnectorTemplateRef {
@@ -84,6 +91,18 @@ export interface PluginExtensionSection {
84
91
  deployment?: JsonSchema;
85
92
  org?: JsonSchema;
86
93
  };
94
+ /** Browser code, styles and assets (needs `permissions.client: true`); see {@link PluginClientSection}. */
95
+ client?: PluginClientSection;
96
+ }
97
+ /**
98
+ * How the plugin suggests it should look when chosen (client extensions spec §6.5). Nothing applies
99
+ * on install; an admin applies it in one confirmed step.
100
+ */
101
+ export interface SuggestedAppearance {
102
+ /** A theme id (file base name) of this plugin. */
103
+ theme?: string;
104
+ /** Replaceable slot id → a `component` contribution id of this plugin's extension in that slot. */
105
+ replacements?: Record<string, string>;
87
106
  }
88
107
  /**
89
108
  * A plugin's description: a string (English) or `{ en, zh? }`, each ≤ 1024 characters. Read it
@@ -123,6 +142,16 @@ export interface PluginManifest {
123
142
  connectorTemplates?: PluginConnectorTemplateRef[];
124
143
  /** Agent templates; omitted = scan `agents/*.md`. */
125
144
  agents?: PluginAgentRef[];
145
+ /** Themes; omitted = scan `themes/*.json`. */
146
+ themes?: PluginThemeRef[];
147
+ /**
148
+ * Setup guides (spec `2026-11-09-setup-guides-v2-design.md`): Markdown documents at
149
+ * `guides/<id>.md` (+ `guides/<id>.zh.md`) the kernel renders for a place; see
150
+ * {@link PluginSetupGuide}.
151
+ */
152
+ setupGuides?: PluginSetupGuide[];
153
+ /** See {@link SuggestedAppearance}. */
154
+ suggestedAppearance?: SuggestedAppearance;
126
155
  extension?: PluginExtensionSection;
127
156
  }
128
157
  /** A connector template file `connectors/<id>.json`; the template id is the file's base name. */
@@ -131,6 +160,12 @@ export interface ConnectorTemplateFile {
131
160
  description?: string;
132
161
  /** Safe path relative to the plugin root (an optional leading `./`), .svg / .png. */
133
162
  icon?: string;
163
+ /**
164
+ * `false`: the template starts switched off in every org, even where its plugin is on, until an
165
+ * org admin switches it on (it then needs no org input while off). Default `true`: on wherever
166
+ * its plugin is. Ignored for a builtin plugin.
167
+ */
168
+ defaultEnabled?: boolean;
134
169
  /** Validated by {@link validateConnectorTemplate}. */
135
170
  template: ConnectorTemplateSpec;
136
171
  }
@@ -162,3 +197,8 @@ export declare function parsePluginManifest(json: unknown): PluginManifest | {
162
197
  export declare function parseConnectorTemplateFile(json: unknown): ConnectorTemplateFile | {
163
198
  errors: string[];
164
199
  };
200
+ /**
201
+ * The theme check of `suggestedAppearance` after the themes are known (the manifest may omit
202
+ * `themes` and let the scan find them): shared by the packer and the kernel.
203
+ */
204
+ export declare function appearanceIssues(manifest: PluginManifest, themeIds: readonly string[]): string[];