@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/storage.d.ts
CHANGED
|
@@ -7,27 +7,34 @@
|
|
|
7
7
|
*/
|
|
8
8
|
/** Object storage extension point ref. */
|
|
9
9
|
export declare const OBJECT_STORE_EXTENSION_POINT = "object-store@1";
|
|
10
|
-
/**
|
|
10
|
+
/** Metadata of an object. */
|
|
11
11
|
export interface ObjectHead {
|
|
12
12
|
key: string;
|
|
13
|
-
/**
|
|
13
|
+
/** Size in bytes. */
|
|
14
14
|
size: number;
|
|
15
15
|
contentType: string;
|
|
16
16
|
etag?: string;
|
|
17
|
-
/** ISO 8601
|
|
17
|
+
/** ISO 8601 time. */
|
|
18
18
|
lastModified?: string;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* The `object-store@1` implementation (provided by an object-store plugin, e.g. S3-compatible
|
|
22
|
+
* storage).
|
|
23
|
+
*/
|
|
21
24
|
export interface ObjectStore {
|
|
22
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Writes (overwriting a key of the same name); give `size` when `body` is a stream if possible.
|
|
27
|
+
*/
|
|
23
28
|
put(key: string, body: Uint8Array | ReadableStream<Uint8Array>, opts: {
|
|
24
29
|
contentType: string;
|
|
25
30
|
size?: number;
|
|
26
31
|
signal?: AbortSignal;
|
|
27
32
|
}): Promise<ObjectHead>;
|
|
28
33
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
34
|
+
* Reads; returns null when missing. `range` is a closed byte range; an omitted `end` means read
|
|
35
|
+
* to the end.
|
|
36
|
+
* With `range`, `head.size` is still the size of the whole object; when the store ignores Range,
|
|
37
|
+
* body may be the whole object.
|
|
31
38
|
*/
|
|
32
39
|
get(key: string, opts?: {
|
|
33
40
|
signal?: AbortSignal;
|
|
@@ -39,15 +46,18 @@ export interface ObjectStore {
|
|
|
39
46
|
head: ObjectHead;
|
|
40
47
|
body: ReadableStream<Uint8Array>;
|
|
41
48
|
} | null>;
|
|
42
|
-
/**
|
|
49
|
+
/** Returns null when missing. */
|
|
43
50
|
head(key: string): Promise<ObjectHead | null>;
|
|
44
|
-
/**
|
|
51
|
+
/** Deletes; a missing key also counts as success. */
|
|
45
52
|
delete(key: string): Promise<void>;
|
|
46
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Deletes all objects under a prefix and returns the number deleted (used for org data deletion).
|
|
55
|
+
*/
|
|
47
56
|
deletePrefix(prefix: string): Promise<number>;
|
|
48
57
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
58
|
+
* Lists objects under a prefix with pagination; an omitted `cursor` in the result means there is
|
|
59
|
+
* no next page. When the listing carries no type, `contentType` is an empty string
|
|
60
|
+
* (use `head` to get it when needed).
|
|
51
61
|
*/
|
|
52
62
|
list(prefix: string, opts?: {
|
|
53
63
|
cursor?: string;
|
|
@@ -56,41 +66,58 @@ export interface ObjectStore {
|
|
|
56
66
|
items: ObjectHead[];
|
|
57
67
|
cursor?: string;
|
|
58
68
|
}>;
|
|
59
|
-
/**
|
|
69
|
+
/** Presigned download URL (options in {@link PresignGetOptions}). */
|
|
60
70
|
presignGet(key: string, opts: PresignGetOptions): Promise<string>;
|
|
61
71
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
72
|
+
* Presigned upload: the browser uploads straight to storage following the returned {@link
|
|
73
|
+
* PresignedUpload}. An upload over `maxSize` must be rejected by the **store side**
|
|
74
|
+
* (a presigned PUT cannot limit the size, so S3-compatible implementations use a POST policy with
|
|
75
|
+
* a `content-length-range` condition).
|
|
64
76
|
*/
|
|
65
77
|
presignPut(key: string, opts: {
|
|
66
78
|
contentType: string;
|
|
67
79
|
maxSize: number;
|
|
68
80
|
ttlSeconds: number;
|
|
69
81
|
}): Promise<PresignedUpload>;
|
|
82
|
+
/**
|
|
83
|
+
* The canonical URI of a key in this store: unsigned, stable, no credentials
|
|
84
|
+
* (`s3://bucket/key`). This is an identifier, never a presigned URL: it may be recorded in an
|
|
85
|
+
* event log and shown to a model, so it must stay valid and carry no secret. Optional: a store
|
|
86
|
+
* with no notion of URIs leaves it out and the kernel falls back to its own reference.
|
|
87
|
+
*/
|
|
88
|
+
uri?(key: string): string;
|
|
70
89
|
}
|
|
71
|
-
/**
|
|
90
|
+
/** Options of a presigned download. */
|
|
72
91
|
export interface PresignGetOptions {
|
|
73
92
|
ttlSeconds: number;
|
|
74
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Download file name, goes into `Content-Disposition` (RFC 6266; non-ASCII uses
|
|
95
|
+
* `filename*=UTF-8''…`).
|
|
96
|
+
*/
|
|
75
97
|
downloadName?: string;
|
|
76
98
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
99
|
+
* How the browser opens it: `attachment` (default, download) or `inline` (display in the page).
|
|
100
|
+
* User-uploaded content should use `inline` only for types
|
|
101
|
+
* that do not execute scripts (images, PDF).
|
|
79
102
|
*/
|
|
80
103
|
disposition?: "attachment" | "inline";
|
|
81
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* Overrides the response `Content-Type` (e.g. return the verified type rather than the type
|
|
106
|
+
* recorded in storage).
|
|
107
|
+
*/
|
|
82
108
|
responseContentType?: string;
|
|
83
109
|
}
|
|
84
110
|
/**
|
|
85
|
-
*
|
|
86
|
-
* - `PUT
|
|
87
|
-
* - `POST
|
|
88
|
-
*
|
|
111
|
+
* The request method of a presigned upload:
|
|
112
|
+
* - `PUT`: the request body is the file bytes, and the request carries `headers`;
|
|
113
|
+
* - `POST`: a `multipart/form-data` form; first put every item of `fields` in as is, and put the
|
|
114
|
+
* file field `file` **last**;
|
|
115
|
+
* the request carries `headers` (usually empty).
|
|
89
116
|
*/
|
|
90
117
|
export interface PresignedUpload {
|
|
91
118
|
method: "PUT" | "POST";
|
|
92
119
|
url: string;
|
|
93
120
|
headers: Record<string, string>;
|
|
94
|
-
/** `POST
|
|
121
|
+
/** Always present for `POST`: the form fields (including policy and signature). */
|
|
95
122
|
fields?: Record<string, string>;
|
|
96
123
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Characters of a viewBox value; longer values are refused before any regex sees them. */
|
|
2
|
+
export declare const VIEWBOX_MAX_CHARS = 128;
|
|
3
|
+
/**
|
|
4
|
+
* The only regexes the viewBox parser runs. Each is one character class under one quantifier,
|
|
5
|
+
* so matching is linear in the (already capped) input: there is nothing to backtrack into.
|
|
6
|
+
*/
|
|
7
|
+
export declare const VIEWBOX_SEPARATOR_RE: RegExp;
|
|
8
|
+
export declare const VIEWBOX_NUMBER_RE: RegExp;
|
|
9
|
+
/** `min-x min-y width height`, width and height > 0; undefined when malformed. */
|
|
10
|
+
export declare function parseViewBox(v: string): [number, number, number, number] | undefined;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Internal to the SDK: not re-exported from index.ts, so not part of the public API.
|
|
2
|
+
/** Characters of a viewBox value; longer values are refused before any regex sees them. */
|
|
3
|
+
export const VIEWBOX_MAX_CHARS = 128;
|
|
4
|
+
/**
|
|
5
|
+
* The only regexes the viewBox parser runs. Each is one character class under one quantifier,
|
|
6
|
+
* so matching is linear in the (already capped) input: there is nothing to backtrack into.
|
|
7
|
+
*/
|
|
8
|
+
export const VIEWBOX_SEPARATOR_RE = /[\s,]+/;
|
|
9
|
+
export const VIEWBOX_NUMBER_RE = /^[-+.0-9eE]+$/;
|
|
10
|
+
/** `min-x min-y width height`, width and height > 0; undefined when malformed. */
|
|
11
|
+
export function parseViewBox(v) {
|
|
12
|
+
if (v.length > VIEWBOX_MAX_CHARS)
|
|
13
|
+
return undefined;
|
|
14
|
+
const parts = v
|
|
15
|
+
.trim()
|
|
16
|
+
.split(VIEWBOX_SEPARATOR_RE)
|
|
17
|
+
.filter((p) => p !== "");
|
|
18
|
+
if (parts.length !== 4 || !parts.every((p) => VIEWBOX_NUMBER_RE.test(p)))
|
|
19
|
+
return undefined;
|
|
20
|
+
const n = parts.map(Number);
|
|
21
|
+
if (!n.every(Number.isFinite) || n[2] <= 0 || n[3] <= 0)
|
|
22
|
+
return undefined;
|
|
23
|
+
return n;
|
|
24
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ParsedTheme } from "./theme.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a logo SVG (UTF-8, ≤ {@link THEME_LIMITS}`.svgBytes`) with a strict, namespace-aware
|
|
4
|
+
* XML parser and re-serializes it. The root must be an `svg` element in the SVG namespace with a
|
|
5
|
+
* numeric `viewBox`; its `width`, `height` and `class` are dropped. Rejected: a DOCTYPE (and so
|
|
6
|
+
* any entity declaration), processing instructions, a non-UTF-8 encoding, elements outside the
|
|
7
|
+
* SVG allowlist (`script`, `foreignObject`, `style`, …) or in the XHTML namespace, `style` and
|
|
8
|
+
* `on*` attributes, `href` / `xlink:href` not starting with `#`, `javascript:` / `vbscript:` in
|
|
9
|
+
* any value, quotes or a backslash in attribute values, any function other than `url(#id)`, colors
|
|
10
|
+
* (`rgb`, `rgba`, `hsl`, `hsla`) and transforms (`translate`, `rotate`, `scale`, `matrix`,
|
|
11
|
+
* `skewX`, `skewY`), a viewBox longer than 128 characters, and animation of `href`, `style` or event
|
|
12
|
+
* handlers. Comments, the XML declaration and elements / attributes in other namespaces (editor
|
|
13
|
+
* metadata) are dropped; CDATA becomes escaped text. Never throws.
|
|
14
|
+
*/
|
|
15
|
+
export declare function sanitizeThemeSvg(bytes: Uint8Array): {
|
|
16
|
+
svg: string;
|
|
17
|
+
} | {
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
20
|
+
/** A woff2 font: the `wOF2` signature and at most {@link THEME_LIMITS}`.fontBytes`. */
|
|
21
|
+
export declare function checkWoff2(bytes: Uint8Array): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* A PNG logo: the PNG signature, an `IHDR` first chunk with a height of at least
|
|
24
|
+
* {@link THEME_LIMITS}`.pngMinHeight` pixels, and at most `maxBytes` (default
|
|
25
|
+
* {@link THEME_LIMITS}`.pngBytes`; an app icon allows {@link THEME_LIMITS}`.appIconBytes`).
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkPng(bytes: Uint8Array, maxBytes?: number): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Every asset a parsed theme names, in order: `fonts.<i>.file`, `logo.mark`, `logo.favicon`,
|
|
30
|
+
* `logo.illustration`, `logo.appIcon`, `logo.appIconMaskable`, `avatars.<i>.file`. `ref` is the
|
|
31
|
+
* path as written (an optional leading `./`). The one list every reader of theme assets uses (the
|
|
32
|
+
* checks, packing, the catalog and delivery), so a file the theme does not name is never read or
|
|
33
|
+
* served.
|
|
34
|
+
*/
|
|
35
|
+
export declare function themeAssetRefs(theme: ParsedTheme): {
|
|
36
|
+
field: string;
|
|
37
|
+
ref: string;
|
|
38
|
+
}[];
|
|
39
|
+
/**
|
|
40
|
+
* Resolves and checks the asset files of a parsed theme ({@link themeAssetRefs}), each by its
|
|
41
|
+
* kind: `fonts[].file` ({@link checkWoff2}); `logo.mark` and `logo.illustration` (`.svg` through
|
|
42
|
+
* {@link sanitizeThemeSvg}, `.png` through {@link checkPng}); `logo.favicon` and `avatars[].file`
|
|
43
|
+
* likewise and square (SVG viewBox or PNG width = height); `logo.appIcon` and
|
|
44
|
+
* `logo.appIconMaskable` PNG only, square, at least {@link THEME_LIMITS}`.appIconMinSize` px and at
|
|
45
|
+
* most {@link THEME_LIMITS}`.appIconBytes`. `files` holds the plugin's files keyed by their path
|
|
46
|
+
* without a leading `./`; the returned `assets` (the sanitized SVG bytes, the other files
|
|
47
|
+
* unchanged) use the same keys. Errors are `<field>: <reason>`, English; the total input size of
|
|
48
|
+
* the theme's distinct assets must stay within {@link THEME_LIMITS}`.assetsBytes`. That limit is
|
|
49
|
+
* per plugin, so a caller reading several themes also checks the sum over all of them (distinct
|
|
50
|
+
* paths).
|
|
51
|
+
*/
|
|
52
|
+
export declare function validateThemeAssets(theme: ParsedTheme, files: Map<string, Uint8Array>): {
|
|
53
|
+
assets: Map<string, Uint8Array>;
|
|
54
|
+
errors: string[];
|
|
55
|
+
};
|