@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/plugin-manifest.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
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";
|
|
11
|
+
import { THEME_LIMITS, themeIdOf } from "./theme.js";
|
|
12
|
+
import { parseSlotRef, uiSlot } from "./ui-slots.js";
|
|
9
13
|
/**
|
|
10
14
|
* The plugin manifest `.capybara-plugin/plugin.json` (package ecosystem spec §4.1). A plugin is a
|
|
11
|
-
* bundle of at most one extension, skills
|
|
15
|
+
* bundle of at most one extension, skills, connector templates, agent templates and themes, packed as
|
|
16
|
+
* an npm-pack tgz:
|
|
12
17
|
*
|
|
13
18
|
* ```
|
|
14
19
|
* package/package.json npm metadata; version equals plugin.json version
|
|
@@ -16,13 +21,14 @@ import { SETUP_GUIDE_FILE_RE, SETUP_GUIDE_LANGUAGES, SETUP_GUIDE_LIMITS, SETUP_G
|
|
|
16
21
|
* package/skills/<name>/SKILL.md skills
|
|
17
22
|
* package/connectors/<id>.json connector templates ({@link ConnectorTemplateFile})
|
|
18
23
|
* package/agents/<name>.md agent templates (parsed by `parseAgentTemplate`)
|
|
24
|
+
* package/themes/<id>.json themes (parsed by `parseThemeFile`)
|
|
19
25
|
* package/dist/index.mjs extension entry (only with an extension)
|
|
20
26
|
* package/migrations/*.sql, package/ui/**
|
|
21
27
|
* ```
|
|
22
28
|
*
|
|
23
29
|
* Paths start with `./` and stay inside the plugin root. Omitting `skills` / `connectorTemplates`
|
|
24
|
-
* / `agents` means "scan `skills/*\/SKILL.md` / `connectors/*.json` / `agents/*.md`
|
|
25
|
-
* kernel when it reads the package). `extension` is written by the packer, never by hand.
|
|
30
|
+
* / `agents` / `themes` means "scan `skills/*\/SKILL.md` / `connectors/*.json` / `agents/*.md` /
|
|
31
|
+
* `themes/*.json`" (done by the kernel when it reads the package). `extension` is written by the packer, never by hand.
|
|
26
32
|
*
|
|
27
33
|
* The committed JSON Schema (`schemas/plugin.v1.schema.json`) is generated from
|
|
28
34
|
* {@link PluginManifestSchema} by `pnpm gen:package-schemas` and drift-checked by
|
|
@@ -44,10 +50,14 @@ export const PLUGIN_MANIFEST_LIMITS = {
|
|
|
44
50
|
connectorTemplates: 20,
|
|
45
51
|
/** Agent templates ({@link AGENT_TEMPLATE_LIMITS}`.perPlugin`). */
|
|
46
52
|
agents: AGENT_TEMPLATE_LIMITS.perPlugin,
|
|
53
|
+
/** Themes ({@link THEME_LIMITS}`.perPlugin`). */
|
|
54
|
+
themes: THEME_LIMITS.perPlugin,
|
|
47
55
|
descriptionChars: 1024,
|
|
48
56
|
publisherChars: 100,
|
|
49
57
|
displayNameChars: 100,
|
|
50
58
|
pathChars: 512,
|
|
59
|
+
/** Entries of `suggestedAppearance.replacements`. */
|
|
60
|
+
appearanceReplacements: 8,
|
|
51
61
|
};
|
|
52
62
|
/** A plugin description as `{ en, zh? }` (a plain string is the English text). */
|
|
53
63
|
export function pluginDescription(d) {
|
|
@@ -56,6 +66,7 @@ export function pluginDescription(d) {
|
|
|
56
66
|
const L = PLUGIN_MANIFEST_LIMITS;
|
|
57
67
|
const MAX_ERRORS = 50;
|
|
58
68
|
const ICON_RE = /\.(?:svg|png)$/i;
|
|
69
|
+
const COMPONENT_ID_RE = /^[a-z][a-z0-9-]{0,39}$/;
|
|
59
70
|
const HTTPS_URL_RE = /^https:\/\/\S+$/;
|
|
60
71
|
const text = (max, what) => z
|
|
61
72
|
.string()
|
|
@@ -82,6 +93,11 @@ const baseId = (p) => (p.split("/").pop() ?? "").replace(/\.json$/, "");
|
|
|
82
93
|
const configFields = z
|
|
83
94
|
.array(z.strictObject({ path: z.string().max(1000), secret: z.boolean(), hot: z.boolean() }))
|
|
84
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
|
+
});
|
|
85
101
|
const staticExtensionManifest = z.strictObject({
|
|
86
102
|
name: z.string(),
|
|
87
103
|
version: z.string(),
|
|
@@ -91,39 +107,39 @@ const staticExtensionManifest = z.strictObject({
|
|
|
91
107
|
optional: z.array(z.string()),
|
|
92
108
|
permissions: z.record(z.string(), z.unknown()),
|
|
93
109
|
ui: z.array(z.record(z.string(), z.unknown())).optional(),
|
|
94
|
-
config: z.strictObject({ deployment: configFields
|
|
95
|
-
});
|
|
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)`,
|
|
110
|
+
config: z.strictObject({ deployment: configFields }),
|
|
100
111
|
});
|
|
101
|
-
const guideText = (max, what) => z.strictObject({ en: text(max, `${what}.en`), zh: text(max, `${what}.zh`).optional() });
|
|
102
112
|
const setupGuide = z.strictObject({
|
|
103
113
|
id: z.string().regex(CATALOG_ITEM_NAME_RE, {
|
|
104
114
|
message: "id must match ^[a-z0-9][a-z0-9-]{0,63}$",
|
|
105
115
|
}),
|
|
106
116
|
place: z.enum(SETUP_GUIDE_PLACES),
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
en: text(SETUP_GUIDE_LIMITS.stepChars, "en"),
|
|
111
|
-
zh: text(SETUP_GUIDE_LIMITS.stepChars, "zh").optional(),
|
|
112
|
-
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}$",
|
|
113
120
|
}))
|
|
114
|
-
.
|
|
121
|
+
.min(1)
|
|
122
|
+
.max(SETUP_GUIDE_LIMITS.templatesPerGuide)
|
|
115
123
|
.optional(),
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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}$" })
|
|
126
141
|
.optional(),
|
|
142
|
+
replacements: z.record(z.string().max(100), z.string().max(100)).optional(),
|
|
127
143
|
});
|
|
128
144
|
const extensionSection = z.strictObject({
|
|
129
145
|
entry: dotPath("entry").refine((p) => p.endsWith(".mjs"), {
|
|
@@ -132,9 +148,8 @@ const extensionSection = z.strictObject({
|
|
|
132
148
|
manifest: staticExtensionManifest,
|
|
133
149
|
migrations: dotPath("migrations").optional(),
|
|
134
150
|
ui: dotPath("ui").optional(),
|
|
135
|
-
configSchemas: z
|
|
136
|
-
|
|
137
|
-
.optional(),
|
|
151
|
+
configSchemas: z.strictObject({ deployment: configSchemaJson.optional() }).optional(),
|
|
152
|
+
client: clientSection.optional(),
|
|
138
153
|
});
|
|
139
154
|
const schema = z
|
|
140
155
|
.strictObject({
|
|
@@ -181,7 +196,7 @@ const schema = z
|
|
|
181
196
|
.max(L.dependencies)
|
|
182
197
|
.optional(),
|
|
183
198
|
skills: z
|
|
184
|
-
.array(z.strictObject({ path: dotPath("path")
|
|
199
|
+
.array(z.strictObject({ path: dotPath("path") }))
|
|
185
200
|
.max(L.skills)
|
|
186
201
|
.optional(),
|
|
187
202
|
connectorTemplates: z
|
|
@@ -196,7 +211,14 @@ const schema = z
|
|
|
196
211
|
}))
|
|
197
212
|
.max(L.agents)
|
|
198
213
|
.optional(),
|
|
214
|
+
themes: z
|
|
215
|
+
.array(z.strictObject({
|
|
216
|
+
path: dotPath("path").refine((p) => p.endsWith(".json") && CATALOG_ITEM_NAME_RE.test(themeIdOf(p)), { message: "path must be a <id>.json file with id matching ^[a-z0-9][a-z0-9-]{0,63}$" }),
|
|
217
|
+
}))
|
|
218
|
+
.max(L.themes)
|
|
219
|
+
.optional(),
|
|
199
220
|
setupGuides: z.array(setupGuide).max(SETUP_GUIDE_LIMITS.guides).optional(),
|
|
221
|
+
suggestedAppearance: suggestedAppearance.optional(),
|
|
200
222
|
extension: extensionSection.optional(),
|
|
201
223
|
})
|
|
202
224
|
.superRefine((m, ctx) => {
|
|
@@ -235,47 +257,119 @@ const schema = z
|
|
|
235
257
|
issue(["agents", i, "path"], `duplicate agent template path ${a.path}`);
|
|
236
258
|
agentPaths.add(a.path);
|
|
237
259
|
});
|
|
260
|
+
const themeIds = new Set();
|
|
261
|
+
m.themes?.forEach((t, i) => {
|
|
262
|
+
const id = themeIdOf(t.path);
|
|
263
|
+
if (themeIds.has(id))
|
|
264
|
+
issue(["themes", i, "path"], `duplicate theme id ${id}`);
|
|
265
|
+
themeIds.add(id);
|
|
266
|
+
});
|
|
238
267
|
const guideIds = new Set();
|
|
268
|
+
const guideTemplates = new Set();
|
|
269
|
+
let channelGuides = 0;
|
|
239
270
|
m.setupGuides?.forEach((g, i) => {
|
|
240
271
|
if (guideIds.has(g.id))
|
|
241
272
|
issue(["setupGuides", i, "id"], `duplicate setup guide id ${g.id}`);
|
|
242
273
|
guideIds.add(g.id);
|
|
243
|
-
if (
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const modes = SETUP_GUIDE_MODES[g.place];
|
|
247
|
-
const badMode = (mode, path) => {
|
|
248
|
-
if (mode !== undefined && !modes.includes(mode)) {
|
|
249
|
-
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");
|
|
250
277
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
+
});
|
|
260
288
|
}
|
|
261
|
-
|
|
262
|
-
|
|
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
|
+
}
|
|
263
299
|
if (g.place === "channel-connection" &&
|
|
264
300
|
m.extension !== undefined &&
|
|
265
301
|
!m.extension.manifest.provides.some((p) => p.startsWith("channel@"))) {
|
|
266
302
|
issue(["setupGuides", i, "place"], "a channel-connection guide needs the plugin's extension to provide channel@1");
|
|
267
303
|
}
|
|
268
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
|
+
}
|
|
269
355
|
if (m.extension === undefined &&
|
|
270
356
|
m.skills?.length === 0 &&
|
|
271
357
|
m.connectorTemplates?.length === 0 &&
|
|
272
|
-
(m.agents === undefined || m.agents.length === 0)
|
|
273
|
-
|
|
358
|
+
(m.agents === undefined || m.agents.length === 0) &&
|
|
359
|
+
(m.themes === undefined || m.themes.length === 0)) {
|
|
360
|
+
issue([], "a plugin must contain an extension, a skill, a connector template, an agent template or a theme");
|
|
274
361
|
}
|
|
275
362
|
const ext = m.extension;
|
|
276
363
|
if (ext === undefined)
|
|
277
364
|
return;
|
|
278
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
|
+
}
|
|
279
373
|
if (!EXTENSION_NAME_RE.test(m.name)) {
|
|
280
374
|
issue(["name"], `a plugin with an extension needs an extension name (${EXTENSION_NAME_RE})`);
|
|
281
375
|
}
|
|
@@ -288,14 +382,12 @@ const schema = z
|
|
|
288
382
|
if (semver.validRange(em.sdk) !== null && !hasUpperBound(em.sdk)) {
|
|
289
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`);
|
|
290
384
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
issue(["extension", "manifest", "config", k], `duplicate config path "${f.path}"`);
|
|
296
|
-
}
|
|
297
|
-
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}"`);
|
|
298
389
|
}
|
|
390
|
+
seen.add(f.path);
|
|
299
391
|
}
|
|
300
392
|
// Name, version, sdk range, extension point refs, permissions, UI contributions: the same
|
|
301
393
|
// rules as defineExtension (with a placeholder setup).
|
|
@@ -328,12 +420,21 @@ const template = z.strictObject({
|
|
|
328
420
|
auth: z.record(z.string(), z.unknown()),
|
|
329
421
|
ownership: z.enum(["org", "personal"]).optional(),
|
|
330
422
|
defaultToolPolicies: z.record(z.string(), z.enum(["allow", "ask", "deny"])).optional(),
|
|
423
|
+
git: GitSourceSchema.optional(),
|
|
331
424
|
icon: z.string().max(L.pathChars).optional(),
|
|
332
425
|
});
|
|
333
426
|
const templateFile = z
|
|
334
427
|
.strictObject({
|
|
335
428
|
displayName: localized,
|
|
336
|
-
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(),
|
|
337
438
|
icon: z
|
|
338
439
|
.string()
|
|
339
440
|
.max(L.pathChars)
|
|
@@ -400,3 +501,13 @@ export function parsePluginManifest(json) {
|
|
|
400
501
|
export function parseConnectorTemplateFile(json) {
|
|
401
502
|
return parseWith(ConnectorTemplateFileSchema, json, "connector template file");
|
|
402
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[];
|