@capybara-hq/plugin-sdk 0.1.0-rc.5 → 0.1.0-rc.51

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 (134) 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 +4 -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 +53 -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 +86 -1
  20. package/dist/bootstrap.js +161 -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 +7 -2
  32. package/dist/connector-auth.js +29 -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 +120 -29
  37. package/dist/define-extension.d.ts +26 -12
  38. package/dist/define-extension.js +11 -4
  39. package/dist/device-denied-paths.d.ts +14 -0
  40. package/dist/device-denied-paths.js +41 -0
  41. package/dist/device-operation.d.ts +302 -0
  42. package/dist/device-operation.js +292 -0
  43. package/dist/device-protocol.d.ts +490 -0
  44. package/dist/device-protocol.js +1117 -0
  45. package/dist/device-provider.d.ts +472 -0
  46. package/dist/device-provider.js +283 -0
  47. package/dist/extension-point.d.ts +2 -0
  48. package/dist/extension-point.js +6 -2
  49. package/dist/file-preview.d.ts +23 -6
  50. package/dist/git-hosts.d.ts +53 -0
  51. package/dist/git-hosts.js +98 -0
  52. package/dist/hooks.d.ts +125 -20
  53. package/dist/hooks.js +5 -0
  54. package/dist/http-access.d.ts +62 -0
  55. package/dist/http-access.js +12 -0
  56. package/dist/identity.d.ts +38 -9
  57. package/dist/identity.js +21 -1
  58. package/dist/index.d.ts +29 -2
  59. package/dist/index.js +29 -2
  60. package/dist/marketplace.d.ts +26 -0
  61. package/dist/marketplace.js +43 -1
  62. package/dist/model-params.d.ts +41 -22
  63. package/dist/model-params.js +28 -15
  64. package/dist/model.d.ts +206 -71
  65. package/dist/model.js +152 -19
  66. package/dist/net.d.ts +52 -0
  67. package/dist/net.js +34 -0
  68. package/dist/network-classes.d.ts +98 -0
  69. package/dist/network-classes.js +291 -0
  70. package/dist/permissions.d.ts +41 -21
  71. package/dist/permissions.js +101 -42
  72. package/dist/plugin-manifest.d.ts +45 -5
  73. package/dist/plugin-manifest.js +169 -6
  74. package/dist/plugin-package.d.ts +82 -38
  75. package/dist/plugin-package.js +61 -29
  76. package/dist/push.d.ts +75 -0
  77. package/dist/push.js +87 -0
  78. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  79. package/dist/sandbox-linux-runtime-source.js +2318 -0
  80. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  81. package/dist/sandbox-native-runtime-source.js +476 -0
  82. package/dist/sandbox-runtime-source.d.ts +19 -0
  83. package/dist/sandbox-runtime-source.js +28 -0
  84. package/dist/sandbox-write-denies.d.ts +139 -0
  85. package/dist/sandbox-write-denies.js +869 -0
  86. package/dist/secret.d.ts +4 -1
  87. package/dist/secret.js +4 -1
  88. package/dist/setup-check.d.ts +128 -0
  89. package/dist/setup-check.js +142 -0
  90. package/dist/setup-guide-parse.d.ts +135 -0
  91. package/dist/setup-guide-parse.js +413 -0
  92. package/dist/setup-guide-render.d.ts +50 -0
  93. package/dist/setup-guide-render.js +367 -0
  94. package/dist/setup-guide.d.ts +109 -0
  95. package/dist/setup-guide.js +377 -0
  96. package/dist/shell-capabilities.d.ts +231 -0
  97. package/dist/shell-capabilities.js +37 -0
  98. package/dist/shell-environment.d.ts +57 -0
  99. package/dist/shell-environment.js +22 -0
  100. package/dist/skill-invocation.d.ts +4 -3
  101. package/dist/skill-invocation.js +5 -4
  102. package/dist/skill.d.ts +34 -21
  103. package/dist/skill.js +49 -32
  104. package/dist/storage.d.ts +52 -25
  105. package/dist/theme-assets.d.ts +55 -0
  106. package/dist/theme-assets.js +507 -0
  107. package/dist/theme-readability.d.ts +37 -0
  108. package/dist/theme-readability.js +145 -0
  109. package/dist/theme-tokens.generated.d.ts +299 -0
  110. package/dist/theme-tokens.generated.js +184 -0
  111. package/dist/theme.d.ts +190 -0
  112. package/dist/theme.js +471 -0
  113. package/dist/tool.d.ts +69 -26
  114. package/dist/tool.js +29 -9
  115. package/dist/ui-parts.d.ts +23 -0
  116. package/dist/ui-parts.js +348 -0
  117. package/dist/ui-resolve.d.ts +35 -0
  118. package/dist/ui-resolve.js +42 -0
  119. package/dist/ui-slots.d.ts +65 -0
  120. package/dist/ui-slots.js +261 -0
  121. package/dist/ui.d.ts +212 -76
  122. package/dist/ui.js +101 -27
  123. package/dist/url.d.ts +4 -1
  124. package/dist/url.js +4 -1
  125. package/package.json +8 -1
  126. package/schemas/bootstrap-extra.v1.schema.json +172 -0
  127. package/schemas/bootstrap.v1.schema.json +6 -0
  128. package/schemas/connector-template.v1.schema.json +35 -0
  129. package/schemas/marketplace.v1.schema.json +14 -0
  130. package/schemas/plugin.v1.schema.json +117 -3
  131. package/schemas/theme.v1.schema.json +302 -0
  132. package/agent-docs/extension-points/sandbox.md +0 -15
  133. package/dist/sandbox.d.ts +0 -232
  134. package/dist/sandbox.js +0 -120
