@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.
- 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 +7 -1
- 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 +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 +29 -3
- package/agent-docs/plugin-format.md +52 -2
- 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 +67 -13
- package/dist/cards.js +91 -21
- package/dist/channel.d.ts +148 -48
- 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 +22 -0
- package/dist/config-ui.js +64 -4
- package/dist/connector-auth.d.ts +15 -2
- package/dist/connector-auth.js +97 -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 +132 -29
- package/dist/define-extension.d.ts +26 -12
- package/dist/define-extension.js +12 -5
- package/dist/device-denied-paths.d.ts +18 -0
- package/dist/device-denied-paths.js +84 -0
- package/dist/device-operation.d.ts +333 -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 +503 -0
- package/dist/device-provider.js +302 -0
- package/dist/dial-in.d.ts +176 -0
- package/dist/dial-in.js +115 -0
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +6 -2
- package/dist/file-preview.d.ts +23 -6
- 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 +62 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +38 -9
- package/dist/identity.js +21 -1
- package/dist/index.d.ts +29 -3
- package/dist/index.js +29 -3
- package/dist/marketplace.d.ts +26 -0
- package/dist/marketplace.js +43 -1
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +206 -71
- package/dist/model.js +152 -19
- 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 +54 -22
- package/dist/permissions.js +119 -43
- package/dist/plugin-manifest.d.ts +45 -5
- package/dist/plugin-manifest.js +174 -6
- package/dist/plugin-package.d.ts +82 -38
- package/dist/plugin-package.js +61 -29
- 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 +2318 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +476 -0
- package/dist/sandbox-runtime-source.d.ts +19 -0
- package/dist/sandbox-runtime-source.js +28 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +4 -1
- package/dist/secret.js +4 -1
- 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 +108 -0
- package/dist/setup-guide.js +367 -0
- 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.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 +55 -0
- package/dist/theme-assets.js +489 -0
- package/dist/theme-readability.d.ts +37 -0
- package/dist/theme-readability.js +145 -0
- package/dist/theme-tokens.generated.d.ts +299 -0
- package/dist/theme-tokens.generated.js +184 -0
- package/dist/theme.d.ts +190 -0
- package/dist/theme.js +471 -0
- package/dist/tool.d.ts +99 -26
- package/dist/tool.js +29 -9
- 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 +212 -76
- package/dist/ui.js +101 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/package.json +13 -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 +35 -0
- package/schemas/marketplace.v1.schema.json +14 -0
- package/schemas/plugin.v1.schema.json +122 -3
- package/schemas/theme.v1.schema.json +302 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
package/dist/permissions.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { DEVICE_PROVIDER_EXTENSION_POINT } from "./device-provider.js";
|
|
2
|
+
import { DIAL_IN_PROTOCOL_RE } from "./dial-in.js";
|
|
1
3
|
import { POLICY_HOOKS } from "./hooks.js";
|
|
4
|
+
import { HTTP_ACCESS } from "./http-access.js";
|
|
5
|
+
import { SETUP_CHECK_ID_RE, SETUP_CHECK_LIMITS } from "./setup-check.js";
|
|
2
6
|
import { UI_ICONS } from "./ui.js";
|
|
3
|
-
|
|
7
|
+
import { isCompactForm, parseSlotRef, uiSlot } from "./ui-slots.js";
|
|
8
|
+
/** Hook mount points (a closed list, see the overall design 2.4). */
|
|
4
9
|
export const HOOK_MOUNT_POINTS = [
|
|
5
10
|
"session.start",
|
|
6
11
|
"session.end",
|
|
@@ -10,6 +15,9 @@ export const HOOK_MOUNT_POINTS = [
|
|
|
10
15
|
"tool.preExecute",
|
|
11
16
|
"tool.postExecute",
|
|
12
17
|
"usage.report",
|
|
18
|
+
"org.member_removed",
|
|
19
|
+
"agent.deleted",
|
|
20
|
+
"org.deleted",
|
|
13
21
|
];
|
|
14
22
|
const HOOKS = new Set(HOOK_MOUNT_POINTS);
|
|
15
23
|
/** A platform API not declared in the manifest was used. */
|
|
@@ -36,6 +44,9 @@ const KEYS = new Set([
|
|
|
36
44
|
"storage",
|
|
37
45
|
"network",
|
|
38
46
|
"ui",
|
|
47
|
+
"client",
|
|
48
|
+
"setupChecks",
|
|
49
|
+
"dialIn",
|
|
39
50
|
]);
|
|
40
51
|
const POLICY = new Set(POLICY_HOOKS);
|
|
41
52
|
const METHODS = new Set(["GET", "POST", "PUT", "DELETE"]);
|
|
@@ -57,8 +68,11 @@ function strList(label, v, errs) {
|
|
|
57
68
|
}
|
|
58
69
|
return out;
|
|
59
70
|
}
|
|
60
|
-
/**
|
|
61
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Validates the permission manifest and returns the list of errors (empty means valid). `provides`
|
|
73
|
+
* is the manifest's `provides` (`permissions.dialIn` needs `device-provider@1` in it).
|
|
74
|
+
*/
|
|
75
|
+
export function validatePermissions(plugin, p, provides = []) {
|
|
62
76
|
if (p === undefined)
|
|
63
77
|
return [];
|
|
64
78
|
if (!isObj(p))
|
|
@@ -68,7 +82,7 @@ export function validatePermissions(plugin, p) {
|
|
|
68
82
|
if (!KEYS.has(k))
|
|
69
83
|
errs.push(`unknown permissions key "${k}"`);
|
|
70
84
|
}
|
|
71
|
-
for (const k of ["secrets", "storage"]) {
|
|
85
|
+
for (const k of ["secrets", "storage", "client"]) {
|
|
72
86
|
if (p[k] !== undefined && typeof p[k] !== "boolean") {
|
|
73
87
|
errs.push(`permissions.${k} must be a boolean`);
|
|
74
88
|
}
|
|
@@ -110,14 +124,27 @@ export function validatePermissions(plugin, p) {
|
|
|
110
124
|
!METHODS.has(r.method) ||
|
|
111
125
|
typeof r.path !== "string" ||
|
|
112
126
|
!r.path.startsWith("/") ||
|
|
113
|
-
|
|
114
|
-
|
|
127
|
+
typeof r.access !== "string" ||
|
|
128
|
+
!HTTP_ACCESS.includes(r.access)) {
|
|
129
|
+
errs.push("permissions.http entries need method GET/POST/PUT/DELETE, a path starting with /, and access public/embed/member/admin");
|
|
115
130
|
continue;
|
|
116
131
|
}
|
|
117
132
|
const key = `${r.method} ${r.path}`;
|
|
118
133
|
if (seen.has(key))
|
|
119
134
|
errs.push(`permissions.http has duplicate route "${key}"`);
|
|
120
135
|
seen.add(key);
|
|
136
|
+
if (r.path === "/orgs" || r.path.startsWith("/orgs/")) {
|
|
137
|
+
errs.push(`permissions.http route "${key}" must not start with /orgs/ (reserved for org routes)`);
|
|
138
|
+
}
|
|
139
|
+
if (r.access === "embed" && !r.path.startsWith(UI_EMBED_PREFIX)) {
|
|
140
|
+
errs.push(`permissions.http embed route "${key}" must be under ${UI_EMBED_PREFIX}`);
|
|
141
|
+
}
|
|
142
|
+
if ((r.access === "member" || r.access === "admin") &&
|
|
143
|
+
// anywhere, not only after a slash: find-my-way lets a later duplicate param win, so
|
|
144
|
+
// `/x-:orgId` would override the mount's `:orgId`
|
|
145
|
+
/:orgId(?![A-Za-z0-9_])/.test(r.path)) {
|
|
146
|
+
errs.push(`permissions.http route "${key}" must not contain :orgId (the org comes from the mount)`);
|
|
147
|
+
}
|
|
121
148
|
}
|
|
122
149
|
}
|
|
123
150
|
}
|
|
@@ -126,9 +153,11 @@ export function validatePermissions(plugin, p) {
|
|
|
126
153
|
errs.push("permissions.ui must be an object");
|
|
127
154
|
else {
|
|
128
155
|
for (const k of Object.keys(p.ui)) {
|
|
129
|
-
if (k !== "views" && k !== "embeds")
|
|
156
|
+
if (k !== "views" && k !== "embeds" && k !== "components")
|
|
130
157
|
errs.push(`unknown permissions.ui key "${k}"`);
|
|
131
158
|
}
|
|
159
|
+
if (p.ui.components !== undefined)
|
|
160
|
+
strList("permissions.ui.components", p.ui.components, errs);
|
|
132
161
|
const views = p.ui.views === undefined ? [] : strList("permissions.ui.views", p.ui.views, errs);
|
|
133
162
|
const embeds = p.ui.embeds === undefined ? [] : strList("permissions.ui.embeds", p.ui.embeds, errs);
|
|
134
163
|
for (const id of views) {
|
|
@@ -137,6 +166,17 @@ export function validatePermissions(plugin, p) {
|
|
|
137
166
|
}
|
|
138
167
|
}
|
|
139
168
|
}
|
|
169
|
+
if (p.setupChecks !== undefined) {
|
|
170
|
+
const ids = strList("permissions.setupChecks", p.setupChecks, errs);
|
|
171
|
+
for (const id of ids) {
|
|
172
|
+
if (!SETUP_CHECK_ID_RE.test(id)) {
|
|
173
|
+
errs.push(`permissions.setupChecks id "${id}" must match ${SETUP_CHECK_ID_RE}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (ids.length > SETUP_CHECK_LIMITS.idsPerExtension) {
|
|
177
|
+
errs.push(`permissions.setupChecks has more than ${SETUP_CHECK_LIMITS.idsPerExtension} ids`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
140
180
|
if (p.models !== undefined) {
|
|
141
181
|
if (!Array.isArray(p.models))
|
|
142
182
|
errs.push("permissions.models must be an array");
|
|
@@ -146,13 +186,13 @@ export function validatePermissions(plugin, p) {
|
|
|
146
186
|
const label = isObj(m) && isObj(m.label) ? m.label : undefined;
|
|
147
187
|
if (!isObj(m) ||
|
|
148
188
|
typeof m.purpose !== "string" ||
|
|
149
|
-
(m.kind !== "chat" && m.kind !== "embedding") ||
|
|
189
|
+
(m.kind !== "chat" && m.kind !== "embedding" && m.kind !== "image_generation") ||
|
|
150
190
|
!label ||
|
|
151
191
|
typeof label.zh !== "string" ||
|
|
152
192
|
label.zh === "" ||
|
|
153
193
|
typeof label.en !== "string" ||
|
|
154
194
|
label.en === "") {
|
|
155
|
-
errs.push("permissions.models entries need purpose, kind chat/embedding
|
|
195
|
+
errs.push("permissions.models entries need purpose, kind chat/embedding/image_generation, label zh/en");
|
|
156
196
|
continue;
|
|
157
197
|
}
|
|
158
198
|
if (!m.purpose.startsWith(`${plugin}.`) || m.purpose.length === plugin.length + 1) {
|
|
@@ -164,24 +204,35 @@ export function validatePermissions(plugin, p) {
|
|
|
164
204
|
}
|
|
165
205
|
}
|
|
166
206
|
}
|
|
207
|
+
if (p.dialIn !== undefined) {
|
|
208
|
+
if (!isObj(p.dialIn) ||
|
|
209
|
+
Object.keys(p.dialIn).some((k) => k !== "protocol") ||
|
|
210
|
+
typeof p.dialIn.protocol !== "string" ||
|
|
211
|
+
!DIAL_IN_PROTOCOL_RE.test(p.dialIn.protocol)) {
|
|
212
|
+
errs.push(`permissions.dialIn must be { protocol: "<name>/<major>" } matching ${DIAL_IN_PROTOCOL_RE}`);
|
|
213
|
+
}
|
|
214
|
+
if (!provides.includes(DEVICE_PROVIDER_EXTENSION_POINT)) {
|
|
215
|
+
errs.push(`permissions.dialIn needs "${DEVICE_PROVIDER_EXTENSION_POINT}" in provides`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
167
218
|
return errs;
|
|
168
219
|
}
|
|
169
220
|
const UI_ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
170
221
|
const UI_TITLE_MAX = 100;
|
|
171
|
-
const UI_PLACES = [
|
|
172
|
-
"conversation",
|
|
173
|
-
"panel",
|
|
174
|
-
"section",
|
|
175
|
-
"inline",
|
|
176
|
-
"page",
|
|
177
|
-
"file-preview",
|
|
178
|
-
];
|
|
179
222
|
const UI_EMBED_PREFIX = "/ui/";
|
|
180
223
|
/**
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
224
|
+
* Checks the structure of the manifest's `ui` and cross-checks it with the permission manifest;
|
|
225
|
+
* returns the problems (empty = valid). Only structural problems (UI slots spec §3.2, client
|
|
226
|
+
* extensions spec §5.1): each contribution's id is listed in the list of its kind,
|
|
227
|
+
* `permissions.ui.views` (view), `permissions.ui.embeds` (embed) or `permissions.ui.components`
|
|
228
|
+
* (component), an id is in at most one of the three, and `permissions.ui` lists no id the `ui`
|
|
229
|
+
* lacks; `permissions.ui.components` needs `permissions.client: true`; an embed's path starts with
|
|
230
|
+
* `/ui/` and is declared in `permissions.http` as GET, a view or component has no path; exactly one
|
|
231
|
+
* of `slot` (a well-formed slot reference) and `place` (a known place); for a slot the catalog
|
|
232
|
+
* knows at the version named, a kind it accepts and, unless an alias, the icon it requires. An
|
|
233
|
+
* unknown slot id or version is not a problem here: `resolveUiSlots` drops that contribution and
|
|
234
|
+
* the rest of the extension loads.
|
|
235
|
+
* Assumes `permissions` passed {@link validatePermissions}.
|
|
185
236
|
*/
|
|
186
237
|
export function validateUiContributions(ui, permissions) {
|
|
187
238
|
const perms = isObj(permissions) ? permissions : {};
|
|
@@ -191,10 +242,21 @@ export function validateUiContributions(ui, permissions) {
|
|
|
191
242
|
: [];
|
|
192
243
|
const views = listed("views");
|
|
193
244
|
const embeds = listed("embeds");
|
|
245
|
+
const components = listed("components");
|
|
246
|
+
// an id in more than one list is reported once, not again as a mismatch of each list
|
|
247
|
+
const multiListed = new Set();
|
|
248
|
+
for (const id of new Set([...views, ...embeds, ...components])) {
|
|
249
|
+
if ([views, embeds, components].filter((l) => l.includes(id)).length > 1)
|
|
250
|
+
multiListed.add(id);
|
|
251
|
+
}
|
|
194
252
|
const gets = new Set((Array.isArray(perms.http) ? perms.http : [])
|
|
195
|
-
.filter((r) => isObj(r) && r.method === "GET")
|
|
253
|
+
.filter((r) => isObj(r) && r.method === "GET" && r.access === "public")
|
|
196
254
|
.map((r) => r.path));
|
|
197
255
|
const errs = [];
|
|
256
|
+
for (const id of multiListed)
|
|
257
|
+
errs.push(`ui "${id}" is listed in more than one of permissions.ui.views / embeds / components`);
|
|
258
|
+
if (components.length > 0 && perms.client !== true)
|
|
259
|
+
errs.push("permissions.ui.components needs permissions.client: true");
|
|
198
260
|
const contributions = [];
|
|
199
261
|
if (ui !== undefined) {
|
|
200
262
|
if (!Array.isArray(ui))
|
|
@@ -203,7 +265,6 @@ export function validateUiContributions(ui, permissions) {
|
|
|
203
265
|
contributions.push(...ui);
|
|
204
266
|
}
|
|
205
267
|
const seen = new Map();
|
|
206
|
-
const aliases = [];
|
|
207
268
|
contributions.forEach((c, i) => {
|
|
208
269
|
const at = `ui[${i}]`;
|
|
209
270
|
if (!isObj(c)) {
|
|
@@ -219,53 +280,68 @@ export function validateUiContributions(ui, permissions) {
|
|
|
219
280
|
if (!title ||
|
|
220
281
|
[title.zh, title.en].some((t) => typeof t !== "string" || t === "" || t.length > UI_TITLE_MAX))
|
|
221
282
|
errs.push(`ui "${id}" title needs non-empty zh and en of at most ${UI_TITLE_MAX} characters`);
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
if (
|
|
225
|
-
errs.push(`ui "${id}"
|
|
283
|
+
// the slot it names, when it is well formed (known to the catalog or not)
|
|
284
|
+
const slotRef = typeof c.slot === "string" ? parseSlotRef(c.slot) : null;
|
|
285
|
+
if (slotRef === null)
|
|
286
|
+
errs.push(`ui "${id}" slot must be a slot reference like "org.page" or "org.page@1"`);
|
|
287
|
+
if (c.after !== undefined && typeof c.after !== "string")
|
|
288
|
+
errs.push(`ui "${id}" after must be a string`);
|
|
289
|
+
if (c.kind !== "view" && c.kind !== "embed" && c.kind !== "component") {
|
|
290
|
+
errs.push(`ui "${id}" kind must be view, embed or component`);
|
|
226
291
|
return;
|
|
227
292
|
}
|
|
293
|
+
if (c.compact !== undefined && !isCompactForm(c.compact))
|
|
294
|
+
errs.push(`ui "${id}" compact must be one of kept, drawer, hidden`);
|
|
228
295
|
if (c.icon !== undefined && !UI_ICONS.includes(c.icon))
|
|
229
296
|
errs.push(`ui "${id}" icon must be one of ${UI_ICONS.join(", ")}`);
|
|
230
|
-
|
|
231
|
-
|
|
297
|
+
// the slot checks describe only the catalog's version: another version is left to
|
|
298
|
+
// resolveUiSlots, which drops it (unsupported-version) without failing the extension
|
|
299
|
+
const known = slotRef === null ? undefined : uiSlot(slotRef.id);
|
|
300
|
+
const spec = known !== undefined && known.version === slotRef?.version ? known : undefined;
|
|
301
|
+
if (spec !== undefined) {
|
|
302
|
+
if (!spec.accepts.includes(c.kind))
|
|
303
|
+
errs.push(`ui "${id}" slot ${spec.id} does not accept kind ${c.kind}`);
|
|
304
|
+
if (spec.icon === "required" && c.icon === undefined)
|
|
305
|
+
errs.push(`ui "${id}" slot ${spec.id} needs an icon`);
|
|
306
|
+
}
|
|
232
307
|
if (seen.has(id))
|
|
233
308
|
errs.push(`ui has duplicate id "${id}"`);
|
|
234
309
|
seen.set(id, c.kind);
|
|
235
310
|
if (c.kind === "view") {
|
|
236
|
-
if (c.place === "file-preview")
|
|
237
|
-
errs.push(`ui "${id}" place file-preview is only allowed for kind embed`);
|
|
238
311
|
if (c.path !== undefined)
|
|
239
312
|
errs.push(`ui "${id}" path is only allowed for kind embed`);
|
|
240
|
-
if (!views.includes(id))
|
|
313
|
+
if (!views.includes(id) && !multiListed.has(id))
|
|
241
314
|
errs.push(`ui "${id}" (view) must be listed in permissions.ui.views`);
|
|
242
315
|
return;
|
|
243
316
|
}
|
|
244
|
-
if (
|
|
317
|
+
if (c.kind === "component") {
|
|
318
|
+
if (c.path !== undefined)
|
|
319
|
+
errs.push(`ui "${id}" is a component and cannot have a path`);
|
|
320
|
+
if (!components.includes(id) && !multiListed.has(id))
|
|
321
|
+
errs.push(`ui "${id}" is a component; list it in permissions.ui.components`);
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (!embeds.includes(id) && !multiListed.has(id))
|
|
245
325
|
errs.push(`ui "${id}" (embed) must be listed in permissions.ui.embeds`);
|
|
246
326
|
if (typeof c.path !== "string" || !c.path.startsWith(UI_EMBED_PREFIX)) {
|
|
247
327
|
errs.push(`ui "${id}" (embed) path must start with "${UI_EMBED_PREFIX}"`);
|
|
248
328
|
}
|
|
249
329
|
else if (!gets.has(c.path)) {
|
|
250
|
-
errs.push(`ui "${id}"
|
|
330
|
+
errs.push(`ui "${id}" embed path "${c.path}" must be declared in permissions.http as GET with access public`);
|
|
251
331
|
}
|
|
252
332
|
});
|
|
253
|
-
const aliasIds = new Set(aliases.map((a) => a.id));
|
|
254
|
-
for (const a of aliases) {
|
|
255
|
-
if (typeof a.target !== "string" ||
|
|
256
|
-
a.target === a.id ||
|
|
257
|
-
aliasIds.has(a.target) ||
|
|
258
|
-
seen.get(a.target) !== a.kind)
|
|
259
|
-
errs.push(`ui "${a.id}" aliasOf must name another, non-alias ${a.kind} contribution`);
|
|
260
|
-
}
|
|
261
333
|
for (const [k, kind, ids] of [
|
|
262
334
|
["views", "view", views],
|
|
263
335
|
["embeds", "embed", embeds],
|
|
264
336
|
]) {
|
|
265
337
|
for (const id of ids) {
|
|
266
|
-
if (seen.get(id) !== kind)
|
|
338
|
+
if (seen.get(id) !== kind && !multiListed.has(id))
|
|
267
339
|
errs.push(`permissions.ui.${k} entry "${id}" has no matching ${kind} contribution in ui`);
|
|
268
340
|
}
|
|
269
341
|
}
|
|
342
|
+
for (const id of components) {
|
|
343
|
+
if (seen.get(id) !== "component" && !multiListed.has(id))
|
|
344
|
+
errs.push(`permissions.ui.components lists "${id}", which is not a component contribution`);
|
|
345
|
+
}
|
|
270
346
|
return errs;
|
|
271
347
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { type PluginClientSection } from "./client-section.js";
|
|
2
3
|
import { type JsonSchema } from "./config-ui.js";
|
|
3
4
|
import { type ConnectorTemplateSpec, type LocalizedName, type StaticExtensionManifest } from "./plugin-package.js";
|
|
5
|
+
import { type PluginSetupGuide } from "./setup-guide.js";
|
|
6
|
+
import { type PluginThemeRef } from "./theme.js";
|
|
4
7
|
/**
|
|
5
8
|
* The plugin manifest `.capybara-plugin/plugin.json` (package ecosystem spec §4.1). A plugin is a
|
|
6
|
-
* bundle of at most one extension, skills
|
|
9
|
+
* bundle of at most one extension, skills, connector templates, agent templates and themes, packed as
|
|
10
|
+
* an npm-pack tgz:
|
|
7
11
|
*
|
|
8
12
|
* ```
|
|
9
13
|
* package/package.json npm metadata; version equals plugin.json version
|
|
@@ -11,13 +15,14 @@ import { type ConnectorTemplateSpec, type LocalizedName, type StaticExtensionMan
|
|
|
11
15
|
* package/skills/<name>/SKILL.md skills
|
|
12
16
|
* package/connectors/<id>.json connector templates ({@link ConnectorTemplateFile})
|
|
13
17
|
* package/agents/<name>.md agent templates (parsed by `parseAgentTemplate`)
|
|
18
|
+
* package/themes/<id>.json themes (parsed by `parseThemeFile`)
|
|
14
19
|
* package/dist/index.mjs extension entry (only with an extension)
|
|
15
20
|
* package/migrations/*.sql, package/ui/**
|
|
16
21
|
* ```
|
|
17
22
|
*
|
|
18
23
|
* Paths start with `./` and stay inside the plugin root. Omitting `skills` / `connectorTemplates`
|
|
19
|
-
* / `agents` means "scan `skills/*\/SKILL.md` / `connectors/*.json` / `agents/*.md`
|
|
20
|
-
* kernel when it reads the package). `extension` is written by the packer, never by hand.
|
|
24
|
+
* / `agents` / `themes` means "scan `skills/*\/SKILL.md` / `connectors/*.json` / `agents/*.md` /
|
|
25
|
+
* `themes/*.json`" (done by the kernel when it reads the package). `extension` is written by the packer, never by hand.
|
|
21
26
|
*
|
|
22
27
|
* The committed JSON Schema (`schemas/plugin.v1.schema.json`) is generated from
|
|
23
28
|
* {@link PluginManifestSchema} by `pnpm gen:package-schemas` and drift-checked by
|
|
@@ -39,10 +44,14 @@ export declare const PLUGIN_MANIFEST_LIMITS: {
|
|
|
39
44
|
readonly connectorTemplates: 20;
|
|
40
45
|
/** Agent templates ({@link AGENT_TEMPLATE_LIMITS}`.perPlugin`). */
|
|
41
46
|
readonly agents: 64;
|
|
47
|
+
/** Themes ({@link THEME_LIMITS}`.perPlugin`). */
|
|
48
|
+
readonly themes: 10;
|
|
42
49
|
readonly descriptionChars: 1024;
|
|
43
50
|
readonly publisherChars: 100;
|
|
44
51
|
readonly displayNameChars: 100;
|
|
45
52
|
readonly pathChars: 512;
|
|
53
|
+
/** Entries of `suggestedAppearance.replacements`. */
|
|
54
|
+
readonly appearanceReplacements: 8;
|
|
46
55
|
};
|
|
47
56
|
/** A plugin this one depends on: a plugin name and a semver range. */
|
|
48
57
|
export interface PluginDependency {
|
|
@@ -54,8 +63,6 @@ export interface PluginDependency {
|
|
|
54
63
|
/** A skill of the plugin: a `./…` directory holding SKILL.md. */
|
|
55
64
|
export interface PluginSkillRef {
|
|
56
65
|
path: string;
|
|
57
|
-
/** Suggested as pinned when an agent selects the skill (spec §9.1). */
|
|
58
|
-
pinned?: boolean;
|
|
59
66
|
}
|
|
60
67
|
/** A connector template of the plugin: a `./…/<id>.json` file ({@link ConnectorTemplateFile}). */
|
|
61
68
|
export interface PluginConnectorTemplateRef {
|
|
@@ -84,6 +91,18 @@ export interface PluginExtensionSection {
|
|
|
84
91
|
deployment?: JsonSchema;
|
|
85
92
|
org?: JsonSchema;
|
|
86
93
|
};
|
|
94
|
+
/** Browser code, styles and assets (needs `permissions.client: true`); see {@link PluginClientSection}. */
|
|
95
|
+
client?: PluginClientSection;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* How the plugin suggests it should look when chosen (client extensions spec §6.5). Nothing applies
|
|
99
|
+
* on install; an admin applies it in one confirmed step.
|
|
100
|
+
*/
|
|
101
|
+
export interface SuggestedAppearance {
|
|
102
|
+
/** A theme id (file base name) of this plugin. */
|
|
103
|
+
theme?: string;
|
|
104
|
+
/** Replaceable slot id → a `component` contribution id of this plugin's extension in that slot. */
|
|
105
|
+
replacements?: Record<string, string>;
|
|
87
106
|
}
|
|
88
107
|
/**
|
|
89
108
|
* A plugin's description: a string (English) or `{ en, zh? }`, each ≤ 1024 characters. Read it
|
|
@@ -123,6 +142,16 @@ export interface PluginManifest {
|
|
|
123
142
|
connectorTemplates?: PluginConnectorTemplateRef[];
|
|
124
143
|
/** Agent templates; omitted = scan `agents/*.md`. */
|
|
125
144
|
agents?: PluginAgentRef[];
|
|
145
|
+
/** Themes; omitted = scan `themes/*.json`. */
|
|
146
|
+
themes?: PluginThemeRef[];
|
|
147
|
+
/**
|
|
148
|
+
* Setup guides (spec `2026-11-09-setup-guides-v2-design.md`): Markdown documents at
|
|
149
|
+
* `guides/<id>.md` (+ `guides/<id>.zh.md`) the kernel renders for a place; see
|
|
150
|
+
* {@link PluginSetupGuide}.
|
|
151
|
+
*/
|
|
152
|
+
setupGuides?: PluginSetupGuide[];
|
|
153
|
+
/** See {@link SuggestedAppearance}. */
|
|
154
|
+
suggestedAppearance?: SuggestedAppearance;
|
|
126
155
|
extension?: PluginExtensionSection;
|
|
127
156
|
}
|
|
128
157
|
/** A connector template file `connectors/<id>.json`; the template id is the file's base name. */
|
|
@@ -131,6 +160,12 @@ export interface ConnectorTemplateFile {
|
|
|
131
160
|
description?: string;
|
|
132
161
|
/** Safe path relative to the plugin root (an optional leading `./`), .svg / .png. */
|
|
133
162
|
icon?: string;
|
|
163
|
+
/**
|
|
164
|
+
* `false`: the template starts switched off in every org, even where its plugin is on, until an
|
|
165
|
+
* org admin switches it on (it then needs no org input while off). Default `true`: on wherever
|
|
166
|
+
* its plugin is. Ignored for a builtin plugin.
|
|
167
|
+
*/
|
|
168
|
+
defaultEnabled?: boolean;
|
|
134
169
|
/** Validated by {@link validateConnectorTemplate}. */
|
|
135
170
|
template: ConnectorTemplateSpec;
|
|
136
171
|
}
|
|
@@ -162,3 +197,8 @@ export declare function parsePluginManifest(json: unknown): PluginManifest | {
|
|
|
162
197
|
export declare function parseConnectorTemplateFile(json: unknown): ConnectorTemplateFile | {
|
|
163
198
|
errors: string[];
|
|
164
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* The theme check of `suggestedAppearance` after the themes are known (the manifest may omit
|
|
202
|
+
* `themes` and let the scan find them): shared by the packer and the kernel.
|
|
203
|
+
*/
|
|
204
|
+
export declare function appearanceIssues(manifest: PluginManifest, themeIds: readonly string[]): string[];
|