@capybara-hq/plugin-sdk 0.1.0-rc.3 → 0.1.0-rc.30
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/agent-docs/agent-templates.md +15 -3
- package/agent-docs/concepts.md +5 -0
- package/agent-docs/connector-templates.md +2 -1
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/config-source.md +1 -1
- package/agent-docs/extension-points/connector.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/counter.md +1 -1
- package/agent-docs/extension-points/directory.md +1 -1
- package/agent-docs/extension-points/file-preview.md +1 -1
- package/agent-docs/extension-points/identity-source.md +1 -1
- package/agent-docs/extension-points/model-provider.md +4 -2
- package/agent-docs/extension-points/object-store.md +3 -1
- package/agent-docs/extension-points/sandbox.md +3 -3
- package/agent-docs/extension-points/secret-store.md +1 -1
- package/agent-docs/extension-points/web-fetch.md +1 -1
- package/agent-docs/extension-points/web-search.md +1 -1
- package/agent-docs/extensions.md +29 -4
- package/agent-docs/plugin-format.md +43 -3
- package/agent-docs/setup.md +46 -0
- package/agent-docs/skills.md +1 -1
- package/agent-docs/tool-naming.md +1 -1
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/bootstrap.d.ts +15 -1
- package/dist/bootstrap.js +17 -1
- package/dist/cards.d.ts +56 -13
- package/dist/cards.js +90 -20
- package/dist/channel.d.ts +111 -48
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +22 -0
- package/dist/config-ui.js +64 -4
- package/dist/connector-auth.d.ts +7 -2
- package/dist/connector-auth.js +29 -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 +135 -26
- package/dist/define-extension.d.ts +26 -12
- package/dist/define-extension.js +11 -4
- package/dist/device-protocol.d.ts +319 -0
- package/dist/device-protocol.js +559 -0
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +5 -2
- package/dist/file-preview.d.ts +1 -1
- package/dist/git-hosts.d.ts +44 -0
- package/dist/git-hosts.js +81 -0
- package/dist/hooks.d.ts +111 -21
- package/dist/hooks.js +5 -0
- package/dist/http-access.d.ts +52 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +22 -9
- package/dist/index.d.ts +21 -1
- package/dist/index.js +21 -1
- package/dist/marketplace.d.ts +26 -0
- package/dist/marketplace.js +43 -1
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +180 -71
- package/dist/model.js +71 -19
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/permissions.d.ts +42 -20
- package/dist/permissions.js +97 -40
- package/dist/plugin-manifest.d.ts +45 -5
- package/dist/plugin-manifest.js +169 -6
- package/dist/plugin-package.d.ts +82 -38
- package/dist/plugin-package.js +61 -29
- package/dist/sandbox-linux-runtime-source.d.ts +15 -0
- package/dist/sandbox-linux-runtime-source.js +1421 -0
- package/dist/sandbox-native-runtime-source.d.ts +8 -0
- package/dist/sandbox-native-runtime-source.js +307 -0
- package/dist/sandbox-operation.d.ts +248 -0
- package/dist/sandbox-operation.js +245 -0
- package/dist/sandbox-runtime-source.d.ts +19 -0
- package/dist/sandbox-runtime-source.js +28 -0
- package/dist/sandbox.d.ts +201 -16
- package/dist/sandbox.js +89 -14
- package/dist/secret.d.ts +4 -1
- package/dist/secret.js +4 -1
- package/dist/setup-check.d.ts +115 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +350 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +94 -0
- package/dist/setup-guide.js +336 -0
- package/dist/skill-invocation.d.ts +4 -3
- package/dist/skill-invocation.js +5 -4
- package/dist/skill.d.ts +34 -21
- package/dist/skill.js +48 -31
- package/dist/storage.d.ts +52 -25
- package/dist/theme-assets.d.ts +39 -0
- package/dist/theme-assets.js +449 -0
- package/dist/theme-readability.d.ts +37 -0
- package/dist/theme-readability.js +145 -0
- package/dist/theme-tokens.generated.d.ts +279 -0
- package/dist/theme-tokens.generated.js +174 -0
- package/dist/theme.d.ts +152 -0
- package/dist/theme.js +392 -0
- package/dist/tool.d.ts +69 -26
- package/dist/tool.js +29 -9
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +337 -0
- package/dist/ui-resolve.d.ts +35 -0
- package/dist/ui-resolve.js +42 -0
- package/dist/ui-slots.d.ts +53 -0
- package/dist/ui-slots.js +238 -0
- package/dist/ui.d.ts +191 -79
- package/dist/ui.js +101 -27
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/package.json +7 -1
- package/schemas/bootstrap.v1.schema.json +6 -0
- package/schemas/connector-template.v1.schema.json +35 -0
- package/schemas/marketplace.v1.schema.json +14 -0
- package/schemas/plugin.v1.schema.json +115 -3
- package/schemas/theme.v1.schema.json +225 -0
package/dist/plugin-package.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import semver from "semver";
|
|
2
2
|
import { ConnectorAuthSchema } from "./connector-auth.js";
|
|
3
3
|
import { EXTENSION_NAME_RE } from "./define-extension.js";
|
|
4
|
+
import { validateGitSource } from "./git-hosts.js";
|
|
4
5
|
/**
|
|
5
6
|
* Plugin package (npm-pack tgz) rules shared by the SDK, the packer and the kernel (spec §4.1). Pure
|
|
6
7
|
* functions only: the kernel reads the tgz and scans imports, `packages/plugin-tools` packs it. The
|
|
@@ -10,16 +11,24 @@ import { EXTENSION_NAME_RE } from "./define-extension.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 const HOST_PROVIDED_PACKAGES = ["@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 const FORBIDDEN_INSTALL_SCRIPTS = [
|
|
17
24
|
"preinstall",
|
|
18
25
|
"install",
|
|
19
26
|
"postinstall",
|
|
20
27
|
"prepare",
|
|
21
28
|
];
|
|
22
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Dependency fields that must not appear: third-party dependencies must be bundled into the entry.
|
|
31
|
+
*/
|
|
23
32
|
const FORBIDDEN_DEP_FIELDS = [
|
|
24
33
|
"dependencies",
|
|
25
34
|
"optionalDependencies",
|
|
@@ -27,16 +36,20 @@ const FORBIDDEN_DEP_FIELDS = [
|
|
|
27
36
|
"bundledDependencies",
|
|
28
37
|
];
|
|
29
38
|
const isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
30
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* npm package name rule (simplified): may carry a scope, lowercase, ≤ 214 characters (the length is
|
|
41
|
+
* checked separately).
|
|
42
|
+
*/
|
|
31
43
|
export const NPM_PACKAGE_NAME_RE = /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/;
|
|
32
44
|
const NPM_NAME_RE = NPM_PACKAGE_NAME_RE;
|
|
33
45
|
/**
|
|
34
|
-
*
|
|
46
|
+
* Whether a path relative to the package is safe: non-empty, not starting with `/`, no `\`, control
|
|
47
|
+
* characters or drive letters, no empty segments, `.` or `..` segments, ≤ 1024 characters.
|
|
35
48
|
*/
|
|
36
49
|
export function isSafePackagePath(p) {
|
|
37
50
|
if (typeof p !== "string" || p === "" || p.length > 1024)
|
|
38
51
|
return false;
|
|
39
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex:
|
|
52
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: control characters are exactly what must be rejected
|
|
40
53
|
if (p.startsWith("/") || p.includes("\\") || /[\u0000-\u001f\u007f]/.test(p))
|
|
41
54
|
return false;
|
|
42
55
|
if (/^[A-Za-z]:/.test(p))
|
|
@@ -45,9 +58,11 @@ export function isSafePackagePath(p) {
|
|
|
45
58
|
}
|
|
46
59
|
const isHostPackage = (name) => HOST_PROVIDED_PACKAGES.some((h) => name === h || name.startsWith(`${h}/`));
|
|
47
60
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
61
|
+
* Checks the entry module's imports (C11): static and literal dynamic imports may only be `node:*`,
|
|
62
|
+
* {@link HOST_PROVIDED_PACKAGES} (subpaths included)
|
|
63
|
+
* and in-package relative paths (`./`, `../`; whether they escape the package is judged by the
|
|
64
|
+
* caller from the file location); non-literal dynamic imports are always rejected.
|
|
65
|
+
* Returns the list of problems (empty means valid).
|
|
51
66
|
*/
|
|
52
67
|
export function checkEntryImports(specifiers) {
|
|
53
68
|
const out = [];
|
|
@@ -71,7 +86,10 @@ export function checkEntryImports(specifiers) {
|
|
|
71
86
|
const WRAPPERS = new Set(["default", "prefault", "optional", "nullable", "readonly", "catch"]);
|
|
72
87
|
const defOf = (s) => s._zod.def;
|
|
73
88
|
const metaOf = (s) => s.meta();
|
|
74
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* The same traversal as the kernel's `configFields`: objects are expanded recursively, wrappers
|
|
91
|
+
* such as default / optional are stripped, and a secret on an object is inherited downward.
|
|
92
|
+
*/
|
|
75
93
|
function configFieldsOf(schema, prefix = "", inheritedSecret = false) {
|
|
76
94
|
if (!schema)
|
|
77
95
|
return [];
|
|
@@ -91,8 +109,10 @@ function configFieldsOf(schema, prefix = "", inheritedSecret = false) {
|
|
|
91
109
|
const byPath = (a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0;
|
|
92
110
|
const jsonClone = (v) => JSON.parse(JSON.stringify(v));
|
|
93
111
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
112
|
+
* The static part of the real manifest: written into `capybara.manifest` when packing, and compared
|
|
113
|
+
* with the in-package one at load time (`manifest_mismatch`).
|
|
114
|
+
* The result survives a JSON round trip (undefined fields removed); config fields are sorted by
|
|
115
|
+
* path.
|
|
96
116
|
*/
|
|
97
117
|
export function staticManifestOf(m) {
|
|
98
118
|
const out = {
|
|
@@ -253,24 +273,27 @@ export function hostSdkProblem(sdk, hostSdkVersion) {
|
|
|
253
273
|
return undefined;
|
|
254
274
|
return `extension.manifest.sdk "${sdk}" is not satisfied by the host SDK version ${hostSdkVersion}`;
|
|
255
275
|
}
|
|
256
|
-
/**
|
|
276
|
+
/** Limits of connector templates and catalog segments. */
|
|
257
277
|
export const CONNECTOR_TEMPLATE_LIMITS = {
|
|
258
|
-
/**
|
|
278
|
+
/** Upper bound on icon bytes. */
|
|
259
279
|
iconBytes: 64 * 1024,
|
|
260
|
-
/**
|
|
280
|
+
/** Upper bound on the characters of the endpoint preset after JSON serialization. */
|
|
261
281
|
endpointChars: 16 * 1024,
|
|
262
|
-
/** `editableEndpoint`
|
|
282
|
+
/** Upper bound on the number of `editableEndpoint` entries. */
|
|
263
283
|
editablePaths: 50,
|
|
264
|
-
/** `defaultToolPolicies`
|
|
284
|
+
/** Upper bound on the number of `defaultToolPolicies` entries. */
|
|
265
285
|
toolPolicies: 1000,
|
|
266
|
-
/** publisher
|
|
286
|
+
/** Upper bound on the characters of publisher. */
|
|
267
287
|
publisherChars: 100,
|
|
268
|
-
/** description
|
|
288
|
+
/** Upper bound on the characters of description. */
|
|
269
289
|
descriptionChars: 1024,
|
|
270
|
-
/** displayName
|
|
290
|
+
/** Upper bound on the characters of displayName per language. */
|
|
271
291
|
displayNameChars: 100,
|
|
272
292
|
};
|
|
273
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* Catalog entry name (the same rule as manifest entry names): starts with a lowercase letter or
|
|
295
|
+
* digit, then lowercase letters, digits and hyphens, ≤ 64.
|
|
296
|
+
*/
|
|
274
297
|
export const CATALOG_ITEM_NAME_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
|
|
275
298
|
/** An exact semver version (a regex JSON Schema can use). */
|
|
276
299
|
export const SEMVER_VERSION_RE = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
|
@@ -279,8 +302,9 @@ export const SHA512_INTEGRITY_RE = /^sha512-[A-Za-z0-9+/]{86}==$/;
|
|
|
279
302
|
const PATH_SEG_RE = /^[A-Za-z0-9_-]{1,100}$/;
|
|
280
303
|
const PROTO_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
281
304
|
/**
|
|
282
|
-
*
|
|
283
|
-
*
|
|
305
|
+
* Credential-style field names (compared lowercased with `-` and `_` removed): templates are seen
|
|
306
|
+
* by every org, so endpoint presets containing these keys are always rejected.
|
|
307
|
+
* Header names such as `authorization` / `cookie` are listed too (credentials in endpoint headers).
|
|
284
308
|
*/
|
|
285
309
|
const CREDENTIAL_KEYS = new Set([
|
|
286
310
|
"token",
|
|
@@ -305,7 +329,7 @@ const CREDENTIAL_KEYS = new Set([
|
|
|
305
329
|
"sessiontoken",
|
|
306
330
|
]);
|
|
307
331
|
const normKey = (k) => k.toLowerCase().replace(/[-_]/g, "");
|
|
308
|
-
/**
|
|
332
|
+
/** Recursively finds credential-style keys (reports only paths, never echoes values). */
|
|
309
333
|
function credentialKeyPaths(v, at, out, depth = 0) {
|
|
310
334
|
if (depth > 20)
|
|
311
335
|
return;
|
|
@@ -333,14 +357,20 @@ const TEMPLATE_KEYS = new Set([
|
|
|
333
357
|
"auth",
|
|
334
358
|
"ownership",
|
|
335
359
|
"defaultToolPolicies",
|
|
360
|
+
"git",
|
|
336
361
|
"icon",
|
|
337
362
|
]);
|
|
338
363
|
/**
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
*
|
|
343
|
-
*
|
|
364
|
+
* Validates the static part of a connector template ({@link ConnectorTemplateSpec}) and returns the
|
|
365
|
+
* list of problems (empty means valid; paths are relative to the template root, values are not
|
|
366
|
+
* echoed):
|
|
367
|
+
* fields complete, no unknown fields; `auth` conforms to {@link ConnectorAuthSchema} (strict: extra
|
|
368
|
+
* fields such as `token` are rejected);
|
|
369
|
+
* no credential-style key at any level of the endpoint preset; `editableEndpoint` is a list of
|
|
370
|
+
* distinct dotted paths; `ownership` agrees with `auth.ownership`;
|
|
371
|
+
* default policies may only be allow / ask / deny; icon is an in-package .svg / .png path.
|
|
372
|
+
* Whether the endpoint conforms to the connector's `endpointSchema` and whether `editableEndpoint`
|
|
373
|
+
* exists in it is checked by the kernel on import against the loaded connector.
|
|
344
374
|
*/
|
|
345
375
|
export function validateConnectorTemplate(t) {
|
|
346
376
|
if (!isObj(t))
|
|
@@ -439,6 +469,8 @@ export function validateConnectorTemplate(t) {
|
|
|
439
469
|
}
|
|
440
470
|
}
|
|
441
471
|
}
|
|
472
|
+
if (t.git !== undefined)
|
|
473
|
+
errs.push(...validateGitSource(t.git, "template.git"));
|
|
442
474
|
if (t.icon !== undefined) {
|
|
443
475
|
if (typeof t.icon !== "string" || !isSafePackagePath(t.icon) || !/\.(svg|png)$/i.test(t.icon)) {
|
|
444
476
|
errs.push("template.icon must be a relative .svg or .png path inside the package");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private Python 3 restricted Linux launcher and syscall broker (`linux-sandbox.py`), staged
|
|
3
|
+
* beside `native-files.py` by a trusted consumer that verifies both digests.
|
|
4
|
+
*
|
|
5
|
+
* Transport: `python3 -I linux-sandbox.py probe` prints the capability report. Otherwise one JSON
|
|
6
|
+
* request on stdin: `{mode: "exec" | "native", roots: {read, write: [{path, fd, dev, ino}]},
|
|
7
|
+
* network: {kind: "none" | "environment"} | {kind: "endpoints", endpoints: [{address, port}]},
|
|
8
|
+
* reportFd, cwd?, env?, argv (exec), timeoutMs? (exec), native (native-files request)}`.
|
|
9
|
+
* Root descriptors are pinned once by the consumer and inherited; the launcher verifies their
|
|
10
|
+
* identity and never reopens a root pathname. Landlock rules, broker metadata checks and the
|
|
11
|
+
* native helper all use those same descriptors. JSON events (`launch`, `exit`, `refused`) go to
|
|
12
|
+
* reportFd, which the restricted child cannot write. SIGTERM cancels the whole owned tree.
|
|
13
|
+
* Full access never uses this launcher: it has no restricted filters.
|
|
14
|
+
*/
|
|
15
|
+
export declare const LINUX_SANDBOX_SOURCE: string;
|