package/dist/tool.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { checkParamValue } from "./model-params.js";
2
2
  import { isHttpUrl } from "./url.js";
3
+ /** Where a conversation comes from; a tool may limit itself to some of these. */
4
+ export const CONVERSATION_SOURCES = ["web", "channel_dm", "channel_group", "subagent"];
3
5
  /** Longest {@link ToolSpec.title}, in code points. */
4
6
  export const TOOL_TITLE_MAX = 80;
5
7
  /** Most {@link ToolSpec.keyArgs}. */
@@ -52,7 +54,10 @@ export function validateToolPresentation(spec) {
52
54
  return out;
53
55
  }
54
56
  const DISPLAY_MAX = 200;
55
- /** 校验 {@link ToolDisplay},返回问题列表(空 = 合法);长度按 Unicode 码点计。 */
57
+ /**
58
+ * Validates a {@link ToolDisplay} and returns the list of problems (empty = valid); length is
59
+ * counted in Unicode code points.
60
+ */
56
61
  export function validateToolDisplay(d) {
57
62
  if (typeof d !== "object" || d === null || Array.isArray(d))
58
63
  return ["display must be an object"];
@@ -67,7 +72,7 @@ export function validateToolDisplay(d) {
67
72
  }
68
73
  return out;
69
74
  }
