@capybara-hq/plugin-sdk 0.1.0-rc.7 → 0.1.0-rc.71
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/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 +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 +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 +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 +232 -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
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address classes of the sandbox network (approval-only profiles design, "Open network"): pure
|
|
3
|
+
* data plus {@link classifyAddress}. The device workers (macOS SRT, the Linux forwarder) and the
|
|
4
|
+
* cloud providers' egress proxies decide every sandboxed connection on the resolved address with
|
|
5
|
+
* this one table, so the classes cannot drift between them.
|
|
6
|
+
*
|
|
7
|
+
* The table ({@link ADDRESS_CLASS_RANGES}) is data a copy in another language can mirror (the Linux
|
|
8
|
+
* forwarder's Python): the class of an address is that of the longest-prefix range containing it.
|
|
9
|
+
* Every family ends with a catch-all, so the table is total.
|
|
10
|
+
*/
|
|
11
|
+
/** Every class closed in `open-public` mode: reachable only by running outside the sandbox. */
|
|
12
|
+
export const OPEN_PUBLIC_DENIED_CLASSES = Object.freeze([
|
|
13
|
+
"private",
|
|
14
|
+
"cgnat",
|
|
15
|
+
"ula",
|
|
16
|
+
"link-local",
|
|
17
|
+
"metadata",
|
|
18
|
+
"loopback",
|
|
19
|
+
"multicast",
|
|
20
|
+
"broadcast",
|
|
21
|
+
"unspecified",
|
|
22
|
+
"nat64",
|
|
23
|
+
"reserved",
|
|
24
|
+
]);
|
|
25
|
+
const range = (family, cidr, cls) => Object.freeze({ family, cidr, class: cls });
|
|
26
|
+
const embedded = (cidr, at) => Object.freeze({ family: "ipv6", cidr, embeddedIpv4At: at });
|
|
27
|
+
/**
|
|
28
|
+
* The address-class table, most specific range first within each family (longest prefix wins).
|
|
29
|
+
* IPv4 follows the kernel's `net/public-address.ts` (and the sandbox-docker egress proxy); IPv6
|
|
30
|
+
* does too, plus closures the design adds: the well-known NAT64 prefixes (`64:ff9b::/96`,
|
|
31
|
+
* `64:ff9b:1::/48`) whatever they embed, `2001::/23` (Teredo, ORCHID and the other IETF
|
|
32
|
+
* assignments), `3fff::/20`, and everything outside global unicast `2000::/3`.
|
|
33
|
+
*
|
|
34
|
+
* Not covered: an operator-specific NAT64 prefix (a network-specific prefix, RFC 6052, announced
|
|
35
|
+
* by the local DNS64) is ordinary global unicast here, so a private IPv4 address reached through
|
|
36
|
+
* it classifies as public. A worker on such a network resolves through a resolver it trusts or adds
|
|
37
|
+
* the prefix to its own deny list.
|
|
38
|
+
*/
|
|
39
|
+
export const ADDRESS_CLASS_RANGES = Object.freeze([
|
|
40
|
+
range("ipv4", "100.100.100.200/32", "metadata"), // Alibaba Cloud, inside CGNAT
|
|
41
|
+
range("ipv4", "168.63.129.16/32", "metadata"), // Azure WireServer
|
|
42
|
+
range("ipv4", "169.254.169.254/32", "metadata"),
|
|
43
|
+
range("ipv4", "255.255.255.255/32", "broadcast"),
|
|
44
|
+
range("ipv4", "192.0.0.0/24", "reserved"), // IETF protocol assignments
|
|
45
|
+
range("ipv4", "192.0.2.0/24", "reserved"), // TEST-NET-1
|
|
46
|
+
range("ipv4", "192.88.99.0/24", "reserved"), // 6to4 relay anycast
|
|
47
|
+
range("ipv4", "198.51.100.0/24", "reserved"), // TEST-NET-2
|
|
48
|
+
range("ipv4", "203.0.113.0/24", "reserved"), // TEST-NET-3
|
|
49
|
+
range("ipv4", "169.254.0.0/16", "link-local"),
|
|
50
|
+
range("ipv4", "192.168.0.0/16", "private"),
|
|
51
|
+
range("ipv4", "198.18.0.0/15", "reserved"), // benchmarking
|
|
52
|
+
range("ipv4", "172.16.0.0/12", "private"),
|
|
53
|
+
range("ipv4", "100.64.0.0/10", "cgnat"),
|
|
54
|
+
range("ipv4", "0.0.0.0/8", "unspecified"),
|
|
55
|
+
range("ipv4", "10.0.0.0/8", "private"),
|
|
56
|
+
range("ipv4", "127.0.0.0/8", "loopback"),
|
|
57
|
+
range("ipv4", "224.0.0.0/4", "multicast"),
|
|
58
|
+
range("ipv4", "240.0.0.0/4", "reserved"),
|
|
59
|
+
range("ipv4", "0.0.0.0/0", "public"),
|
|
60
|
+
range("ipv6", "::/128", "unspecified"),
|
|
61
|
+
range("ipv6", "::1/128", "loopback"),
|
|
62
|
+
range("ipv6", "fd00:ec2::254/128", "metadata"), // AWS IMDS over IPv6, inside ULA
|
|
63
|
+
embedded("::ffff:0:0/96", 96), // v4-mapped
|
|
64
|
+
embedded("::ffff:0:0:0/96", 96), // SIIT IPv4-translated
|
|
65
|
+
range("ipv6", "64:ff9b::/96", "nat64"),
|
|
66
|
+
embedded("::/96", 96), // v4-compatible (deprecated)
|
|
67
|
+
range("ipv6", "100::/64", "reserved"), // discard-only
|
|
68
|
+
range("ipv6", "64:ff9b:1::/48", "nat64"), // local-use NAT64
|
|
69
|
+
range("ipv6", "2001:db8::/32", "reserved"), // documentation
|
|
70
|
+
range("ipv6", "2001::/23", "reserved"), // IETF protocol assignments: Teredo, ORCHID, …
|
|
71
|
+
range("ipv6", "3fff::/20", "reserved"), // documentation (RFC 9637)
|
|
72
|
+
embedded("2002::/16", 16), // 6to4
|
|
73
|
+
range("ipv6", "fe80::/10", "link-local"),
|
|
74
|
+
range("ipv6", "fec0::/10", "reserved"), // deprecated site-local
|
|
75
|
+
range("ipv6", "ff00::/8", "multicast"),
|
|
76
|
+
range("ipv6", "fc00::/7", "ula"),
|
|
77
|
+
range("ipv6", "2000::/3", "public"),
|
|
78
|
+
range("ipv6", "::/0", "reserved"), // unallocated outside global unicast
|
|
79
|
+
]);
|
|
80
|
+
const OCTET = /^(0|[1-9][0-9]{0,2})$/;
|
|
81
|
+
const GROUP = /^[0-9a-fA-F]{1,4}$/;
|
|
82
|
+
const ZONE = /^[0-9A-Za-z._~-]+$/;
|
|
83
|
+
/** A strict dotted-quad IPv4 address as a number; null otherwise (no octal, hex or short forms). */
|
|
84
|
+
function ipv4Value(ip) {
|
|
85
|
+
const parts = ip.split(".");
|
|
86
|
+
if (parts.length !== 4)
|
|
87
|
+
return null;
|
|
88
|
+
let value = 0;
|
|
89
|
+
for (const part of parts) {
|
|
90
|
+
if (!OCTET.test(part))
|
|
91
|
+
return null;
|
|
92
|
+
const octet = Number(part);
|
|
93
|
+
if (octet > 255)
|
|
94
|
+
return null;
|
|
95
|
+
value = value * 256 + octet;
|
|
96
|
+
}
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
/** An IPv6 address (optionally with a trailing dotted IPv4 address) as a 128-bit value; or null. */
|
|
100
|
+
function ipv6Value(ip) {
|
|
101
|
+
const halves = ip.split("::");
|
|
102
|
+
if (halves.length > 2)
|
|
103
|
+
return null;
|
|
104
|
+
const side = (s) => {
|
|
105
|
+
if (s === undefined || s === "")
|
|
106
|
+
return [];
|
|
107
|
+
const parts = s.split(":");
|
|
108
|
+
const groups = [];
|
|
109
|
+
for (let i = 0; i < parts.length; i++) {
|
|
110
|
+
const part = parts[i];
|
|
111
|
+
if (i === parts.length - 1 && part.includes(".")) {
|
|
112
|
+
const v4 = ipv4Value(part);
|
|
113
|
+
if (v4 === null)
|
|
114
|
+
return null;
|
|
115
|
+
groups.push((v4 >>> 16).toString(16), (v4 & 0xffff).toString(16));
|
|
116
|
+
}
|
|
117
|
+
else if (GROUP.test(part))
|
|
118
|
+
groups.push(part);
|
|
119
|
+
else
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return groups;
|
|
123
|
+
};
|
|
124
|
+
const head = side(halves[0]);
|
|
125
|
+
const tail = halves.length === 2 ? side(halves[1]) : [];
|
|
126
|
+
if (head === null || tail === null)
|
|
127
|
+
return null;
|
|
128
|
+
// a trailing IPv4 address may only end the address
|
|
129
|
+
if (halves.length === 2 && halves[0]?.includes("."))
|
|
130
|
+
return null;
|
|
131
|
+
const count = head.length + tail.length;
|
|
132
|
+
if (halves.length === 2 ? count > 7 : count !== 8)
|
|
133
|
+
return null;
|
|
134
|
+
const groups = [...head, ...Array(8 - count).fill("0"), ...tail];
|
|
135
|
+
let value = 0n;
|
|
136
|
+
for (const g of groups)
|
|
137
|
+
value = (value << 16n) | BigInt(Number.parseInt(g, 16));
|
|
138
|
+
return value;
|
|
139
|
+
}
|
|
140
|
+
const compiled = ADDRESS_CLASS_RANGES.map((entry) => {
|
|
141
|
+
const [address = "", prefix = ""] = entry.cidr.split("/");
|
|
142
|
+
const bits = entry.family === "ipv4" ? 32 : 128;
|
|
143
|
+
const value = entry.family === "ipv4" ? ipv4Value(address) : ipv6Value(address);
|
|
144
|
+
if (value === null)
|
|
145
|
+
throw new Error(`Invalid address-class range ${entry.cidr}`);
|
|
146
|
+
return { bits, network: BigInt(value), prefix: Number(prefix), entry };
|
|
147
|
+
});
|
|
148
|
+
function lookup(bits, value) {
|
|
149
|
+
for (const r of compiled) {
|
|
150
|
+
if (r.bits !== bits)
|
|
151
|
+
continue;
|
|
152
|
+
const shift = BigInt(bits - r.prefix);
|
|
153
|
+
if (value >> shift !== r.network >> shift)
|
|
154
|
+
continue;
|
|
155
|
+
const e = r.entry;
|
|
156
|
+
if ("class" in e)
|
|
157
|
+
return e.class;
|
|
158
|
+
return lookup(32, (value >> BigInt(128 - 32 - e.embeddedIpv4At)) & 0xffffffffn);
|
|
159
|
+
}
|
|
160
|
+
// unreachable: each family ends with a catch-all range
|
|
161
|
+
throw new Error("The address-class table is not total");
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Classifies one IPv4 or IPv6 address literal by {@link ADDRESS_CLASS_RANGES}. IPv6 may carry a
|
|
165
|
+
* zone (`fe80::1%en0`) and a trailing dotted IPv4 address; an IPv6 form that embeds an IPv4 address
|
|
166
|
+
* (v4-mapped and the others in the table) classifies as that IPv4 address, except NAT64. Throws on a
|
|
167
|
+
* string that is not an IP address: brackets, ports, short, octal or hex IPv4 forms, and an IPv4
|
|
168
|
+
* address with a zone.
|
|
169
|
+
*/
|
|
170
|
+
export function classifyAddress(ip) {
|
|
171
|
+
const v4 = ipv4Value(ip);
|
|
172
|
+
if (v4 !== null)
|
|
173
|
+
return lookup(32, BigInt(v4));
|
|
174
|
+
const zone = ip.indexOf("%");
|
|
175
|
+
const address = zone >= 0 ? ip.slice(0, zone) : ip;
|
|
176
|
+
if (zone >= 0 && !ZONE.test(ip.slice(zone + 1)))
|
|
177
|
+
return notAnAddress(ip);
|
|
178
|
+
const v6 = address.includes(":") ? ipv6Value(address) : null;
|
|
179
|
+
if (v6 === null)
|
|
180
|
+
return notAnAddress(ip);
|
|
181
|
+
return lookup(128, v6);
|
|
182
|
+
}
|
|
183
|
+
function notAnAddress(ip) {
|
|
184
|
+
throw new Error(`${JSON.stringify(ip.slice(0, 64))} is not an IP address`);
|
|
185
|
+
}
|
|
186
|
+
const formatAddress = (bits, v) => {
|
|
187
|
+
if (bits === 32)
|
|
188
|
+
return [24n, 16n, 8n, 0n].map((sh) => ((v >> sh) & 0xffn).toString()).join(".");
|
|
189
|
+
const groups = Array.from({ length: 8 }, (_, i) => Number((v >> BigInt(112 - 16 * i)) & 0xffffn));
|
|
190
|
+
// RFC 5952: the first longest run of two or more zero groups becomes "::"
|
|
191
|
+
let best = -1;
|
|
192
|
+
let bestLength = 1;
|
|
193
|
+
for (let i = 0; i < 8;) {
|
|
194
|
+
if (groups[i] !== 0) {
|
|
195
|
+
i++;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
let j = i;
|
|
199
|
+
while (j < 8 && groups[j] === 0)
|
|
200
|
+
j++;
|
|
201
|
+
if (j - i > bestLength) {
|
|
202
|
+
best = i;
|
|
203
|
+
bestLength = j - i;
|
|
204
|
+
}
|
|
205
|
+
i = j;
|
|
206
|
+
}
|
|
207
|
+
const hex = (gs) => gs.map((g) => g.toString(16)).join(":");
|
|
208
|
+
if (best < 0)
|
|
209
|
+
return hex(groups);
|
|
210
|
+
return `${hex(groups.slice(0, best))}::${hex(groups.slice(best + bestLength))}`;
|
|
211
|
+
};
|
|
212
|
+
/** The class shared by every address of the block, or null when the table splits it. */
|
|
213
|
+
function blockClass(bits, network, prefix) {
|
|
214
|
+
let containing;
|
|
215
|
+
for (const r of compiled) {
|
|
216
|
+
if (r.bits !== bits)
|
|
217
|
+
continue;
|
|
218
|
+
if (r.prefix > prefix) {
|
|
219
|
+
const shift = BigInt(bits - prefix);
|
|
220
|
+
if (r.network >> shift === network >> shift)
|
|
221
|
+
return null; // a range inside the block
|
|
222
|
+
}
|
|
223
|
+
else if (containing === undefined) {
|
|
224
|
+
const shift = BigInt(bits - r.prefix);
|
|
225
|
+
if (r.network >> shift === network >> shift)
|
|
226
|
+
containing = r;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (containing === undefined)
|
|
230
|
+
return null;
|
|
231
|
+
const e = containing.entry;
|
|
232
|
+
if ("class" in e)
|
|
233
|
+
return e.class;
|
|
234
|
+
const at = e.embeddedIpv4At;
|
|
235
|
+
const v4 = (network >> BigInt(128 - 32 - at)) & 0xffffffffn;
|
|
236
|
+
return blockClass(32, v4, Math.min(32, Math.max(0, prefix - at)));
|
|
237
|
+
}
|
|
238
|
+
/** The closed CIDRs of a block, merged where both halves are closed ("full" = all closed). */
|
|
239
|
+
function closedOf(bits, network, prefix) {
|
|
240
|
+
const cls = blockClass(bits, network, prefix);
|
|
241
|
+
if (cls !== null)
|
|
242
|
+
return OPEN_PUBLIC_DENIED_CLASSES.includes(cls) ? "full" : [];
|
|
243
|
+
const half = 1n << BigInt(bits - prefix - 1);
|
|
244
|
+
const halves = [network, network | half].map((n) => ({
|
|
245
|
+
n,
|
|
246
|
+
closed: closedOf(bits, n, prefix + 1),
|
|
247
|
+
}));
|
|
248
|
+
if (halves.every((h) => h.closed === "full"))
|
|
249
|
+
return "full";
|
|
250
|
+
return halves.flatMap((h) => h.closed === "full" ? [`${formatAddress(bits, h.n)}/${prefix + 1}`] : h.closed);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Every address closed in `open-public` mode as one CIDR list (IPv4, then IPv6), computed from
|
|
254
|
+
* {@link ADDRESS_CLASS_RANGES}: for a consumer that can only deny ranges (the macOS runtime's
|
|
255
|
+
* resolved-address deny list). Embedded forms are expanded (the v4-mapped, SIIT, v4-compatible and
|
|
256
|
+
* 6to4 sub-ranges of every closed IPv4 range), and adjacent closed blocks are merged. An address
|
|
257
|
+
* is in a listed CIDR exactly when {@link classifyAddress} gives it a closed class.
|
|
258
|
+
*/
|
|
259
|
+
export const OPEN_PUBLIC_DENIED_CIDRS = Object.freeze([32, 128].flatMap((bits) => {
|
|
260
|
+
const closed = closedOf(bits, 0n, 0);
|
|
261
|
+
return closed === "full" ? [`${formatAddress(bits, 0n)}/0`] : closed;
|
|
262
|
+
}));
|
|
263
|
+
/**
|
|
264
|
+
* Encrypted DNS for a network whose resolver answers with fake IPs (maintainer decision
|
|
265
|
+
* 2026-11-19): a router running a fake-IP proxy (OpenClash and the like) intercepts every port-53
|
|
266
|
+
* query and answers each name with an address in {@link fakeIpCidr} (`198.18.0.0/15`, a reserved
|
|
267
|
+
* class), so in open mode every name would resolve to a closed address. When the system
|
|
268
|
+
* resolver's answer for a name contains such an address, a sandbox egress proxy re-resolves the
|
|
269
|
+
* name (A and AAAA) through DNS-over-HTTPS (RFC 8484, GET, wire format) at these IP-literal
|
|
270
|
+
* endpoints, in order (Cloudflare, then Google as the fallback), verifying TLS against the
|
|
271
|
+
* endpoint's IP SAN so no DNS is needed to reach them. {@link timeoutMs} is one overall deadline
|
|
272
|
+
* per name, covering A and AAAA and every endpoint; each endpoint gets its share of the time left.
|
|
273
|
+
* An answer is cached only when both queries succeeded, for its TTL, at most
|
|
274
|
+
* {@link cacheTtlCapSeconds}, and for at most {@link cacheMaxNames} names. The real address is
|
|
275
|
+
* classified like any resolved address and dialled as checked. When encrypted DNS fails the
|
|
276
|
+
* connection is refused, naming the fake-IP resolver; the fake address is never dialled. The same
|
|
277
|
+
* rule applies to an allowlisted name. Shared by the macOS worker and the Linux forwarder, so both
|
|
278
|
+
* keep identical endpoints and limits.
|
|
279
|
+
*/
|
|
280
|
+
export const SANDBOX_FAKE_IP_DNS = Object.freeze({
|
|
281
|
+
fakeIpCidr: "198.18.0.0/15",
|
|
282
|
+
endpoints: Object.freeze([
|
|
283
|
+
"https://1.1.1.1/dns-query",
|
|
284
|
+
"https://1.0.0.1/dns-query",
|
|
285
|
+
"https://8.8.8.8/dns-query",
|
|
286
|
+
"https://8.8.4.4/dns-query",
|
|
287
|
+
]),
|
|
288
|
+
timeoutMs: 5000,
|
|
289
|
+
cacheTtlCapSeconds: 300,
|
|
290
|
+
cacheMaxNames: 256,
|
|
291
|
+
});
|
package/dist/permissions.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { type PolicyHook } from "./hooks.js";
|
|
2
|
+
import { type HttpPermission } from "./http-access.js";
|
|
2
3
|
/** Extension permission manifest: governance, not a sandbox; using an undeclared platform API throws ExtensionPermissionError. */
|
|
3
4
|
export interface ExtensionPermissions {
|
|
4
5
|
/** ctx.secrets */
|
|
5
6
|
secrets?: boolean;
|
|
6
|
-
/** ctx.http.route
|
|
7
|
-
http?:
|
|
8
|
-
|
|
9
|
-
path: string;
|
|
10
|
-
public?: boolean;
|
|
11
|
-
}[];
|
|
12
|
-
/** ctx.tools.register 的工具名。 */
|
|
7
|
+
/** Routes registered with ctx.http.route; each declares who may call it (`access`). */
|
|
8
|
+
http?: HttpPermission[];
|
|
9
|
+
/** Tool names for ctx.tools.register. */
|
|
13
10
|
tools?: string[];
|
|
14
11
|
/**
|
|
15
12
|
* Hook mount points (`ctx.hooks.on`). From M7, five mount points are registrable; see
|
|
@@ -24,32 +21,67 @@ export interface ExtensionPermissions {
|
|
|
24
21
|
policyHooks?: PolicyHook[];
|
|
25
22
|
/**
|
|
26
23
|
* Model purposes (`ctx.models`): each key must be `<extension name>.<name>`; an org admin maps
|
|
27
|
-
* each to a model of its `kind`. `ctx.models.embed`
|
|
24
|
+
* each to a model of its `kind`. `ctx.models.embed` accepts the `embedding` ones, `generateImage`
|
|
25
|
+
* the `image_generation` ones.
|
|
28
26
|
*/
|
|
29
27
|
models?: {
|
|
30
28
|
purpose: string;
|
|
31
|
-
kind: "chat" | "embedding";
|
|
29
|
+
kind: "chat" | "embedding" | "image_generation";
|
|
32
30
|
label: {
|
|
33
31
|
zh: string;
|
|
34
32
|
en: string;
|
|
35
33
|
};
|
|
36
34
|
}[];
|
|
37
|
-
/** ctx.storage
|
|
35
|
+
/** ctx.storage (object storage, keys confined under `plugins/<plugin name>/<orgId>/`). */
|
|
38
36
|
storage?: boolean;
|
|
39
|
-
/**
|
|
37
|
+
/** Domains accessed; displayed only, not enforced. */
|
|
40
38
|
network?: string[];
|
|
41
39
|
/**
|
|
42
|
-
*
|
|
43
|
-
* `
|
|
40
|
+
* Client code: the package's `client` section (a browser bundle the web app loads for the
|
|
41
|
+
* extension's orgs). Sensitive and blocking; required when `ui.components` lists anything.
|
|
42
|
+
*/
|
|
43
|
+
client?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The ids of the `ui` contributions, one list per kind (each id in exactly one list): `views`
|
|
46
|
+
* are recorded in the snapshot without blocking the load; `embeds` and `components` block the
|
|
47
|
+
* load until approved and are sensitive. `components` needs `client: true`.
|
|
44
48
|
*/
|
|
45
49
|
ui?: {
|
|
46
50
|
views?: string[];
|
|
47
51
|
embeds?: string[];
|
|
52
|
+
components?: string[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Setup check ids registered with `ctx.setup.check` (each matches `SETUP_CHECK_ID_RE`, at most
|
|
56
|
+
* `SETUP_CHECK_LIMITS.idsPerExtension`). Recorded in the snapshot and shown at review as
|
|
57
|
+
* `setupCheck:<id>`, but never blocks loading: a check receives only data the extension already
|
|
58
|
+
* receives for the same target.
|
|
59
|
+
*/
|
|
60
|
+
setupChecks?: string[];
|
|
61
|
+
/**
|
|
62
|
+
* The dial-in channel (`ctx.dialIn`): machines connect to the deployment and serve this
|
|
63
|
+
* extension's devices, speaking `protocol` (`<name>/<major>`, {@link DIAL_IN_PROTOCOL_RE}) inside
|
|
64
|
+
* the kernel's envelope. Only for an extension that provides `device-provider@1`; its provider
|
|
65
|
+
* then implements `dialIn` (`DialInHandler`).
|
|
66
|
+
*/
|
|
67
|
+
dialIn?: {
|
|
68
|
+
protocol: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* `ctx.deviceAccess`: services this extension runs in the conversation's device and reaches
|
|
72
|
+
* through requests and viewer streams. `services` lists 1 to
|
|
73
|
+
* {@link DEVICE_ACCESS_MAX_SERVICES} service names ({@link DEVICE_SERVICE_NAME_RE}); a service
|
|
74
|
+
* not listed is refused. Any extension may declare it (no `provides` needed).
|
|
75
|
+
*/
|
|
76
|
+
deviceAccess?: {
|
|
77
|
+
services: string[];
|
|
48
78
|
};
|
|
49
79
|
}
|
|
50
|
-
/**
|
|
51
|
-
export declare const
|
|
52
|
-
/**
|
|
80
|
+
/** The most services `permissions.deviceAccess.services` may list. */
|
|
81
|
+
export declare const DEVICE_ACCESS_MAX_SERVICES = 4;
|
|
82
|
+
/** Hook mount points (a closed list, see the overall design 2.4). */
|
|
83
|
+
export declare const HOOK_MOUNT_POINTS: readonly ["session.start", "session.end", "agent.preStep", "model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report", "org.member_removed", "agent.deleted", "org.deleted"];
|
|
84
|
+
/** A hook mount point name. */
|
|
53
85
|
export type HookMountPoint = (typeof HOOK_MOUNT_POINTS)[number];
|
|
54
86
|
/** A platform API not declared in the manifest was used. */
|
|
55
87
|
export declare class ExtensionPermissionError extends Error {
|
|
@@ -59,12 +91,23 @@ export declare class ExtensionPermissionError extends Error {
|
|
|
59
91
|
export declare class ExtensionPointUnavailableError extends Error {
|
|
60
92
|
constructor(message: string);
|
|
61
93
|
}
|
|
62
|
-
/** 校验权限清单,返回错误列表(空表示合法)。 */
|
|
63
|
-
export declare function validatePermissions(plugin: string, p: unknown): string[];
|
|
64
94
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
|
|
68
|
-
|
|
95
|
+
* Validates the permission manifest and returns the list of errors (empty means valid). `provides`
|
|
96
|
+
* is the manifest's `provides` (`permissions.dialIn` needs `device-provider@1` in it).
|
|
97
|
+
*/
|
|
98
|
+
export declare function validatePermissions(plugin: string, p: unknown, provides?: readonly string[]): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Checks the structure of the manifest's `ui` and cross-checks it with the permission manifest;
|
|
101
|
+
* returns the problems (empty = valid). Only structural problems (UI slots spec §3.2, client
|
|
102
|
+
* extensions spec §5.1): each contribution's id is listed in the list of its kind,
|
|
103
|
+
* `permissions.ui.views` (view), `permissions.ui.embeds` (embed) or `permissions.ui.components`
|
|
104
|
+
* (component), an id is in at most one of the three, and `permissions.ui` lists no id the `ui`
|
|
105
|
+
* lacks; `permissions.ui.components` needs `permissions.client: true`; an embed's path starts with
|
|
106
|
+
* `/ui/` and is declared in `permissions.http` as GET, a view or component has no path; exactly one
|
|
107
|
+
* of `slot` (a well-formed slot reference) and `place` (a known place); for a slot the catalog
|
|
108
|
+
* knows at the version named, a kind it accepts and, unless an alias, the icon it requires. An
|
|
109
|
+
* unknown slot id or version is not a problem here: `resolveUiSlots` drops that contribution and
|
|
110
|
+
* the rest of the extension loads.
|
|
111
|
+
* Assumes `permissions` passed {@link validatePermissions}.
|
|
69
112
|
*/
|
|
70
113
|
export declare function validateUiContributions(ui: unknown, permissions: unknown): string[];
|