@capybara-hq/plugin-sdk 0.1.0-rc.8 → 0.1.0-rc.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +11 -3
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/device-provider.md +15 -0
- package/agent-docs/extension-points/file-preview.md +3 -1
- package/agent-docs/extension-points/identity-source.md +2 -0
- package/agent-docs/extension-points/model-provider.md +3 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extensions.md +77 -4
- package/agent-docs/plugin-format.md +45 -10
- package/agent-docs/setup.md +54 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/avatar-presets.d.ts +8 -0
- package/dist/avatar-presets.js +17 -0
- package/dist/bootstrap.d.ts +109 -1
- package/dist/bootstrap.js +185 -2
- package/dist/cards.d.ts +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 +224 -30
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +23 -13
- package/dist/define-extension.js +19 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +339 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +285 -50
- package/dist/device-protocol.js +755 -90
- package/dist/device-provider.d.ts +780 -0
- package/dist/device-provider.js +409 -0
- package/dist/device-service.d.ts +126 -0
- package/dist/device-service.js +211 -0
- package/dist/dial-in.d.ts +286 -0
- package/dist/dial-in.js +213 -0
- package/dist/directory.d.ts +15 -12
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +7 -3
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +43 -10
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +125 -20
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +71 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +70 -9
- package/dist/identity.js +46 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.js +28 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +210 -75
- package/dist/model.js +152 -19
- package/dist/native-failure.d.ts +13 -0
- package/dist/native-failure.js +31 -0
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/network-classes.d.ts +98 -0
- package/dist/network-classes.js +291 -0
- package/dist/permissions.d.ts +65 -22
- package/dist/permissions.js +139 -43
- package/dist/platform-only.d.ts +27 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +30 -6
- package/dist/plugin-manifest.js +147 -55
- package/dist/plugin-package.d.ts +82 -39
- package/dist/plugin-package.js +68 -41
- package/dist/push.d.ts +75 -0
- package/dist/push.js +87 -0
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +2343 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +480 -0
- package/dist/sandbox-runtime-source.d.ts +47 -0
- package/dist/sandbox-runtime-source.js +73 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +8 -2
- package/dist/secret.js +11 -4
- package/dist/setup-check.d.ts +128 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +356 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +86 -72
- package/dist/setup-guide.js +340 -108
- package/dist/shell-capabilities.d.ts +211 -0
- package/dist/shell-capabilities.js +44 -0
- package/dist/shell-environment.d.ts +57 -0
- package/dist/shell-environment.js +21 -0
- package/dist/skill-invocation.d.ts +5 -0
- package/dist/skill-invocation.js +4 -3
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +40 -26
- package/dist/storage.d.ts +52 -25
- package/dist/svg-viewbox.d.ts +10 -0
- package/dist/svg-viewbox.js +24 -0
- package/dist/theme-assets.d.ts +25 -9
- package/dist/theme-assets.js +87 -47
- package/dist/theme-tokens.generated.d.ts +26 -2
- package/dist/theme-tokens.generated.js +17 -0
- package/dist/theme.d.ts +48 -10
- package/dist/theme.js +100 -21
- package/dist/tool.d.ts +156 -30
- package/dist/tool.js +91 -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 +245 -77
- package/dist/ui.js +104 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/dist/web.d.ts +26 -20
- package/package.json +12 -1
- package/schemas/bootstrap-extra.v1.schema.json +186 -0
- package/schemas/bootstrap.v1.schema.json +20 -0
- package/schemas/connector-template.v1.schema.json +62 -4
- package/schemas/plugin.v1.schema.json +74 -143
- package/schemas/theme.v1.schema.json +77 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
package/dist/plugin-manifest.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import semver from "semver";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { AGENT_TEMPLATE_LIMITS } from "./agent-template.js";
|
|
4
|
+
import { validateClientSection } from "./client-section.js";
|
|
4
5
|
import { CONFIG_UI_LIMITS } from "./config-ui.js";
|
|
5
6
|
import { defineExtension, EXTENSION_NAME_RE } from "./define-extension.js";
|
|
7
|
+
import { GitSourceSchema } from "./git-hosts.js";
|
|
6
8
|
import { CATALOG_ITEM_NAME_RE, CONNECTOR_TEMPLATE_LIMITS, isSafePackagePath, SEMVER_VERSION_RE, validateConnectorTemplate, } from "./plugin-package.js";
|
|
7
9
|
import { hasUpperBound } from "./semver-range.js";
|
|
8
|
-
import {
|
|
10
|
+
import { SETUP_GUIDE_LIMITS, SETUP_GUIDE_PLACES } from "./setup-guide.js";
|
|
9
11
|
import { THEME_LIMITS, themeIdOf } from "./theme.js";
|
|
12
|
+
import { parseSlotRef, uiSlot } from "./ui-slots.js";
|
|
10
13
|
/**
|
|
11
14
|
* The plugin manifest `.capybara-plugin/plugin.json` (package ecosystem spec §4.1). A plugin is a
|
|
12
15
|
* bundle of at most one extension, skills, connector templates, agent templates and themes, packed as
|
|
@@ -53,6 +56,8 @@ export const PLUGIN_MANIFEST_LIMITS = {
|
|
|
53
56
|
publisherChars: 100,
|
|
54
57
|
displayNameChars: 100,
|
|
55
58
|
pathChars: 512,
|
|
59
|
+
/** Entries of `suggestedAppearance.replacements`. */
|
|
60
|
+
appearanceReplacements: 8,
|
|
56
61
|
};
|
|
57
62
|
/** A plugin description as `{ en, zh? }` (a plain string is the English text). */
|
|
58
63
|
export function pluginDescription(d) {
|
|
@@ -61,6 +66,7 @@ export function pluginDescription(d) {
|
|
|
61
66
|
const L = PLUGIN_MANIFEST_LIMITS;
|
|
62
67
|
const MAX_ERRORS = 50;
|
|
63
68
|
const ICON_RE = /\.(?:svg|png)$/i;
|
|
69
|
+
const COMPONENT_ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
64
70
|
const HTTPS_URL_RE = /^https:\/\/\S+$/;
|
|
65
71
|
const text = (max, what) => z
|
|
66
72
|
.string()
|
|
@@ -87,6 +93,11 @@ const baseId = (p) => (p.split("/").pop() ?? "").replace(/\.json$/, "");
|
|
|
87
93
|
const configFields = z
|
|
88
94
|
.array(z.strictObject({ path: z.string().max(1000), secret: z.boolean(), hot: z.boolean() }))
|
|
89
95
|
.max(1000);
|
|
96
|
+
const configSchemaJson = z
|
|
97
|
+
.record(z.string(), z.unknown())
|
|
98
|
+
.refine((v) => new TextEncoder().encode(JSON.stringify(v)).length <= CONFIG_UI_LIMITS.configSchemaBytes, {
|
|
99
|
+
message: `must be at most ${CONFIG_UI_LIMITS.configSchemaBytes} bytes of JSON (${CONFIG_UI_LIMITS.configSchemaBytes / 1024} KiB)`,
|
|
100
|
+
});
|
|
90
101
|
const staticExtensionManifest = z.strictObject({
|
|
91
102
|
name: z.string(),
|
|
92
103
|
version: z.string(),
|
|
@@ -96,39 +107,39 @@ const staticExtensionManifest = z.strictObject({
|
|
|
96
107
|
optional: z.array(z.string()),
|
|
97
108
|
permissions: z.record(z.string(), z.unknown()),
|
|
98
109
|
ui: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
99
|
-
config: z.strictObject({ deployment: configFields
|
|
110
|
+
config: z.strictObject({ deployment: configFields }),
|
|
100
111
|
});
|
|
101
|
-
const configSchemaJson = z
|
|
102
|
-
.record(z.string(), z.unknown())
|
|
103
|
-
.refine((v) => new TextEncoder().encode(JSON.stringify(v)).length <= CONFIG_UI_LIMITS.configSchemaBytes, {
|
|
104
|
-
message: `must be at most ${CONFIG_UI_LIMITS.configSchemaBytes} bytes of JSON (${CONFIG_UI_LIMITS.configSchemaBytes / 1024} KiB)`,
|
|
105
|
-
});
|
|
106
|
-
const guideText = (max, what) => z.strictObject({ en: text(max, `${what}.en`), zh: text(max, `${what}.zh`).optional() });
|
|
107
112
|
const setupGuide = z.strictObject({
|
|
108
113
|
id: z.string().regex(CATALOG_ITEM_NAME_RE, {
|
|
109
114
|
message: "id must match ^[a-z0-9][a-z0-9-]{0,63}$",
|
|
110
115
|
}),
|
|
111
116
|
place: z.enum(SETUP_GUIDE_PLACES),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
en: text(SETUP_GUIDE_LIMITS.stepChars, "en"),
|
|
116
|
-
zh: text(SETUP_GUIDE_LIMITS.stepChars, "zh").optional(),
|
|
117
|
-
mode: z.string().max(64).optional(),
|
|
117
|
+
templates: z
|
|
118
|
+
.array(z.string().regex(CATALOG_ITEM_NAME_RE, {
|
|
119
|
+
message: "a template must match ^[a-z0-9][a-z0-9-]{0,63}$",
|
|
118
120
|
}))
|
|
119
|
-
.
|
|
121
|
+
.min(1)
|
|
122
|
+
.max(SETUP_GUIDE_LIMITS.templatesPerGuide)
|
|
120
123
|
.optional(),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
});
|
|
125
|
+
const clientSection = z
|
|
126
|
+
.strictObject({
|
|
127
|
+
entry: z.string().max(L.pathChars).optional(),
|
|
128
|
+
styles: z.array(z.string().max(L.pathChars)).max(64).optional(),
|
|
129
|
+
assets: z.array(z.string().max(L.pathChars)).max(256).optional(),
|
|
130
|
+
integrity: z.record(z.string().max(L.pathChars), z.string().max(128)),
|
|
131
|
+
apiVersion: z.number().int().min(1),
|
|
132
|
+
})
|
|
133
|
+
.superRefine((c, ctx) => {
|
|
134
|
+
for (const e of validateClientSection(c))
|
|
135
|
+
ctx.addIssue({ code: "custom", path: [], message: e });
|
|
136
|
+
});
|
|
137
|
+
const suggestedAppearance = z.strictObject({
|
|
138
|
+
theme: z
|
|
139
|
+
.string()
|
|
140
|
+
.regex(CATALOG_ITEM_NAME_RE, { message: "theme must match ^[a-z0-9][a-z0-9-]{0,63}$" })
|
|
131
141
|
.optional(),
|
|
142
|
+
replacements: z.record(z.string().max(100), z.string().max(100)).optional(),
|
|
132
143
|
});
|
|
133
144
|
const extensionSection = z.strictObject({
|
|
134
145
|
entry: dotPath("entry").refine((p) => p.endsWith(".mjs"), {
|
|
@@ -137,9 +148,8 @@ const extensionSection = z.strictObject({
|
|
|
137
148
|
manifest: staticExtensionManifest,
|
|
138
149
|
migrations: dotPath("migrations").optional(),
|
|
139
150
|
ui: dotPath("ui").optional(),
|
|
140
|
-
configSchemas: z
|
|
141
|
-
|
|
142
|
-
.optional(),
|
|
151
|
+
configSchemas: z.strictObject({ deployment: configSchemaJson.optional() }).optional(),
|
|
152
|
+
client: clientSection.optional(),
|
|
143
153
|
});
|
|
144
154
|
const schema = z
|
|
145
155
|
.strictObject({
|
|
@@ -186,7 +196,7 @@ const schema = z
|
|
|
186
196
|
.max(L.dependencies)
|
|
187
197
|
.optional(),
|
|
188
198
|
skills: z
|
|
189
|
-
.array(z.strictObject({ path: dotPath("path")
|
|
199
|
+
.array(z.strictObject({ path: dotPath("path") }))
|
|
190
200
|
.max(L.skills)
|
|
191
201
|
.optional(),
|
|
192
202
|
connectorTemplates: z
|
|
@@ -208,6 +218,7 @@ const schema = z
|
|
|
208
218
|
.max(L.themes)
|
|
209
219
|
.optional(),
|
|
210
220
|
setupGuides: z.array(setupGuide).max(SETUP_GUIDE_LIMITS.guides).optional(),
|
|
221
|
+
suggestedAppearance: suggestedAppearance.optional(),
|
|
211
222
|
extension: extensionSection.optional(),
|
|
212
223
|
})
|
|
213
224
|
.superRefine((m, ctx) => {
|
|
@@ -254,36 +265,93 @@ const schema = z
|
|
|
254
265
|
themeIds.add(id);
|
|
255
266
|
});
|
|
256
267
|
const guideIds = new Set();
|
|
268
|
+
const guideTemplates = new Set();
|
|
269
|
+
let channelGuides = 0;
|
|
257
270
|
m.setupGuides?.forEach((g, i) => {
|
|
258
271
|
if (guideIds.has(g.id))
|
|
259
272
|
issue(["setupGuides", i, "id"], `duplicate setup guide id ${g.id}`);
|
|
260
273
|
guideIds.add(g.id);
|
|
261
|
-
if (
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const modes = SETUP_GUIDE_MODES[g.place];
|
|
265
|
-
const badMode = (mode, path) => {
|
|
266
|
-
if (mode !== undefined && !modes.includes(mode)) {
|
|
267
|
-
issue(path, `mode must be one of ${modes.join(", ")} for place ${g.place}`);
|
|
274
|
+
if (g.place === "connector-template") {
|
|
275
|
+
if (g.templates === undefined) {
|
|
276
|
+
issue(["setupGuides", i, "templates"], "templates is required for a connector-template guide");
|
|
268
277
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
+
else {
|
|
279
|
+
g.templates.forEach((t, j) => {
|
|
280
|
+
if (m.connectorTemplates !== undefined && !ids.has(t)) {
|
|
281
|
+
issue(["setupGuides", i, "templates", j], `template ${t} is not one of the plugin's connector templates`);
|
|
282
|
+
}
|
|
283
|
+
if (guideTemplates.has(t)) {
|
|
284
|
+
issue(["setupGuides", i, "templates", j], `at most one setup guide per connector template (${t} is named twice)`);
|
|
285
|
+
}
|
|
286
|
+
guideTemplates.add(t);
|
|
287
|
+
});
|
|
278
288
|
}
|
|
279
|
-
|
|
280
|
-
|
|
289
|
+
}
|
|
290
|
+
else if (g.templates !== undefined) {
|
|
291
|
+
issue(["setupGuides", i, "templates"], "templates is only for connector-template guides");
|
|
292
|
+
}
|
|
293
|
+
if (g.place === "channel-connection") {
|
|
294
|
+
channelGuides++;
|
|
295
|
+
if (channelGuides === 2) {
|
|
296
|
+
issue(["setupGuides", i, "place"], "a plugin has at most one channel-connection guide");
|
|
297
|
+
}
|
|
298
|
+
}
|
|
281
299
|
if (g.place === "channel-connection" &&
|
|
282
300
|
m.extension !== undefined &&
|
|
283
301
|
!m.extension.manifest.provides.some((p) => p.startsWith("channel@"))) {
|
|
284
302
|
issue(["setupGuides", i, "place"], "a channel-connection guide needs the plugin's extension to provide channel@1");
|
|
285
303
|
}
|
|
286
304
|
});
|
|
305
|
+
const sa = m.suggestedAppearance;
|
|
306
|
+
if (sa !== undefined) {
|
|
307
|
+
const at = ["suggestedAppearance"];
|
|
308
|
+
if (sa.theme === undefined && sa.replacements === undefined) {
|
|
309
|
+
issue(at, "suggestedAppearance needs theme or replacements");
|
|
310
|
+
}
|
|
311
|
+
if (sa.theme !== undefined && m.themes !== undefined && !themeIds.has(sa.theme)) {
|
|
312
|
+
issue([...at, "theme"], `suggestedAppearance.theme names ${sa.theme}, which is not a theme of the plugin`);
|
|
313
|
+
}
|
|
314
|
+
if (sa.replacements !== undefined) {
|
|
315
|
+
const entries = Object.entries(sa.replacements);
|
|
316
|
+
if (m.extension === undefined) {
|
|
317
|
+
issue([...at, "replacements"], "suggestedAppearance.replacements needs an extension");
|
|
318
|
+
}
|
|
319
|
+
if (entries.length > L.appearanceReplacements) {
|
|
320
|
+
issue([...at, "replacements"], `suggestedAppearance.replacements has ${entries.length} entries; the limit is ${L.appearanceReplacements}`);
|
|
321
|
+
}
|
|
322
|
+
const seen = new Set();
|
|
323
|
+
for (const [slot, id] of entries) {
|
|
324
|
+
const ref = parseSlotRef(slot);
|
|
325
|
+
if (ref === null) {
|
|
326
|
+
issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} is not a slot ref`);
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (seen.has(ref.id)) {
|
|
330
|
+
issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names the slot ${ref.id} again; give each slot once`);
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
seen.add(ref.id);
|
|
334
|
+
if (!COMPONENT_ID_RE.test(id)) {
|
|
335
|
+
issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names ${id}, which is not a contribution id`);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
const known = uiSlot(ref.id);
|
|
339
|
+
if (known === undefined)
|
|
340
|
+
continue;
|
|
341
|
+
if (known.cardinality !== "single") {
|
|
342
|
+
issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} is not a replaceable slot`);
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
const ok = (m.extension?.manifest.ui ?? []).some((u) => {
|
|
346
|
+
const us = typeof u.slot === "string" ? parseSlotRef(u.slot) : null;
|
|
347
|
+
return u.id === id && u.kind === "component" && us?.id === ref.id;
|
|
348
|
+
});
|
|
349
|
+
if (!ok) {
|
|
350
|
+
issue([...at, "replacements"], `suggestedAppearance.replacements: ${slot} names ${id}, which is not a component contribution in that slot`);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
287
355
|
if (m.extension === undefined &&
|
|
288
356
|
m.skills?.length === 0 &&
|
|
289
357
|
m.connectorTemplates?.length === 0 &&
|
|
@@ -295,6 +363,13 @@ const schema = z
|
|
|
295
363
|
if (ext === undefined)
|
|
296
364
|
return;
|
|
297
365
|
const em = ext.manifest;
|
|
366
|
+
const hasClientPermission = em.permissions.client === true;
|
|
367
|
+
if (ext.client !== undefined && !hasClientPermission) {
|
|
368
|
+
issue(["extension", "client"], "extension.client needs permissions.client: true");
|
|
369
|
+
}
|
|
370
|
+
if (ext.client === undefined && hasClientPermission) {
|
|
371
|
+
issue(["extension", "manifest", "permissions", "client"], "permissions.client is true but extension.client is missing (pack the plugin with its client code, or drop permissions.client)");
|
|
372
|
+
}
|
|
298
373
|
if (!EXTENSION_NAME_RE.test(m.name)) {
|
|
299
374
|
issue(["name"], `a plugin with an extension needs an extension name (${EXTENSION_NAME_RE})`);
|
|
300
375
|
}
|
|
@@ -307,14 +382,12 @@ const schema = z
|
|
|
307
382
|
if (semver.validRange(em.sdk) !== null && !hasUpperBound(em.sdk)) {
|
|
308
383
|
issue(["extension", "manifest", "sdk"], `"${em.sdk}" has no upper bound: use a range such as ^0.1.0 so a future major SDK is not assumed compatible`);
|
|
309
384
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
issue(["extension", "manifest", "config", k], `duplicate config path "${f.path}"`);
|
|
315
|
-
}
|
|
316
|
-
seen.add(f.path);
|
|
385
|
+
const seen = new Set();
|
|
386
|
+
for (const f of em.config.deployment) {
|
|
387
|
+
if (seen.has(f.path)) {
|
|
388
|
+
issue(["extension", "manifest", "config", "deployment"], `duplicate config path "${f.path}"`);
|
|
317
389
|
}
|
|
390
|
+
seen.add(f.path);
|
|
318
391
|
}
|
|
319
392
|
// Name, version, sdk range, extension point refs, permissions, UI contributions: the same
|
|
320
393
|
// rules as defineExtension (with a placeholder setup).
|
|
@@ -347,12 +420,21 @@ const template = z.strictObject({
|
|
|
347
420
|
auth: z.record(z.string(), z.unknown()),
|
|
348
421
|
ownership: z.enum(["org", "personal"]).optional(),
|
|
349
422
|
defaultToolPolicies: z.record(z.string(), z.enum(["allow", "ask", "deny"])).optional(),
|
|
423
|
+
git: GitSourceSchema.optional(),
|
|
350
424
|
icon: z.string().max(L.pathChars).optional(),
|
|
351
425
|
});
|
|
352
426
|
const templateFile = z
|
|
353
427
|
.strictObject({
|
|
354
428
|
displayName: localized,
|
|
355
|
-
description:
|
|
429
|
+
description: z
|
|
430
|
+
.union([
|
|
431
|
+
text(CONNECTOR_TEMPLATE_LIMITS.descriptionChars, "description"),
|
|
432
|
+
z.strictObject({
|
|
433
|
+
zh: text(CONNECTOR_TEMPLATE_LIMITS.descriptionChars, "description.zh"),
|
|
434
|
+
en: text(CONNECTOR_TEMPLATE_LIMITS.descriptionChars, "description.en"),
|
|
435
|
+
}),
|
|
436
|
+
])
|
|
437
|
+
.optional(),
|
|
356
438
|
icon: z
|
|
357
439
|
.string()
|
|
358
440
|
.max(L.pathChars)
|
|
@@ -419,3 +501,13 @@ export function parsePluginManifest(json) {
|
|
|
419
501
|
export function parseConnectorTemplateFile(json) {
|
|
420
502
|
return parseWith(ConnectorTemplateFileSchema, json, "connector template file");
|
|
421
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* The theme check of `suggestedAppearance` after the themes are known (the manifest may omit
|
|
506
|
+
* `themes` and let the scan find them): shared by the packer and the kernel.
|
|
507
|
+
*/
|
|
508
|
+
export function appearanceIssues(manifest, themeIds) {
|
|
509
|
+
const theme = manifest.suggestedAppearance?.theme;
|
|
510
|
+
if (theme === undefined || themeIds.includes(theme))
|
|
511
|
+
return [];
|
|
512
|
+
return [`suggestedAppearance.theme names ${theme}, which is not a theme of the plugin`];
|
|
513
|
+
}
|
package/dist/plugin-package.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ExtensionManifest } from "./define-extension.js";
|
|
2
|
+
import { type GitSource } from "./git-hosts.js";
|
|
2
3
|
import type { ExtensionPermissions } from "./permissions.js";
|
|
3
4
|
import type { PluginManifest } from "./plugin-manifest.js";
|
|
4
5
|
/**
|
|
@@ -10,17 +11,29 @@ import type { PluginManifest } from "./plugin-manifest.js";
|
|
|
10
11
|
* entry is single-file ESM with third-party dependencies bundled; only {@link HOST_PROVIDED_PACKAGES}
|
|
11
12
|
* come from the host.
|
|
12
13
|
*/
|
|
13
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Packages provided by the host (peerDependencies, linked to the host's copy on install); every
|
|
16
|
+
* other third-party dependency must be bundled into the entry.
|
|
17
|
+
*/
|
|
14
18
|
export declare const HOST_PROVIDED_PACKAGES: readonly ["@capybara-hq/plugin-sdk", "zod"];
|
|
15
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Scripts npm runs automatically on install: a plugin package must never have any (installs run no
|
|
21
|
+
* scripts, so having them would mislead).
|
|
22
|
+
*/
|
|
16
23
|
export declare const FORBIDDEN_INSTALL_SCRIPTS: readonly ["preinstall", "install", "postinstall", "prepare"];
|
|
17
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* A config field in the static manifest (a dotted path; an empty string when the root is itself the
|
|
26
|
+
* leaf).
|
|
27
|
+
*/
|
|
18
28
|
export interface StaticConfigField {
|
|
19
29
|
path: string;
|
|
20
30
|
secret: boolean;
|
|
21
31
|
hot: boolean;
|
|
22
32
|
}
|
|
23
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* The static part of the plugin manifest (JSON-serializable; excludes setup, zod schemas and
|
|
35
|
+
* migration paths).
|
|
36
|
+
*/
|
|
24
37
|
export interface StaticExtensionManifest {
|
|
25
38
|
name: string;
|
|
26
39
|
version: string;
|
|
@@ -32,30 +45,40 @@ export interface StaticExtensionManifest {
|
|
|
32
45
|
ui?: ExtensionManifest["ui"];
|
|
33
46
|
config: {
|
|
34
47
|
deployment: StaticConfigField[];
|
|
35
|
-
org: StaticConfigField[];
|
|
36
48
|
};
|
|
37
49
|
}
|
|
38
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* An import in the entry module: `name` is the specifier (an empty string for a dynamic import that
|
|
52
|
+
* is not a literal).
|
|
53
|
+
*/
|
|
39
54
|
export interface EntryImport {
|
|
40
55
|
name: string;
|
|
41
56
|
dynamic: boolean;
|
|
42
57
|
literal: boolean;
|
|
43
58
|
}
|
|
44
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* npm package name rule (simplified): may carry a scope, lowercase, ≤ 214 characters (the length is
|
|
61
|
+
* checked separately).
|
|
62
|
+
*/
|
|
45
63
|
export declare const NPM_PACKAGE_NAME_RE: RegExp;
|
|
46
64
|
/**
|
|
47
|
-
*
|
|
65
|
+
* Whether a path relative to the package is safe: non-empty, not starting with `/`, no `\`, control
|
|
66
|
+
* characters or drive letters, no empty segments, `.` or `..` segments, ≤ 1024 characters.
|
|
48
67
|
*/
|
|
49
68
|
export declare function isSafePackagePath(p: string): boolean;
|
|
50
69
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
70
|
+
* Checks the entry module's imports (C11): static and literal dynamic imports may only be `node:*`,
|
|
71
|
+
* {@link HOST_PROVIDED_PACKAGES} (subpaths included)
|
|
72
|
+
* and in-package relative paths (`./`, `../`; whether they escape the package is judged by the
|
|
73
|
+
* caller from the file location); non-literal dynamic imports are always rejected.
|
|
74
|
+
* Returns the list of problems (empty means valid).
|
|
54
75
|
*/
|
|
55
76
|
export declare function checkEntryImports(specifiers: EntryImport[]): string[];
|
|
56
77
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
78
|
+
* The static part of the real manifest: written into `capybara.manifest` when packing, and compared
|
|
79
|
+
* with the in-package one at load time (`manifest_mismatch`).
|
|
80
|
+
* The result survives a JSON round trip (undefined fields removed); config fields are sorted by
|
|
81
|
+
* path.
|
|
59
82
|
*/
|
|
60
83
|
export declare function staticManifestOf(m: ExtensionManifest): StaticExtensionManifest;
|
|
61
84
|
/**
|
|
@@ -78,62 +101,82 @@ export declare function validatePluginPackageJsonFor(pkg: unknown, manifest: Plu
|
|
|
78
101
|
*/
|
|
79
102
|
export declare function hostSdkProblem(sdk: string, hostSdkVersion: string): string | undefined;
|
|
80
103
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
104
|
+
* Connector template (C30): connector plugin reference + `Connector.kind` + endpoint preset +
|
|
105
|
+
* endpoint paths an org may change + auth preset (no credentials) +
|
|
106
|
+
* default ownership + default policy per tool + icon. When installing, an org may only fill in
|
|
107
|
+
* credentials, the client id / secret and the fields in `editableEndpoint`.
|
|
83
108
|
*/
|
|
84
109
|
export interface ConnectorTemplateSpec {
|
|
85
|
-
/**
|
|
110
|
+
/** Connector plugin name (e.g. `connector-mcp`). */
|
|
86
111
|
plugin: string;
|
|
87
|
-
/**
|
|
112
|
+
/** Semver range of the connector plugin, optional. */
|
|
88
113
|
pluginVersion?: string;
|
|
89
|
-
/** `Connector.kind
|
|
114
|
+
/** `Connector.kind` (e.g. `"mcp"`). */
|
|
90
115
|
connector: string;
|
|
91
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* Endpoint preset; on import the kernel validates it against that connector's `endpointSchema`.
|
|
118
|
+
*/
|
|
92
119
|
endpoint: Record<string, unknown>;
|
|
93
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Dotted paths an org may change when installing (e.g. `"url"`); everything else follows the
|
|
122
|
+
* template. The paths must exist in the connector's endpoint schema.
|
|
123
|
+
*/
|
|
94
124
|
editableEndpoint?: string[];
|
|
95
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* The same shape as the auth method of the connector install API ({@link ConnectorAuthSchema}),
|
|
127
|
+
* carrying no credentials.
|
|
128
|
+
*/
|
|
96
129
|
auth: Record<string, unknown>;
|
|
97
|
-
/**
|
|
130
|
+
/** Defaults to `auth.ownership`; if given it must agree. */
|
|
98
131
|
ownership?: "org" | "personal";
|
|
99
|
-
/**
|
|
132
|
+
/** Tool name -> default policy (recorded as `policy_source 'template'` after install). */
|
|
100
133
|
defaultToolPolicies?: Record<string, "allow" | "ask" | "deny">;
|
|
101
|
-
/**
|
|
134
|
+
/** Git hosts this connector's credential serves in sandboxes ({@link GitSource}). */
|
|
135
|
+
git?: GitSource;
|
|
136
|
+
/** In-package path, svg / png, ≤ {@link CONNECTOR_TEMPLATE_LIMITS}`.iconBytes`. */
|
|
102
137
|
icon?: string;
|
|
103
138
|
}
|
|
104
|
-
/**
|
|
139
|
+
/** Bilingual display name. */
|
|
105
140
|
export interface LocalizedName {
|
|
106
141
|
zh: string;
|
|
107
142
|
en: string;
|
|
108
143
|
}
|
|
109
|
-
/**
|
|
144
|
+
/** Limits of connector templates and catalog segments. */
|
|
110
145
|
export declare const CONNECTOR_TEMPLATE_LIMITS: {
|
|
111
|
-
/**
|
|
146
|
+
/** Upper bound on icon bytes. */
|
|
112
147
|
readonly iconBytes: number;
|
|
113
|
-
/**
|
|
148
|
+
/** Upper bound on the characters of the endpoint preset after JSON serialization. */
|
|
114
149
|
readonly endpointChars: number;
|
|
115
|
-
/** `editableEndpoint`
|
|
150
|
+
/** Upper bound on the number of `editableEndpoint` entries. */
|
|
116
151
|
readonly editablePaths: 50;
|
|
117
|
-
/** `defaultToolPolicies`
|
|
152
|
+
/** Upper bound on the number of `defaultToolPolicies` entries. */
|
|
118
153
|
readonly toolPolicies: 1000;
|
|
119
|
-
/** publisher
|
|
154
|
+
/** Upper bound on the characters of publisher. */
|
|
120
155
|
readonly publisherChars: 100;
|
|
121
|
-
/** description
|
|
156
|
+
/** Upper bound on the characters of description (per language when it is `{ zh, en }`). */
|
|
122
157
|
readonly descriptionChars: 1024;
|
|
123
|
-
/** displayName
|
|
158
|
+
/** Upper bound on the characters of displayName per language. */
|
|
124
159
|
readonly displayNameChars: 100;
|
|
125
160
|
};
|
|
126
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Catalog entry name (the same rule as manifest entry names): starts with a lowercase letter or
|
|
163
|
+
* digit, then lowercase letters, digits and hyphens, ≤ 64.
|
|
164
|
+
*/
|
|
127
165
|
export declare const CATALOG_ITEM_NAME_RE: RegExp;
|
|
128
166
|
/** An exact semver version (a regex JSON Schema can use). */
|
|
129
167
|
export declare const SEMVER_VERSION_RE: RegExp;
|
|
130
168
|
/** The sha512 SRI of an npm package tgz: `sha512-<86 base64 chars>==`. */
|
|
131
169
|
export declare const SHA512_INTEGRITY_RE: RegExp;
|
|
132
170
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
171
|
+
* Validates the static part of a connector template ({@link ConnectorTemplateSpec}) and returns the
|
|
172
|
+
* list of problems (empty means valid; paths are relative to the template root, values are not
|
|
173
|
+
* echoed):
|
|
174
|
+
* fields complete, no unknown fields; `auth` conforms to {@link ConnectorAuthSchema} (strict: extra
|
|
175
|
+
* fields such as `token` are rejected);
|
|
176
|
+
* no credential-style key at any level of the endpoint preset; `editableEndpoint` is a list of
|
|
177
|
+
* distinct dotted paths; `ownership` agrees with `auth.ownership`;
|
|
178
|
+
* default policies may only be allow / ask / deny; icon is an in-package .svg / .png path.
|
|
179
|
+
* Whether the endpoint conforms to the connector's `endpointSchema` and whether `editableEndpoint`
|
|
180
|
+
* exists in it is checked by the kernel on import against the loaded connector.
|
|
138
181
|
*/
|
|
139
182
|
export declare function validateConnectorTemplate(t: unknown): string[];
|