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