@capybara-hq/plugin-sdk 0.1.0-rc.9 → 0.1.0-rc.90
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 +3 -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 +5 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extension-points/trigger-source.md +19 -0
- package/agent-docs/extensions.md +98 -4
- package/agent-docs/plugin-format.md +45 -10
- package/agent-docs/setup.md +54 -0
- package/api/plugin-sdk.api.md +5983 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/agents-ctx.d.ts +116 -0
- package/dist/agents-ctx.js +22 -0
- 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 +121 -13
- package/dist/cards.js +161 -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 +344 -31
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +18 -12
- package/dist/define-extension.js +18 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +348 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +286 -49
- package/dist/device-protocol.js +766 -89
- package/dist/device-provider.d.ts +820 -0
- package/dist/device-provider.js +432 -0
- package/dist/device-service.d.ts +204 -0
- package/dist/device-service.js +291 -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 +8 -3
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +46 -9
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +185 -22
- package/dist/hooks.js +6 -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/inbox.d.ts +103 -0
- package/dist/inbox.js +173 -0
- package/dist/index.d.ts +30 -4
- package/dist/index.js +30 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +295 -77
- package/dist/model.js +249 -21
- 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 +95 -25
- package/dist/permissions.js +175 -54
- 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 +216 -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 +40 -12
- package/dist/theme-tokens.generated.js +36 -8
- package/dist/theme.d.ts +56 -10
- package/dist/theme.js +117 -23
- package/dist/tool.d.ts +242 -28
- package/dist/tool.js +135 -13
- package/dist/trigger-source.d.ts +35 -0
- package/dist/trigger-source.js +2 -0
- package/dist/triggers.d.ts +88 -0
- package/dist/triggers.js +71 -0
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +374 -0
- package/dist/ui-resolve.d.ts +2 -7
- package/dist/ui-resolve.js +7 -19
- package/dist/ui-slots.d.ts +27 -5
- package/dist/ui-slots.js +112 -19
- package/dist/ui.d.ts +203 -64
- package/dist/ui.js +117 -23
- 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 +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/permissions.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
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";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
4
|
+
import { HTTP_ACCESS } from "./http-access.js";
|
|
5
|
+
import { SETUP_CHECK_ID_RE, SETUP_CHECK_LIMITS } from "./setup-check.js";
|
|
6
|
+
import { TRIGGER_MAX_TYPES, TRIGGER_TYPE_RE } from "./triggers.js";
|
|
7
|
+
import { UI_ICONS, UI_PAGE_FRAMES, UI_PAGE_NAVS } from "./ui.js";
|
|
8
|
+
import { isCompactForm, parseSlotRef, uiSlot } from "./ui-slots.js";
|
|
9
|
+
/** The most services `permissions.deviceAccess.services` may list. */
|
|
10
|
+
export const DEVICE_ACCESS_MAX_SERVICES = 4;
|
|
11
|
+
/** Hook mount points (a closed list, see the overall design 2.4). */
|
|
5
12
|
export const HOOK_MOUNT_POINTS = [
|
|
6
13
|
"session.start",
|
|
7
14
|
"session.end",
|
|
@@ -11,6 +18,10 @@ export const HOOK_MOUNT_POINTS = [
|
|
|
11
18
|
"tool.preExecute",
|
|
12
19
|
"tool.postExecute",
|
|
13
20
|
"usage.report",
|
|
21
|
+
"org.member_removed",
|
|
22
|
+
"agent.deleted",
|
|
23
|
+
"org.deleted",
|
|
24
|
+
"run.lifecycle",
|
|
14
25
|
];
|
|
15
26
|
const HOOKS = new Set(HOOK_MOUNT_POINTS);
|
|
16
27
|
/** A platform API not declared in the manifest was used. */
|
|
@@ -37,6 +48,15 @@ const KEYS = new Set([
|
|
|
37
48
|
"storage",
|
|
38
49
|
"network",
|
|
39
50
|
"ui",
|
|
51
|
+
"client",
|
|
52
|
+
"setupChecks",
|
|
53
|
+
"dialIn",
|
|
54
|
+
"deviceAccess",
|
|
55
|
+
"triggers",
|
|
56
|
+
"inbox",
|
|
57
|
+
"agents",
|
|
58
|
+
"conversations",
|
|
59
|
+
"people",
|
|
40
60
|
]);
|
|
41
61
|
const POLICY = new Set(POLICY_HOOKS);
|
|
42
62
|
const METHODS = new Set(["GET", "POST", "PUT", "DELETE"]);
|
|
@@ -58,8 +78,11 @@ function strList(label, v, errs) {
|
|
|
58
78
|
}
|
|
59
79
|
return out;
|
|
60
80
|
}
|
|
61
|
-
/**
|
|
62
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Validates the permission manifest and returns the list of errors (empty means valid). `provides`
|
|
83
|
+
* is the manifest's `provides` (`permissions.dialIn` needs `device-provider@1` in it).
|
|
84
|
+
*/
|
|
85
|
+
export function validatePermissions(plugin, p, provides = []) {
|
|
63
86
|
if (p === undefined)
|
|
64
87
|
return [];
|
|
65
88
|
if (!isObj(p))
|
|
@@ -69,11 +92,21 @@ export function validatePermissions(plugin, p) {
|
|
|
69
92
|
if (!KEYS.has(k))
|
|
70
93
|
errs.push(`unknown permissions key "${k}"`);
|
|
71
94
|
}
|
|
72
|
-
for (const k of ["secrets", "storage"]) {
|
|
95
|
+
for (const k of ["secrets", "storage", "client", "inbox"]) {
|
|
73
96
|
if (p[k] !== undefined && typeof p[k] !== "boolean") {
|
|
74
97
|
errs.push(`permissions.${k} must be a boolean`);
|
|
75
98
|
}
|
|
76
99
|
}
|
|
100
|
+
for (const [k, flag] of [
|
|
101
|
+
["agents", "read"],
|
|
102
|
+
["conversations", "subjects"],
|
|
103
|
+
["people", "read"],
|
|
104
|
+
]) {
|
|
105
|
+
const v = p[k];
|
|
106
|
+
if (v !== undefined &&
|
|
107
|
+
(!isObj(v) || Object.keys(v).some((x) => x !== flag) || v[flag] !== true))
|
|
108
|
+
errs.push(`permissions.${k} must be { ${flag}: true }`);
|
|
109
|
+
}
|
|
77
110
|
if (p.tools !== undefined)
|
|
78
111
|
strList("permissions.tools", p.tools, errs);
|
|
79
112
|
if (p.hooks !== undefined) {
|
|
@@ -111,14 +144,27 @@ export function validatePermissions(plugin, p) {
|
|
|
111
144
|
!METHODS.has(r.method) ||
|
|
112
145
|
typeof r.path !== "string" ||
|
|
113
146
|
!r.path.startsWith("/") ||
|
|
114
|
-
|
|
115
|
-
|
|
147
|
+
typeof r.access !== "string" ||
|
|
148
|
+
!HTTP_ACCESS.includes(r.access)) {
|
|
149
|
+
errs.push("permissions.http entries need method GET/POST/PUT/DELETE, a path starting with /, and access public/embed/member/admin");
|
|
116
150
|
continue;
|
|
117
151
|
}
|
|
118
152
|
const key = `${r.method} ${r.path}`;
|
|
119
153
|
if (seen.has(key))
|
|
120
154
|
errs.push(`permissions.http has duplicate route "${key}"`);
|
|
121
155
|
seen.add(key);
|
|
156
|
+
if (r.path === "/orgs" || r.path.startsWith("/orgs/")) {
|
|
157
|
+
errs.push(`permissions.http route "${key}" must not start with /orgs/ (reserved for org routes)`);
|
|
158
|
+
}
|
|
159
|
+
if (r.access === "embed" && !r.path.startsWith(UI_EMBED_PREFIX)) {
|
|
160
|
+
errs.push(`permissions.http embed route "${key}" must be under ${UI_EMBED_PREFIX}`);
|
|
161
|
+
}
|
|
162
|
+
if ((r.access === "member" || r.access === "admin") &&
|
|
163
|
+
// anywhere, not only after a slash: find-my-way lets a later duplicate param win, so
|
|
164
|
+
// `/x-:orgId` would override the mount's `:orgId`
|
|
165
|
+
/:orgId(?![A-Za-z0-9_])/.test(r.path)) {
|
|
166
|
+
errs.push(`permissions.http route "${key}" must not contain :orgId (the org comes from the mount)`);
|
|
167
|
+
}
|
|
122
168
|
}
|
|
123
169
|
}
|
|
124
170
|
}
|
|
@@ -127,9 +173,11 @@ export function validatePermissions(plugin, p) {
|
|
|
127
173
|
errs.push("permissions.ui must be an object");
|
|
128
174
|
else {
|
|
129
175
|
for (const k of Object.keys(p.ui)) {
|
|
130
|
-
if (k !== "views" && k !== "embeds")
|
|
176
|
+
if (k !== "views" && k !== "embeds" && k !== "components")
|
|
131
177
|
errs.push(`unknown permissions.ui key "${k}"`);
|
|
132
178
|
}
|
|
179
|
+
if (p.ui.components !== undefined)
|
|
180
|
+
strList("permissions.ui.components", p.ui.components, errs);
|
|
133
181
|
const views = p.ui.views === undefined ? [] : strList("permissions.ui.views", p.ui.views, errs);
|
|
134
182
|
const embeds = p.ui.embeds === undefined ? [] : strList("permissions.ui.embeds", p.ui.embeds, errs);
|
|
135
183
|
for (const id of views) {
|
|
@@ -138,6 +186,17 @@ export function validatePermissions(plugin, p) {
|
|
|
138
186
|
}
|
|
139
187
|
}
|
|
140
188
|
}
|
|
189
|
+
if (p.setupChecks !== undefined) {
|
|
190
|
+
const ids = strList("permissions.setupChecks", p.setupChecks, errs);
|
|
191
|
+
for (const id of ids) {
|
|
192
|
+
if (!SETUP_CHECK_ID_RE.test(id)) {
|
|
193
|
+
errs.push(`permissions.setupChecks id "${id}" must match ${SETUP_CHECK_ID_RE}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (ids.length > SETUP_CHECK_LIMITS.idsPerExtension) {
|
|
197
|
+
errs.push(`permissions.setupChecks has more than ${SETUP_CHECK_LIMITS.idsPerExtension} ids`);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
141
200
|
if (p.models !== undefined) {
|
|
142
201
|
if (!Array.isArray(p.models))
|
|
143
202
|
errs.push("permissions.models must be an array");
|
|
@@ -147,13 +206,13 @@ export function validatePermissions(plugin, p) {
|
|
|
147
206
|
const label = isObj(m) && isObj(m.label) ? m.label : undefined;
|
|
148
207
|
if (!isObj(m) ||
|
|
149
208
|
typeof m.purpose !== "string" ||
|
|
150
|
-
(m.kind !== "chat" && m.kind !== "embedding") ||
|
|
209
|
+
(m.kind !== "chat" && m.kind !== "embedding" && m.kind !== "image_generation") ||
|
|
151
210
|
!label ||
|
|
152
211
|
typeof label.zh !== "string" ||
|
|
153
212
|
label.zh === "" ||
|
|
154
213
|
typeof label.en !== "string" ||
|
|
155
214
|
label.en === "") {
|
|
156
|
-
errs.push("permissions.models entries need purpose, kind chat/embedding
|
|
215
|
+
errs.push("permissions.models entries need purpose, kind chat/embedding/image_generation, label zh/en");
|
|
157
216
|
continue;
|
|
158
217
|
}
|
|
159
218
|
if (!m.purpose.startsWith(`${plugin}.`) || m.purpose.length === plugin.length + 1) {
|
|
@@ -165,21 +224,68 @@ export function validatePermissions(plugin, p) {
|
|
|
165
224
|
}
|
|
166
225
|
}
|
|
167
226
|
}
|
|
227
|
+
if (p.dialIn !== undefined) {
|
|
228
|
+
if (!isObj(p.dialIn) ||
|
|
229
|
+
Object.keys(p.dialIn).some((k) => k !== "protocol") ||
|
|
230
|
+
typeof p.dialIn.protocol !== "string" ||
|
|
231
|
+
!DIAL_IN_PROTOCOL_RE.test(p.dialIn.protocol)) {
|
|
232
|
+
errs.push(`permissions.dialIn must be { protocol: "<name>/<major>" } matching ${DIAL_IN_PROTOCOL_RE}`);
|
|
233
|
+
}
|
|
234
|
+
if (!provides.includes(DEVICE_PROVIDER_EXTENSION_POINT)) {
|
|
235
|
+
errs.push(`permissions.dialIn needs "${DEVICE_PROVIDER_EXTENSION_POINT}" in provides`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (p.deviceAccess !== undefined) {
|
|
239
|
+
if (!isObj(p.deviceAccess) ||
|
|
240
|
+
Object.keys(p.deviceAccess).some((k) => k !== "services" && k !== "loopbackPorts") ||
|
|
241
|
+
(p.deviceAccess.loopbackPorts !== undefined &&
|
|
242
|
+
typeof p.deviceAccess.loopbackPorts !== "boolean")) {
|
|
243
|
+
errs.push("permissions.deviceAccess must be { services: string[], loopbackPorts?: boolean }");
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
const names = strList("permissions.deviceAccess.services", p.deviceAccess.services, errs);
|
|
247
|
+
if (Array.isArray(p.deviceAccess.services)) {
|
|
248
|
+
const n = p.deviceAccess.services.length;
|
|
249
|
+
if (n < 1 || n > DEVICE_ACCESS_MAX_SERVICES)
|
|
250
|
+
errs.push(`permissions.deviceAccess.services must list 1 to ${DEVICE_ACCESS_MAX_SERVICES} services`);
|
|
251
|
+
}
|
|
252
|
+
for (const name of names) {
|
|
253
|
+
if (!DEVICE_SERVICE_NAME_RE.test(name))
|
|
254
|
+
errs.push(`permissions.deviceAccess.services entry "${name}" must match ${DEVICE_SERVICE_NAME_RE}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (p.triggers !== undefined) {
|
|
259
|
+
if (!isObj(p.triggers) || Object.keys(p.triggers).some((k) => k !== "emit")) {
|
|
260
|
+
errs.push("permissions.triggers must be { emit: string[] }");
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const types = strList("permissions.triggers.emit", p.triggers.emit, errs);
|
|
264
|
+
if (types.length > TRIGGER_MAX_TYPES)
|
|
265
|
+
errs.push(`permissions.triggers.emit lists at most ${TRIGGER_MAX_TYPES} types`);
|
|
266
|
+
for (const t of types) {
|
|
267
|
+
if (!TRIGGER_TYPE_RE.test(t))
|
|
268
|
+
errs.push(`permissions.triggers.emit entry "${t}" must match ${TRIGGER_TYPE_RE}`);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
168
272
|
return errs;
|
|
169
273
|
}
|
|
170
274
|
const UI_ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
171
275
|
const UI_TITLE_MAX = 100;
|
|
172
|
-
const UI_PLACES = Object.keys(PLACE_SLOTS);
|
|
173
276
|
const UI_EMBED_PREFIX = "/ui/";
|
|
174
277
|
/**
|
|
175
278
|
* Checks the structure of the manifest's `ui` and cross-checks it with the permission manifest;
|
|
176
|
-
* returns the problems (empty = valid). Only structural problems (UI slots spec §3.2
|
|
177
|
-
* contribution's id is listed in
|
|
178
|
-
* `permissions.ui.
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
279
|
+
* returns the problems (empty = valid). Only structural problems (UI slots spec §3.2, client
|
|
280
|
+
* extensions spec §5.1): each contribution's id is listed in the list of its kind,
|
|
281
|
+
* `permissions.ui.views` (view), `permissions.ui.embeds` (embed) or `permissions.ui.components`
|
|
282
|
+
* (component), an id is in at most one of the three, and `permissions.ui` lists no id the `ui`
|
|
283
|
+
* lacks; `permissions.ui.components` needs `permissions.client: true`; an embed's path starts with
|
|
284
|
+
* `/ui/` and is declared in `permissions.http` as GET, a view or component has no path; exactly one
|
|
285
|
+
* of `slot` (a well-formed slot reference) and `place` (a known place); for a slot the catalog
|
|
286
|
+
* knows at the version named, a kind it accepts and, unless an alias, the icon it requires. An
|
|
287
|
+
* unknown slot id or version is not a problem here: `resolveUiSlots` drops that contribution and
|
|
288
|
+
* the rest of the extension loads.
|
|
183
289
|
* Assumes `permissions` passed {@link validatePermissions}.
|
|
184
290
|
*/
|
|
185
291
|
export function validateUiContributions(ui, permissions) {
|
|
@@ -190,10 +296,21 @@ export function validateUiContributions(ui, permissions) {
|
|
|
190
296
|
: [];
|
|
191
297
|
const views = listed("views");
|
|
192
298
|
const embeds = listed("embeds");
|
|
299
|
+
const components = listed("components");
|
|
300
|
+
// an id in more than one list is reported once, not again as a mismatch of each list
|
|
301
|
+
const multiListed = new Set();
|
|
302
|
+
for (const id of new Set([...views, ...embeds, ...components])) {
|
|
303
|
+
if ([views, embeds, components].filter((l) => l.includes(id)).length > 1)
|
|
304
|
+
multiListed.add(id);
|
|
305
|
+
}
|
|
193
306
|
const gets = new Set((Array.isArray(perms.http) ? perms.http : [])
|
|
194
|
-
.filter((r) => isObj(r) && r.method === "GET")
|
|
307
|
+
.filter((r) => isObj(r) && r.method === "GET" && r.access === "public")
|
|
195
308
|
.map((r) => r.path));
|
|
196
309
|
const errs = [];
|
|
310
|
+
for (const id of multiListed)
|
|
311
|
+
errs.push(`ui "${id}" is listed in more than one of permissions.ui.views / embeds / components`);
|
|
312
|
+
if (components.length > 0 && perms.client !== true)
|
|
313
|
+
errs.push("permissions.ui.components needs permissions.client: true");
|
|
197
314
|
const contributions = [];
|
|
198
315
|
if (ui !== undefined) {
|
|
199
316
|
if (!Array.isArray(ui))
|
|
@@ -202,7 +319,6 @@ export function validateUiContributions(ui, permissions) {
|
|
|
202
319
|
contributions.push(...ui);
|
|
203
320
|
}
|
|
204
321
|
const seen = new Map();
|
|
205
|
-
const aliases = [];
|
|
206
322
|
contributions.forEach((c, i) => {
|
|
207
323
|
const at = `ui[${i}]`;
|
|
208
324
|
if (!isObj(c)) {
|
|
@@ -218,28 +334,18 @@ export function validateUiContributions(ui, permissions) {
|
|
|
218
334
|
if (!title ||
|
|
219
335
|
[title.zh, title.en].some((t) => typeof t !== "string" || t === "" || t.length > UI_TITLE_MAX))
|
|
220
336
|
errs.push(`ui "${id}" title needs non-empty zh and en of at most ${UI_TITLE_MAX} characters`);
|
|
221
|
-
// the slot it names, when
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
errs.push(`ui "${id}"
|
|
225
|
-
}
|
|
226
|
-
else if (c.slot !== undefined) {
|
|
227
|
-
slotRef = typeof c.slot === "string" ? parseSlotRef(c.slot) : null;
|
|
228
|
-
if (slotRef === null)
|
|
229
|
-
errs.push(`ui "${id}" slot must be a slot reference like "org.page" or "org.page@1"`);
|
|
230
|
-
}
|
|
231
|
-
else if (!UI_PLACES.includes(c.place)) {
|
|
232
|
-
errs.push(`ui "${id}" place must be one of ${UI_PLACES.join(", ")}`);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
slotRef = { id: PLACE_SLOTS[c.place], version: 1 };
|
|
236
|
-
}
|
|
337
|
+
// the slot it names, when it is well formed (known to the catalog or not)
|
|
338
|
+
const slotRef = typeof c.slot === "string" ? parseSlotRef(c.slot) : null;
|
|
339
|
+
if (slotRef === null)
|
|
340
|
+
errs.push(`ui "${id}" slot must be a slot reference like "org.page" or "org.page@1"`);
|
|
237
341
|
if (c.after !== undefined && typeof c.after !== "string")
|
|
238
342
|
errs.push(`ui "${id}" after must be a string`);
|
|
239
|
-
if (c.kind !== "view" && c.kind !== "embed") {
|
|
240
|
-
errs.push(`ui "${id}" kind must be view or
|
|
343
|
+
if (c.kind !== "view" && c.kind !== "embed" && c.kind !== "component") {
|
|
344
|
+
errs.push(`ui "${id}" kind must be view, embed or component`);
|
|
241
345
|
return;
|
|
242
346
|
}
|
|
347
|
+
if (c.compact !== undefined && !isCompactForm(c.compact))
|
|
348
|
+
errs.push(`ui "${id}" compact must be one of kept, drawer, hidden`);
|
|
243
349
|
if (c.icon !== undefined && !UI_ICONS.includes(c.icon))
|
|
244
350
|
errs.push(`ui "${id}" icon must be one of ${UI_ICONS.join(", ")}`);
|
|
245
351
|
// the slot checks describe only the catalog's version: another version is left to
|
|
@@ -249,46 +355,61 @@ export function validateUiContributions(ui, permissions) {
|
|
|
249
355
|
if (spec !== undefined) {
|
|
250
356
|
if (!spec.accepts.includes(c.kind))
|
|
251
357
|
errs.push(`ui "${id}" slot ${spec.id} does not accept kind ${c.kind}`);
|
|
252
|
-
if (spec.icon === "required" && c.icon === undefined
|
|
358
|
+
if (spec.icon === "required" && c.icon === undefined)
|
|
253
359
|
errs.push(`ui "${id}" slot ${spec.id} needs an icon`);
|
|
254
360
|
}
|
|
255
|
-
if (c.aliasOf !== undefined)
|
|
256
|
-
aliases.push({ id, kind: c.kind, target: c.aliasOf });
|
|
257
361
|
if (seen.has(id))
|
|
258
362
|
errs.push(`ui has duplicate id "${id}"`);
|
|
259
363
|
seen.set(id, c.kind);
|
|
364
|
+
if (c.frame !== undefined || c.nav !== undefined) {
|
|
365
|
+
const onPage = slotRef?.id === "org.page" && c.kind === "component";
|
|
366
|
+
for (const [k, allowed] of [
|
|
367
|
+
["frame", UI_PAGE_FRAMES],
|
|
368
|
+
["nav", UI_PAGE_NAVS],
|
|
369
|
+
]) {
|
|
370
|
+
if (c[k] === undefined)
|
|
371
|
+
continue;
|
|
372
|
+
if (!onPage)
|
|
373
|
+
errs.push(`ui "${id}" ${k} is only allowed on a component of the org.page slot`);
|
|
374
|
+
else if (!allowed.includes(c[k]))
|
|
375
|
+
errs.push(`ui "${id}" ${k} must be one of ${allowed.join(", ")}`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
260
378
|
if (c.kind === "view") {
|
|
261
379
|
if (c.path !== undefined)
|
|
262
380
|
errs.push(`ui "${id}" path is only allowed for kind embed`);
|
|
263
|
-
if (!views.includes(id))
|
|
381
|
+
if (!views.includes(id) && !multiListed.has(id))
|
|
264
382
|
errs.push(`ui "${id}" (view) must be listed in permissions.ui.views`);
|
|
265
383
|
return;
|
|
266
384
|
}
|
|
267
|
-
if (
|
|
385
|
+
if (c.kind === "component") {
|
|
386
|
+
if (c.path !== undefined)
|
|
387
|
+
errs.push(`ui "${id}" is a component and cannot have a path`);
|
|
388
|
+
if (!components.includes(id) && !multiListed.has(id))
|
|
389
|
+
errs.push(`ui "${id}" is a component; list it in permissions.ui.components`);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (!embeds.includes(id) && !multiListed.has(id))
|
|
268
393
|
errs.push(`ui "${id}" (embed) must be listed in permissions.ui.embeds`);
|
|
269
394
|
if (typeof c.path !== "string" || !c.path.startsWith(UI_EMBED_PREFIX)) {
|
|
270
395
|
errs.push(`ui "${id}" (embed) path must start with "${UI_EMBED_PREFIX}"`);
|
|
271
396
|
}
|
|
272
397
|
else if (!gets.has(c.path)) {
|
|
273
|
-
errs.push(`ui "${id}"
|
|
398
|
+
errs.push(`ui "${id}" embed path "${c.path}" must be declared in permissions.http as GET with access public`);
|
|
274
399
|
}
|
|
275
400
|
});
|
|
276
|
-
const aliasIds = new Set(aliases.map((a) => a.id));
|
|
277
|
-
for (const a of aliases) {
|
|
278
|
-
if (typeof a.target !== "string" ||
|
|
279
|
-
a.target === a.id ||
|
|
280
|
-
aliasIds.has(a.target) ||
|
|
281
|
-
seen.get(a.target) !== a.kind)
|
|
282
|
-
errs.push(`ui "${a.id}" aliasOf must name another, non-alias ${a.kind} contribution`);
|
|
283
|
-
}
|
|
284
401
|
for (const [k, kind, ids] of [
|
|
285
402
|
["views", "view", views],
|
|
286
403
|
["embeds", "embed", embeds],
|
|
287
404
|
]) {
|
|
288
405
|
for (const id of ids) {
|
|
289
|
-
if (seen.get(id) !== kind)
|
|
406
|
+
if (seen.get(id) !== kind && !multiListed.has(id))
|
|
290
407
|
errs.push(`permissions.ui.${k} entry "${id}" has no matching ${kind} contribution in ui`);
|
|
291
408
|
}
|
|
292
409
|
}
|
|
410
|
+
for (const id of components) {
|
|
411
|
+
if (seen.get(id) !== "component" && !multiListed.has(id))
|
|
412
|
+
errs.push(`permissions.ui.components lists "${id}", which is not a component contribution`);
|
|
413
|
+
}
|
|
293
414
|
return errs;
|
|
294
415
|
}
|
|
@@ -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,4 +1,5 @@
|
|
|
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";
|
|
@@ -49,6 +50,8 @@ export declare const PLUGIN_MANIFEST_LIMITS: {
|
|
|
49
50
|
readonly publisherChars: 100;
|
|
50
51
|
readonly displayNameChars: 100;
|
|
51
52
|
readonly pathChars: 512;
|
|
53
|
+
/** Entries of `suggestedAppearance.replacements`. */
|
|
54
|
+
readonly appearanceReplacements: 8;
|
|
52
55
|
};
|
|
53
56
|
/** A plugin this one depends on: a plugin name and a semver range. */
|
|
54
57
|
export interface PluginDependency {
|
|
@@ -60,8 +63,6 @@ export interface PluginDependency {
|
|
|
60
63
|
/** A skill of the plugin: a `./…` directory holding SKILL.md. */
|
|
61
64
|
export interface PluginSkillRef {
|
|
62
65
|
path: string;
|
|
63
|
-
/** Suggested as pinned when an agent selects the skill (spec §9.1). */
|
|
64
|
-
pinned?: boolean;
|
|
65
66
|
}
|
|
66
67
|
/** A connector template of the plugin: a `./…/<id>.json` file ({@link ConnectorTemplateFile}). */
|
|
67
68
|
export interface PluginConnectorTemplateRef {
|
|
@@ -88,8 +89,19 @@ export interface PluginExtensionSection {
|
|
|
88
89
|
*/
|
|
89
90
|
configSchemas?: {
|
|
90
91
|
deployment?: JsonSchema;
|
|
91
|
-
org?: JsonSchema;
|
|
92
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>;
|
|
93
105
|
}
|
|
94
106
|
/**
|
|
95
107
|
* A plugin's description: a string (English) or `{ en, zh? }`, each ≤ 1024 characters. Read it
|
|
@@ -132,16 +144,23 @@ export interface PluginManifest {
|
|
|
132
144
|
/** Themes; omitted = scan `themes/*.json`. */
|
|
133
145
|
themes?: PluginThemeRef[];
|
|
134
146
|
/**
|
|
135
|
-
* Setup guides (spec `2026-11-
|
|
136
|
-
* 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}.
|
|
137
150
|
*/
|
|
138
151
|
setupGuides?: PluginSetupGuide[];
|
|
152
|
+
/** See {@link SuggestedAppearance}. */
|
|
153
|
+
suggestedAppearance?: SuggestedAppearance;
|
|
139
154
|
extension?: PluginExtensionSection;
|
|
140
155
|
}
|
|
141
156
|
/** A connector template file `connectors/<id>.json`; the template id is the file's base name. */
|
|
142
157
|
export interface ConnectorTemplateFile {
|
|
143
158
|
displayName: LocalizedName;
|
|
144
|
-
|
|
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;
|
|
145
164
|
/** Safe path relative to the plugin root (an optional leading `./`), .svg / .png. */
|
|
146
165
|
icon?: string;
|
|
147
166
|
/**
|
|
@@ -181,3 +200,8 @@ export declare function parsePluginManifest(json: unknown): PluginManifest | {
|
|
|
181
200
|
export declare function parseConnectorTemplateFile(json: unknown): ConnectorTemplateFile | {
|
|
182
201
|
errors: string[];
|
|
183
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[];
|