@botiverse/porthole 0.7.0 → 0.9.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 +9 -2
- package/THIRD_PARTY_NOTICES.md +421 -0
- package/dist/annotate/types.d.ts +40 -4
- package/dist/annotate/types.js +6 -1
- package/dist/annotate/validate.d.ts +10 -0
- package/dist/annotate/validate.js +24 -1
- package/dist/bridge/bounded-text.d.ts +34 -0
- package/dist/bridge/bounded-text.js +188 -0
- package/dist/bridge/bridge.d.ts +25 -5
- package/dist/bridge/bridge.js +311 -73
- package/dist/bridge/json-data.d.ts +28 -0
- package/dist/bridge/json-data.js +86 -0
- package/dist/bridge/navigation.d.ts +5 -0
- package/dist/bridge/navigation.js +7 -0
- package/dist/bridge/refusal.js +1 -0
- package/dist/bridge/types.d.ts +32 -1
- package/dist/check/page-source.js +1 -1
- package/dist/check/page.js +2 -0
- package/dist/compile/compile.d.ts +6 -0
- package/dist/compile/compile.js +3 -1
- package/dist/compile/policy.d.ts +38 -2
- package/dist/compile/policy.js +122 -7
- package/dist/config/capabilities.d.ts +23 -4
- package/dist/config/capabilities.js +12 -2
- package/dist/config/schema.d.ts +11 -0
- package/dist/config/validate.d.ts +8 -2
- package/dist/config/validate.js +28 -6
- package/dist/config/warnings.d.ts +20 -0
- package/dist/config/warnings.js +25 -0
- package/dist/conformance/behavior.js +46 -1
- package/dist/conformance/cookies.d.ts +15 -0
- package/dist/conformance/cookies.js +80 -0
- package/dist/conformance/harness/page.d.ts +1 -0
- package/dist/conformance/harness/page.js +9 -2
- package/dist/conformance/harness-source.js +1 -1
- package/dist/conformance/host-kit.js +5 -1
- package/dist/conformance/index.d.ts +10 -0
- package/dist/conformance/limits.js +38 -1
- package/dist/conformance/runtime.js +10 -0
- package/dist/conformance/served.d.ts +2 -0
- package/dist/conformance/served.js +737 -4
- package/dist/files/paths.js +4 -0
- package/dist/guide/gates.d.ts +7 -1
- package/dist/guide/gates.js +12 -0
- package/dist/guide/guide.js +2 -2
- package/dist/guide/runtime.js +11 -3
- package/dist/host/create-host.js +81 -39
- package/dist/host/pages-of-set.d.ts +43 -0
- package/dist/host/pages-of-set.js +196 -0
- package/dist/host/types.d.ts +8 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -2
- package/dist/mcp/adapter.js +11 -15
- package/dist/node/index.d.ts +36 -4
- package/dist/node/index.js +402 -101
- package/dist/platform/types.d.ts +9 -0
- package/dist/platform/web.js +8 -0
- package/dist/presets/presets.d.ts +16 -8
- package/dist/presets/presets.js +39 -8
- package/dist/protocol/live-data.d.ts +6 -2
- package/dist/protocol/live-data.js +20 -1
- package/dist/protocol/mcp-apps.d.ts +13 -2
- package/dist/protocol/mcp-apps.js +10 -2
- package/dist/protocol/message-text.d.ts +8 -0
- package/dist/protocol/message-text.js +29 -0
- package/dist/protocol/runtime-calls.js +3 -0
- package/dist/protocol/shell-adapter.js +16 -22
- package/dist/react/context-notice.d.ts +32 -0
- package/dist/react/context-notice.js +28 -0
- package/dist/react/dialog.js +62 -18
- package/dist/react/frame.d.ts +18 -3
- package/dist/react/frame.js +79 -2
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/runtime/contract.d.ts +9 -1
- package/dist/runtime/contract.js +31 -2
- package/dist/runtime/db.d.ts +41 -6
- package/dist/runtime/db.js +120 -16
- package/dist/runtime/declaration.d.ts +15 -1
- package/dist/runtime/declaration.js +184 -87
- package/dist/runtime/requests.js +27 -11
- package/dist/runtime/types.generated.js +1 -1
- package/dist/server/files.d.ts +5 -0
- package/dist/server/files.js +22 -7
- package/dist/server/host.d.ts +18 -1
- package/dist/server/host.js +132 -2
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/peer.d.ts +4 -0
- package/dist/server/peer.js +19 -0
- package/dist/server/proxy.d.ts +6 -0
- package/dist/server/proxy.js +12 -3
- package/dist/server/server.js +113 -26
- package/dist/server/types.d.ts +6 -3
- package/dist/shell/annotate.d.ts +7 -2
- package/dist/shell/annotate.js +233 -15
- package/dist/shell/document.d.ts +8 -0
- package/dist/shell/document.js +3 -0
- package/dist/shell/runtime.js +361 -14
- package/docs/ADOPTING.md +119 -14
- package/docs/ARCHITECTURE.md +15 -4
- package/docs/DECISIONS.md +1610 -9
- package/docs/DESIGN.md +114 -30
- package/docs/THREAT_MODEL.md +652 -0
- package/package.json +14 -3
- package/src/annotate/types.ts +37 -5
- package/src/annotate/validate.ts +30 -1
- package/src/bridge/bounded-text.ts +240 -0
- package/src/bridge/bridge.ts +373 -84
- package/src/bridge/json-data.ts +95 -0
- package/src/bridge/navigation.ts +10 -0
- package/src/bridge/refusal.ts +1 -0
- package/src/bridge/types.ts +30 -1
- package/src/check/page.ts +2 -0
- package/src/compile/compile.ts +9 -1
- package/src/compile/policy.ts +130 -7
- package/src/config/capabilities.ts +22 -3
- package/src/config/schema.ts +11 -0
- package/src/config/validate.ts +43 -5
- package/src/config/warnings.ts +42 -0
- package/src/conformance/behavior.ts +54 -1
- package/src/conformance/cookies.ts +93 -0
- package/src/conformance/harness/page.ts +11 -2
- package/src/conformance/host-kit.ts +10 -1
- package/src/conformance/index.ts +10 -0
- package/src/conformance/limits.ts +39 -1
- package/src/conformance/runtime.ts +21 -0
- package/src/conformance/served.ts +888 -4
- package/src/files/paths.ts +4 -0
- package/src/guide/gates.ts +13 -1
- package/src/guide/guide.ts +3 -3
- package/src/guide/runtime.ts +12 -3
- package/src/host/create-host.ts +88 -38
- package/src/host/pages-of-set.ts +226 -0
- package/src/host/types.ts +15 -1
- package/src/index.ts +5 -0
- package/src/mcp/adapter.ts +16 -20
- package/src/node/index.ts +507 -116
- package/src/platform/types.ts +6 -0
- package/src/platform/web.ts +10 -0
- package/src/presets/presets.ts +60 -17
- package/src/protocol/live-data.ts +31 -3
- package/src/protocol/mcp-apps.ts +11 -2
- package/src/protocol/message-text.ts +36 -0
- package/src/protocol/runtime-calls.ts +3 -0
- package/src/protocol/shell-adapter.ts +27 -23
- package/src/react/context-notice.tsx +95 -0
- package/src/react/dialog.tsx +77 -17
- package/src/react/frame.tsx +107 -2
- package/src/react/index.ts +8 -1
- package/src/runtime/contract.ts +36 -2
- package/src/runtime/db.ts +140 -20
- package/src/runtime/declaration.ts +227 -89
- package/src/runtime/requests.ts +27 -11
- package/src/runtime/types.generated.ts +1 -1
- package/src/server/files.ts +29 -11
- package/src/server/host.ts +158 -3
- package/src/server/index.ts +1 -0
- package/src/server/peer.ts +21 -0
- package/src/server/proxy.ts +13 -3
- package/src/server/server.ts +139 -36
- package/src/server/types.ts +6 -3
- package/src/shell/annotate.ts +233 -15
- package/src/shell/document.ts +8 -0
- package/src/shell/runtime.ts +361 -14
- package/types/runtime/v1/context.d.ts +13 -2
|
@@ -2,7 +2,7 @@ import { expect, type Frame } from "@playwright/test";
|
|
|
2
2
|
import { presets } from "../presets/presets.ts";
|
|
3
3
|
import { resolveTheme } from "../theme/variables.ts";
|
|
4
4
|
import type { LaunchedDisplay } from "./index.ts";
|
|
5
|
-
import { inline, type Probe, type ProbeContext } from "./kit.ts";
|
|
5
|
+
import { inline, js, type Probe, type ProbeContext } from "./kit.ts";
|
|
6
6
|
import { settle } from "./oracles.ts";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -73,6 +73,21 @@ async function bodyData(display: LaunchedDisplay, name: string, timeout = 5_000)
|
|
|
73
73
|
return (await frame.locator("body").getAttribute(`data-${name}`)) ?? "";
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/** A model context update (P100): what the view says the person is looking at. */
|
|
77
|
+
const CONTEXT_UPDATE = {
|
|
78
|
+
content: [{ type: "text", text: "The person is looking at March's signups." }],
|
|
79
|
+
structuredContent: { month: "March", signups: 412 },
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** Content that sends it as the App SDK does (`ui/update-model-context`), and keeps the answer. */
|
|
83
|
+
const CONTEXT_CONTENT = `<p>signups</p>
|
|
84
|
+
<script>
|
|
85
|
+
addEventListener("message", (event) => {
|
|
86
|
+
if (event.data && event.data.id === "ctx-1") document.body.dataset.answer = JSON.stringify(event.data.error ? event.data.error.data : event.data.result);
|
|
87
|
+
});
|
|
88
|
+
parent.postMessage({ jsonrpc: "2.0", id: "ctx-1", method: "ui/update-model-context", params: ${js(CONTEXT_UPDATE)} }, "*");
|
|
89
|
+
</script>`;
|
|
90
|
+
|
|
76
91
|
const PROMPT_CONTENT = `<button id="ask">Explain March</button>
|
|
77
92
|
<script>
|
|
78
93
|
document.getElementById("ask").addEventListener("click", () => {
|
|
@@ -501,4 +516,42 @@ export const BEHAVIOR_PROBES: readonly Probe[] = [
|
|
|
501
516
|
expect(await display.calls()).toEqual([]);
|
|
502
517
|
},
|
|
503
518
|
},
|
|
519
|
+
{
|
|
520
|
+
id: "12.model-context",
|
|
521
|
+
item: 12,
|
|
522
|
+
title:
|
|
523
|
+
"what content tells the model, the person is shown first, whole; a host that can't show it gets none (S5, P100)",
|
|
524
|
+
async run(context) {
|
|
525
|
+
const config = inline({ capabilities: { setModelContext: {} } });
|
|
526
|
+
const display = await context.launch({ config, content: CONTEXT_CONTENT });
|
|
527
|
+
const said = display.shown?.bind(display);
|
|
528
|
+
if (said === undefined) {
|
|
529
|
+
return context.inapplicable(
|
|
530
|
+
"this host's harness doesn't say what it shows the person (LaunchedDisplay.shown)",
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
expect(await bodyData(display, "answer")).toBe("{}");
|
|
534
|
+
const shown = await said();
|
|
535
|
+
expect(shown, "the update reached the model unseen").toHaveLength(1);
|
|
536
|
+
expect(shown[0]).toMatchObject({
|
|
537
|
+
capability: "setModelContext",
|
|
538
|
+
args: CONTEXT_UPDATE,
|
|
539
|
+
display: { title: "Probe" },
|
|
540
|
+
});
|
|
541
|
+
expect(await display.calls()).toEqual([
|
|
542
|
+
{ capability: "setModelContext", args: CONTEXT_UPDATE },
|
|
543
|
+
]);
|
|
544
|
+
|
|
545
|
+
const unseen = await context.launch({ config, shows: false, content: CONTEXT_CONTENT });
|
|
546
|
+
const answer = JSON.parse(await bodyData(unseen, "answer")) as { code?: string };
|
|
547
|
+
if (answer.code === undefined && ((await unseen.shown?.()) ?? []).length > 0) {
|
|
548
|
+
return context.inapplicable(
|
|
549
|
+
"this host always has a show function (a default surface), so a display without one can't be shown; it showed the person instead",
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
expect(answer.code, "an update nobody could see was taken").toBe("not_allowed");
|
|
553
|
+
expect(await refusals(unseen)).toContain("setModelContext:no-show");
|
|
554
|
+
expect(await unseen.calls()).toEqual([]);
|
|
555
|
+
},
|
|
556
|
+
},
|
|
504
557
|
];
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Browser, BrowserContext, Page } from "@playwright/test";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether this browser keeps a cookie a cross-site frame's own document was answered with
|
|
5
|
+
* (P025, P098): what a framed url-mode app needs, since its every request rides on the cookie its
|
|
6
|
+
* ticket's answer set. Measured, never assumed from the engine's name: Playwright's WebKit keeps
|
|
7
|
+
* none on Linux and keeps them on macOS (the audit of 2026-10-19), and an engine's policy changes
|
|
8
|
+
* between versions.
|
|
9
|
+
*
|
|
10
|
+
* The probe is the browser's own, outside the host under test: in a context of its own, a page on
|
|
11
|
+
* one site frames a page on another (both answered by the probe's routes, never the network,
|
|
12
|
+
* never the host's server), whose answer sets a cookie as Porthole's server sets a framed one
|
|
13
|
+
* (`Secure; SameSite=None; Partitioned`, over the display's own scheme); the frame then reads
|
|
14
|
+
* whether it was kept. Asked once per browser.
|
|
15
|
+
*/
|
|
16
|
+
export function keepsFramedCookies(page: Page, scheme: "http:" | "https:"): Promise<boolean> {
|
|
17
|
+
const browser = page.context().browser();
|
|
18
|
+
const key = `${scheme} ${browser === null ? "persistent" : browser.version()}`;
|
|
19
|
+
const known = cache(browser ?? page.context());
|
|
20
|
+
let answer = known.get(key);
|
|
21
|
+
if (answer === undefined) {
|
|
22
|
+
answer = probe(browser, page.context(), scheme);
|
|
23
|
+
known.set(key, answer);
|
|
24
|
+
}
|
|
25
|
+
return answer;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const answers = new WeakMap<Browser | BrowserContext, Map<string, Promise<boolean>>>();
|
|
29
|
+
|
|
30
|
+
function cache(owner: Browser | BrowserContext): Map<string, Promise<boolean>> {
|
|
31
|
+
let known = answers.get(owner);
|
|
32
|
+
if (known === undefined) {
|
|
33
|
+
known = new Map();
|
|
34
|
+
answers.set(owner, known);
|
|
35
|
+
}
|
|
36
|
+
return known;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Two sites the probe makes up: the embedding page's, and the frame's. */
|
|
40
|
+
function sites(scheme: "http:" | "https:"): { top: string; framed: string } {
|
|
41
|
+
// Over http, as a loopback host and its content origins are (a `*.localhost` frame on a
|
|
42
|
+
// `127.0.0.1` page, the leak suite's own shape); over https, two names that are each a site.
|
|
43
|
+
// Default ports: a browser refuses to navigate to some others (9 is on Fetch's bad-port list).
|
|
44
|
+
return scheme === "http:"
|
|
45
|
+
? {
|
|
46
|
+
top: "http://127.0.0.1/__porthole-cookie-probe/",
|
|
47
|
+
framed: "http://porthole-cookie-probe.localhost/",
|
|
48
|
+
}
|
|
49
|
+
: {
|
|
50
|
+
top: "https://porthole-cookie-probe-top.test/",
|
|
51
|
+
framed: "https://porthole-cookie-probe-frame.test/",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function probe(
|
|
56
|
+
browser: Browser | null,
|
|
57
|
+
context: BrowserContext,
|
|
58
|
+
scheme: "http:" | "https:",
|
|
59
|
+
): Promise<boolean> {
|
|
60
|
+
const own = browser === null ? null : await browser.newContext();
|
|
61
|
+
const page = await (own ?? context).newPage();
|
|
62
|
+
try {
|
|
63
|
+
const { top, framed } = sites(scheme);
|
|
64
|
+
await page.route(`${framed}**`, (route) =>
|
|
65
|
+
route.fulfill({
|
|
66
|
+
status: 200,
|
|
67
|
+
headers: {
|
|
68
|
+
"content-type": "text/html; charset=utf-8",
|
|
69
|
+
"cache-control": "no-store",
|
|
70
|
+
"set-cookie": "porthole-cookie-probe=1; Path=/; Secure; SameSite=None; Partitioned",
|
|
71
|
+
},
|
|
72
|
+
body: "<!doctype html><title>probe</title>",
|
|
73
|
+
}),
|
|
74
|
+
);
|
|
75
|
+
await page.route(top, (route) =>
|
|
76
|
+
route.fulfill({
|
|
77
|
+
status: 200,
|
|
78
|
+
headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" },
|
|
79
|
+
body: `<!doctype html><title>probe</title><iframe src="${framed}frame"></iframe>`,
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
await page.goto(top);
|
|
83
|
+
const frame = await (await page.locator("iframe").elementHandle())?.contentFrame();
|
|
84
|
+
if (frame === null || frame === undefined) {
|
|
85
|
+
throw new Error("keepsFramedCookies: the probe's frame didn't load");
|
|
86
|
+
}
|
|
87
|
+
await frame.waitForLoadState("load");
|
|
88
|
+
return await frame.evaluate(() => document.cookie.includes("porthole-cookie-probe=1"));
|
|
89
|
+
} finally {
|
|
90
|
+
await page.close();
|
|
91
|
+
await own?.close();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -19,6 +19,8 @@ interface Shown {
|
|
|
19
19
|
readonly calls: RecordedCall[];
|
|
20
20
|
readonly events: RecordedEvent[];
|
|
21
21
|
readonly confirmations: { request: ConfirmRequest; resolve: (accepted: boolean) => void }[];
|
|
22
|
+
/** What the host put in front of the person (`show`, P100). */
|
|
23
|
+
readonly disclosed: ConfirmRequest[];
|
|
22
24
|
readonly received: unknown[];
|
|
23
25
|
origin: string | null;
|
|
24
26
|
/** Why the instance couldn't be located (the issue endpoint's refusal). */
|
|
@@ -114,6 +116,7 @@ const harness = {
|
|
|
114
116
|
const container = box(id, spec.widthPx ?? 600, spec.heightPx);
|
|
115
117
|
const calls: RecordedCall[] = [];
|
|
116
118
|
const confirmations: Shown["confirmations"] = [];
|
|
119
|
+
const disclosed: ConfirmRequest[] = [];
|
|
117
120
|
const host = createHost(spec.config, {
|
|
118
121
|
handlers: recorder(calls),
|
|
119
122
|
...(spec.confirms === false
|
|
@@ -122,6 +125,9 @@ const harness = {
|
|
|
122
125
|
confirm: (request: ConfirmRequest) =>
|
|
123
126
|
new Promise<boolean>((resolve) => confirmations.push({ request, resolve })),
|
|
124
127
|
}),
|
|
128
|
+
...(spec.shows === false
|
|
129
|
+
? {}
|
|
130
|
+
: { show: (request: ConfirmRequest) => void disclosed.push(request) }),
|
|
125
131
|
theme: (scheme) => spec.hostTheme?.[scheme] ?? {},
|
|
126
132
|
hostInfo: { name: "porthole-conformance", version: "1" },
|
|
127
133
|
...(nonce === undefined ? {} : { nonce }),
|
|
@@ -132,18 +138,19 @@ const harness = {
|
|
|
132
138
|
scheme: spec.scheme ?? "light",
|
|
133
139
|
...(spec.document === undefined ? {} : { document: spec.document }),
|
|
134
140
|
});
|
|
135
|
-
const
|
|
141
|
+
const display: Shown = {
|
|
136
142
|
handle,
|
|
137
143
|
calls,
|
|
138
144
|
events: [],
|
|
139
145
|
confirmations,
|
|
146
|
+
disclosed,
|
|
140
147
|
received: [],
|
|
141
148
|
origin: null,
|
|
142
149
|
failure: null,
|
|
143
150
|
frame: null,
|
|
144
151
|
};
|
|
145
152
|
const initialized = new Promise<void>((resolve) => handle.on("initialized", () => resolve()));
|
|
146
|
-
watch(id,
|
|
153
|
+
watch(id, display);
|
|
147
154
|
if (spec.document === undefined) {
|
|
148
155
|
await Promise.race([initialized, pause(5_000)]);
|
|
149
156
|
for (const partial of spec.partials ?? []) {
|
|
@@ -178,6 +185,7 @@ const harness = {
|
|
|
178
185
|
calls,
|
|
179
186
|
events: [],
|
|
180
187
|
confirmations: [],
|
|
188
|
+
disclosed: [],
|
|
181
189
|
received: [],
|
|
182
190
|
origin: null,
|
|
183
191
|
failure: null,
|
|
@@ -240,6 +248,7 @@ const harness = {
|
|
|
240
248
|
displays.get(id)?.handle.setContent(html, { partial });
|
|
241
249
|
},
|
|
242
250
|
calls: (id: number) => displays.get(id)?.calls ?? [],
|
|
251
|
+
shown: (id: number) => displays.get(id)?.disclosed ?? [],
|
|
243
252
|
events: (id: number) => displays.get(id)?.events ?? [],
|
|
244
253
|
errors: (id: number) =>
|
|
245
254
|
(displays.get(id)?.events ?? []).flatMap((event) =>
|
|
@@ -11,7 +11,12 @@ import type { ConformanceHarness } from "./harness/page.ts";
|
|
|
11
11
|
import type { FrameOutcome } from "../host/types.ts";
|
|
12
12
|
import type { ConformanceHost, LaunchedDisplay, LaunchSpec } from "./index.ts";
|
|
13
13
|
import { leakTests, type ConformanceFixtures, type ConformanceTest } from "./probes.ts";
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
servedTests,
|
|
16
|
+
TAB_CASES,
|
|
17
|
+
type ServedConformanceHost,
|
|
18
|
+
type ServedDisplay,
|
|
19
|
+
} from "./served.ts";
|
|
15
20
|
|
|
16
21
|
/**
|
|
17
22
|
* The conformance runner (P066): an app points it at its real page (its CSP, its nonce, its
|
|
@@ -240,6 +245,7 @@ export function hostConformance(options: HostConformanceOptions): HostConformanc
|
|
|
240
245
|
return request;
|
|
241
246
|
},
|
|
242
247
|
calls: () => invoke(page, "calls", id),
|
|
248
|
+
shown: () => invoke(page, "shown", id),
|
|
243
249
|
errors: () => invoke(page, "errors", id),
|
|
244
250
|
events: () => invoke(page, "events", id),
|
|
245
251
|
destroy: () => invoke(page, "destroy", id),
|
|
@@ -430,6 +436,7 @@ const URL_CASES = [
|
|
|
430
436
|
"served.url.ticket",
|
|
431
437
|
"served.url.tab",
|
|
432
438
|
"served.url.framed",
|
|
439
|
+
"served.url.siblings",
|
|
433
440
|
];
|
|
434
441
|
const PROXY_CASES = ["served.proxy.view", "served.proxy.parent-only", "served.proxy.egress"];
|
|
435
442
|
const DOMAIN_CASES = [
|
|
@@ -440,6 +447,8 @@ const DOMAIN_CASES = [
|
|
|
440
447
|
"served.domain.address",
|
|
441
448
|
"served.domain.storage-scope",
|
|
442
449
|
"served.domain.ticket-once",
|
|
450
|
+
"served.domain.self-navigation",
|
|
451
|
+
...TAB_CASES,
|
|
443
452
|
"served.domain.frame-ancestors",
|
|
444
453
|
"served.domain.egress",
|
|
445
454
|
];
|
package/src/conformance/index.ts
CHANGED
|
@@ -49,6 +49,11 @@ export interface LaunchSpec {
|
|
|
49
49
|
};
|
|
50
50
|
/** Whether the host has a `confirm` function (default true): without one, gated calls are refused. */
|
|
51
51
|
readonly confirms?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the host has a `show` function (default true, P100): without one, `show`-gated calls
|
|
54
|
+
* (a model context update, by default) are refused.
|
|
55
|
+
*/
|
|
56
|
+
readonly shows?: boolean;
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
export interface RecordedCall {
|
|
@@ -75,6 +80,11 @@ export interface LaunchedDisplay {
|
|
|
75
80
|
): Promise<ConfirmRequest>;
|
|
76
81
|
/** The calls that reached the host's handlers, in order. */
|
|
77
82
|
calls(): Promise<readonly RecordedCall[]>;
|
|
83
|
+
/**
|
|
84
|
+
* What the host showed the person for `show`-gated calls (P100: each model context update), in
|
|
85
|
+
* order. A host whose harness doesn't say has `12.model-context` reported inapplicable.
|
|
86
|
+
*/
|
|
87
|
+
shown?(): Promise<readonly ConfirmRequest[]>;
|
|
78
88
|
/** The errors the display reported. */
|
|
79
89
|
errors(): Promise<readonly string[]>;
|
|
80
90
|
/** Every event the display emitted, in order. */
|
|
@@ -149,6 +149,44 @@ export const LIMIT_PROBES: readonly Probe[] = [
|
|
|
149
149
|
expect(await quiet.errors()).toEqual([]);
|
|
150
150
|
},
|
|
151
151
|
},
|
|
152
|
+
{
|
|
153
|
+
id: "14.error-shapes",
|
|
154
|
+
item: 14,
|
|
155
|
+
title:
|
|
156
|
+
"what content logs as an error reaches the host as bounded text in any shape structured clone carries: a cycle, a BigInt, a shared graph (S05)",
|
|
157
|
+
async run(context) {
|
|
158
|
+
// A graph of 20 objects each holding the next twice: 2^20 leaves written as a tree.
|
|
159
|
+
const logs = `<script>
|
|
160
|
+
(() => {
|
|
161
|
+
const say = (data) => parent.postMessage({ jsonrpc: "2.0", method: "notifications/message", params: { level: "error", data } }, "*");
|
|
162
|
+
const cycle = { name: "porthole-cycle" };
|
|
163
|
+
cycle.self = cycle;
|
|
164
|
+
let graph = "leaf";
|
|
165
|
+
for (let i = 0; i < 20; i += 1) graph = { a: graph, b: graph };
|
|
166
|
+
say(cycle);
|
|
167
|
+
say({ big: 5n });
|
|
168
|
+
say(graph);
|
|
169
|
+
say("porthole-after");
|
|
170
|
+
})();
|
|
171
|
+
</script>`;
|
|
172
|
+
const page = `<!doctype html><html><head><title>View</title></head><body><p>x</p>${logs}</body></html>`;
|
|
173
|
+
for (const display of [
|
|
174
|
+
await context.launch({ config: inline(), content: `<p>x</p>${logs}` }),
|
|
175
|
+
await context.launch({ config: presets.mcpApp(), content: "", document: page }),
|
|
176
|
+
]) {
|
|
177
|
+
await expect
|
|
178
|
+
.poll(async () => (await display.errors()).includes("porthole-after"))
|
|
179
|
+
.toBe(true);
|
|
180
|
+
const errors = await display.errors();
|
|
181
|
+
expect(errors).toContain('{"name":"porthole-cycle","self":"[Circular]"}');
|
|
182
|
+
expect(errors).toContain('{"big":"5n"}');
|
|
183
|
+
const graph = errors.find((each) => each.startsWith('{"a":{"a":'));
|
|
184
|
+
expect(graph, "the shared graph, reported").toBeDefined();
|
|
185
|
+
expect(graph).toContain('"b":"[Repeated]"');
|
|
186
|
+
expect(graph?.length).toBeLessThanOrEqual(2_000);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
},
|
|
152
190
|
{
|
|
153
191
|
id: "14.silent",
|
|
154
192
|
item: 14,
|
|
@@ -586,7 +624,7 @@ export const LIMIT_PROBES: readonly Probe[] = [
|
|
|
586
624
|
export const LIMIT_CHECKS: { readonly [Id in LimitId]: readonly string[] } = {
|
|
587
625
|
layout: ["11.size", "14.fill"],
|
|
588
626
|
theme: ["11.theme-flip", "11.document-theme", "14.theme-never"],
|
|
589
|
-
errors: ["14.errors"],
|
|
627
|
+
errors: ["14.errors", "14.error-shapes"],
|
|
590
628
|
silent: ["14.silent"],
|
|
591
629
|
network: ["1.connect", "2.resources"],
|
|
592
630
|
"inline-assets": ["14.inline-assets"],
|
|
@@ -121,6 +121,7 @@ export function defineRuntimeConformance(
|
|
|
121
121
|
// Gates the person answers are the app's UI: a yes here, so the services are what's tested.
|
|
122
122
|
confirm: () => Promise.resolve(true),
|
|
123
123
|
consent: () => true,
|
|
124
|
+
show: () => {},
|
|
124
125
|
userActivation: () => true,
|
|
125
126
|
onEvent: () => {},
|
|
126
127
|
});
|
|
@@ -393,6 +394,26 @@ export function defineRuntimeConformance(
|
|
|
393
394
|
"an admin writes it",
|
|
394
395
|
);
|
|
395
396
|
});
|
|
397
|
+
// P093: a store that folds case keeps `Config/main` where `config/main` is.
|
|
398
|
+
add(
|
|
399
|
+
"db: a rule holds for its collection in any case, at the bridge and in the app",
|
|
400
|
+
async (handlers) => {
|
|
401
|
+
for (const path of ["Config/main", "CONFIG/main"]) {
|
|
402
|
+
expect(
|
|
403
|
+
codeOf(await as(handlers, viewers.interact)("db", { op: "set", path, data: {} })) ===
|
|
404
|
+
"forbidden",
|
|
405
|
+
`the rule for config holds at the bridge for ${path}`,
|
|
406
|
+
);
|
|
407
|
+
const past = await direct(
|
|
408
|
+
handlers,
|
|
409
|
+
"db",
|
|
410
|
+
{ op: "set", path, data: {} },
|
|
411
|
+
viewers.interact,
|
|
412
|
+
);
|
|
413
|
+
expect(!past.ok, `the app's handler holds the rule for config for ${path} itself`);
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
);
|
|
396
417
|
}
|
|
397
418
|
|
|
398
419
|
if (config.capabilities.artifact !== undefined) {
|