@capybara-hq/plugin-sdk 0.1.0-rc.8 → 0.1.0-rc.81
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.
- package/README.md +1 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +11 -3
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/device-provider.md +15 -0
- package/agent-docs/extension-points/file-preview.md +3 -1
- package/agent-docs/extension-points/identity-source.md +2 -0
- package/agent-docs/extension-points/model-provider.md +3 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extensions.md +77 -4
- package/agent-docs/plugin-format.md +45 -10
- package/agent-docs/setup.md +54 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/avatar-presets.d.ts +8 -0
- package/dist/avatar-presets.js +17 -0
- package/dist/bootstrap.d.ts +109 -1
- package/dist/bootstrap.js +185 -2
- package/dist/cards.d.ts +97 -13
- package/dist/cards.js +121 -19
- package/dist/channel.d.ts +133 -47
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +28 -6
- package/dist/config-ui.js +88 -25
- package/dist/config-url-fetch.d.ts +19 -0
- package/dist/config-url-fetch.js +43 -0
- package/dist/connector-auth.d.ts +13 -2
- package/dist/connector-auth.js +82 -8
- package/dist/connector.d.ts +74 -32
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +224 -30
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +23 -13
- package/dist/define-extension.js +19 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +339 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +285 -50
- package/dist/device-protocol.js +755 -90
- package/dist/device-provider.d.ts +780 -0
- package/dist/device-provider.js +409 -0
- package/dist/device-service.d.ts +126 -0
- package/dist/device-service.js +211 -0
- package/dist/dial-in.d.ts +286 -0
- package/dist/dial-in.js +213 -0
- package/dist/directory.d.ts +15 -12
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +7 -3
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +43 -10
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +125 -20
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +71 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +70 -9
- package/dist/identity.js +46 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.js +28 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +227 -75
- package/dist/model.js +152 -19
- package/dist/native-failure.d.ts +13 -0
- package/dist/native-failure.js +31 -0
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/network-classes.d.ts +98 -0
- package/dist/network-classes.js +291 -0
- package/dist/permissions.d.ts +65 -22
- package/dist/permissions.js +139 -43
- package/dist/platform-only.d.ts +27 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +30 -6
- package/dist/plugin-manifest.js +147 -55
- package/dist/plugin-package.d.ts +82 -39
- package/dist/plugin-package.js +68 -41
- package/dist/push.d.ts +75 -0
- package/dist/push.js +87 -0
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +2343 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +480 -0
- package/dist/sandbox-runtime-source.d.ts +47 -0
- package/dist/sandbox-runtime-source.js +73 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +8 -2
- package/dist/secret.js +11 -4
- package/dist/setup-check.d.ts +128 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +356 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +86 -72
- package/dist/setup-guide.js +340 -108
- package/dist/shell-capabilities.d.ts +211 -0
- package/dist/shell-capabilities.js +44 -0
- package/dist/shell-environment.d.ts +57 -0
- package/dist/shell-environment.js +21 -0
- package/dist/skill-invocation.d.ts +5 -0
- package/dist/skill-invocation.js +4 -3
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +40 -26
- package/dist/storage.d.ts +52 -25
- package/dist/svg-viewbox.d.ts +10 -0
- package/dist/svg-viewbox.js +24 -0
- package/dist/theme-assets.d.ts +25 -9
- package/dist/theme-assets.js +87 -47
- package/dist/theme-tokens.generated.d.ts +26 -2
- package/dist/theme-tokens.generated.js +17 -0
- package/dist/theme.d.ts +48 -10
- package/dist/theme.js +100 -21
- package/dist/tool.d.ts +196 -31
- package/dist/tool.js +133 -13
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +385 -0
- package/dist/ui-resolve.d.ts +35 -0
- package/dist/ui-resolve.js +42 -0
- package/dist/ui-slots.d.ts +65 -0
- package/dist/ui-slots.js +261 -0
- package/dist/ui.d.ts +245 -77
- package/dist/ui.js +104 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/dist/web.d.ts +26 -20
- package/package.json +12 -1
- package/schemas/bootstrap-extra.v1.schema.json +186 -0
- package/schemas/bootstrap.v1.schema.json +20 -0
- package/schemas/connector-template.v1.schema.json +62 -4
- package/schemas/plugin.v1.schema.json +74 -143
- package/schemas/theme.v1.schema.json +77 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
package/dist/tool.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
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"];
|
|
5
|
+
const INPUT_VIEW_KINDS = ["file_write", "file_edit", "command", "text"];
|
|
6
|
+
/** The property names a {@link ToolInputView} refers to, by kind. */
|
|
7
|
+
function inputViewFields(view) {
|
|
8
|
+
switch (view.kind) {
|
|
9
|
+
case "file_write":
|
|
10
|
+
return [view.path, view.content];
|
|
11
|
+
case "file_edit":
|
|
12
|
+
return [view.path, view.old, view.new];
|
|
13
|
+
case "command":
|
|
14
|
+
return view.description === undefined ? [view.command] : [view.command, view.description];
|
|
15
|
+
default:
|
|
16
|
+
return [view.field];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Shortest {@link ToolSpec.timeoutMs}: one second. */
|
|
20
|
+
export const TOOL_TIMEOUT_MIN_MS = 1000;
|
|
21
|
+
/** Longest {@link ToolSpec.timeoutMs} the kernel accepts: ten minutes. */
|
|
22
|
+
export const TOOL_TIMEOUT_MAX_MS = 600_000;
|
|
3
23
|
/** Longest {@link ToolSpec.title}, in code points. */
|
|
4
24
|
export const TOOL_TITLE_MAX = 80;
|
|
5
25
|
/** Most {@link ToolSpec.keyArgs}. */
|
|
@@ -28,6 +48,11 @@ export function validateToolPresentation(spec) {
|
|
|
28
48
|
else if (typeof title === "string" && CONTROL_OR_FORMAT.test(title)) {
|
|
29
49
|
out.push("title must not contain control, bidi or invisible characters");
|
|
30
50
|
}
|
|
51
|
+
const schema = spec.inputSchema;
|
|
52
|
+
const props = typeof schema?.properties === "object" && schema.properties !== null
|
|
53
|
+
? schema.properties
|
|
54
|
+
: {};
|
|
55
|
+
out.push(...validateInputView(spec.inputView, props));
|
|
31
56
|
const keyArgs = spec.keyArgs;
|
|
32
57
|
if (keyArgs === undefined)
|
|
33
58
|
return out;
|
|
@@ -41,18 +66,40 @@ export function validateToolPresentation(spec) {
|
|
|
41
66
|
out.push("keyArgs must not repeat a name");
|
|
42
67
|
if (keyArgs.some((k) => CONTROL_OR_FORMAT.test(k)))
|
|
43
68
|
out.push("keyArgs names must not contain control, bidi or invisible characters");
|
|
44
|
-
const schema = spec.inputSchema;
|
|
45
|
-
const props = typeof schema?.properties === "object" && schema.properties !== null
|
|
46
|
-
? schema.properties
|
|
47
|
-
: {};
|
|
48
69
|
for (const k of keyArgs) {
|
|
49
70
|
if (!Object.hasOwn(props, k))
|
|
50
71
|
out.push(`keyArgs names "${k}", which is not a property of inputSchema`);
|
|
51
72
|
}
|
|
52
73
|
return out;
|
|
53
74
|
}
|
|
75
|
+
function validateInputView(view, props) {
|
|
76
|
+
if (view === undefined)
|
|
77
|
+
return [];
|
|
78
|
+
const kinds = INPUT_VIEW_KINDS.join(", ");
|
|
79
|
+
const kindProblem = `inputView kind must be one of ${kinds}`;
|
|
80
|
+
if (typeof view !== "object" || view === null || Array.isArray(view))
|
|
81
|
+
return [kindProblem];
|
|
82
|
+
const v = view;
|
|
83
|
+
if (!INPUT_VIEW_KINDS.includes(v.kind))
|
|
84
|
+
return [kindProblem];
|
|
85
|
+
const out = [];
|
|
86
|
+
for (const name of inputViewFields(v)) {
|
|
87
|
+
const label = typeof name === "string" ? name : String(name);
|
|
88
|
+
const prop = typeof name === "string" && Object.hasOwn(props, name)
|
|
89
|
+
? props[name]
|
|
90
|
+
: undefined;
|
|
91
|
+
if (typeof name !== "string" || CONTROL_OR_FORMAT.test(name) || prop?.type !== "string")
|
|
92
|
+
out.push(`inputView names "${label}", which is not a string property of inputSchema`);
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
/** The most characters of `ToolResult.card.text`. */
|
|
97
|
+
export const CARD_TEXT_MAX = 2000;
|
|
54
98
|
const DISPLAY_MAX = 200;
|
|
55
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Validates a {@link ToolDisplay} and returns the list of problems (empty = valid); length is
|
|
101
|
+
* counted in Unicode code points.
|
|
102
|
+
*/
|
|
56
103
|
export function validateToolDisplay(d) {
|
|
57
104
|
if (typeof d !== "object" || d === null || Array.isArray(d))
|
|
58
105
|
return ["display must be an object"];
|
|
@@ -67,7 +114,13 @@ export function validateToolDisplay(d) {
|
|
|
67
114
|
}
|
|
68
115
|
return out;
|
|
69
116
|
}
|
|
70
|
-
/**
|
|
117
|
+
/** The longest {@link InputForm.body}, in characters (per language). */
|
|
118
|
+
export const INPUT_FORM_BODY_MAX = 2000;
|
|
119
|
+
/** The most buttons a form's choices may draw. */
|
|
120
|
+
export const INPUT_CHOICES_MAX = 3;
|
|
121
|
+
/** The longest choice label, in characters (per language). */
|
|
122
|
+
export const INPUT_CHOICE_LABEL_MAX = 40;
|
|
123
|
+
/** A tool execution failure: message is for the model and must be in English and actionable. */
|
|
71
124
|
export class ToolError extends Error {
|
|
72
125
|
kind;
|
|
73
126
|
constructor(message, opts) {
|
|
@@ -76,9 +129,12 @@ export class ToolError extends Error {
|
|
|
76
129
|
this.kind = opts?.kind ?? "error";
|
|
77
130
|
}
|
|
78
131
|
}
|
|
79
|
-
/**
|
|
132
|
+
/** Plugin tool name rule. */
|
|
80
133
|
export const EXTENSION_TOOL_NAME = /^[a-zA-Z0-9_-]{1,40}$/;
|
|
81
|
-
/**
|
|
134
|
+
/**
|
|
135
|
+
* Validates the tool declarations a plugin registers and returns the list of problems (empty =
|
|
136
|
+
* valid).
|
|
137
|
+
*/
|
|
82
138
|
export function validateToolSpec(spec) {
|
|
83
139
|
const out = [];
|
|
84
140
|
if (typeof spec?.name !== "string" || !EXTENSION_TOOL_NAME.test(spec.name))
|
|
@@ -93,6 +149,19 @@ export function validateToolSpec(spec) {
|
|
|
93
149
|
out.push('defaultPolicy must be "allow" or "ask"');
|
|
94
150
|
if (typeof spec?.inputSchema === "object" && spec.inputSchema !== null)
|
|
95
151
|
out.push(...validateToolPresentation(spec));
|
|
152
|
+
const sources = spec?.sources;
|
|
153
|
+
if (sources !== undefined &&
|
|
154
|
+
(!Array.isArray(sources) ||
|
|
155
|
+
sources.length === 0 ||
|
|
156
|
+
sources.some((s) => !CONVERSATION_SOURCES.includes(s))))
|
|
157
|
+
out.push(`sources must be a non-empty list of ${CONVERSATION_SOURCES.join(", ")}`);
|
|
158
|
+
const timeout = spec?.timeoutMs;
|
|
159
|
+
if (timeout !== undefined &&
|
|
160
|
+
(typeof timeout !== "number" ||
|
|
161
|
+
!Number.isInteger(timeout) ||
|
|
162
|
+
timeout < TOOL_TIMEOUT_MIN_MS ||
|
|
163
|
+
timeout > TOOL_TIMEOUT_MAX_MS))
|
|
164
|
+
out.push(`timeoutMs must be a whole number of milliseconds from ${TOOL_TIMEOUT_MIN_MS} to ${TOOL_TIMEOUT_MAX_MS}`);
|
|
96
165
|
return out;
|
|
97
166
|
}
|
|
98
167
|
const SCHEMA_KEYS = {
|
|
@@ -101,7 +170,7 @@ const SCHEMA_KEYS = {
|
|
|
101
170
|
number: ["type", "minimum", "maximum"],
|
|
102
171
|
integer: ["type", "minimum", "maximum"],
|
|
103
172
|
};
|
|
104
|
-
/**
|
|
173
|
+
/** Checks whether a schema falls within the ParamSchema subset and returns the list of problems. */
|
|
105
174
|
function schemaProblems(schema) {
|
|
106
175
|
if (typeof schema !== "object" || schema === null || Array.isArray(schema))
|
|
107
176
|
return ["schema must be an object"];
|
|
@@ -130,7 +199,7 @@ function schemaProblems(schema) {
|
|
|
130
199
|
return out;
|
|
131
200
|
}
|
|
132
201
|
const isEnum = (s) => s.type === "string" && "enum" in s;
|
|
133
|
-
/**
|
|
202
|
+
/** Validates an interactive form declaration and returns the list of problems (empty = valid). */
|
|
134
203
|
export function validateInputForm(form) {
|
|
135
204
|
const out = [];
|
|
136
205
|
if (!form || !Array.isArray(form.fields))
|
|
@@ -139,6 +208,8 @@ export function validateInputForm(form) {
|
|
|
139
208
|
out.push("form must have at least one field");
|
|
140
209
|
if (form.url !== undefined && !isHttpUrl(form.url))
|
|
141
210
|
out.push("url must be an absolute http(s) URL of at most 2000 characters");
|
|
211
|
+
if (form.body !== undefined && !textWithin(form.body, INPUT_FORM_BODY_MAX))
|
|
212
|
+
out.push(`body must be non-empty text of at most ${INPUT_FORM_BODY_MAX} characters`);
|
|
142
213
|
const seen = new Set();
|
|
143
214
|
for (const f of form.fields) {
|
|
144
215
|
const at = `field ${JSON.stringify(f?.key)}`;
|
|
@@ -156,10 +227,56 @@ export function validateInputForm(form) {
|
|
|
156
227
|
continue;
|
|
157
228
|
if ((f.multiSelect || f.allowOther) && !isEnum(f.schema))
|
|
158
229
|
out.push(`${at}: multiSelect and allowOther require a string enum schema`);
|
|
230
|
+
if (f.choices !== undefined)
|
|
231
|
+
out.push(...choicesProblems(form, f).map((p) => `${at}: ${p}`));
|
|
232
|
+
}
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
/** Non-empty text (a string or both languages) of at most `max` characters per language. */
|
|
236
|
+
function textWithin(t, max) {
|
|
237
|
+
const ok = (x) => typeof x === "string" && x.trim() !== "" && x.length <= max;
|
|
238
|
+
if (typeof t === "string")
|
|
239
|
+
return ok(t);
|
|
240
|
+
return (typeof t === "object" &&
|
|
241
|
+
t !== null &&
|
|
242
|
+
ok(t.zh) &&
|
|
243
|
+
ok(t.en));
|
|
244
|
+
}
|
|
245
|
+
/** The rules of {@link InputForm} `choices` (buttons): see the field's documentation. */
|
|
246
|
+
function choicesProblems(form, f) {
|
|
247
|
+
const out = [];
|
|
248
|
+
const c = f.choices;
|
|
249
|
+
if (!Array.isArray(c) || c.length === 0 || c.length > INPUT_CHOICES_MAX)
|
|
250
|
+
return [`choices must be an array of 1 to ${INPUT_CHOICES_MAX} items`];
|
|
251
|
+
if (form.fields.length !== 1)
|
|
252
|
+
out.push("choices are allowed only on a form's single field");
|
|
253
|
+
if (f.required !== true)
|
|
254
|
+
out.push("choices require required: true");
|
|
255
|
+
const bool = f.schema.type === "boolean";
|
|
256
|
+
const single = isEnum(f.schema) && !f.multiSelect && !f.allowOther;
|
|
257
|
+
if (!bool && !single)
|
|
258
|
+
out.push("choices require a boolean or a single-choice string enum (no multiSelect / allowOther)");
|
|
259
|
+
const seen = new Set();
|
|
260
|
+
for (const x of c) {
|
|
261
|
+
const v = x?.value;
|
|
262
|
+
const valid = bool
|
|
263
|
+
? typeof v === "boolean"
|
|
264
|
+
: single && typeof v === "string" && f.schema.enum.includes(v);
|
|
265
|
+
if (!valid)
|
|
266
|
+
out.push(`choice value ${JSON.stringify(v)} is not a value of the field`);
|
|
267
|
+
else if (seen.has(v))
|
|
268
|
+
out.push(`duplicate choice value ${JSON.stringify(v)}`);
|
|
269
|
+
else
|
|
270
|
+
seen.add(v);
|
|
271
|
+
if (!textWithin(x?.label, INPUT_CHOICE_LABEL_MAX))
|
|
272
|
+
out.push(`choice label must be non-empty text of at most ${INPUT_CHOICE_LABEL_MAX} characters`);
|
|
159
273
|
}
|
|
160
274
|
return out;
|
|
161
275
|
}
|
|
162
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* Validates whether the answer a user submitted conforms to the form and returns the list of
|
|
278
|
+
* problems (empty = valid).
|
|
279
|
+
*/
|
|
163
280
|
export function validateAnswer(form, answer) {
|
|
164
281
|
const out = [];
|
|
165
282
|
const byKey = new Map(form.fields.map((f) => [f.key, f]));
|
|
@@ -168,7 +285,8 @@ export function validateAnswer(form, answer) {
|
|
|
168
285
|
out.push(`unknown field ${JSON.stringify(k)}`);
|
|
169
286
|
for (const f of form.fields) {
|
|
170
287
|
const at = `field ${JSON.stringify(f.key)}`;
|
|
171
|
-
//
|
|
288
|
+
// Look only at the answer's own keys: inherited properties such as `toString` / `constructor`
|
|
289
|
+
// do not count as answered
|
|
172
290
|
const v = Object.hasOwn(answer, f.key) ? answer[f.key] : undefined;
|
|
173
291
|
if (v === undefined) {
|
|
174
292
|
if (f.required)
|
|
@@ -209,7 +327,9 @@ export function validateAnswer(form, answer) {
|
|
|
209
327
|
}
|
|
210
328
|
return out;
|
|
211
329
|
}
|
|
212
|
-
/**
|
|
330
|
+
/**
|
|
331
|
+
* An allowOther enum field accepts any non-empty text; the rest are validated against the schema.
|
|
332
|
+
*/
|
|
213
333
|
function otherOrValue(f, v) {
|
|
214
334
|
if (f.allowOther && isEnum(f.schema)) {
|
|
215
335
|
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;
|
package/dist/ui-parts.js
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
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
|
+
"composer.box",
|
|
16
|
+
"composer.options",
|
|
17
|
+
"composer.send",
|
|
18
|
+
"properties-panel",
|
|
19
|
+
"section",
|
|
20
|
+
"right-panel",
|
|
21
|
+
"status-bar",
|
|
22
|
+
"button",
|
|
23
|
+
"button.primary",
|
|
24
|
+
"card",
|
|
25
|
+
"input",
|
|
26
|
+
"dialog",
|
|
27
|
+
"code-block",
|
|
28
|
+
"menu",
|
|
29
|
+
"segmented",
|
|
30
|
+
"stat-card",
|
|
31
|
+
"switch",
|
|
32
|
+
"switch.knob",
|
|
33
|
+
"org-avatar",
|
|
34
|
+
"agent-chip",
|
|
35
|
+
"image-placeholder",
|
|
36
|
+
];
|
|
37
|
+
export const UI_PARTS = [
|
|
38
|
+
{
|
|
39
|
+
name: "shell",
|
|
40
|
+
version: 1,
|
|
41
|
+
owner: ["packages/design/src/shell/app-shell.tsx"],
|
|
42
|
+
states: [],
|
|
43
|
+
description: {
|
|
44
|
+
en: "The App Shell root.",
|
|
45
|
+
zh: "应用外壳的根节点。",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "sidebar",
|
|
50
|
+
version: 1,
|
|
51
|
+
owner: ["packages/design/src/shell/sidebar.tsx"],
|
|
52
|
+
states: [],
|
|
53
|
+
description: {
|
|
54
|
+
en: "The left sidebar.",
|
|
55
|
+
zh: "左侧边栏。",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "sidebar.brand",
|
|
60
|
+
version: 1,
|
|
61
|
+
owner: ["packages/design/src/shell/sidebar.tsx"],
|
|
62
|
+
states: [],
|
|
63
|
+
description: {
|
|
64
|
+
en: "The brand row of the sidebar.",
|
|
65
|
+
zh: "侧边栏的品牌行。",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "sidebar.item",
|
|
70
|
+
version: 1,
|
|
71
|
+
owner: [
|
|
72
|
+
"packages/design/src/shell/sidebar.tsx",
|
|
73
|
+
"packages/design/src/shell/sidebar-conversations.tsx",
|
|
74
|
+
],
|
|
75
|
+
states: ["aria-current"],
|
|
76
|
+
description: {
|
|
77
|
+
en: "A navigation or conversation row of the sidebar.",
|
|
78
|
+
zh: "侧边栏的导航行或对话行。",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "title-bar",
|
|
83
|
+
version: 1,
|
|
84
|
+
owner: ["packages/design/src/conversation/title-bar.tsx"],
|
|
85
|
+
states: [],
|
|
86
|
+
description: {
|
|
87
|
+
en: "The conversation title bar.",
|
|
88
|
+
zh: "对话标题栏。",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "page-header",
|
|
93
|
+
version: 1,
|
|
94
|
+
owner: ["packages/design/src/shell/page-header.tsx"],
|
|
95
|
+
states: [],
|
|
96
|
+
description: {
|
|
97
|
+
en: "The header of a page.",
|
|
98
|
+
zh: "页面头部。",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "thread",
|
|
103
|
+
version: 1,
|
|
104
|
+
owner: ["packages/design/src/templates/conversation-page.tsx"],
|
|
105
|
+
states: ["aria-busy"],
|
|
106
|
+
description: {
|
|
107
|
+
en: "The conversation stream.",
|
|
108
|
+
zh: "对话消息流。",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "message.user",
|
|
113
|
+
version: 1,
|
|
114
|
+
owner: ["packages/design/src/conversation/bubble.tsx"],
|
|
115
|
+
states: [],
|
|
116
|
+
description: {
|
|
117
|
+
en: "A person's message.",
|
|
118
|
+
zh: "用户发出的消息。",
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "message.user.bubble",
|
|
123
|
+
version: 1,
|
|
124
|
+
owner: ["packages/design/src/conversation/bubble.tsx"],
|
|
125
|
+
states: [],
|
|
126
|
+
description: {
|
|
127
|
+
en: "The bubble of a person's message (inside the full-width `message.user` row).",
|
|
128
|
+
zh: "用户消息的气泡本身(在占满宽度的 message.user 行之内)。",
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "message.assistant",
|
|
133
|
+
version: 1,
|
|
134
|
+
owner: ["apps/web/src/components/conversation/Thread.tsx"],
|
|
135
|
+
states: ["aria-busy"],
|
|
136
|
+
description: {
|
|
137
|
+
en: "An assistant turn; `aria-busy` while its text is still streaming (the live reply).",
|
|
138
|
+
zh: "智能体的一轮回复;正在流式输出时带 aria-busy(正在生成的回复)。",
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "tool-row",
|
|
143
|
+
version: 1,
|
|
144
|
+
owner: ["packages/design/src/conversation/tool-row.tsx"],
|
|
145
|
+
states: ["aria-expanded"],
|
|
146
|
+
description: {
|
|
147
|
+
en: "A tool call line.",
|
|
148
|
+
zh: "工具调用行。",
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "composer",
|
|
153
|
+
version: 1,
|
|
154
|
+
owner: ["packages/design/src/conversation/composer.tsx"],
|
|
155
|
+
states: ["aria-busy"],
|
|
156
|
+
description: {
|
|
157
|
+
en: "The whole composer: the token warning, the attachments, the text box and the control row. From 600 up with a fine pointer it is the box; in the mobile form (below 600, or a touch device at any width) it draws nothing and `composer.box` is the floating pill, the control row around it.",
|
|
158
|
+
zh: "整个输入框:令牌提醒、附件、文本框与控件行。600 及以上且为精确指针时它就是那个框;移动形态(600 以下,或任意宽度的触屏设备)下它不画任何东西,`composer.box` 是浮动的胶囊,控件行在其上下。",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "composer.box",
|
|
163
|
+
version: 1,
|
|
164
|
+
owner: ["packages/design/src/conversation/composer.tsx"],
|
|
165
|
+
states: [],
|
|
166
|
+
description: {
|
|
167
|
+
en: "The composer's text box: the text with the attach and send buttons. In the mobile form it is the floating pill (round ends, `:focus-within` while the text or one of its buttons has focus, never for the control row); from 600 up with a fine pointer it draws no box of its own (`display: contents`).",
|
|
168
|
+
zh: "输入框的文本框:文字与添加、发送按钮。移动形态下它是浮动胶囊(圆头;文字或其中按钮获得焦点时 `:focus-within`,控件行获得焦点时不会);600 及以上且为精确指针时它不画自己的框(`display: contents`)。",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: "composer.options",
|
|
173
|
+
version: 1,
|
|
174
|
+
owner: ["packages/design/src/conversation/composer-options.tsx"],
|
|
175
|
+
states: ["aria-expanded"],
|
|
176
|
+
description: {
|
|
177
|
+
en: "The composer's settings chip (model, effort, device, permission) opening the options sheet: in the mobile form only, above the pill.",
|
|
178
|
+
zh: "输入框的设置胶囊(模型、推理强度、设备、权限),打开选项面板:仅移动形态,位于胶囊上方。",
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
name: "composer.send",
|
|
183
|
+
version: 1,
|
|
184
|
+
owner: ["packages/design/src/conversation/composer.tsx"],
|
|
185
|
+
states: ["disabled", "aria-busy"],
|
|
186
|
+
description: {
|
|
187
|
+
en: "The composer's send button, and the stop button in its place while a run is going (its `aria-label` tells them apart). In the mobile form a round button inside `composer.box`.",
|
|
188
|
+
zh: "输入框的发送按钮,运行中同一位置的停止按钮(以 `aria-label` 区分)。移动形态下是 `composer.box` 内的圆形按钮。",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "properties-panel",
|
|
193
|
+
version: 1,
|
|
194
|
+
owner: ["packages/design/src/conversation/panels.tsx"],
|
|
195
|
+
states: [],
|
|
196
|
+
description: {
|
|
197
|
+
en: "The conversation properties panel.",
|
|
198
|
+
zh: "对话属性面板。",
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "section",
|
|
203
|
+
version: 1,
|
|
204
|
+
owner: [
|
|
205
|
+
"packages/design/src/conversation/panels.tsx",
|
|
206
|
+
"packages/design/src/templates/form-page.tsx",
|
|
207
|
+
],
|
|
208
|
+
states: [],
|
|
209
|
+
description: {
|
|
210
|
+
en: "A property section or form section.",
|
|
211
|
+
zh: "属性分区或表单分区。",
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
name: "right-panel",
|
|
216
|
+
version: 1,
|
|
217
|
+
owner: ["packages/design/src/conversation/panels.tsx"],
|
|
218
|
+
states: [],
|
|
219
|
+
description: {
|
|
220
|
+
en: "A full-height right pane.",
|
|
221
|
+
zh: "占满高度的右侧窗格。",
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "status-bar",
|
|
226
|
+
version: 1,
|
|
227
|
+
owner: ["packages/design/src/shell/status-bar.tsx"],
|
|
228
|
+
states: [],
|
|
229
|
+
description: {
|
|
230
|
+
en: "The status bar.",
|
|
231
|
+
zh: "状态栏。",
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: "button",
|
|
236
|
+
version: 1,
|
|
237
|
+
owner: [
|
|
238
|
+
"packages/design/src/controls/button.tsx",
|
|
239
|
+
"packages/design/src/conversation/composer.tsx",
|
|
240
|
+
"packages/design/src/conversation/composer-options.tsx",
|
|
241
|
+
],
|
|
242
|
+
states: ["disabled"],
|
|
243
|
+
description: {
|
|
244
|
+
en: "Every button.",
|
|
245
|
+
zh: "所有按钮。",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "button.primary",
|
|
250
|
+
version: 1,
|
|
251
|
+
owner: ["packages/design/src/controls/button.tsx"],
|
|
252
|
+
states: ["disabled"],
|
|
253
|
+
description: {
|
|
254
|
+
en: "A primary button (carried together with `button`).",
|
|
255
|
+
zh: "主按钮(与 button 同时出现)。",
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "card",
|
|
260
|
+
version: 1,
|
|
261
|
+
owner: [
|
|
262
|
+
"packages/design/src/layout/index.tsx",
|
|
263
|
+
"packages/design/src/conversation/panels.tsx",
|
|
264
|
+
"packages/design/src/display/card-grid.tsx",
|
|
265
|
+
],
|
|
266
|
+
states: [],
|
|
267
|
+
description: {
|
|
268
|
+
en: "A card, inline card or object card.",
|
|
269
|
+
zh: "卡片、行内卡片或对象卡片。",
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
name: "input",
|
|
274
|
+
version: 1,
|
|
275
|
+
owner: ["packages/design/src/controls/inputs.tsx", "packages/design/src/controls/select.tsx"],
|
|
276
|
+
states: ["disabled"],
|
|
277
|
+
description: {
|
|
278
|
+
en: "Text inputs, textareas and selects.",
|
|
279
|
+
zh: "文本框、多行文本框和下拉选择。",
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: "dialog",
|
|
284
|
+
version: 1,
|
|
285
|
+
owner: ["packages/design/src/overlays/dialog.tsx", "packages/design/src/overlays/sheet.tsx"],
|
|
286
|
+
states: [],
|
|
287
|
+
description: {
|
|
288
|
+
en: "A dialog or sheet.",
|
|
289
|
+
zh: "对话框或抽屉。",
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name: "code-block",
|
|
294
|
+
version: 1,
|
|
295
|
+
owner: ["packages/design/src/display/chat.tsx"],
|
|
296
|
+
states: [],
|
|
297
|
+
description: {
|
|
298
|
+
en: "A code block (Markdown code, setup guides, diffs).",
|
|
299
|
+
zh: "代码块(Markdown 代码、设置指引、差异)。",
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: "menu",
|
|
304
|
+
version: 1,
|
|
305
|
+
owner: ["packages/design/src/overlays/menus.tsx", "packages/design/src/conversation/menu.tsx"],
|
|
306
|
+
states: [],
|
|
307
|
+
description: {
|
|
308
|
+
en: "A menu, submenu, popover or the composer's menus.",
|
|
309
|
+
zh: "菜单、子菜单、弹出层或输入框的菜单。",
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: "segmented",
|
|
314
|
+
version: 1,
|
|
315
|
+
owner: ["packages/design/src/display/tabs.tsx"],
|
|
316
|
+
states: [],
|
|
317
|
+
description: {
|
|
318
|
+
en: "A segmented control (its segments are radios with `aria-checked`).",
|
|
319
|
+
zh: "分段控件(各段是带 aria-checked 的单选项)。",
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
name: "stat-card",
|
|
324
|
+
version: 1,
|
|
325
|
+
owner: ["packages/design/src/display/stat-cards.tsx"],
|
|
326
|
+
states: [],
|
|
327
|
+
description: {
|
|
328
|
+
en: "A metric card of a StatCards row.",
|
|
329
|
+
zh: "指标卡片行里的一张指标卡。",
|
|
330
|
+
},
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: "switch",
|
|
334
|
+
version: 1,
|
|
335
|
+
owner: ["packages/design/src/controls/toggles.tsx"],
|
|
336
|
+
states: ["aria-checked", "disabled"],
|
|
337
|
+
description: {
|
|
338
|
+
en: "A switch; `aria-checked` says on or off.",
|
|
339
|
+
zh: "开关;aria-checked 表示开或关。",
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "switch.knob",
|
|
344
|
+
version: 1,
|
|
345
|
+
owner: ["packages/design/src/controls/toggles.tsx"],
|
|
346
|
+
states: [],
|
|
347
|
+
description: {
|
|
348
|
+
en: "The knob inside a `switch` (style it from the switch's state).",
|
|
349
|
+
zh: "开关里的滑块(按所在开关的状态设置样式)。",
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
name: "org-avatar",
|
|
354
|
+
version: 1,
|
|
355
|
+
owner: ["packages/design/src/shell/sidebar.tsx"],
|
|
356
|
+
states: [],
|
|
357
|
+
description: {
|
|
358
|
+
en: "The org's initial block in the sidebar's org switcher.",
|
|
359
|
+
zh: "侧边栏组织切换器里的组织首字方块。",
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
name: "agent-chip",
|
|
364
|
+
version: 1,
|
|
365
|
+
owner: ["packages/design/src/conversation/agent-row.tsx"],
|
|
366
|
+
states: ["aria-pressed"],
|
|
367
|
+
description: {
|
|
368
|
+
en: "An agent chip of the new conversation's agents row; `aria-pressed` on the selected one.",
|
|
369
|
+
zh: "新会话智能体行里的智能体标签;选中的那个带 aria-pressed。",
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
name: "image-placeholder",
|
|
374
|
+
version: 1,
|
|
375
|
+
owner: ["packages/design/src/conversation/files.tsx"],
|
|
376
|
+
states: ["aria-busy"],
|
|
377
|
+
description: {
|
|
378
|
+
en: "A generating image's placeholder in the conversation.",
|
|
379
|
+
zh: "对话中正在生成的图片的占位框。",
|
|
380
|
+
},
|
|
381
|
+
},
|
|
382
|
+
];
|
|
383
|
+
export function uiPart(name) {
|
|
384
|
+
return UI_PARTS.find((p) => p.name === name);
|
|
385
|
+
}
|
|
@@ -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
|
+
};
|