@capybara-hq/plugin-sdk 0.1.0-rc.6 → 0.1.0-rc.61

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.
Files changed (136) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +7 -1
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +2 -0
  9. package/agent-docs/extension-points/model-provider.md +3 -1
  10. package/agent-docs/extension-points/object-store.md +2 -0
  11. package/agent-docs/extension-points/push-provider.md +17 -0
  12. package/agent-docs/extensions.md +29 -3
  13. package/agent-docs/plugin-format.md +52 -2
  14. package/agent-docs/setup.md +54 -0
  15. package/dist/agent-template.d.ts +15 -6
  16. package/dist/agent-template.js +32 -13
  17. package/dist/avatar-presets.d.ts +8 -0
  18. package/dist/avatar-presets.js +17 -0
  19. package/dist/bootstrap.d.ts +109 -1
  20. package/dist/bootstrap.js +185 -2
  21. package/dist/cards.d.ts +67 -13
  22. package/dist/cards.js +91 -21
  23. package/dist/channel.d.ts +148 -48
  24. package/dist/channel.js +10 -5
  25. package/dist/client-css.d.ts +36 -0
  26. package/dist/client-css.js +326 -0
  27. package/dist/client-section.d.ts +35 -0
  28. package/dist/client-section.js +133 -0
  29. package/dist/config-ui.d.ts +22 -0
  30. package/dist/config-ui.js +64 -4
  31. package/dist/connector-auth.d.ts +15 -2
  32. package/dist/connector-auth.js +97 -8
  33. package/dist/connector.d.ts +74 -32
  34. package/dist/context.d.ts +40 -0
  35. package/dist/context.js +2 -0
  36. package/dist/ctx.d.ts +132 -29
  37. package/dist/define-extension.d.ts +26 -12
  38. package/dist/define-extension.js +12 -5
  39. package/dist/device-denied-paths.d.ts +18 -0
  40. package/dist/device-denied-paths.js +84 -0
  41. package/dist/device-operation.d.ts +333 -0
  42. package/dist/device-operation.js +312 -0
  43. package/dist/device-protocol.d.ts +285 -50
  44. package/dist/device-protocol.js +755 -90
  45. package/dist/device-provider.d.ts +503 -0
  46. package/dist/device-provider.js +302 -0
  47. package/dist/dial-in.d.ts +176 -0
  48. package/dist/dial-in.js +115 -0
  49. package/dist/extension-point.d.ts +2 -0
  50. package/dist/extension-point.js +6 -2
  51. package/dist/file-preview.d.ts +23 -6
  52. package/dist/git-hosts.d.ts +53 -0
  53. package/dist/git-hosts.js +98 -0
  54. package/dist/hooks.d.ts +125 -20
  55. package/dist/hooks.js +5 -0
  56. package/dist/http-access.d.ts +62 -0
  57. package/dist/http-access.js +12 -0
  58. package/dist/identity.d.ts +38 -9
  59. package/dist/identity.js +21 -1
  60. package/dist/index.d.ts +29 -3
  61. package/dist/index.js +29 -3
  62. package/dist/marketplace.d.ts +26 -0
  63. package/dist/marketplace.js +43 -1
  64. package/dist/model-params.d.ts +41 -22
  65. package/dist/model-params.js +28 -15
  66. package/dist/model.d.ts +206 -71
  67. package/dist/model.js +152 -19
  68. package/dist/net.d.ts +52 -0
  69. package/dist/net.js +34 -0
  70. package/dist/network-classes.d.ts +98 -0
  71. package/dist/network-classes.js +291 -0
  72. package/dist/permissions.d.ts +54 -22
  73. package/dist/permissions.js +119 -43
  74. package/dist/plugin-manifest.d.ts +45 -5
  75. package/dist/plugin-manifest.js +174 -6
  76. package/dist/plugin-package.d.ts +82 -38
  77. package/dist/plugin-package.js +61 -29
  78. package/dist/push.d.ts +75 -0
  79. package/dist/push.js +87 -0
  80. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  81. package/dist/sandbox-linux-runtime-source.js +2318 -0
  82. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  83. package/dist/sandbox-native-runtime-source.js +476 -0
  84. package/dist/sandbox-runtime-source.d.ts +19 -0
  85. package/dist/sandbox-runtime-source.js +28 -0
  86. package/dist/sandbox-write-denies.d.ts +139 -0
  87. package/dist/sandbox-write-denies.js +869 -0
  88. package/dist/secret.d.ts +4 -1
  89. package/dist/secret.js +4 -1
  90. package/dist/setup-check.d.ts +128 -0
  91. package/dist/setup-check.js +142 -0
  92. package/dist/setup-guide-parse.d.ts +121 -0
  93. package/dist/setup-guide-parse.js +356 -0
  94. package/dist/setup-guide-render.d.ts +45 -0
  95. package/dist/setup-guide-render.js +351 -0
  96. package/dist/setup-guide.d.ts +108 -0
  97. package/dist/setup-guide.js +367 -0
  98. package/dist/shell-capabilities.d.ts +211 -0
  99. package/dist/shell-capabilities.js +44 -0
  100. package/dist/shell-environment.d.ts +57 -0
  101. package/dist/shell-environment.js +21 -0
  102. package/dist/skill.d.ts +27 -17
  103. package/dist/skill.js +40 -26
  104. package/dist/storage.d.ts +52 -25
  105. package/dist/svg-viewbox.d.ts +10 -0
  106. package/dist/svg-viewbox.js +24 -0
  107. package/dist/theme-assets.d.ts +55 -0
  108. package/dist/theme-assets.js +489 -0
  109. package/dist/theme-readability.d.ts +37 -0
  110. package/dist/theme-readability.js +145 -0
  111. package/dist/theme-tokens.generated.d.ts +299 -0
  112. package/dist/theme-tokens.generated.js +184 -0
  113. package/dist/theme.d.ts +190 -0
  114. package/dist/theme.js +471 -0
  115. package/dist/tool.d.ts +99 -26
  116. package/dist/tool.js +29 -9
  117. package/dist/ui-parts.d.ts +23 -0
  118. package/dist/ui-parts.js +385 -0
  119. package/dist/ui-resolve.d.ts +35 -0
  120. package/dist/ui-resolve.js +42 -0
  121. package/dist/ui-slots.d.ts +65 -0
  122. package/dist/ui-slots.js +261 -0
  123. package/dist/ui.d.ts +212 -76
  124. package/dist/ui.js +101 -27
  125. package/dist/url.d.ts +4 -1
  126. package/dist/url.js +4 -1
  127. package/package.json +13 -1
  128. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  129. package/schemas/bootstrap.v1.schema.json +20 -0
  130. package/schemas/connector-template.v1.schema.json +35 -0
  131. package/schemas/marketplace.v1.schema.json +14 -0
  132. package/schemas/plugin.v1.schema.json +122 -3
  133. package/schemas/theme.v1.schema.json +302 -0
  134. package/agent-docs/extension-points/sandbox.md +0 -15
  135. package/dist/sandbox.d.ts +0 -254
  136. 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
