@botiverse/porthole 0.5.1 → 0.7.0
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 +41 -0
- package/dist/bridge/bridge.d.ts +13 -0
- package/dist/bridge/bridge.js +208 -13
- package/dist/bridge/navigation.d.ts +1 -6
- package/dist/bridge/navigation.js +11 -0
- package/dist/bridge/refusal.d.ts +5 -1
- package/dist/bridge/refusal.js +16 -0
- package/dist/bridge/types.d.ts +41 -4
- package/dist/check/check.d.ts +19 -3
- package/dist/check/check.js +55 -8
- package/dist/check/files.d.ts +26 -0
- package/dist/check/files.js +307 -0
- package/dist/check/instrument.d.ts +3 -0
- package/dist/check/lint.js +31 -12
- package/dist/check/page-source.js +1 -1
- package/dist/check/page.js +14 -0
- package/dist/check/tools.d.ts +23 -0
- package/dist/check/tools.js +27 -3
- package/dist/compile/policy.d.ts +34 -0
- package/dist/compile/policy.js +74 -0
- package/dist/config/capabilities.d.ts +62 -3
- package/dist/config/capabilities.js +20 -0
- package/dist/config/schema.d.ts +32 -0
- package/dist/config/validate.d.ts +1 -1
- package/dist/config/validate.js +74 -5
- package/dist/conformance/harness-source.js +1 -1
- package/dist/conformance/index.d.ts +1 -0
- package/dist/conformance/index.js +2 -0
- package/dist/conformance/runtime.d.ts +58 -0
- package/dist/conformance/runtime.js +314 -0
- package/dist/files/paths.d.ts +99 -0
- package/dist/files/paths.js +263 -0
- package/dist/files/types.d.ts +24 -0
- package/dist/files/types.js +83 -0
- package/dist/guide/gates.d.ts +3 -0
- package/dist/guide/gates.js +19 -0
- package/dist/guide/guide.d.ts +2 -0
- package/dist/guide/guide.js +44 -32
- package/dist/guide/limits.js +4 -4
- package/dist/guide/runtime.d.ts +13 -0
- package/dist/guide/runtime.js +202 -0
- package/dist/host/create-host.js +45 -0
- package/dist/host/locate.js +8 -0
- package/dist/host/locator.js +7 -0
- package/dist/host/types.d.ts +18 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +16 -3
- package/dist/isolation/types.d.ts +8 -0
- package/dist/presets/presets.d.ts +6 -0
- package/dist/presets/presets.js +1 -0
- package/dist/protocol/adapter.d.ts +4 -0
- package/dist/protocol/mcp-apps.d.ts +6 -0
- package/dist/protocol/mcp-apps.js +6 -0
- package/dist/protocol/runtime-calls.d.ts +28 -0
- package/dist/protocol/runtime-calls.js +113 -0
- package/dist/protocol/shell-adapter.js +52 -3
- package/dist/react/dialog.js +31 -0
- package/dist/react/frame.d.ts +13 -0
- package/dist/react/frame.js +6 -0
- package/dist/runtime/contract.d.ts +193 -0
- package/dist/runtime/contract.js +216 -0
- package/dist/runtime/db.d.ts +153 -0
- package/dist/runtime/db.js +398 -0
- package/dist/runtime/declaration.d.ts +86 -0
- package/dist/runtime/declaration.js +266 -0
- package/dist/runtime/levels.d.ts +33 -0
- package/dist/runtime/levels.js +41 -0
- package/dist/runtime/requests.d.ts +125 -0
- package/dist/runtime/requests.js +199 -0
- package/dist/runtime/segments.d.ts +8 -0
- package/dist/runtime/segments.js +14 -0
- package/dist/runtime/types.generated.d.ts +1 -0
- package/dist/runtime/types.generated.js +19 -0
- package/dist/server/files.d.ts +57 -0
- package/dist/server/files.js +338 -0
- package/dist/server/host.d.ts +44 -2
- package/dist/server/host.js +42 -2
- package/dist/server/index.d.ts +5 -2
- package/dist/server/index.js +5 -1
- package/dist/server/keys.d.ts +8 -0
- package/dist/server/keys.js +34 -0
- package/dist/server/pseudonym.d.ts +9 -0
- package/dist/server/pseudonym.js +20 -0
- package/dist/server/server.d.ts +0 -5
- package/dist/server/server.js +468 -24
- package/dist/server/types.d.ts +118 -5
- package/dist/shell/document.d.ts +27 -0
- package/dist/shell/document.js +46 -2
- package/dist/shell/legacy.d.ts +21 -0
- package/dist/shell/legacy.js +63 -0
- package/dist/shell/plan.d.ts +17 -1
- package/dist/shell/plan.js +13 -2
- package/dist/shell/runtime.d.ts +2 -1
- package/dist/shell/runtime.js +114 -46
- package/dist/shell/use.d.ts +15 -0
- package/dist/shell/use.js +235 -0
- package/docs/ADOPTING.md +142 -5
- package/docs/ARCHITECTURE.md +34 -5
- package/docs/DECISIONS.md +716 -7
- package/docs/DESIGN.md +97 -3
- package/package.json +3 -1
- package/src/bridge/bridge.ts +281 -17
- package/src/bridge/navigation.ts +12 -0
- package/src/bridge/refusal.ts +16 -0
- package/src/bridge/types.ts +46 -4
- package/src/check/check.ts +100 -14
- package/src/check/files.ts +384 -0
- package/src/check/instrument.ts +3 -0
- package/src/check/lint.ts +33 -12
- package/src/check/page.ts +14 -0
- package/src/check/tools.ts +52 -3
- package/src/compile/policy.ts +92 -0
- package/src/config/capabilities.ts +49 -2
- package/src/config/schema.ts +32 -0
- package/src/config/validate.ts +107 -5
- package/src/conformance/index.ts +7 -0
- package/src/conformance/runtime.ts +573 -0
- package/src/files/paths.ts +323 -0
- package/src/files/types.ts +101 -0
- package/src/guide/gates.ts +25 -0
- package/src/guide/guide.ts +78 -52
- package/src/guide/limits.ts +4 -4
- package/src/guide/runtime.ts +244 -0
- package/src/host/create-host.ts +55 -0
- package/src/host/locate.ts +10 -0
- package/src/host/locator.ts +11 -0
- package/src/host/types.ts +18 -0
- package/src/index.ts +121 -0
- package/src/isolation/types.ts +8 -0
- package/src/presets/presets.ts +7 -0
- package/src/protocol/adapter.ts +3 -1
- package/src/protocol/mcp-apps.ts +7 -0
- package/src/protocol/runtime-calls.ts +138 -0
- package/src/protocol/shell-adapter.ts +56 -2
- package/src/react/dialog.tsx +33 -0
- package/src/react/frame.tsx +19 -0
- package/src/runtime/contract.ts +305 -0
- package/src/runtime/db.ts +530 -0
- package/src/runtime/declaration.ts +378 -0
- package/src/runtime/levels.ts +69 -0
- package/src/runtime/requests.ts +339 -0
- package/src/runtime/segments.ts +17 -0
- package/src/runtime/types.generated.ts +19 -0
- package/src/server/files.ts +425 -0
- package/src/server/host.ts +84 -3
- package/src/server/index.ts +22 -0
- package/src/server/keys.ts +53 -0
- package/src/server/pseudonym.ts +21 -0
- package/src/server/server.ts +565 -26
- package/src/server/types.ts +124 -4
- package/src/shell/document.ts +74 -4
- package/src/shell/legacy.ts +64 -0
- package/src/shell/plan.ts +37 -3
- package/src/shell/runtime.ts +114 -46
- package/src/shell/use.ts +235 -0
- package/types/runtime/v1/artifact.d.ts +50 -0
- package/types/runtime/v1/assets.d.ts +43 -0
- package/types/runtime/v1/chat.d.ts +13 -0
- package/types/runtime/v1/clipboard.d.ts +14 -0
- package/types/runtime/v1/comments.d.ts +24 -0
- package/types/runtime/v1/context.d.ts +16 -0
- package/types/runtime/v1/data.d.ts +29 -0
- package/types/runtime/v1/db.d.ts +110 -0
- package/types/runtime/v1/downloads.d.ts +22 -0
- package/types/runtime/v1/links.d.ts +13 -0
- package/types/runtime/v1/porthole.d.ts +44 -0
- package/types/runtime/v1/user.d.ts +19 -0
package/dist/check/page.js
CHANGED
|
@@ -22,6 +22,16 @@ const DECLINED = {
|
|
|
22
22
|
subscribeData: () => {
|
|
23
23
|
throw new Error("The host declined the subscription");
|
|
24
24
|
},
|
|
25
|
+
comments: () => false,
|
|
26
|
+
artifact: () => {
|
|
27
|
+
throw new Error("The host declined the artifact call");
|
|
28
|
+
},
|
|
29
|
+
assets: () => {
|
|
30
|
+
throw new Error("The host declined the asset call");
|
|
31
|
+
},
|
|
32
|
+
db: () => {
|
|
33
|
+
throw new Error("The host declined the db call");
|
|
34
|
+
},
|
|
25
35
|
};
|
|
26
36
|
/**
|
|
27
37
|
* The web platform, with no person on the page: no call comes from a click (P078). The driver's
|
|
@@ -125,6 +135,10 @@ const check = {
|
|
|
125
135
|
title: "Check",
|
|
126
136
|
scheme: spec.scheme,
|
|
127
137
|
...(spec.instance === undefined ? {} : { instance: spec.instance }),
|
|
138
|
+
// Under a runtime: the page's declaration (none by default), a viewer who only views.
|
|
139
|
+
...(spec.config.runtime === undefined
|
|
140
|
+
? {}
|
|
141
|
+
: { declaration: spec.declaration ?? null, viewer: { level: "view" } }),
|
|
128
142
|
});
|
|
129
143
|
const run = {
|
|
130
144
|
display,
|
package/dist/check/tools.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PortholeConfig } from "../config/schema.ts";
|
|
2
2
|
import { type Finding } from "./lint.ts";
|
|
3
|
+
import { type FileContents, type FileFinding } from "./files.ts";
|
|
3
4
|
/**
|
|
4
5
|
* The agent's tools, as a tool list names them (P073): a name, a description and a JSON Schema
|
|
5
6
|
* for each, from the config, so a host lists them in one line (an MCP server's `tools/list`, an
|
|
@@ -54,6 +55,28 @@ export type AdmitResult = {
|
|
|
54
55
|
export declare function admitContent(config: PortholeConfig, content: string, options?: {
|
|
55
56
|
readonly refuseOn?: "error" | "never";
|
|
56
57
|
}): AdmitResult;
|
|
58
|
+
export type AdmitFilesResult = {
|
|
59
|
+
readonly ok: true;
|
|
60
|
+
/** Warnings (and errors, with `refuseOn: "never"`), for the tool's answer. */
|
|
61
|
+
readonly findings: readonly FileFinding[];
|
|
62
|
+
/** One line for the agent, or null when there's nothing to say. */
|
|
63
|
+
readonly note: string | null;
|
|
64
|
+
} | {
|
|
65
|
+
readonly ok: false;
|
|
66
|
+
readonly findings: readonly FileFinding[];
|
|
67
|
+
/** What to tell the agent: what to change, and to call the tool again. */
|
|
68
|
+
readonly refusal: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* A publish tool's check before it takes a page with files (P081): refuses only what certainly
|
|
72
|
+
* fails (a path or limit the server won't take, no entry, a page `admitContent` would refuse, a
|
|
73
|
+
* page's reference that starts with /); the rest, references to files that aren't in the set
|
|
74
|
+
* among them, are warnings. `refuseOn: "never"` refuses nothing.
|
|
75
|
+
*/
|
|
76
|
+
export declare function admitFiles(config: PortholeConfig, files: FileContents, options?: {
|
|
77
|
+
readonly entry?: string;
|
|
78
|
+
readonly refuseOn?: "error" | "never";
|
|
79
|
+
}): AdmitFilesResult;
|
|
57
80
|
/**
|
|
58
81
|
* What to tell the agent when its manual changes (a display kind flipped between served and
|
|
59
82
|
* opaque, P073): the lines that are new, or null when the manual reads the same.
|
package/dist/check/tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { generateGuide, generateToolDescription } from "../guide/guide.js";
|
|
1
|
+
import { builtInTopics, generateGuide, generateToolDescription } from "../guide/guide.js";
|
|
3
2
|
import { fragmentOf, lintContent } from "./lint.js";
|
|
3
|
+
import { lintFiles, whereOf } from "./files.js";
|
|
4
4
|
const noun = (config) => config.mode === "artifact" ? "page" : config.mode === "mcp-app" ? "view" : "widget";
|
|
5
5
|
/** The show tool's name: the config's `guide.toolName`, else `show_<noun>`. */
|
|
6
6
|
const showName = (config) => config.guide.toolName ?? `show_${noun(config)}`;
|
|
@@ -8,7 +8,7 @@ const showName = (config) => config.guide.toolName ?? `show_${noun(config)}`;
|
|
|
8
8
|
const guideName = (config) => config.guide.guideToolName ?? `${noun(config)}_guide`;
|
|
9
9
|
/** The topics the manual has: the built-in ones and the config's own. */
|
|
10
10
|
export function guideTopics(config) {
|
|
11
|
-
return [...
|
|
11
|
+
return [...builtInTopics(config), ...Object.keys(config.guide.topics ?? {})];
|
|
12
12
|
}
|
|
13
13
|
/** The tool that shows content: `{ title, html }`. */
|
|
14
14
|
export function showTool(config, options = {}) {
|
|
@@ -124,6 +124,30 @@ export function admitContent(config, content, options = {}) {
|
|
|
124
124
|
: `Shown. Fix these next time:\n${findings.map((each) => `- ${said(each)}`).join("\n")}`,
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* A publish tool's check before it takes a page with files (P081): refuses only what certainly
|
|
129
|
+
* fails (a path or limit the server won't take, no entry, a page `admitContent` would refuse, a
|
|
130
|
+
* page's reference that starts with /); the rest, references to files that aren't in the set
|
|
131
|
+
* among them, are warnings. `refuseOn: "never"` refuses nothing.
|
|
132
|
+
*/
|
|
133
|
+
export function admitFiles(config, files, options = {}) {
|
|
134
|
+
const findings = lintFiles(config, files, options.entry === undefined ? {} : { entry: options.entry });
|
|
135
|
+
const errors = findings.filter((each) => each.severity === "error");
|
|
136
|
+
if (errors.length > 0 && (options.refuseOn ?? "error") === "error") {
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
findings,
|
|
140
|
+
refusal: `Not published. Change this, then publish again:\n${errors.map((each) => `- ${whereOf(each)}${each.message}`).join("\n")}`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
ok: true,
|
|
145
|
+
findings,
|
|
146
|
+
note: findings.length === 0
|
|
147
|
+
? null
|
|
148
|
+
: `Published. Fix these next time:\n${findings.map((each) => `- ${whereOf(each)}${each.message}`).join("\n")}`,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
127
151
|
/**
|
|
128
152
|
* What to tell the agent when its manual changes (a display kind flipped between served and
|
|
129
153
|
* opaque, P073): the lines that are new, or null when the manual reads the same.
|
package/dist/compile/policy.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CapabilityName, type Gate } from "../config/capabilities.ts";
|
|
2
2
|
import type { PortholeConfig } from "../config/schema.ts";
|
|
3
|
+
import { assetCodeRuns } from "../runtime/contract.ts";
|
|
3
4
|
/**
|
|
4
5
|
* The frame's policies, derived from the config: its CSP (in the shell's `<meta>` for opaque
|
|
5
6
|
* frames, in headers for served ones), its `sandbox` and `allow` attributes, and the `frame-src`
|
|
@@ -14,6 +15,11 @@ export declare function anyHttps(config: PortholeConfig, kind: EgressKind): bool
|
|
|
14
15
|
export declare function declaredCapabilities(config: PortholeConfig): CapabilityName[];
|
|
15
16
|
/** The gates a declared capability runs under: its own, else the vocabulary's defaults. */
|
|
16
17
|
export declare function effectiveGates(config: PortholeConfig, name: CapabilityName): readonly Gate[];
|
|
18
|
+
/**
|
|
19
|
+
* The gates one call runs under: its host function's, and its runtime method's own (after the
|
|
20
|
+
* review: `artifact.publish`, `assets.delete`, an upload whose code may run), every one applying.
|
|
21
|
+
*/
|
|
22
|
+
export declare function callGates(config: PortholeConfig, name: CapabilityName, args: unknown): readonly Gate[];
|
|
17
23
|
/** The origins content may reach for `kind`: the base allowlist plus every declared capability's. */
|
|
18
24
|
export declare function egressOrigins(config: PortholeConfig, kind: EgressKind): string[];
|
|
19
25
|
/** Every origin content may reach, of any kind. */
|
|
@@ -31,6 +37,34 @@ export declare function librarySources(config: PortholeConfig): string[];
|
|
|
31
37
|
* whose app serves its own policy.
|
|
32
38
|
*/
|
|
33
39
|
export declare function frameCspDirectives(config: PortholeConfig): CspDirective[];
|
|
40
|
+
/** The directives a page of a file set loads its own files under (P082): everything that loads. */
|
|
41
|
+
export declare const FILE_SET_DIRECTIVES: readonly ["script-src", "style-src", "font-src", "img-src", "media-src", "connect-src", "worker-src"];
|
|
42
|
+
/**
|
|
43
|
+
* A served page's CSP when it comes with files (P082): the frame's, with its version's own files
|
|
44
|
+
* opened for each kind that loads (`FILE_SET_DIRECTIVES`), by `source`, the files' path on the
|
|
45
|
+
* content origin (`https://a-x.example-usercontent.com/v/3/`). Never `'self'`: the origin's other
|
|
46
|
+
* paths (other versions, Porthole's own) stay closed, and frames, plugins, forms and `<base>` stay
|
|
47
|
+
* `'none'`. Opaque frames have no files, and keep P022's rule whole.
|
|
48
|
+
*/
|
|
49
|
+
export declare function fileSetCspDirectives(directives: readonly CspDirective[], source: string): CspDirective[];
|
|
50
|
+
/**
|
|
51
|
+
* The directives a page opens its artifact's asset library to (P089), at `/_blob/` on its own
|
|
52
|
+
* origin: what loads without running, always; what runs (scripts, styles) only where uploads are
|
|
53
|
+
* the admins' alone, who publish the page's code anyway.
|
|
54
|
+
*/
|
|
55
|
+
export declare const ASSET_DIRECTIVES: readonly ["img-src", "media-src", "font-src", "connect-src"];
|
|
56
|
+
export declare const ASSET_CODE_DIRECTIVES: readonly ["script-src", "style-src"];
|
|
57
|
+
export { assetCodeRuns };
|
|
58
|
+
/**
|
|
59
|
+
* A served page's CSP with its asset library opened (P089), on `origin` (the page's own, exact:
|
|
60
|
+
* never a sibling's): only where the config declares `assets`. Never `'self'`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function assetCspDirectives(config: PortholeConfig, directives: readonly CspDirective[], origin: string): CspDirective[];
|
|
63
|
+
/**
|
|
64
|
+
* The CSP of a file of a set that is neither a page nor a script (P081): nothing loads from it,
|
|
65
|
+
* and opened as a document (an SVG, an XML file) it runs nothing, on an opaque origin.
|
|
66
|
+
*/
|
|
67
|
+
export declare const INERT_FILE_CSP = "default-src 'none'; sandbox";
|
|
34
68
|
export declare function serializeCsp(directives: readonly CspDirective[]): string;
|
|
35
69
|
/**
|
|
36
70
|
* The frame's `sandbox` tokens. Opaque: scripts only, so the frame is an opaque origin and gets
|
package/dist/compile/policy.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CAPABILITIES } from "../config/capabilities.js";
|
|
2
2
|
import { LIBRARY_PATH } from "../libraries/libraries.js";
|
|
3
|
+
import { assetCodeRuns, familyOf, methodGates, methodOf } from "../runtime/contract.js";
|
|
4
|
+
import { ASSET_PATH } from "../runtime/requests.js";
|
|
3
5
|
/** Whether `kind` loads from any https site (`EgressConfig.anyHttps`, P059): passive kinds only. */
|
|
4
6
|
export function anyHttps(config, kind) {
|
|
5
7
|
return (config.egress.anyHttps ?? []).some((each) => each === kind);
|
|
@@ -12,6 +14,17 @@ export function declaredCapabilities(config) {
|
|
|
12
14
|
export function effectiveGates(config, name) {
|
|
13
15
|
return config.capabilities[name]?.gates ?? CAPABILITIES[name].defaultGates;
|
|
14
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The gates one call runs under: its host function's, and its runtime method's own (after the
|
|
19
|
+
* review: `artifact.publish`, `assets.delete`, an upload whose code may run), every one applying.
|
|
20
|
+
*/
|
|
21
|
+
export function callGates(config, name, args) {
|
|
22
|
+
const gates = effectiveGates(config, name);
|
|
23
|
+
const family = familyOf(name);
|
|
24
|
+
const method = family === null ? null : methodOf(name, args);
|
|
25
|
+
const own = family === null || method === null ? [] : methodGates(config, family.name, method);
|
|
26
|
+
return own.length === 0 ? gates : [...gates, ...own.filter((gate) => !gates.includes(gate))];
|
|
27
|
+
}
|
|
15
28
|
const unique = (values) => [...new Set(values)];
|
|
16
29
|
/** The origins content may reach for `kind`: the base allowlist plus every declared capability's. */
|
|
17
30
|
export function egressOrigins(config, kind) {
|
|
@@ -76,6 +89,67 @@ export function frameCspDirectives(config) {
|
|
|
76
89
|
["webrtc", "'block'"],
|
|
77
90
|
];
|
|
78
91
|
}
|
|
92
|
+
/** The directives a page of a file set loads its own files under (P082): everything that loads. */
|
|
93
|
+
export const FILE_SET_DIRECTIVES = [
|
|
94
|
+
"script-src",
|
|
95
|
+
"style-src",
|
|
96
|
+
"font-src",
|
|
97
|
+
"img-src",
|
|
98
|
+
"media-src",
|
|
99
|
+
"connect-src",
|
|
100
|
+
"worker-src",
|
|
101
|
+
];
|
|
102
|
+
/**
|
|
103
|
+
* A served page's CSP when it comes with files (P082): the frame's, with its version's own files
|
|
104
|
+
* opened for each kind that loads (`FILE_SET_DIRECTIVES`), by `source`, the files' path on the
|
|
105
|
+
* content origin (`https://a-x.example-usercontent.com/v/3/`). Never `'self'`: the origin's other
|
|
106
|
+
* paths (other versions, Porthole's own) stay closed, and frames, plugins, forms and `<base>` stay
|
|
107
|
+
* `'none'`. Opaque frames have no files, and keep P022's rule whole.
|
|
108
|
+
*/
|
|
109
|
+
export function fileSetCspDirectives(directives, source) {
|
|
110
|
+
const opened = new Set(FILE_SET_DIRECTIVES);
|
|
111
|
+
return directives.map(([name, ...sources]) => {
|
|
112
|
+
if (!opened.has(name)) {
|
|
113
|
+
return [name, ...sources];
|
|
114
|
+
}
|
|
115
|
+
const kept = sources.filter((each) => each !== "'none'");
|
|
116
|
+
return [name, ...kept, source];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The directives a page opens its artifact's asset library to (P089), at `/_blob/` on its own
|
|
121
|
+
* origin: what loads without running, always; what runs (scripts, styles) only where uploads are
|
|
122
|
+
* the admins' alone, who publish the page's code anyway.
|
|
123
|
+
*/
|
|
124
|
+
export const ASSET_DIRECTIVES = ["img-src", "media-src", "font-src", "connect-src"];
|
|
125
|
+
export const ASSET_CODE_DIRECTIVES = ["script-src", "style-src"];
|
|
126
|
+
export { assetCodeRuns };
|
|
127
|
+
/**
|
|
128
|
+
* A served page's CSP with its asset library opened (P089), on `origin` (the page's own, exact:
|
|
129
|
+
* never a sibling's): only where the config declares `assets`. Never `'self'`.
|
|
130
|
+
*/
|
|
131
|
+
export function assetCspDirectives(config, directives, origin) {
|
|
132
|
+
if (config.capabilities.assets === undefined || config.isolation !== "domain") {
|
|
133
|
+
return [...directives];
|
|
134
|
+
}
|
|
135
|
+
const source = `${origin}${ASSET_PATH}`;
|
|
136
|
+
const opened = new Set([
|
|
137
|
+
...ASSET_DIRECTIVES,
|
|
138
|
+
...(assetCodeRuns(config) ? ASSET_CODE_DIRECTIVES : []),
|
|
139
|
+
]);
|
|
140
|
+
return directives.map(([name, ...sources]) => {
|
|
141
|
+
if (!opened.has(name)) {
|
|
142
|
+
return [name, ...sources];
|
|
143
|
+
}
|
|
144
|
+
const kept = sources.filter((each) => each !== "'none'");
|
|
145
|
+
return [name, ...kept, source];
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The CSP of a file of a set that is neither a page nor a script (P081): nothing loads from it,
|
|
150
|
+
* and opened as a document (an SVG, an XML file) it runs nothing, on an opaque origin.
|
|
151
|
+
*/
|
|
152
|
+
export const INERT_FILE_CSP = "default-src 'none'; sandbox";
|
|
79
153
|
export function serializeCsp(directives) {
|
|
80
154
|
return directives.map((directive) => directive.join(" ")).join("; ");
|
|
81
155
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { AnnotationReport } from "../annotate/types.ts";
|
|
2
|
+
import type { DbRequest, DbResult } from "../runtime/db.ts";
|
|
3
|
+
import type { ArtifactInfo, ArtifactRequest, AssetInfo, AssetRequest, CommentRequest, PublishedVersion, UserInfo } from "../runtime/requests.ts";
|
|
2
4
|
/**
|
|
3
5
|
* The capability vocabulary (PRINCIPLE 4): every power content has beyond drawing is one of these
|
|
4
6
|
* host functions, named in the config. A capability the config doesn't declare is not wired into
|
|
@@ -8,7 +10,7 @@ import type { AnnotationReport } from "../annotate/types.ts";
|
|
|
8
10
|
* are on by default), and is served either by a handler the host passes or as an event the
|
|
9
11
|
* framework emits.
|
|
10
12
|
*/
|
|
11
|
-
export declare const CAPABILITY_NAMES: readonly ["sendPrompt", "openLink", "downloadFile", "callTool", "readData", "subscribeData", "setModelContext", "reportError", "resize", "copyText", "annotate"];
|
|
13
|
+
export declare const CAPABILITY_NAMES: readonly ["sendPrompt", "openLink", "downloadFile", "callTool", "readData", "subscribeData", "setModelContext", "reportError", "resize", "copyText", "annotate", "user", "comments", "artifact", "assets", "db"];
|
|
12
14
|
export type CapabilityName = (typeof CAPABILITY_NAMES)[number];
|
|
13
15
|
/**
|
|
14
16
|
* What must hold before a call reaches the host's handler. A capability's gates all apply.
|
|
@@ -32,8 +34,11 @@ export type Gate = "user-activation" | "confirm" | "consent" | {
|
|
|
32
34
|
export interface CapabilitySpec {
|
|
33
35
|
/** The gates a declared capability gets when its config names none. */
|
|
34
36
|
readonly defaultGates: readonly Gate[];
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
+
/**
|
|
38
|
+
* `handler`: the host passes a function that performs it. `event`: the framework emits it.
|
|
39
|
+
* `viewer`: the framework answers it from the viewer the host gave the display (`user`).
|
|
40
|
+
*/
|
|
41
|
+
readonly served: "handler" | "event" | "viewer";
|
|
37
42
|
/** The global the shell defines for it (sugar over the protocol message), if any. */
|
|
38
43
|
readonly global?: string;
|
|
39
44
|
/**
|
|
@@ -142,6 +147,46 @@ export declare const CAPABILITIES: {
|
|
|
142
147
|
readonly defaultGates: readonly [Gate];
|
|
143
148
|
readonly served: "event";
|
|
144
149
|
};
|
|
150
|
+
/** Who is viewing (P087): answered from the viewer the host gave the display. */
|
|
151
|
+
readonly user: {
|
|
152
|
+
readonly defaultGates: readonly [Gate];
|
|
153
|
+
readonly served: "viewer";
|
|
154
|
+
readonly request: {
|
|
155
|
+
readonly method: "porthole/call";
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/** Opens the host's comment composer at the page's anchor (P090): write-only. */
|
|
159
|
+
readonly comments: {
|
|
160
|
+
readonly defaultGates: readonly ["user-activation", Gate];
|
|
161
|
+
readonly served: "handler";
|
|
162
|
+
readonly request: {
|
|
163
|
+
readonly method: "porthole/call";
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/** This artifact's current version, and a new version of it, base-checked (P088). */
|
|
167
|
+
readonly artifact: {
|
|
168
|
+
readonly defaultGates: readonly [Gate];
|
|
169
|
+
readonly served: "handler";
|
|
170
|
+
readonly request: {
|
|
171
|
+
readonly method: "porthole/call";
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
/** The artifact's asset library, served at `/_blob/<id>` (P089). */
|
|
175
|
+
readonly assets: {
|
|
176
|
+
readonly defaultGates: readonly [Gate];
|
|
177
|
+
readonly served: "handler";
|
|
178
|
+
readonly request: {
|
|
179
|
+
readonly method: "porthole/call";
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/** The artifact's shared document store (P088). */
|
|
183
|
+
readonly db: {
|
|
184
|
+
readonly defaultGates: readonly [Gate];
|
|
185
|
+
readonly served: "handler";
|
|
186
|
+
readonly request: {
|
|
187
|
+
readonly method: "porthole/call";
|
|
188
|
+
};
|
|
189
|
+
};
|
|
145
190
|
};
|
|
146
191
|
/** The arguments a call carries, once the adapter has validated them. */
|
|
147
192
|
export interface CapabilityArgs {
|
|
@@ -186,6 +231,12 @@ export interface CapabilityArgs {
|
|
|
186
231
|
};
|
|
187
232
|
/** What the frame reported, once checked (`AnnotationReport`). */
|
|
188
233
|
readonly annotate: AnnotationReport;
|
|
234
|
+
readonly user: Readonly<Record<string, never>>;
|
|
235
|
+
readonly comments: CommentRequest;
|
|
236
|
+
readonly artifact: ArtifactRequest;
|
|
237
|
+
readonly assets: AssetRequest;
|
|
238
|
+
/** Paths checked, `me` resolved, the viewer's own data only (P088). */
|
|
239
|
+
readonly db: DbRequest;
|
|
189
240
|
}
|
|
190
241
|
/** What a call resolves to. Protocol-shaped results (a tool's result) stay opaque to the core. */
|
|
191
242
|
export interface CapabilityResults {
|
|
@@ -205,6 +256,14 @@ export interface CapabilityResults {
|
|
|
205
256
|
/** Whether the text was copied. */
|
|
206
257
|
readonly copyText: boolean;
|
|
207
258
|
readonly annotate: undefined;
|
|
259
|
+
readonly user: UserInfo;
|
|
260
|
+
/** Whether the composer opened. Never a thread: content doesn't read comments (P090). */
|
|
261
|
+
readonly comments: boolean;
|
|
262
|
+
/** `get`: the current version; `publish`: the new one. */
|
|
263
|
+
readonly artifact: ArtifactInfo | PublishedVersion;
|
|
264
|
+
/** `list`: the library; `upload`: the new asset; `delete`: whether it was removed. */
|
|
265
|
+
readonly assets: AssetInfo | readonly AssetInfo[] | boolean;
|
|
266
|
+
readonly db: DbResult;
|
|
208
267
|
}
|
|
209
268
|
/** The capabilities a host serves with a handler. */
|
|
210
269
|
export type HandledCapability = {
|
|
@@ -19,6 +19,12 @@ export const CAPABILITY_NAMES = [
|
|
|
19
19
|
"resize",
|
|
20
20
|
"copyText",
|
|
21
21
|
"annotate",
|
|
22
|
+
// The capability runtime's own (P085, `config.runtime`): reached through `porthole.use`.
|
|
23
|
+
"user",
|
|
24
|
+
"comments",
|
|
25
|
+
"artifact",
|
|
26
|
+
"assets",
|
|
27
|
+
"db",
|
|
22
28
|
];
|
|
23
29
|
const rate = (perMinute) => ({ rateLimit: { perMinute } });
|
|
24
30
|
/** The most text one `copyText` call carries. */
|
|
@@ -86,6 +92,20 @@ export const CAPABILITIES = {
|
|
|
86
92
|
* (it shares the realm): UI hints for the host, never permissions.
|
|
87
93
|
*/
|
|
88
94
|
annotate: { defaultGates: [rate(120)], served: "event" },
|
|
95
|
+
/** Who is viewing (P087): answered from the viewer the host gave the display. */
|
|
96
|
+
user: { defaultGates: [rate(60)], served: "viewer", request: { method: "porthole/call" } },
|
|
97
|
+
/** Opens the host's comment composer at the page's anchor (P090): write-only. */
|
|
98
|
+
comments: {
|
|
99
|
+
defaultGates: ["user-activation", rate(30)],
|
|
100
|
+
served: "handler",
|
|
101
|
+
request: { method: "porthole/call" },
|
|
102
|
+
},
|
|
103
|
+
/** This artifact's current version, and a new version of it, base-checked (P088). */
|
|
104
|
+
artifact: { defaultGates: [rate(10)], served: "handler", request: { method: "porthole/call" } },
|
|
105
|
+
/** The artifact's asset library, served at `/_blob/<id>` (P089). */
|
|
106
|
+
assets: { defaultGates: [rate(30)], served: "handler", request: { method: "porthole/call" } },
|
|
107
|
+
/** The artifact's shared document store (P088). */
|
|
108
|
+
db: { defaultGates: [rate(600)], served: "handler", request: { method: "porthole/call" } },
|
|
89
109
|
};
|
|
90
110
|
/** A capability's spec, as the general shape (the table above keeps literal types). */
|
|
91
111
|
export function capabilitySpec(name) {
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { RuntimeVersion } from "../runtime/contract.ts";
|
|
2
|
+
import type { ViewerLevel } from "../runtime/levels.ts";
|
|
1
3
|
import type { CapabilityName, Gate } from "./capabilities.ts";
|
|
2
4
|
/**
|
|
3
5
|
* One config per kind of display (PRINCIPLE 3). The compiler derives the frame's CSP, its sandbox
|
|
@@ -41,6 +43,20 @@ export interface CapabilityConfig {
|
|
|
41
43
|
readonly resource?: readonly string[];
|
|
42
44
|
/** Replaces the generated manual entry for this capability. */
|
|
43
45
|
readonly guide?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The least viewer level that may call each of the runtime methods it serves (P087), by method
|
|
48
|
+
* name (`db: { levels: { set: "admin" } }`, `sendPrompt: { levels: { send: "admin" } }`): over
|
|
49
|
+
* the contract's own, never below a method's floor (`RUNTIME_CAPABILITIES`). For
|
|
50
|
+
* `assets.upload`, `admin` or above also lets the page run what was uploaded as scripts and
|
|
51
|
+
* styles (P089); `interact` doesn't.
|
|
52
|
+
*/
|
|
53
|
+
readonly levels?: Readonly<Record<string, ViewerLevel>>;
|
|
54
|
+
/**
|
|
55
|
+
* Gates of each runtime method it serves, by name, in place of the contract's own (after the
|
|
56
|
+
* review: `artifact.publish` and `assets.delete` need a click and a yes; `assets.upload` a yes
|
|
57
|
+
* where uploaded code may run). Every one applies on top of `gates`. `[]`: none of its own.
|
|
58
|
+
*/
|
|
59
|
+
readonly methodGates?: Readonly<Record<string, readonly Gate[]>>;
|
|
44
60
|
}
|
|
45
61
|
/** The declared capabilities. Absent: not available, not wired, not in the CSP, not in the manual. */
|
|
46
62
|
export type CapabilityMap = {
|
|
@@ -113,6 +129,14 @@ export interface Limits {
|
|
|
113
129
|
* when absent.
|
|
114
130
|
*/
|
|
115
131
|
readonly loadTimeoutMs?: number;
|
|
132
|
+
/**
|
|
133
|
+
* A served page's files (P081): the most a version holds (default 1000), the largest one,
|
|
134
|
+
* bytes (default 25 MiB), and all of them together, bytes (default 100 MiB: a host sets its
|
|
135
|
+
* own). The manual states them; `checkFileSet` and `lintFiles` hold a version to them.
|
|
136
|
+
*/
|
|
137
|
+
readonly maxFiles?: number;
|
|
138
|
+
readonly maxFileBytes?: number;
|
|
139
|
+
readonly maxVersionBytes?: number;
|
|
116
140
|
}
|
|
117
141
|
/**
|
|
118
142
|
* Sandbox tokens a url-mode frame may add to its baseline, by the host's choice (P037): a
|
|
@@ -195,6 +219,14 @@ export interface PortholeConfig {
|
|
|
195
219
|
* declares no `reportError`). Absent: the manual says they are reported to the app.
|
|
196
220
|
*/
|
|
197
221
|
readonly errors?: "agent" | "host" | "none";
|
|
222
|
+
/**
|
|
223
|
+
* The capability runtime (P085): content reaches capabilities through one global,
|
|
224
|
+
* `porthole.use(name)`, under this contract version, and the manual teaches it (with declaring
|
|
225
|
+
* them, `capabilities: { name: config }`, for pages that are published). Only with it may the
|
|
226
|
+
* config declare the runtime's own host functions (`user`, `comments`, `artifact`, `assets`,
|
|
227
|
+
* `db`). Absent: 0.6's frames, globals and manual, exactly.
|
|
228
|
+
*/
|
|
229
|
+
readonly runtime?: RuntimeVersion;
|
|
198
230
|
}
|
|
199
231
|
export interface StorageConfig {
|
|
200
232
|
/**
|
|
@@ -10,7 +10,7 @@ export declare class ConfigError extends Error {
|
|
|
10
10
|
constructor(path: string, message: string);
|
|
11
11
|
}
|
|
12
12
|
/** The built-in manual topics; a host's own topics may not reuse these names. */
|
|
13
|
-
export declare const BUILT_IN_TOPICS: readonly ["widget", "chart", "interactive"];
|
|
13
|
+
export declare const BUILT_IN_TOPICS: readonly ["widget", "chart", "interactive", "capabilities"];
|
|
14
14
|
/**
|
|
15
15
|
* Whether `value` is a CSP host source Porthole accepts: a scheme, a host (optionally `*.` for
|
|
16
16
|
* every subdomain) and an optional port, nothing else. Insecure schemes only for loopback names.
|
package/dist/config/validate.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { CAPABILITY_NAMES, isCapabilityName } from "./capabilities.js";
|
|
1
|
+
import { CAPABILITY_NAMES, isCapabilityName, } from "./capabilities.js";
|
|
2
|
+
import { RUNTIME_HOST_FUNCTIONS, RUNTIME_VERSIONS, familyOf, isRuntimeVersion, runtimeCapability, } from "../runtime/contract.js";
|
|
3
|
+
import { atLeast, isViewerLevel } from "../runtime/levels.js";
|
|
2
4
|
import { PASSIVE_KINDS, URL_PERMISSIONS, URL_SANDBOX_EXTRAS, } from "./schema.js";
|
|
3
5
|
/**
|
|
4
6
|
* Checks a config before anything is derived from it. Every string that ends up in a CSP, an
|
|
@@ -15,7 +17,7 @@ export class ConfigError extends Error {
|
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
/** The built-in manual topics; a host's own topics may not reuse these names. */
|
|
18
|
-
export const BUILT_IN_TOPICS = ["widget", "chart", "interactive"];
|
|
20
|
+
export const BUILT_IN_TOPICS = ["widget", "chart", "interactive", "capabilities"];
|
|
19
21
|
const LOOPBACK = /^(localhost|127\.0\.0\.1|\[::1\])$|\.localhost$/u;
|
|
20
22
|
/**
|
|
21
23
|
* Suffixes under which anyone can register or publish a name (a public suffix): a wildcard over
|
|
@@ -260,6 +262,7 @@ export function validateConfig(input) {
|
|
|
260
262
|
"permissions",
|
|
261
263
|
"storage",
|
|
262
264
|
"errors",
|
|
265
|
+
"runtime",
|
|
263
266
|
], "config");
|
|
264
267
|
if (!MODES.includes(config.mode)) {
|
|
265
268
|
fail("config.mode", `must be one of ${MODES.join(", ")}`);
|
|
@@ -277,7 +280,41 @@ export function validateConfig(input) {
|
|
|
277
280
|
fail(path, `is not a capability (${CAPABILITY_NAMES.join(", ")})`);
|
|
278
281
|
}
|
|
279
282
|
const capability = object(value, path);
|
|
280
|
-
only(capability, ["gates", "connect", "resource", "guide"], path);
|
|
283
|
+
only(capability, ["gates", "connect", "resource", "guide", "levels", "methodGates"], path);
|
|
284
|
+
if (capability.methodGates !== undefined) {
|
|
285
|
+
const family = familyOf(name);
|
|
286
|
+
for (const [method, gates] of Object.entries(object(capability.methodGates, `${path}.methodGates`))) {
|
|
287
|
+
const methods = family === null ? undefined : runtimeCapability(family.name).methods;
|
|
288
|
+
if (methods === undefined ||
|
|
289
|
+
!Object.hasOwn(methods, method) ||
|
|
290
|
+
methods[method]?.serves !== name) {
|
|
291
|
+
fail(`${path}.methodGates.${method}`, `is not a runtime method ${name} serves`);
|
|
292
|
+
}
|
|
293
|
+
if (!Array.isArray(gates)) {
|
|
294
|
+
fail(`${path}.methodGates.${method}`, "must be an array of gates");
|
|
295
|
+
}
|
|
296
|
+
gates.forEach((each, index) => gate(each, `${path}.methodGates.${method}[${index}]`));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (capability.levels !== undefined) {
|
|
300
|
+
const levels = object(capability.levels, `${path}.levels`);
|
|
301
|
+
const family = familyOf(name);
|
|
302
|
+
for (const [method, level] of Object.entries(levels)) {
|
|
303
|
+
const methods = family === null ? undefined : runtimeCapability(family.name).methods;
|
|
304
|
+
const spec = methods !== undefined && Object.hasOwn(methods, method) ? methods[method] : undefined;
|
|
305
|
+
if (family === null || spec === undefined || spec.serves !== name) {
|
|
306
|
+
fail(`${path}.levels.${method}`, family === null
|
|
307
|
+
? `${name} serves no runtime method: it has no levels`
|
|
308
|
+
: `is not a method ${name} serves (${family.methods.join(", ")})`);
|
|
309
|
+
}
|
|
310
|
+
if (!isViewerLevel(level)) {
|
|
311
|
+
fail(`${path}.levels.${method}`, "must be view, interact, admin or owner");
|
|
312
|
+
}
|
|
313
|
+
if (spec !== undefined && !atLeast(level, spec.floor)) {
|
|
314
|
+
fail(`${path}.levels.${method}`, `can't be below ${spec.floor} (${family?.name}.${method}'s floor, P087)`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
281
318
|
if (capability.gates !== undefined) {
|
|
282
319
|
if (!Array.isArray(capability.gates)) {
|
|
283
320
|
fail(`${path}.gates`, "must be an array");
|
|
@@ -293,6 +330,29 @@ export function validateConfig(input) {
|
|
|
293
330
|
if (config.mode === "url" && Object.keys(capabilities).length > 0) {
|
|
294
331
|
fail("config.capabilities", "url mode has no shell, so it can declare no capabilities");
|
|
295
332
|
}
|
|
333
|
+
// The capability runtime (P085): its global and its own host functions.
|
|
334
|
+
if (config.runtime !== undefined) {
|
|
335
|
+
if (!isRuntimeVersion(config.runtime)) {
|
|
336
|
+
fail("config.runtime", `must be a runtime contract version: ${RUNTIME_VERSIONS.join(", ")}`);
|
|
337
|
+
}
|
|
338
|
+
if (config.mode !== "inline" && config.mode !== "artifact") {
|
|
339
|
+
fail("config.runtime", "the runtime is the shell's: inline widgets and artifact pages only");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
for (const name of RUNTIME_HOST_FUNCTIONS) {
|
|
343
|
+
if (capabilities[name] === undefined) {
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (config.runtime === undefined) {
|
|
347
|
+
fail(`config.capabilities.${name}`, "is the capability runtime's: set config.runtime (content reaches it through porthole.use)");
|
|
348
|
+
}
|
|
349
|
+
if ((name === "artifact" || name === "assets") && config.mode !== "artifact") {
|
|
350
|
+
fail(`config.capabilities.${name}`, "is an artifact page's: artifact mode only");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (capabilities.assets !== undefined && config.isolation !== "domain") {
|
|
354
|
+
fail("config.capabilities.assets", "assets are served from the page's own origin (/_blob/): domain isolation only");
|
|
355
|
+
}
|
|
296
356
|
const egress = object(config.egress, "config.egress");
|
|
297
357
|
const kinds = ["connect", "script", "style", "img", "font", "media"];
|
|
298
358
|
only(egress, [...kinds, "anyHttps", "libraries"], "config.egress");
|
|
@@ -366,13 +426,20 @@ export function validateConfig(input) {
|
|
|
366
426
|
"maxPromptChars",
|
|
367
427
|
"maxErrorReports",
|
|
368
428
|
];
|
|
369
|
-
|
|
429
|
+
const fileLimitNames = ["maxFiles", "maxFileBytes", "maxVersionBytes"];
|
|
430
|
+
only(limits, [...limitNames, "loadTimeoutMs", ...fileLimitNames], "config.limits");
|
|
370
431
|
for (const name of limitNames) {
|
|
371
432
|
positive(limits[name], `config.limits.${name}`);
|
|
372
433
|
}
|
|
373
434
|
if (limits.loadTimeoutMs !== undefined) {
|
|
374
435
|
positive(limits.loadTimeoutMs, "config.limits.loadTimeoutMs", 600_000);
|
|
375
436
|
}
|
|
437
|
+
// A served page's files (P081): optional, with fileLimits' defaults.
|
|
438
|
+
for (const name of fileLimitNames) {
|
|
439
|
+
if (limits[name] !== undefined) {
|
|
440
|
+
positive(limits[name], `config.limits.${name}`);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
376
443
|
if (limits.minHeightPx > limits.maxHeightPx) {
|
|
377
444
|
fail("config.limits.minHeightPx", "must not exceed maxHeightPx");
|
|
378
445
|
}
|
|
@@ -401,7 +468,9 @@ export function validateConfig(input) {
|
|
|
401
468
|
for (const [name, text] of Object.entries(object(guide.topics, "config.guide.topics"))) {
|
|
402
469
|
const path = `config.guide.topics.${name}`;
|
|
403
470
|
if (!/^[a-z][a-z0-9-]{0,31}$/u.test(name) ||
|
|
404
|
-
|
|
471
|
+
// `capabilities` is built in only under the runtime (P085): a 0.6 config's own stays.
|
|
472
|
+
(BUILT_IN_TOPICS.includes(name) &&
|
|
473
|
+
(name !== "capabilities" || config.runtime !== undefined))) {
|
|
405
474
|
fail(path, "must be a new topic name (lowercase), not a built-in one");
|
|
406
475
|
}
|
|
407
476
|
if (typeof text !== "string" || text.trim() === "") {
|