@capybara-hq/plugin-sdk 0.1.0-rc.9 → 0.1.0-rc.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/agent-docs/agent-templates.md +14 -2
- package/agent-docs/concepts.md +14 -5
- package/agent-docs/connector-templates.md +11 -3
- package/agent-docs/extension-points/channel.md +1 -1
- package/agent-docs/extension-points/context.md +15 -0
- package/agent-docs/extension-points/device-provider.md +15 -0
- package/agent-docs/extension-points/file-preview.md +3 -1
- package/agent-docs/extension-points/identity-source.md +2 -0
- package/agent-docs/extension-points/model-provider.md +5 -1
- package/agent-docs/extension-points/object-store.md +2 -0
- package/agent-docs/extension-points/push-provider.md +17 -0
- package/agent-docs/extension-points/trigger-source.md +19 -0
- package/agent-docs/extensions.md +98 -4
- package/agent-docs/plugin-format.md +45 -10
- package/agent-docs/setup.md +54 -0
- package/api/plugin-sdk.api.md +5983 -0
- package/dist/agent-template.d.ts +15 -6
- package/dist/agent-template.js +32 -13
- package/dist/agents-ctx.d.ts +116 -0
- package/dist/agents-ctx.js +22 -0
- package/dist/avatar-presets.d.ts +8 -0
- package/dist/avatar-presets.js +17 -0
- package/dist/bootstrap.d.ts +109 -1
- package/dist/bootstrap.js +185 -2
- package/dist/cards.d.ts +121 -13
- package/dist/cards.js +161 -19
- package/dist/channel.d.ts +133 -47
- package/dist/channel.js +10 -5
- package/dist/client-css.d.ts +36 -0
- package/dist/client-css.js +326 -0
- package/dist/client-section.d.ts +35 -0
- package/dist/client-section.js +133 -0
- package/dist/config-ui.d.ts +28 -6
- package/dist/config-ui.js +88 -25
- package/dist/config-url-fetch.d.ts +19 -0
- package/dist/config-url-fetch.js +43 -0
- package/dist/connector-auth.d.ts +13 -2
- package/dist/connector-auth.js +82 -8
- package/dist/connector.d.ts +74 -32
- package/dist/context.d.ts +40 -0
- package/dist/context.js +2 -0
- package/dist/ctx.d.ts +344 -31
- package/dist/ctx.js +9 -1
- package/dist/define-extension.d.ts +18 -12
- package/dist/define-extension.js +18 -5
- package/dist/device-denied-paths.d.ts +20 -0
- package/dist/device-denied-paths.js +118 -0
- package/dist/device-operation.d.ts +348 -0
- package/dist/device-operation.js +312 -0
- package/dist/device-protocol.d.ts +286 -49
- package/dist/device-protocol.js +766 -89
- package/dist/device-provider.d.ts +820 -0
- package/dist/device-provider.js +432 -0
- package/dist/device-service.d.ts +204 -0
- package/dist/device-service.js +291 -0
- package/dist/dial-in.d.ts +286 -0
- package/dist/dial-in.js +213 -0
- package/dist/directory.d.ts +15 -12
- package/dist/extension-point.d.ts +2 -0
- package/dist/extension-point.js +8 -3
- package/dist/field-meta.d.ts +19 -0
- package/dist/field-meta.js +54 -0
- package/dist/file-preview.d.ts +46 -9
- package/dist/git-hosts.d.ts +53 -0
- package/dist/git-hosts.js +98 -0
- package/dist/hooks.d.ts +185 -22
- package/dist/hooks.js +6 -0
- package/dist/http-access.d.ts +71 -0
- package/dist/http-access.js +12 -0
- package/dist/identity.d.ts +70 -9
- package/dist/identity.js +46 -1
- package/dist/inbox.d.ts +103 -0
- package/dist/inbox.js +173 -0
- package/dist/index.d.ts +30 -4
- package/dist/index.js +30 -4
- package/dist/model-params.d.ts +41 -22
- package/dist/model-params.js +28 -15
- package/dist/model.d.ts +295 -77
- package/dist/model.js +249 -21
- package/dist/native-failure.d.ts +13 -0
- package/dist/native-failure.js +31 -0
- package/dist/net.d.ts +52 -0
- package/dist/net.js +34 -0
- package/dist/network-classes.d.ts +98 -0
- package/dist/network-classes.js +291 -0
- package/dist/permissions.d.ts +95 -25
- package/dist/permissions.js +175 -54
- package/dist/platform-only.d.ts +27 -0
- package/dist/platform-only.js +35 -0
- package/dist/plugin-manifest.d.ts +30 -6
- package/dist/plugin-manifest.js +147 -55
- package/dist/plugin-package.d.ts +82 -39
- package/dist/plugin-package.js +68 -41
- package/dist/push.d.ts +75 -0
- package/dist/push.js +87 -0
- package/dist/sandbox-linux-runtime-source.d.ts +1 -0
- package/dist/sandbox-linux-runtime-source.js +2343 -0
- package/dist/sandbox-native-runtime-source.d.ts +10 -0
- package/dist/sandbox-native-runtime-source.js +480 -0
- package/dist/sandbox-runtime-source.d.ts +47 -0
- package/dist/sandbox-runtime-source.js +73 -0
- package/dist/sandbox-write-denies.d.ts +139 -0
- package/dist/sandbox-write-denies.js +869 -0
- package/dist/secret.d.ts +8 -2
- package/dist/secret.js +11 -4
- package/dist/setup-check.d.ts +128 -0
- package/dist/setup-check.js +142 -0
- package/dist/setup-guide-parse.d.ts +121 -0
- package/dist/setup-guide-parse.js +356 -0
- package/dist/setup-guide-render.d.ts +45 -0
- package/dist/setup-guide-render.js +351 -0
- package/dist/setup-guide.d.ts +86 -72
- package/dist/setup-guide.js +340 -108
- package/dist/shell-capabilities.d.ts +216 -0
- package/dist/shell-capabilities.js +44 -0
- package/dist/shell-environment.d.ts +57 -0
- package/dist/shell-environment.js +21 -0
- package/dist/skill-invocation.d.ts +5 -0
- package/dist/skill-invocation.js +4 -3
- package/dist/skill.d.ts +27 -17
- package/dist/skill.js +40 -26
- package/dist/storage.d.ts +52 -25
- package/dist/svg-viewbox.d.ts +10 -0
- package/dist/svg-viewbox.js +24 -0
- package/dist/theme-assets.d.ts +25 -9
- package/dist/theme-assets.js +87 -47
- package/dist/theme-tokens.generated.d.ts +40 -12
- package/dist/theme-tokens.generated.js +36 -8
- package/dist/theme.d.ts +56 -10
- package/dist/theme.js +117 -23
- package/dist/tool.d.ts +242 -28
- package/dist/tool.js +135 -13
- package/dist/trigger-source.d.ts +35 -0
- package/dist/trigger-source.js +2 -0
- package/dist/triggers.d.ts +88 -0
- package/dist/triggers.js +71 -0
- package/dist/ui-parts.d.ts +23 -0
- package/dist/ui-parts.js +374 -0
- package/dist/ui-resolve.d.ts +2 -7
- package/dist/ui-resolve.js +7 -19
- package/dist/ui-slots.d.ts +27 -5
- package/dist/ui-slots.js +112 -19
- package/dist/ui.d.ts +203 -64
- package/dist/ui.js +117 -23
- package/dist/url.d.ts +4 -1
- package/dist/url.js +4 -1
- package/dist/web.d.ts +26 -20
- package/package.json +13 -1
- package/schemas/bootstrap-extra.v1.schema.json +186 -0
- package/schemas/bootstrap.v1.schema.json +20 -0
- package/schemas/connector-template.v1.schema.json +62 -4
- package/schemas/plugin.v1.schema.json +74 -143
- package/schemas/theme.v1.schema.json +77 -0
- package/agent-docs/extension-points/sandbox.md +0 -15
- package/dist/org-access.d.ts +0 -27
- package/dist/org-access.js +0 -35
- package/dist/sandbox.d.ts +0 -254
- package/dist/sandbox.js +0 -153
package/dist/sandbox.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sandbox contract `sandbox@2`: a single-select, brokered extension point (extensions may not
|
|
3
|
-
* `requires` it; the kernel's `SandboxService` consumes it). The provider implements only the
|
|
4
|
-
* primitives below; the kernel builds `glob` / `grep` / `edit` from `exec` plus `readFile` /
|
|
5
|
-
* `writeFile`.
|
|
6
|
-
*
|
|
7
|
-
* `@2` separates a device's **file system** from its **instance**: the file system
|
|
8
|
-
* (`createFileSystem`) lives until the device is deleted (`destroyFileSystem`); instances
|
|
9
|
-
* (`create`) attach to it and come and go (`destroy` drops the instance and keeps the files).
|
|
10
|
-
*/
|
|
11
|
-
/** Sandbox extension point ref. */
|
|
12
|
-
export const SANDBOX_EXTENSION_POINT = "sandbox@2";
|
|
13
|
-
/** The roots inside the sandbox the model may access. */
|
|
14
|
-
export const SANDBOX_ROOTS = ["/workspace", "/skills", "/tmp"];
|
|
15
|
-
const MAX_PATH_LENGTH = 4096;
|
|
16
|
-
/** The roots every container-like provider uses; the same paths as {@link SANDBOX_ROOTS}. */
|
|
17
|
-
export const DEFAULT_SANDBOX_ROOTS = Object.freeze({
|
|
18
|
-
workspace: "/workspace",
|
|
19
|
-
skills: "/skills",
|
|
20
|
-
tmp: "/tmp",
|
|
21
|
-
});
|
|
22
|
-
/** The roots of an instance, falling back to {@link DEFAULT_SANDBOX_ROOTS}. */
|
|
23
|
-
export function rootsOf(h) {
|
|
24
|
-
return h.roots ?? DEFAULT_SANDBOX_ROOTS;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The instance is definitely gone on the provider's side (container removed, E2B sandbox expired).
|
|
28
|
-
* `exec` / `readFile` / `writeFile` / `stat` must throw it (not a plain Error) when they find the
|
|
29
|
-
* instance gone; the kernel then rebuilds the instance and retries once. A transient connection
|
|
30
|
-
* failure throws a plain error.
|
|
31
|
-
*/
|
|
32
|
-
export class SandboxGoneError extends Error {
|
|
33
|
-
sandboxGone = true;
|
|
34
|
-
constructor(message, opts) {
|
|
35
|
-
super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
|
|
36
|
-
this.name = "SandboxGoneError";
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/** Duck-typed check (not instanceof), so a plugin bundling another plugin-sdk copy still matches. */
|
|
40
|
-
export function isSandboxGoneError(e) {
|
|
41
|
-
return (e instanceof Error &&
|
|
42
|
-
e.name === "SandboxGoneError" &&
|
|
43
|
-
e.sandboxGone === true);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* The file system is definitely gone on the provider's side (volume removed, E2B sandbox killed).
|
|
47
|
-
* `create` throws it instead of attaching the instance to a new, empty file system; the kernel then
|
|
48
|
-
* reports the device's files as lost rather than handing out a silently empty workspace.
|
|
49
|
-
*/
|
|
50
|
-
export class FileSystemGoneError extends Error {
|
|
51
|
-
fileSystemGone = true;
|
|
52
|
-
constructor(message, opts) {
|
|
53
|
-
super(message, opts && "cause" in opts ? { cause: opts.cause } : undefined);
|
|
54
|
-
this.name = "FileSystemGoneError";
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/** Duck-typed check (not instanceof), so a plugin bundling another plugin-sdk copy still matches. */
|
|
58
|
-
export function isFileSystemGoneError(e) {
|
|
59
|
-
return (e instanceof Error &&
|
|
60
|
-
e.name === "FileSystemGoneError" &&
|
|
61
|
-
e.fileSystemGone === true);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A holder tag (`exec` argument `tag`, {@link SandboxProvider.killTagged}): the kernel passes its
|
|
65
|
-
* lease tokens (UUIDs). Providers check tags against it before putting them in a command line or a
|
|
66
|
-
* kill pattern.
|
|
67
|
-
*/
|
|
68
|
-
export const SANDBOX_TAG_RE = /^[a-z0-9-]{1,64}$/;
|
|
69
|
-
// biome-ignore lint/suspicious/noControlCharactersInRegex: 正是要拦控制字符
|
|
70
|
-
const CONTROL = /[\u0000-\u001f\u007f]/;
|
|
71
|
-
/**
|
|
72
|
-
* The root-independent checks of a path inside an instance (non-empty, at most 4096 characters, no
|
|
73
|
-
* control characters or backslashes, absolute, no empty or `..` segments); returns the errors,
|
|
74
|
-
* empty when valid. {@link validateSandboxPath} adds root membership.
|
|
75
|
-
*/
|
|
76
|
-
export function validateSandboxPathShape(p) {
|
|
77
|
-
if (typeof p !== "string" || p.length === 0)
|
|
78
|
-
return ["path must be a non-empty string"];
|
|
79
|
-
if (p.length > MAX_PATH_LENGTH)
|
|
80
|
-
return [`path must be at most ${MAX_PATH_LENGTH} characters`];
|
|
81
|
-
if (CONTROL.test(p))
|
|
82
|
-
return ["path must not contain control characters"];
|
|
83
|
-
if (p.includes("\\"))
|
|
84
|
-
return ["path must not contain backslashes"];
|
|
85
|
-
if (!p.startsWith("/"))
|
|
86
|
-
return ["path must be absolute"];
|
|
87
|
-
if (p.includes("//"))
|
|
88
|
-
return ["path must not contain empty segments"];
|
|
89
|
-
for (const seg of p.split("/")) {
|
|
90
|
-
let decoded = seg;
|
|
91
|
-
try {
|
|
92
|
-
decoded = decodeURIComponent(seg);
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
// invalid percent-encoding is taken literally
|
|
96
|
-
}
|
|
97
|
-
if (seg === ".." || decoded === ".." || decoded.includes("/") || decoded.includes("\\")) {
|
|
98
|
-
return ["path must not contain '..' segments"];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return [];
|
|
102
|
-
}
|
|
103
|
-
/** A structural error after which {@link validateSandboxPath} stops (before the root check). */
|
|
104
|
-
const STOPS = new Set([
|
|
105
|
-
"path must be a non-empty string",
|
|
106
|
-
`path must be at most ${MAX_PATH_LENGTH} characters`,
|
|
107
|
-
"path must not contain control characters",
|
|
108
|
-
"path must not contain backslashes",
|
|
109
|
-
"path must be absolute",
|
|
110
|
-
"path must not contain empty segments",
|
|
111
|
-
]);
|
|
112
|
-
/**
|
|
113
|
-
* Checks a path inside an instance; returns the errors, empty when valid: the
|
|
114
|
-
* {@link validateSandboxPathShape} checks, then root membership. `roots`: the instance's roots
|
|
115
|
-
* ({@link rootsOf}); absent means {@link SANDBOX_ROOTS}. The path must be one of them or under one.
|
|
116
|
-
*/
|
|
117
|
-
export function validateSandboxPath(p, roots) {
|
|
118
|
-
const errors = validateSandboxPathShape(p);
|
|
119
|
-
if (errors.some((e) => STOPS.has(e)))
|
|
120
|
-
return errors;
|
|
121
|
-
const allowed = roots === undefined ? SANDBOX_ROOTS : [roots.workspace, roots.skills, roots.tmp];
|
|
122
|
-
if (!allowed.some((r) => p === r || p.startsWith(`${r}/`))) {
|
|
123
|
-
errors.push(`path must be under ${allowed.join(", ")}`);
|
|
124
|
-
}
|
|
125
|
-
return errors;
|
|
126
|
-
}
|
|
127
|
-
const LABEL = /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/;
|
|
128
|
-
/** 校验出站白名单主机名:小写、无协议与端口、可选前导 `*.`、IDN 只认 punycode。 */
|
|
129
|
-
export function validateAllowHost(h) {
|
|
130
|
-
if (typeof h !== "string" || h.length === 0)
|
|
131
|
-
return ["host must be a non-empty string"];
|
|
132
|
-
if (h.length > 253)
|
|
133
|
-
return ["host must be at most 253 characters"];
|
|
134
|
-
const name = h.startsWith("*.") ? h.slice(2) : h;
|
|
135
|
-
if (name.length === 0)
|
|
136
|
-
return ["wildcard must be followed by a domain"];
|
|
137
|
-
const labels = name.split(".");
|
|
138
|
-
if (labels.every((l) => LABEL.test(l))) {
|
|
139
|
-
const tld = labels[labels.length - 1];
|
|
140
|
-
if (labels.length < 2)
|
|
141
|
-
return ["host must have at least two labels (no single-label names)"];
|
|
142
|
-
// 末段必须以字母开头:挡住 IPv4 的十进制 / 八进制 / 十六进制写法
|
|
143
|
-
if (!/^[a-z]/.test(tld))
|
|
144
|
-
return ["host must not be an IP address literal"];
|
|
145
|
-
if (["local", "internal", "localhost"].includes(tld)) {
|
|
146
|
-
return ["host must not be in an internal-only domain (.local, .internal, .localhost)"];
|
|
147
|
-
}
|
|
148
|
-
return [];
|
|
149
|
-
}
|
|
150
|
-
return [
|
|
151
|
-
"host must be a lowercase hostname without scheme, port or path (optional leading '*.'; IDN as punycode)",
|
|
152
|
-
];
|
|
153
|
-
}
|