+ });
@@ -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 注册的路由(`public` 表示免登录)。 */
7
- http?: {
8
- method: "GET" | "POST" | "PUT" | "DELETE";
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,56 @@ 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` / `describe` accept the `embedding` ones.
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(对象存储,键限定在 `plugins/<插件名>/<orgId>/` 下)。 */
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
- * 界面贡献的 id(与清单 `ui` 一一对应):`views` 记入快照但不卡加载;
43
- * `embeds` 卡加载、需批准,并标为敏感项。
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;
48
69
  };
49
70
  }
50
- /** hook 挂载点(封闭列表,见总设计 2.4)。 */
51
- export declare const HOOK_MOUNT_POINTS: readonly ["session.start", "session.end", "agent.preStep", "model.request", "model.response", "tool.preExecute", "tool.postExecute", "usage.report"];
52
- /** hook 挂载点名。 */
71
+ /** Hook mount points (a closed list, see the overall design 2.4). */
72
+ 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"];
73
+ /** A hook mount point name. */
53
74
  export type HookMountPoint = (typeof HOOK_MOUNT_POINTS)[number];
54
75
  /** A platform API not declared in the manifest was used. */
55
76
  export declare class ExtensionPermissionError extends Error {
@@ -59,12 +80,23 @@ export declare class ExtensionPermissionError extends Error {
59
80
  export declare class ExtensionPointUnavailableError extends Error {
60
81
  constructor(message: string);
61
82
  }
62
- /** 校验权限清单,返回错误列表(空表示合法)。 */
63
- export declare function validatePermissions(plugin: string, p: unknown): string[];
64
83
  /**
65
- * 校验清单 `ui` 并与权限清单交叉核对,返回错误列表(空表示合法):
66
- * 每个贡献的 id 恰好出现在 `permissions.ui.views`(kind view)或 `permissions.ui.embeds`(kind embed)里,
67
- * `permissions.ui` 里也不能有清单 `ui` 没有的 id;embed 的 path 以 `/ui/` 开头并在 `permissions.http` 中声明为 GET。
68
- * 假定 `permissions` 已经过 {@link validatePermissions}。
84
+ * Validates the permission manifest and returns the list of errors (empty means valid). `provides`
85
+ * is the manifest's `provides` (`permissions.dialIn` needs `device-provider@1` in it).
86
+ */
87
+ export declare function validatePermissions(plugin: string, p: unknown, provides?: readonly string[]): string[];
88
+ /**
89
+ * Checks the structure of the manifest's `ui` and cross-checks it with the permission manifest;
90
+ * returns the problems (empty = valid). Only structural problems (UI slots spec §3.2, client
91
+ * extensions spec §5.1): each contribution's id is listed in the list of its kind,
92
+ * `permissions.ui.views` (view), `permissions.ui.embeds` (embed) or `permissions.ui.components`
93
+ * (component), an id is in at most one of the three, and `permissions.ui` lists no id the `ui`
94
+ * lacks; `permissions.ui.components` needs `permissions.client: true`; an embed's path starts with
95
+ * `/ui/` and is declared in `permissions.http` as GET, a view or component has no path; exactly one
96
+ * of `slot` (a well-formed slot reference) and `place` (a known place); for a slot the catalog
97
+ * knows at the version named, a kind it accepts and, unless an alias, the icon it requires. An
98
+ * unknown slot id or version is not a problem here: `resolveUiSlots` drops that contribution and
99
+ * the rest of the extension loads.
100
+ * Assumes `permissions` passed {@link validatePermissions}.
69
101
  */
70
102
  export declare function validateUiContributions(ui: unknown, permissions: unknown): string[];