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

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 +503 -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
package/dist/tool.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type ParamSchema } from "./model-params.js";
2
- /** 工具注解(与 MCP 对齐的提示,用于推导默认策略)。 */
2
+ /** Tool annotations (hints aligned with MCP, used to derive the default policy). */
3
3
  export interface ToolAnnotations {
4
4
  readOnlyHint?: boolean;
5
5
  destructiveHint?: boolean;
@@ -7,17 +7,26 @@ export interface ToolAnnotations {
7
7
  openWorldHint?: boolean;
8
8
  requiresUserInteraction?: boolean;
9
9
  }
10
+ /** Where a conversation comes from; a tool may limit itself to some of these. */
11
+ export declare const CONVERSATION_SOURCES: readonly ["web", "channel_dm", "channel_group", "subagent"];
12
+ /** A conversation source (see {@link CONVERSATION_SOURCES}). */
13
+ export type ConversationSource = (typeof CONVERSATION_SOURCES)[number];
10
14
  export interface ToolSpec {
11
15
  name: string;
12
16
  description: string;
13
17
  inputSchema: Record<string, unknown>;
14
18
  annotations?: ToolAnnotations;
15
- /** 仅插件 / 内置工具可声明;缺省按注解推导。 */
19
+ /**
20
+ * Only plugin / builtin tools may declare it; when omitted it is derived from the annotations.
21
+ */
16
22
  defaultPolicy?: "allow" | "ask";
17
23
  /**
18
- * 仅连接器工具:连接器自己的不透明数据(如 OpenAPI 的方法、路径模板、参数位置、服务器地址),可 JSON 序列化。
19
- * 内核把它与定义一起存进快照并计入指纹(变了即漂移、需复核),调用时经 `callTool` 的 `ctx.spec` 原样交回;
20
- * 绝不发给模型。
24
+ * Connector tools only: the connector's own opaque data (e.g. OpenAPI's method, path template,
25
+ * parameter locations, server address), JSON-serializable.
26
+ * The kernel stores it with the definition in the snapshot and counts it in the fingerprint (a
27
+ * change means drift and needs review), and hands it back unchanged via `ctx.spec` of `callTool`
28
+ * on a call;
29
+ * never sent to the model.
21
30
  */
22
31
  connectorData?: Record<string, unknown>;
23
32
  /**
@@ -33,6 +42,11 @@ export interface ToolSpec {
33
42
  * model and not part of the definition fingerprint.
34
43
  */
35
44
  keyArgs?: string[];
45
+ /**
46
+ * The conversation sources this tool is offered in; absent = every source. A non-empty list of
47
+ * {@link CONVERSATION_SOURCES}.
48
+ */
49
+ sources?: ConversationSource[];
36
50
  }
37
51
  /** Longest {@link ToolSpec.title}, in code points. */
38
52
  export declare const TOOL_TITLE_MAX = 80;
@@ -58,7 +72,10 @@ export type ToolContent = {
58
72
  name?: string;
59
73
  mimeType?: string;
60
74
  };
61
- /** 工具调用的一句话说明,给界面显示(中英文各 ≤ 200 字符);不进模型上下文。 */
75
+ /**
76
+ * A one-sentence description of a tool call, shown in the UI (Chinese and English each ≤ 200
77
+ * characters); does not enter the model context.
78
+ */
62
79
  export interface ToolDisplay {
63
80
  summary: {
64
81
  zh: string;
@@ -68,33 +85,44 @@ export interface ToolDisplay {
68
85
  export interface ToolResult {
69
86
  content: ToolContent[];
70
87
  isError?: boolean;
71
- /** 可选:对话流里显示这句说明,代替原样的输入 JSON。 */
88
+ /** Optional: show this description in the conversation stream in place of the raw input JSON. */
72
89
  display?: ToolDisplay;
73
90
  /**
74
91
  * Optional: an inline card under this call in the conversation: `view` is a ui contribution of
75
- * the same extension with `place: "inline"`, rendered with `card: { callId, key }`. Display only
76
- * (recorded on the `tool_result` event, never in the model's context); an unknown view is dropped
77
- * with a warning and the result is kept.
92
+ * the same extension in the `conversation.tool-result.card` slot, rendered with
93
+ * `card: { callId, key }`. Display only (recorded on the `tool_result` event, never in the model's
94
+ * context); an unknown view is dropped with a warning and the result is kept.
78
95
  */
79
96
  card?: {
80
97
  view: string;
81
98
  key?: string;
82
99
  };
83
100
  }
84
- /** 校验 {@link ToolDisplay},返回问题列表(空 = 合法);长度按 Unicode 码点计。 */
101
+ /**
102
+ * Validates a {@link ToolDisplay} and returns the list of problems (empty = valid); length is
103
+ * counted in Unicode code points.
104
+ */
85
105
  export declare function validateToolDisplay(d: unknown): string[];
86
106
  /** Text shown to people: bilingual (`zh` / `en`) or a single string shown as is. */
87
107
  export type LocalizedText = {
88
108
  zh: string;
89
109
  en: string;
90
110
  } | string;
91
- /** 交互表单:字段的 schema 只用 M2 的 ParamSchema 子集;枚举字段可设 multiSelect 与 allowOther。 */
111
+ /**
112
+ * Interactive form: field schemas use only the ParamSchema subset of M2; enum fields may set
113
+ * multiSelect and allowOther.
114
+ */
92
115
  export interface InputForm {
93
- /** 插件可给双语;内核内置工具给英文(模型生成的问题原样展示)。 */
116
+ /**
117
+ * A plugin may give both languages; builtin kernel tools give English (model-generated questions
118
+ * are displayed as is).
119
+ */
94
120
  title: LocalizedText;
95
121
  /**
96
- * 可选:需要用户在浏览器里打开的外部页面(如 MCP URL 模式的 elicitation:去对方页面授权 / 付款 / 填敏感信息)。
97
- * 界面把它显示为链接(完整地址可见);只接受 http(s) 绝对地址、≤ 2000 字符。
122
+ * Optional: an external page the user must open in a browser (e.g. an MCP URL-mode elicitation:
123
+ * go to the other party's page to authorize / pay / enter sensitive information).
124
+ * The UI shows it as a link (the full address visible); only absolute http(s) addresses, ≤ 2000
125
+ * characters, are accepted.
98
126
  */
99
127
  url?: string;
100
128
  fields: {
@@ -108,8 +136,9 @@ export interface InputForm {
108
136
  }[];
109
137
  }
110
138
  /**
111
- * 工具需要用户输入:内核暂停运行、渲染表单;用户提交后用同一 input 再次调用该工具,
112
- * 并在 ctx.resume 中带回 state 与 answer。state ≤ 16 KB,可 JSON 序列化。
139
+ * The tool needs user input: the kernel pauses the run and renders a form; after the user submits,
140
+ * the tool is called again with the same input,
141
+ * and state and answer are brought back in ctx.resume. state ≤ 16 KB, JSON-serializable.
113
142
  */
114
143
  export interface InputRequired {
115
144
  kind: "input_required";
@@ -117,14 +146,44 @@ export interface InputRequired {
117
146
  state?: unknown;
118
147
  }
119
148
  export type FormAnswer = Record<string, string | number | boolean | string[]>;
149
+ /**
150
+ * What a tool handler gets with each invocation.
151
+ *
152
+ * **Side effects and idempotency.** The kernel runs a call's effect at most once: it records
153
+ * that the call started before invoking the handler, and when a run dies after that and before
154
+ * the result is recorded, the result is written as unknown (an error result the model sees:
155
+ * `Result unknown: the call was interrupted before a result was recorded. Verify the outcome
156
+ * before retrying.`) and **the handler is never called again** for that call. The model, or a
157
+ * person, may then decide to call the tool again: that is a new call with a new `callId`.
158
+ *
159
+ * One logical call may still invoke the handler more than once: each `InputRequired` round
160
+ * resumes it with `resume`. `callId` and `idempotencyKey` stay the same across those
161
+ * invocations. A tool with an external side effect passes `idempotencyKey` downstream (for
162
+ * example as an `Idempotency-Key` header, or stored with the record it creates) so the effect
163
+ * applies once per logical call and an unknown outcome can be checked against the external
164
+ * system before retrying.
165
+ */
120
166
  export interface ToolCallContext {
121
167
  orgId: string;
122
168
  accountId: string;
123
169
  agentId: string;
124
170
  conversationId: string;
171
+ /**
172
+ * The model's id for this call. Stable across every invocation of one logical call (the
173
+ * `InputRequired` rounds), but unique only within its run: two runs of one conversation may
174
+ * reuse an id, so `conversationId` + `callId` is not a key. Use `idempotencyKey`.
175
+ */
125
176
  callId: string;
177
+ /**
178
+ * The key of this logical call for idempotent side effects: 64 lowercase hex characters derived
179
+ * from the conversation, the run and `callId`. The same for every invocation of the call
180
+ * (each `InputRequired` round), different for every other call, including a later call the
181
+ * model makes to retry it. Optional in the type so older extensions compile; the kernel always
182
+ * passes it.
183
+ */
184
+ idempotencyKey?: string;
126
185
  signal: AbortSignal;
127
- /** null = 用户取消或超时。 */
186
+ /** null = the user cancelled or it timed out. */
128
187
  resume?: {
129
188
  state: unknown;
130
189
  answer: FormAnswer | null;
@@ -137,26 +196,40 @@ export interface ToolCallContext {
137
196
  * always passes it.
138
197
  */
139
198
  config?: unknown;
199
+ /** Where the conversation comes from. The kernel always passes it. */
200
+ source?: ConversationSource;
201
+ /** The conversation's owner (`conversations.account_id`). The kernel always passes it; `accountId` stays the run's trigger account. */
202
+ ownerAccountId?: string;
203
+ /** The trigger account's role in the org. The kernel always passes it. */
204
+ role?: "owner" | "admin" | "member" | "guest";
140
205
  }
141
206
  export type ToolHandler = (input: unknown, ctx: ToolCallContext) => Promise<ToolResult | InputRequired>;
142
207
  /**
143
- * 工具错误的类别:
144
- * - `error`(缺省):远端可用、但这次调用失败(参数不对、业务错误、鉴权失败等),不计入连接器熔断;
145
- * - `unavailable`:远端不可用(连接 / 传输错误、超时、HTTP 5xx),计入连接器熔断(连接器用它告诉内核)。
208
+ * Tool error categories:
209
+ * - `error` (default): the remote is available but this call failed (bad parameters, business
210
+ * error, auth failure, etc.), not counted toward the connector circuit breaker;
211
+ * - `unavailable`: the remote is unavailable (connection / transport error, timeout, HTTP 5xx),
212
+ * counted toward the connector circuit breaker (connectors use it to tell the kernel).
146
213
  */
147
214
  export type ToolErrorKind = "error" | "unavailable";
148
- /** 工具执行失败:message 给模型看,须为英文且可操作。 */
215
+ /** A tool execution failure: message is for the model and must be in English and actionable. */
149
216
  export declare class ToolError extends Error {
150
217
  readonly kind: ToolErrorKind;
151
218
  constructor(message: string, opts?: {
152
219
  kind?: ToolErrorKind;
153
220
  });
154
221
  }
155
- /** 插件工具名规则。 */
222
+ /** Plugin tool name rule. */
156
223
  export declare const EXTENSION_TOOL_NAME: RegExp;
157
- /** 校验插件注册的工具声明,返回问题列表(空 = 合法)。 */
224
+ /**
225
+ * Validates the tool declarations a plugin registers and returns the list of problems (empty =
226
+ * valid).
227
+ */
158
228
  export declare function validateToolSpec(spec: ToolSpec): string[];
159
- /** 校验交互表单的声明,返回问题列表(空 = 合法)。 */
229
+ /** Validates an interactive form declaration and returns the list of problems (empty = valid). */
160
230
  export declare function validateInputForm(form: InputForm): string[];
161
- /** 校验用户提交的答案是否符合表单,返回问题列表(空 = 合法)。 */
231
+ /**
232
+ * Validates whether the answer a user submitted conforms to the form and returns the list of
233
+ * problems (empty = valid).
234
+ */
162
235
  export declare function validateAnswer(form: InputForm, answer: FormAnswer): string[];
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", "composer.box", "composer.options", "composer.send", "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;