70
- /** 工具执行失败:message 给模型看,须为英文且可操作。 */
75
+ /** A tool execution failure: message is for the model and must be in English and actionable. */
71
76
  export class ToolError extends Error {
72
77
  kind;
73
78
  constructor(message, opts) {
@@ -76,9 +81,12 @@ export class ToolError extends Error {
76
81
  this.kind = opts?.kind ?? "error";
77
82
  }
78
83
  }
79
- /** 插件工具名规则。 */
84
+ /** Plugin tool name rule. */
80
85
  export const EXTENSION_TOOL_NAME = /^[a-zA-Z0-9_-]{1,40}$/;
81
- /** 校验插件注册的工具声明,返回问题列表(空 = 合法)。 */
86
+ /**
87
+ * Validates the tool declarations a plugin registers and returns the list of problems (empty =
88
+ * valid).
89
+ */
82
90
  export function validateToolSpec(spec) {
83
91
  const out = [];
84
92
  if (typeof spec?.name !== "string" || !EXTENSION_TOOL_NAME.test(spec.name))
@@ -93,6 +101,12 @@ export function validateToolSpec(spec) {
93
101
  out.push('defaultPolicy must be "allow" or "ask"');
94
102
  if (typeof spec?.inputSchema === "object" && spec.inputSchema !== null)
95
103
  out.push(...validateToolPresentation(spec));
104
+ const sources = spec?.sources;
105
+ if (sources !== undefined &&
106
+ (!Array.isArray(sources) ||
107
+ sources.length === 0 ||
108
+ sources.some((s) => !CONVERSATION_SOURCES.includes(s))))
109
+ out.push(`sources must be a non-empty list of ${CONVERSATION_SOURCES.join(", ")}`);
96
110
  return out;
97
111
  }
98
112
  const SCHEMA_KEYS = {
@@ -101,7 +115,7 @@ const SCHEMA_KEYS = {
101
115
  number: ["type", "minimum", "maximum"],
102
116
  integer: ["type", "minimum", "maximum"],
103
117
  };
104
- /** 检查 schema 是否落在 ParamSchema 子集内,返回问题列表。 */
118
+ /** Checks whether a schema falls within the ParamSchema subset and returns the list of problems. */
105
119
  function schemaProblems(schema) {
106
120
  if (typeof schema !== "object" || schema === null || Array.isArray(schema))
107
121
  return ["schema must be an object"];
@@ -130,7 +144,7 @@ function schemaProblems(schema) {
130
144
  return out;
131
145
  }
132
146
  const isEnum = (s) => s.type === "string" && "enum" in s;
133
- /** 校验交互表单的声明,返回问题列表(空 = 合法)。 */
147
+ /** Validates an interactive form declaration and returns the list of problems (empty = valid). */
134
148
  export function validateInputForm(form) {
135
149
  const out = [];
136
150
  if (!form || !Array.isArray(form.fields))
@@ -159,7 +173,10 @@ export function validateInputForm(form) {
159
173
  }
160
174
  return out;
161
175
  }
162
- /** 校验用户提交的答案是否符合表单,返回问题列表(空 = 合法)。 */
176
+ /**
177
+ * Validates whether the answer a user submitted conforms to the form and returns the list of
178
+ * problems (empty = valid).
179
+ */
163
180
  export function validateAnswer(form, answer) {
164
181
  const out = [];
165
182
  const byKey = new Map(form.fields.map((f) => [f.key, f]));
@@ -168,7 +185,8 @@ export function validateAnswer(form, answer) {
168
185
  out.push(`unknown field ${JSON.stringify(k)}`);
169
186
  for (const f of form.fields) {
170
187
  const at = `field ${JSON.stringify(f.key)}`;
171
- // 只认答案自身的键:`toString` / `constructor` 等继承属性不算已回答
188
+ // Look only at the answer's own keys: inherited properties such as `toString` / `constructor`
189
+ // do not count as answered
172
190
  const v = Object.hasOwn(answer, f.key) ? answer[f.key] : undefined;
173
191
  if (v === undefined) {
174
192
  if (f.required)
@@ -209,7 +227,9 @@ export function validateAnswer(form, answer) {
209
227
  }
210
228
  return out;
211
229
  }
212
- /** allowOther 的枚举字段接受任意非空文本,其余按 schema 校验。 */
230
+ /**
231
+ * An allowOther enum field accepts any non-empty text; the rest are validated against the schema.
232
+ */
213
233
  function otherOrValue(f, v) {
214
234
  if (f.allowOther && isEnum(f.schema)) {
215
235
  return typeof v === "string" && v !== "" ? undefined : "other text must be a non-empty string";
@@ -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" | "aria-checked" | "aria-pressed" | "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.user.bubble", "message.assistant", "tool-row", "composer", "properties-panel", "section", "right-panel", "status-bar", "button", "button.primary", "card", "input", "dialog", "code-block", "menu", "segmented", "stat-card", "switch", "switch.knob", "org-avatar", "agent-chip", "image-placeholder"];
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,348 @@
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.user.bubble",
12
+ "message.assistant",
13
+ "tool-row",
14
+ "composer",
15
+ "properties-panel",
16
+ "section",
17
+ "right-panel",
18
+ "status-bar",
19
+ "button",
20
+ "button.primary",
21
+ "card",
22
+ "input",
23
+ "dialog",
24
+ "code-block",
25
+ "menu",
26
+ "segmented",
27
+ "stat-card",
28
+ "switch",
29
+ "switch.knob",
30
+ "org-avatar",
31
+ "agent-chip",
32
+ "image-placeholder",
33
+ ];
34
+ export const UI_PARTS = [
35
+ {
36
+ name: "shell",
37
+ version: 1,
38
+ owner: ["packages/design/src/shell/app-shell.tsx"],
39
+ states: [],
40
+ description: {
41
+ en: "The App Shell root.",
42
+ zh: "应用外壳的根节点。",
43
+ },
44
+ },
45
+ {
46
+ name: "sidebar",
47
+ version: 1,
48
+ owner: ["packages/design/src/shell/sidebar.tsx"],
49
+ states: [],
50
+ description: {
51
+ en: "The left sidebar.",
52
+ zh: "左侧边栏。",
53
+ },
54
+ },
55
+ {
56
+ name: "sidebar.brand",
57
+ version: 1,
58
+ owner: ["packages/design/src/shell/sidebar.tsx"],
59
+ states: [],
60
+ description: {
61
+ en: "The brand row of the sidebar.",
62
+ zh: "侧边栏的品牌行。",
63
+ },
64
+ },
65
+ {
66
+ name: "sidebar.item",
67
+ version: 1,
68
+ owner: [
69
+ "packages/design/src/shell/sidebar.tsx",
70
+ "packages/design/src/shell/sidebar-conversations.tsx",
71
+ ],
72
+ states: ["aria-current"],
73
+ description: {
74
+ en: "A navigation or conversation row of the sidebar.",
75
+ zh: "侧边栏的导航行或对话行。",
76
+ },
77
+ },
78
+ {
79
+ name: "title-bar",
80
+ version: 1,
81
+ owner: ["packages/design/src/conversation/title-bar.tsx"],
82
+ states: [],
83
+ description: {
84
+ en: "The conversation title bar.",
85
+ zh: "对话标题栏。",
86
+ },
87
+ },
88
+ {
89
+ name: "page-header",
90
+ version: 1,
91
+ owner: ["packages/design/src/shell/page-header.tsx"],
92
+ states: [],
93
+ description: {
94
+ en: "The header of a page.",
95
+ zh: "页面头部。",
96
+ },
97
+ },
98
+ {
99
+ name: "thread",
100
+ version: 1,
101
+ owner: ["packages/design/src/templates/conversation-page.tsx"],
102
+ states: ["aria-busy"],
103
+ description: {
104
+ en: "The conversation stream.",
105
+ zh: "对话消息流。",
106
+ },
107
+ },
108
+ {
109
+ name: "message.user",
110
+ version: 1,
111
+ owner: ["packages/design/src/conversation/bubble.tsx"],
112
+ states: [],
113
+ description: {
114
+ en: "A person's message.",
115
+ zh: "用户发出的消息。",
116
+ },
117
+ },
118
+ {
119
+ name: "message.user.bubble",
120
+ version: 1,
121
+ owner: ["packages/design/src/conversation/bubble.tsx"],
122
+ states: [],
123
+ description: {
124
+ en: "The bubble of a person's message (inside the full-width `message.user` row).",
125
+ zh: "用户消息的气泡本身(在占满宽度的 message.user 行之内)。",
126
+ },
127
+ },
128
+ {
129
+ name: "message.assistant",
130
+ version: 1,
131
+ owner: ["apps/web/src/components/conversation/Thread.tsx"],
132
+ states: ["aria-busy"],
133
+ description: {
134
+ en: "An assistant turn; `aria-busy` while its text is still streaming (the live reply).",
135
+ zh: "智能体的一轮回复;正在流式输出时带 aria-busy(正在生成的回复)。",
136
+ },
137
+ },
138
+ {
139
+ name: "tool-row",
140
+ version: 1,
141
+ owner: ["packages/design/src/conversation/tool-row.tsx"],
142
+ states: ["aria-expanded"],
143
+ description: {
144
+ en: "A tool call line.",
145
+ zh: "工具调用行。",
146
+ },
147
+ },
148
+ {
149
+ name: "composer",
150
+ version: 1,
151
+ owner: ["packages/design/src/conversation/composer.tsx"],
152
+ states: ["aria-busy"],
153
+ description: {
154
+ en: "The composer box.",
155
+ zh: "输入框。",
156
+ },
157
+ },
158
+ {
159
+ name: "properties-panel",
160
+ version: 1,
161
+ owner: ["packages/design/src/conversation/panels.tsx"],
162
+ states: [],
163
+ description: {
164
+ en: "The conversation properties panel.",
165
+ zh: "对话属性面板。",
166
+ },
167
+ },
168
+ {
169
+ name: "section",
170
+ version: 1,
171
+ owner: [
172
+ "packages/design/src/conversation/panels.tsx",
173
+ "packages/design/src/templates/form-page.tsx",
174
+ ],
175
+ states: [],
176
+ description: {
177
+ en: "A property section or form section.",
178
+ zh: "属性分区或表单分区。",
179
+ },
180
+ },
181
+ {
182
+ name: "right-panel",
183
+ version: 1,
184
+ owner: ["packages/design/src/conversation/panels.tsx"],
185
+ states: [],
186
+ description: {
187
+ en: "A full-height right pane.",
188
+ zh: "占满高度的右侧窗格。",
189
+ },
190
+ },
191
+ {
192
+ name: "status-bar",
193
+ version: 1,
194
+ owner: ["packages/design/src/shell/status-bar.tsx"],
195
+ states: [],
196
+ description: {
197
+ en: "The status bar.",
198
+ zh: "状态栏。",
199
+ },
200
+ },
201
+ {
202
+ name: "button",
203
+ version: 1,
204
+ owner: ["packages/design/src/controls/button.tsx"],
205
+ states: ["disabled"],
206
+ description: {
207
+ en: "Every button.",
208
+ zh: "所有按钮。",
209
+ },
210
+ },
211
+ {
212
+ name: "button.primary",
213
+ version: 1,
214
+ owner: ["packages/design/src/controls/button.tsx"],
215
+ states: ["disabled"],
216
+ description: {
217
+ en: "A primary button (carried together with `button`).",
218
+ zh: "主按钮(与 button 同时出现)。",
219
+ },
220
+ },
221
+ {
222
+ name: "card",
223
+ version: 1,
224
+ owner: [
225
+ "packages/design/src/layout/index.tsx",
226
+ "packages/design/src/conversation/panels.tsx",
227
+ "packages/design/src/display/card-grid.tsx",
228
+ ],
229
+ states: [],
230
+ description: {
231
+ en: "A card, inline card or object card.",
232
+ zh: "卡片、行内卡片或对象卡片。",
233
+ },
234
+ },
235
+ {
236
+ name: "input",
237
+ version: 1,
238
+ owner: ["packages/design/src/controls/inputs.tsx", "packages/design/src/controls/select.tsx"],
239
+ states: ["disabled"],
240
+ description: {
241
+ en: "Text inputs, textareas and selects.",
242
+ zh: "文本框、多行文本框和下拉选择。",
243
+ },
244
+ },
245
+ {
246
+ name: "dialog",
247
+ version: 1,
248
+ owner: ["packages/design/src/overlays/dialog.tsx", "packages/design/src/overlays/sheet.tsx"],
249
+ states: [],
250
+ description: {
251
+ en: "A dialog or sheet.",
252
+ zh: "对话框或抽屉。",
253
+ },
254
+ },
255
+ {
256
+ name: "code-block",
257
+ version: 1,
258
+ owner: ["packages/design/src/display/chat.tsx"],
259
+ states: [],
260
+ description: {
261
+ en: "A code block (Markdown code, setup guides, diffs).",
262
+ zh: "代码块(Markdown 代码、设置指引、差异)。",
263
+ },
264
+ },
265
+ {
266
+ name: "menu",
267
+ version: 1,
268
+ owner: ["packages/design/src/overlays/menus.tsx", "packages/design/src/conversation/menu.tsx"],
269
+ states: [],
270
+ description: {
271
+ en: "A menu, submenu, popover or the composer's menus.",
272
+ zh: "菜单、子菜单、弹出层或输入框的菜单。",
273
+ },
274
+ },
275
+ {
276
+ name: "segmented",
277
+ version: 1,
278
+ owner: ["packages/design/src/display/tabs.tsx"],
279
+ states: [],
280
+ description: {
281
+ en: "A segmented control (its segments are radios with `aria-checked`).",
282
+ zh: "分段控件(各段是带 aria-checked 的单选项)。",
283
+ },
284
+ },
285
+ {
286
+ name: "stat-card",
287
+ version: 1,
288
+ owner: ["packages/design/src/display/stat-cards.tsx"],
289
+ states: [],
290
+ description: {
291
+ en: "A metric card of a StatCards row.",
292
+ zh: "指标卡片行里的一张指标卡。",
293
+ },
294
+ },
295
+ {
296
+ name: "switch",
297
+ version: 1,
298
+ owner: ["packages/design/src/controls/toggles.tsx"],
299
+ states: ["aria-checked", "disabled"],
300
+ description: {
301
+ en: "A switch; `aria-checked` says on or off.",
302
+ zh: "开关;aria-checked 表示开或关。",
303
+ },
304
+ },
305
+ {
306
+ name: "switch.knob",
307
+ version: 1,
308
+ owner: ["packages/design/src/controls/toggles.tsx"],
309
+ states: [],
310
+ description: {
311
+ en: "The knob inside a `switch` (style it from the switch's state).",
312
+ zh: "开关里的滑块(按所在开关的状态设置样式)。",
313
+ },
314
+ },
315
+ {
316
+ name: "org-avatar",
317
+ version: 1,
318
+ owner: ["packages/design/src/shell/sidebar.tsx"],
319
+ states: [],
320
+ description: {
321
+ en: "The org's initial block in the sidebar's org switcher.",
322
+ zh: "侧边栏组织切换器里的组织首字方块。",
323
+ },
324
+ },
325
+ {
326
+ name: "agent-chip",
327
+ version: 1,
328
+ owner: ["packages/design/src/conversation/agent-row.tsx"],
329
+ states: ["aria-pressed"],
330
+ description: {
331
+ en: "An agent chip of the new conversation's agents row; `aria-pressed` on the selected one.",
332
+ zh: "新会话智能体行里的智能体标签;选中的那个带 aria-pressed。",
333
+ },
334
+ },
335
+ {
336
+ name: "image-placeholder",
337
+ version: 1,
338
+ owner: ["packages/design/src/conversation/files.tsx"],
339
+ states: ["aria-busy"],
340
+ description: {
341
+ en: "A generating image's placeholder in the conversation.",
342
+ zh: "对话中正在生成的图片的占位框。",
343
+ },
344
+ },
345
+ ];
346
+ export function uiPart(name) {
347
+ return UI_PARTS.find((p) => p.name === name);
348
+ }
@@ -0,0 +1,35 @@
1
+ import type { UiContribution } from "./ui.js";
2
+ import { type UiSlotSpec } from "./ui-slots.js";
3
+ /** A contribution whose slot the catalog knows at the version it names (UI slots spec §3.2). */
4
+ export interface ResolvedUiContribution {
5
+ contribution: UiContribution;
6
+ slot: UiSlotSpec;
7
+ version: number;
8
+ /**
9
+ * For a slot with anchors: the anchor it goes after (the contribution's own `after` when it is one
10
+ * of the slot's anchors, else the slot's first anchor). Absent for a slot without anchors.
11
+ */
12
+ after?: string;
13
+ }
14
+ /** Why a contribution was dropped: its slot is not in the catalog, or not at that version. */
15
+ export type UiDropReason = "unknown-slot" | "unsupported-version";
16
+ /** A contribution left out of the loaded extension; `ref` is the slot reference it names. */
17
+ export interface DroppedUiContribution {
18
+ id: string;
19
+ ref: string;
20
+ reason: UiDropReason;
21
+ }
22
+ /**
23
+ * Resolves the slots of a manifest's `ui` against the catalog (UI slots spec §3.2). Assumes
24
+ * `validateUiContributions` passed; never throws. A contribution to an unknown slot or to a version
25
+ * other than the slot's is dropped; an `after` that is not an anchor of the slot is listed in
26
+ * `unknownAnchors` and the contribution keeps the slot's default position. Both lists keep manifest order.
27
+ */
28
+ export declare function resolveUiSlots(ui: readonly UiContribution[] | undefined): {
29
+ resolved: ResolvedUiContribution[];
30
+ dropped: DroppedUiContribution[];
31
+ unknownAnchors: {
32
+ id: string;
33
+ after: string;
34
+ }[];
35
+ };
@@ -0,0 +1,42 @@
1
+ import { parseSlotRef, uiSlot } from "./ui-slots.js";
2
+ /**
3
+ * Resolves the slots of a manifest's `ui` against the catalog (UI slots spec §3.2). Assumes
4
+ * `validateUiContributions` passed; never throws. A contribution to an unknown slot or to a version
5
+ * other than the slot's is dropped; an `after` that is not an anchor of the slot is listed in
6
+ * `unknownAnchors` and the contribution keeps the slot's default position. Both lists keep manifest order.
7
+ */
8
+ export function resolveUiSlots(ui) {
9
+ const list = ui ?? [];
10
+ const own = new Map();
11
+ for (const c of list) {
12
+ const ref = parseSlotRef(c.slot);
13
+ const slot = ref === null ? undefined : uiSlot(ref.id);
14
+ own.set(c.id, ref === null || slot === undefined
15
+ ? { ok: false, reason: "unknown-slot" }
16
+ : ref.version !== slot.version
17
+ ? { ok: false, reason: "unsupported-version" }
18
+ : { ok: true, slot, version: ref.version });
19
+ }
20
+ const resolved = [];
21
+ const dropped = [];
22
+ const unknownAnchors = [];
23
+ for (const c of list) {
24
+ const r = own.get(c.id);
25
+ if (!r.ok) {
26
+ dropped.push({ id: c.id, ref: c.slot, reason: r.reason });
27
+ continue;
28
+ }
29
+ const anchors = r.slot.anchors ?? [];
30
+ if (c.after !== undefined && !anchors.includes(c.after)) {
31
+ unknownAnchors.push({ id: c.id, after: c.after });
32
+ }
33
+ const after = c.after !== undefined && anchors.includes(c.after) ? c.after : anchors[0];
34
+ resolved.push({
35
+ contribution: c,
36
+ slot: r.slot,
37
+ version: r.version,
38
+ ...(anchors.length > 0 && { after }),
39
+ });
40
+ }
41
+ return { resolved, dropped, unknownAnchors };
42
+ }
@@ -0,0 +1,65 @@
1
+ import type { UiKind } from "./ui.js";
2
+ export type UiSlotScope = "conversation" | "agent" | "org" | "platform" | "file";
3
+ export type UiSlotRole = "guest" | "member" | "admin" | "superAdmin";
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", "shell.brand", "shell.overlay", "conversation.empty", "conversation.composer.frame"];
6
+ /**
7
+ * What a slot (or a contribution) becomes on a compact screen (mobile layout spec §5.6): `kept` =
8
+ * rendered in its place, `drawer` = moved into a sheet or pushed page, `hidden` = not rendered.
9
+ * Order of narrowing: `kept` < `drawer` < `hidden`.
10
+ */
11
+ export type CompactForm = "kept" | "drawer" | "hidden";
12
+ /** True when `v` is one of the three compact forms (used to validate manifests). */
13
+ export declare function isCompactForm(v: unknown): v is CompactForm;
14
+ /** A contribution may narrow its slot's compact form, never widen it. */
15
+ export declare function effectiveCompact(slot: CompactForm, contribution?: CompactForm): CompactForm;
16
+ export type UiSlotId = (typeof UI_SLOT_IDS)[number];
17
+ /** One slot of the catalog: where extension UI may go and what it receives (UI slots spec §3.1). */
18
+ export interface UiSlotSpec {
19
+ id: UiSlotId;
20
+ /** Bumped only on an incompatible change of the slot's contract. */
21
+ version: number;
22
+ /** Path relative to `apps/web/src` of the component that renders the slot. */
23
+ owner: string;
24
+ scope: UiSlotScope;
25
+ accepts: readonly UiKind[];
26
+ /** `single`: one winner replaces the built-in; `list`: every contribution is shown. */
27
+ cardinality: "list" | "single";
28
+ /** A single slot replaces a built-in block (client extensions spec §6.1). */
29
+ replaceable?: true;
30
+ /** What a replaceable slot shows without a winner. */
31
+ builtin?: {
32
+ en: string;
33
+ zh: string;
34
+ };
35
+ minRole: UiSlotRole;
36
+ /** Context ids passed to render (`conversationId`, `agentId`, …). */
37
+ args: readonly string[];
38
+ density: "dense" | "regular";
39
+ icon: "required" | "optional" | "none";
40
+ /** The slot's form on a compact screen (mobile layout spec §5.6). */
41
+ compact: CompactForm;
42
+ /** Built-in parts a contribution may be placed after; the first is the default. */
43
+ anchors?: readonly string[];
44
+ limits?: {
45
+ maxShown?: number;
46
+ };
47
+ description: {
48
+ en: string;
49
+ zh: string;
50
+ };
51
+ }
52
+ export declare const UI_SLOTS: readonly UiSlotSpec[];
53
+ export declare function uiSlot(id: string): UiSlotSpec | undefined;
54
+ /** Reads `<id>` or `<id>@<version>` (version 1 when omitted); does not check the catalog. */
55
+ export declare function parseSlotRef(ref: string): {
56
+ id: string;
57
+ version: number;
58
+ } | null;
59
+ export declare const UI_ARRANGEABLE_SLOTS: readonly UiSlotId[];
60
+ /** Slots with one winner that replaces a built-in block. */
61
+ export declare const UI_SINGLE_SLOTS: readonly UiSlotId[];
62
+ /** Slots that accept the `component` kind. */
63
+ export declare const UI_COMPONENT_SLOTS: readonly UiSlotId[];
64
+ export declare const UI_CONTRIBUTION_KEY_RE: RegExp;
65
+ export declare function uiContributionKey(plugin: string, id: string): string;