@capybara-hq/plugin-sdk 0.1.0-rc.10 → 0.1.0-rc.11

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.
@@ -38,6 +38,7 @@ const KEYS = new Set([
38
38
  "storage",
39
39
  "network",
40
40
  "ui",
41
+ "client",
41
42
  "setupChecks",
42
43
  ]);
43
44
  const POLICY = new Set(POLICY_HOOKS);
@@ -71,7 +72,7 @@ export function validatePermissions(plugin, p) {
71
72
  if (!KEYS.has(k))
72
73
  errs.push(`unknown permissions key "${k}"`);
73
74
  }
74
- for (const k of ["secrets", "storage"]) {
75
+ for (const k of ["secrets", "storage", "client"]) {
75
76
  if (p[k] !== undefined && typeof p[k] !== "boolean") {
76
77
  errs.push(`permissions.${k} must be a boolean`);
77
78
  }
@@ -129,9 +130,11 @@ export function validatePermissions(plugin, p) {
129
130
  errs.push("permissions.ui must be an object");
130
131
  else {
131
132
  for (const k of Object.keys(p.ui)) {
132
- if (k !== "views" && k !== "embeds")
133
+ if (k !== "views" && k !== "embeds" && k !== "components")
133
134
  errs.push(`unknown permissions.ui key "${k}"`);
134
135
  }
136
+ if (p.ui.components !== undefined)
137
+ strList("permissions.ui.components", p.ui.components, errs);
135
138
  const views = p.ui.views === undefined ? [] : strList("permissions.ui.views", p.ui.views, errs);
136
139
  const embeds = p.ui.embeds === undefined ? [] : strList("permissions.ui.embeds", p.ui.embeds, errs);
137
140
  for (const id of views) {
@@ -186,13 +189,16 @@ const UI_PLACES = Object.keys(PLACE_SLOTS);
186
189
  const UI_EMBED_PREFIX = "/ui/";
187
190
  /**
188
191
  * Checks the structure of the manifest's `ui` and cross-checks it with the permission manifest;
189
- * returns the problems (empty = valid). Only structural problems (UI slots spec §3.2): each
190
- * contribution's id is listed in exactly `permissions.ui.views` (kind view) or
191
- * `permissions.ui.embeds` (kind embed), and `permissions.ui` lists no id the `ui` lacks; an embed's
192
- * path starts with `/ui/` and is declared in `permissions.http` as GET; exactly one of `slot` (a
193
- * well-formed slot reference) and `place` (a known place); for a slot the catalog knows at the
194
- * version named, a kind it accepts and, unless an alias, the icon it requires. An unknown slot id or version is not a
195
- * problem here: `resolveUiSlots` drops that contribution and the rest of the extension loads.
192
+ * returns the problems (empty = valid). Only structural problems (UI slots spec §3.2, client
193
+ * extensions spec §5.1): each contribution's id is listed in the list of its kind,
194
+ * `permissions.ui.views` (view), `permissions.ui.embeds` (embed) or `permissions.ui.components`
195
+ * (component), an id is in at most one of the three, and `permissions.ui` lists no id the `ui`
196
+ * lacks; `permissions.ui.components` needs `permissions.client: true`; an embed's path starts with
197
+ * `/ui/` and is declared in `permissions.http` as GET, a view or component has no path; exactly one
198
+ * of `slot` (a well-formed slot reference) and `place` (a known place); for a slot the catalog
199
+ * knows at the version named, a kind it accepts and, unless an alias, the icon it requires. An
200
+ * unknown slot id or version is not a problem here: `resolveUiSlots` drops that contribution and
201
+ * the rest of the extension loads.
196
202
  * Assumes `permissions` passed {@link validatePermissions}.
197
203
  */
198
204
  export function validateUiContributions(ui, permissions) {
@@ -203,10 +209,21 @@ export function validateUiContributions(ui, permissions) {
203
209
  : [];
204
210
  const views = listed("views");
205
211
  const embeds = listed("embeds");
212
+ const components = listed("components");
213
+ // an id in more than one list is reported once, not again as a mismatch of each list
214
+ const multiListed = new Set();
215
+ for (const id of new Set([...views, ...embeds, ...components])) {
216
+ if ([views, embeds, components].filter((l) => l.includes(id)).length > 1)
217
+ multiListed.add(id);
218
+ }
206
219
  const gets = new Set((Array.isArray(perms.http) ? perms.http : [])
207
220
  .filter((r) => isObj(r) && r.method === "GET")
208
221
  .map((r) => r.path));
209
222
  const errs = [];
223
+ for (const id of multiListed)
224
+ errs.push(`ui "${id}" is listed in more than one of permissions.ui.views / embeds / components`);
225
+ if (components.length > 0 && perms.client !== true)
226
+ errs.push("permissions.ui.components needs permissions.client: true");
210
227
  const contributions = [];
211
228
  if (ui !== undefined) {
212
229
  if (!Array.isArray(ui))
@@ -249,8 +266,8 @@ export function validateUiContributions(ui, permissions) {
249
266
  }
250
267
  if (c.after !== undefined && typeof c.after !== "string")
251
268
  errs.push(`ui "${id}" after must be a string`);
252
- if (c.kind !== "view" && c.kind !== "embed") {
253
- errs.push(`ui "${id}" kind must be view or embed`);
269
+ if (c.kind !== "view" && c.kind !== "embed" && c.kind !== "component") {
270
+ errs.push(`ui "${id}" kind must be view, embed or component`);
254
271
  return;
255
272
  }
256
273
  if (c.icon !== undefined && !UI_ICONS.includes(c.icon))
@@ -273,11 +290,18 @@ export function validateUiContributions(ui, permissions) {
273
290
  if (c.kind === "view") {
274
291
  if (c.path !== undefined)
275
292
  errs.push(`ui "${id}" path is only allowed for kind embed`);
276
- if (!views.includes(id))
293
+ if (!views.includes(id) && !multiListed.has(id))
277
294
  errs.push(`ui "${id}" (view) must be listed in permissions.ui.views`);
278
295
  return;
279
296
  }
280
- if (!embeds.includes(id))
297
+ if (c.kind === "component") {
298
+ if (c.path !== undefined)
299
+ errs.push(`ui "${id}" is a component and cannot have a path`);
300
+ if (!components.includes(id) && !multiListed.has(id))
301
+ errs.push(`ui "${id}" is a component; list it in permissions.ui.components`);
302
+ return;
303
+ }
304
+ if (!embeds.includes(id) && !multiListed.has(id))
281
305
  errs.push(`ui "${id}" (embed) must be listed in permissions.ui.embeds`);
282
306
  if (typeof c.path !== "string" || !c.path.startsWith(UI_EMBED_PREFIX)) {
283
307
  errs.push(`ui "${id}" (embed) path must start with "${UI_EMBED_PREFIX}"`);
@@ -299,9 +323,13 @@ export function validateUiContributions(ui, permissions) {
299
323
  ["embeds", "embed", embeds],
300
324
  ]) {
301
325
  for (const id of ids) {
302
- if (seen.get(id) !== kind)
326
+ if (seen.get(id) !== kind && !multiListed.has(id))
303
327
  errs.push(`permissions.ui.${k} entry "${id}" has no matching ${kind} contribution in ui`);
304
328
  }
305
329
  }
330
+ for (const id of components) {
331
+ if (seen.get(id) !== "component" && !multiListed.has(id))
332
+ errs.push(`permissions.ui.components lists "${id}", which is not a component contribution`);
333
+ }
306
334
  return errs;
307
335
  }
@@ -1,4 +1,5 @@
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";
4
5
  import { type PluginSetupGuide } from "./setup-guide.js";
@@ -49,6 +50,8 @@ export declare const PLUGIN_MANIFEST_LIMITS: {
49
50
  readonly publisherChars: 100;
50
51
  readonly displayNameChars: 100;
51
52
  readonly pathChars: 512;
53
+ /** Entries of `suggestedAppearance.replacements`. */
54
+ readonly appearanceReplacements: 8;
52
55
  };
53
56
  /** A plugin this one depends on: a plugin name and a semver range. */
54
57
  export interface PluginDependency {
@@ -90,6 +93,18 @@ export interface PluginExtensionSection {
90
93
  deployment?: JsonSchema;
91
94
  org?: JsonSchema;
92
95
  };
96
+ /** Browser code, styles and assets (needs `permissions.client: true`); see {@link PluginClientSection}. */
97
+ client?: PluginClientSection;
98
+ }
99
+ /**
100
+ * How the plugin suggests it should look when chosen (client extensions spec §6.5). Nothing applies
101
+ * on install; an admin applies it in one confirmed step.
102
+ */
103
+ export interface SuggestedAppearance {
104
+ /** A theme id (file base name) of this plugin. */
105
+ theme?: string;
106
+ /** Replaceable slot id → a `component` contribution id of this plugin's extension in that slot. */
107
+ replacements?: Record<string, string>;
93
108
  }
94
109
  /**
95
110
  * A plugin's description: a string (English) or `{ en, zh? }`, each ≤ 1024 characters. Read it
@@ -137,6 +152,8 @@ export interface PluginManifest {
137
152
  * {@link PluginSetupGuide}.
138
153
  */
139
154
  setupGuides?: PluginSetupGuide[];
155
+ /** See {@link SuggestedAppearance}. */
156
+ suggestedAppearance?: SuggestedAppearance;
140
157
  extension?: PluginExtensionSection;
141
158
  }
142
159
  /** A connector template file `connectors/<id>.json`; the template id is the file's base name. */
@@ -182,3 +199,8 @@ export declare function parsePluginManifest(json: unknown): PluginManifest | {
182
199
  export declare function parseConnectorTemplateFile(json: unknown): ConnectorTemplateFile | {
183
200
  errors: string[];
184
201
  };
202
+ /**
203
+ * The theme check of `suggestedAppearance` after the themes are known (the manifest may omit
204
+ * `themes` and let the scan find them): shared by the packer and the kernel.
205
+ */
206
+ export declare function appearanceIssues(manifest: PluginManifest, themeIds: readonly string[]): string[];
@@ -1,12 +1,14 @@
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";
6
7
  import { CATALOG_ITEM_NAME_RE, CONNECTOR_TEMPLATE_LIMITS, isSafePackagePath, SEMVER_VERSION_RE, validateConnectorTemplate, } from "./plugin-package.js";
7
8
  import { hasUpperBound } from "./semver-range.js";
8
9
  import { SETUP_GUIDE_LIMITS, SETUP_GUIDE_PLACES } from "./setup-guide.js";
9
10
  import { THEME_LIMITS, themeIdOf } from "./theme.js";
11
+ import { parseSlotRef, uiSlot } from "./ui-slots.js";
10
12
  /**
11
13
  * The plugin manifest `.capybara-plugin/plugin.json` (package ecosystem spec §4.1). A plugin is a
12
14
  * bundle of at most one extension, skills, connector templates, agent templates and themes, packed as
@@ -53,6 +55,8 @@ export const PLUGIN_MANIFEST_LIMITS = {
53
55
  publisherChars: 100,
54
56
  displayNameChars: 100,
55
57
  pathChars: 512,
58
+ /** Entries of `suggestedAppearance.replacements`. */
59
+ appearanceReplacements: 8,
56
60
  };
57
61
  /** A plugin description as `{ en, zh? }` (a plain string is the English text). */
58
62
  export function pluginDescription(d) {
@@ -61,6 +65,7 @@ export function pluginDescription(d) {
61
65
  const L = PLUGIN_MANIFEST_LIMITS;
62
66
  const MAX_ERRORS = 50;
63
67
  const ICON_RE = /\.(?:svg|png)$/i;
68
+ const COMPONENT_ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
64
69
  const HTTPS_URL_RE = /^https:\/\/\S+$/;
65
70
  const text = (max, what) => z
66
71
  .string()
@@ -113,6 +118,25 @@ const setupGuide = z.strictObject({
113
118
  .regex(CATALOG_ITEM_NAME_RE, { message: "template must match ^[a-z0-9][a-z0-9-]{0,63}$" })
114
119
  .optional(),
115
120
  });
121
+ const clientSection = z
122
+ .strictObject({
123
+ entry: z.string().max(L.pathChars).optional(),
124
+ styles: z.array(z.string().max(L.pathChars)).max(64).optional(),
125
+ assets: z.array(z.string().max(L.pathChars)).max(256).optional(),
126
+ integrity: z.record(z.string().max(L.pathChars), z.string().max(128)),
127
+ apiVersion: z.number().int().min(1),
128
+ })
129
+ .superRefine((c, ctx) => {
130
+ for (const e of validateClientSection(c))
131
+ ctx.addIssue({ code: "custom", path: [], message: e });
132
+ });
133
+ const suggestedAppearance = z.strictObject({
134
+ theme: z
135
+ .string()
136
+ .regex(CATALOG_ITEM_NAME_RE, { message: "theme must match ^[a-z0-9][a-z0-9-]{0,63}$" })
137
+ .optional(),
138
+ replacements: z.record(z.string().max(100), z.string().max(100)).optional(),
139
+ });
116
140
  const extensionSection = z.strictObject({
117
141
  entry: dotPath("entry").refine((p) => p.endsWith(".mjs"), {
118
142
  message: "entry must be a .mjs file",
@@ -123,6 +147,7 @@ const extensionSection = z.strictObject({
123
147
  configSchemas: z
124
148
  .strictObject({ deployment: configSchemaJson.optional(), org: configSchemaJson.optional() })
125
149
  .optional(),
150
+ client: clientSection.optional(),
126
151
  });
127
152
  const schema = z
128
153
  .strictObject({
@@ -191,6 +216,7 @@ const schema = z
191
216
  .max(L.themes)
192
217
  .optional(),
193
218
  setupGuides: z.array(setupGuide).max(SETUP_GUIDE_LIMITS.guides).optional(),
219
+ suggestedAppearance: suggestedAppearance.optional(),
194
220
  extension: extensionSection.optional(),
195
221
  })
196
222
  .superRefine((m, ctx) => {
@@ -272,6 +298,56 @@ const schema = z
272
298
  issue(["setupGuides", i, "place"], "a channel-connection guide needs the plugin's extension to provide channel@1");
273
299
  }
274
300
  });
301
+ const sa = m.suggestedAppearance;
302
+ if (sa !== undefined) {
303
+ const at = ["suggestedAppearance"];
304
+ if (sa.theme === undefined && sa.replacements === undefined) {
305
+ issue(at, "suggestedAppearance needs theme or replacements");
306
+ }
307
+ if (sa.theme !== undefined && m.themes !== undefined && !themeIds.has(sa.theme)) {
308
+ issue([...at, "theme"], `suggestedAppearance.theme names ${sa.theme}, which is not a theme of the plugin`);
309
+ }
310
+ if (sa.replacements !== undefined) {
311
+ const entries = Object.entries(sa.replacements);
312
+ if (m.extension === undefined) {
313
+ issue([...at, "replacements"], "suggestedAppearance.replacements needs an extension");
314
+ }
315
+ if (entries.length > L.appearanceReplacements) {
316
+ issue([...at, "replacements"], `suggestedAppearance.replacements has ${entries.length} entries; the limit is ${L.appearanceReplacements}`);
317
+ }
318
+ const seen = new Set();
319
+ for (const [slot, id] of entries) {
320
+ const ref = parseSlotRef(slot);
321
+ if (ref === null) {
322
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} is not a slot ref`);
323
+ continue;
324
+ }
325
+ if (seen.has(ref.id)) {
326
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names the slot ${ref.id} again; give each slot once`);
327
+ continue;
328
+ }
329
+ seen.add(ref.id);
330
+ if (!COMPONENT_ID_RE.test(id)) {
331
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names ${id}, which is not a contribution id`);
332
+ continue;
333
+ }
334
+ const known = uiSlot(ref.id);
335
+ if (known === undefined)
336
+ continue;
337
+ if (known.cardinality !== "single") {
338
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} is not a replaceable slot`);
339
+ continue;
340
+ }
341
+ const ok = (m.extension?.manifest.ui ?? []).some((u) => {
342
+ const us = typeof u.slot === "string" ? parseSlotRef(u.slot) : null;
343
+ return u.id === id && u.kind === "component" && us?.id === ref.id;
344
+ });
345
+ if (!ok) {
346
+ issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names ${id}, which is not a component contribution in that slot`);
347
+ }
348
+ }
349
+ }
350
+ }
275
351
  if (m.extension === undefined &&
276
352
  m.skills?.length === 0 &&
277
353
  m.connectorTemplates?.length === 0 &&
@@ -283,6 +359,13 @@ const schema = z
283
359
  if (ext === undefined)
284
360
  return;
285
361
  const em = ext.manifest;
362
+ const hasClientPermission = em.permissions.client === true;
363
+ if (ext.client !== undefined && !hasClientPermission) {
364
+ issue(["extension", "client"], "extension.client needs permissions.client: true");
365
+ }
366
+ if (ext.client === undefined && hasClientPermission) {
367
+ 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)");
368
+ }
286
369
  if (!EXTENSION_NAME_RE.test(m.name)) {
287
370
  issue(["name"], `a plugin with an extension needs an extension name (${EXTENSION_NAME_RE})`);
288
371
  }
@@ -407,3 +490,13 @@ export function parsePluginManifest(json) {
407
490
  export function parseConnectorTemplateFile(json) {
408
491
  return parseWith(ConnectorTemplateFileSchema, json, "connector template file");
409
492
  }
493
+ /**
494
+ * The theme check of `suggestedAppearance` after the themes are known (the manifest may omit
495
+ * `themes` and let the scan find them): shared by the packer and the kernel.
496
+ */
497
+ export function appearanceIssues(manifest, themeIds) {
498
+ const theme = manifest.suggestedAppearance?.theme;
499
+ if (theme === undefined || themeIds.includes(theme))
500
+ return [];
501
+ return [`suggestedAppearance.theme names ${theme}, which is not a theme of the plugin`];
502
+ }
@@ -0,0 +1,23 @@
1
+ /** The ARIA / data states a part promises (client extensions spec §7.1). */
2
+ export type UiPartState = "aria-current" | "aria-selected" | "aria-expanded" | "aria-busy" | "disabled";
3
+ /** Every part name of the catalog, in catalog order. */
4
+ export declare const UI_PART_NAMES: readonly ["shell", "sidebar", "sidebar.brand", "sidebar.item", "title-bar", "page-header", "thread", "message.user", "message.assistant", "tool-row", "composer", "properties-panel", "section", "right-panel", "status-bar", "button", "button.primary", "card", "input", "dialog"];
5
+ export type UiPartName = (typeof UI_PART_NAMES)[number];
6
+ /** One built-in element plugin CSS may select with `[data-cap-part~="<name>"]`. */
7
+ export interface UiPartSpec {
8
+ name: UiPartName;
9
+ /** Bumped when the part is renamed, removed or drops a promised state. */
10
+ version: number;
11
+ /**
12
+ * The files (relative to the repository root) that render the element: one concept can be drawn
13
+ * by several components (a sidebar row, a card). `check:ui-parts` pins each literal to one of them.
14
+ */
15
+ owner: readonly string[];
16
+ states: readonly UiPartState[];
17
+ description: {
18
+ en: string;
19
+ zh: string;
20
+ };
21
+ }
22
+ export declare const UI_PARTS: readonly UiPartSpec[];
23
+ export declare function uiPart(name: string): UiPartSpec | undefined;
@@ -0,0 +1,238 @@
1
+ /** Every part name of the catalog, in catalog order. */
2
+ export const UI_PART_NAMES = [
3
+ "shell",
4
+ "sidebar",
5
+ "sidebar.brand",
6
+ "sidebar.item",
7
+ "title-bar",
8
+ "page-header",
9
+ "thread",
10
+ "message.user",
11
+ "message.assistant",
12
+ "tool-row",
13
+ "composer",
14
+ "properties-panel",
15
+ "section",
16
+ "right-panel",
17
+ "status-bar",
18
+ "button",
19
+ "button.primary",
20
+ "card",
21
+ "input",
22
+ "dialog",
23
+ ];
24
+ export const UI_PARTS = [
25
+ {
26
+ name: "shell",
27
+ version: 1,
28
+ owner: ["packages/design/src/shell/app-shell.tsx"],
29
+ states: [],
30
+ description: {
31
+ en: "The App Shell root.",
32
+ zh: "应用外壳的根节点。",
33
+ },
34
+ },
35
+ {
36
+ name: "sidebar",
37
+ version: 1,
38
+ owner: ["packages/design/src/shell/sidebar.tsx"],
39
+ states: [],
40
+ description: {
41
+ en: "The left sidebar.",
42
+ zh: "左侧边栏。",
43
+ },
44
+ },
45
+ {
46
+ name: "sidebar.brand",
47
+ version: 1,
48
+ owner: ["packages/design/src/shell/sidebar.tsx"],
49
+ states: [],
50
+ description: {
51
+ en: "The brand row of the sidebar.",
52
+ zh: "侧边栏的品牌行。",
53
+ },
54
+ },
55
+ {
56
+ name: "sidebar.item",
57
+ version: 1,
58
+ owner: [
59
+ "packages/design/src/shell/sidebar.tsx",
60
+ "packages/design/src/shell/sidebar-conversations.tsx",
61
+ ],
62
+ states: ["aria-current"],
63
+ description: {
64
+ en: "A navigation or conversation row of the sidebar.",
65
+ zh: "侧边栏的导航行或对话行。",
66
+ },
67
+ },
68
+ {
69
+ name: "title-bar",
70
+ version: 1,
71
+ owner: ["packages/design/src/conversation/title-bar.tsx"],
72
+ states: [],
73
+ description: {
74
+ en: "The conversation title bar.",
75
+ zh: "对话标题栏。",
76
+ },
77
+ },
78
+ {
79
+ name: "page-header",
80
+ version: 1,
81
+ owner: ["packages/design/src/shell/page-header.tsx"],
82
+ states: [],
83
+ description: {
84
+ en: "The header of a page.",
85
+ zh: "页面头部。",
86
+ },
87
+ },
88
+ {
89
+ name: "thread",
90
+ version: 1,
91
+ owner: ["packages/design/src/templates/conversation-page.tsx"],
92
+ states: ["aria-busy"],
93
+ description: {
94
+ en: "The conversation stream.",
95
+ zh: "对话消息流。",
96
+ },
97
+ },
98
+ {
99
+ name: "message.user",
100
+ version: 1,
101
+ owner: ["packages/design/src/conversation/bubble.tsx"],
102
+ states: [],
103
+ description: {
104
+ en: "A person's message.",
105
+ zh: "用户发出的消息。",
106
+ },
107
+ },
108
+ {
109
+ name: "message.assistant",
110
+ version: 1,
111
+ owner: ["apps/web/src/components/conversation/Thread.tsx"],
112
+ states: [],
113
+ description: {
114
+ en: "An assistant turn.",
115
+ zh: "智能体的一轮回复。",
116
+ },
117
+ },
118
+ {
119
+ name: "tool-row",
120
+ version: 1,
121
+ owner: ["packages/design/src/conversation/tool-row.tsx"],
122
+ states: ["aria-expanded"],
123
+ description: {
124
+ en: "A tool call line.",
125
+ zh: "工具调用行。",
126
+ },
127
+ },
128
+ {
129
+ name: "composer",
130
+ version: 1,
131
+ owner: ["packages/design/src/conversation/composer.tsx"],
132
+ states: ["aria-busy"],
133
+ description: {
134
+ en: "The composer box.",
135
+ zh: "输入框。",
136
+ },
137
+ },
138
+ {
139
+ name: "properties-panel",
140
+ version: 1,
141
+ owner: ["packages/design/src/conversation/panels.tsx"],
142
+ states: [],
143
+ description: {
144
+ en: "The conversation properties panel.",
145
+ zh: "对话属性面板。",
146
+ },
147
+ },
148
+ {
149
+ name: "section",
150
+ version: 1,
151
+ owner: [
152
+ "packages/design/src/conversation/panels.tsx",
153
+ "packages/design/src/templates/form-page.tsx",
154
+ ],
155
+ states: [],
156
+ description: {
157
+ en: "A property section or form section.",
158
+ zh: "属性分区或表单分区。",
159
+ },
160
+ },
161
+ {
162
+ name: "right-panel",
163
+ version: 1,
164
+ owner: ["packages/design/src/conversation/panels.tsx"],
165
+ states: [],
166
+ description: {
167
+ en: "A full-height right pane.",
168
+ zh: "占满高度的右侧窗格。",
169
+ },
170
+ },
171
+ {
172
+ name: "status-bar",
173
+ version: 1,
174
+ owner: ["packages/design/src/shell/status-bar.tsx"],
175
+ states: [],
176
+ description: {
177
+ en: "The status bar.",
178
+ zh: "状态栏。",
179
+ },
180
+ },
181
+ {
182
+ name: "button",
183
+ version: 1,
184
+ owner: ["packages/design/src/controls/button.tsx"],
185
+ states: ["disabled"],
186
+ description: {
187
+ en: "Every button.",
188
+ zh: "所有按钮。",
189
+ },
190
+ },
191
+ {
192
+ name: "button.primary",
193
+ version: 1,
194
+ owner: ["packages/design/src/controls/button.tsx"],
195
+ states: ["disabled"],
196
+ description: {
197
+ en: "A primary button (carried together with `button`).",
198
+ zh: "主按钮(与 button 同时出现)。",
199
+ },
200
+ },
201
+ {
202
+ name: "card",
203
+ version: 1,
204
+ owner: [
205
+ "packages/design/src/layout/index.tsx",
206
+ "packages/design/src/conversation/panels.tsx",
207
+ "packages/design/src/display/card-grid.tsx",
208
+ ],
209
+ states: [],
210
+ description: {
211
+ en: "A card, inline card or object card.",
212
+ zh: "卡片、行内卡片或对象卡片。",
213
+ },
214
+ },
215
+ {
216
+ name: "input",
217
+ version: 1,
218
+ owner: ["packages/design/src/controls/inputs.tsx", "packages/design/src/controls/select.tsx"],
219
+ states: ["disabled"],
220
+ description: {
221
+ en: "Text inputs, textareas and selects.",
222
+ zh: "文本框、多行文本框和下拉选择。",
223
+ },
224
+ },
225
+ {
226
+ name: "dialog",
227
+ version: 1,
228
+ owner: ["packages/design/src/overlays/dialog.tsx", "packages/design/src/overlays/sheet.tsx"],
229
+ states: [],
230
+ description: {
231
+ en: "A dialog or sheet.",
232
+ zh: "对话框或抽屉。",
233
+ },
234
+ },
235
+ ];
236
+ export function uiPart(name) {
237
+ return UI_PARTS.find((p) => p.name === name);
238
+ }
@@ -2,7 +2,7 @@ import type { UiKind, UiPlace } from "./ui.js";
2
2
  export type UiSlotScope = "conversation" | "agent" | "org" | "platform" | "file";
3
3
  export type UiSlotRole = "guest" | "member" | "admin" | "superAdmin";
4
4
  /** Every slot id of the catalog, in catalog order (UI slots spec §3). */
5
- export declare const UI_SLOT_IDS: readonly ["conversation.panel", "conversation.properties.section", "conversation.tool-result.card", "org.page", "file.preview", "agent.detail.section", "org.settings.section", "platform.page"];
5
+ export declare const UI_SLOT_IDS: readonly ["conversation.panel", "conversation.properties.section", "conversation.tool-result.card", "org.page", "file.preview", "agent.detail.section", "org.settings.section", "platform.page", "shell.brand", "shell.overlay", "conversation.empty", "conversation.composer.frame"];
6
6
  export type UiSlotId = (typeof UI_SLOT_IDS)[number];
7
7
  /** One slot of the catalog: where extension UI may go and what it receives (UI slots spec §3.1). */
8
8
  export interface UiSlotSpec {
@@ -13,7 +13,15 @@ export interface UiSlotSpec {
13
13
  owner: string;
14
14
  scope: UiSlotScope;
15
15
  accepts: readonly UiKind[];
16
- cardinality: "list";
16
+ /** `single`: one winner replaces the built-in; `list`: every contribution is shown. */
17
+ cardinality: "list" | "single";
18
+ /** A single slot replaces a built-in block (client extensions spec §6.1). */
19
+ replaceable?: true;
20
+ /** What a replaceable slot shows without a winner. */
21
+ builtin?: {
22
+ en: string;
23
+ zh: string;
24
+ };
17
25
  minRole: UiSlotRole;
18
26
  /** Context ids passed to render (`conversationId`, `agentId`, …). */
19
27
  args: readonly string[];
@@ -39,5 +47,9 @@ export declare function parseSlotRef(ref: string): {
39
47
  /** @deprecated step A of the UI slots spec §4 */
40
48
  export declare const PLACE_SLOTS: Readonly<Record<UiPlace, UiSlotId>>;
41
49
  export declare const UI_ARRANGEABLE_SLOTS: readonly UiSlotId[];
50
+ /** Slots with one winner that replaces a built-in block. */
51
+ export declare const UI_SINGLE_SLOTS: readonly UiSlotId[];
52
+ /** Slots that accept the `component` kind. */
53
+ export declare const UI_COMPONENT_SLOTS: readonly UiSlotId[];
42
54
  export declare const UI_CONTRIBUTION_KEY_RE: RegExp;
43
55
  export declare function uiContributionKey(plugin: string, id: string): string;