@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
|
@@ -5,7 +5,7 @@ import { entryTests } from "./entry.js";
|
|
|
5
5
|
import HARNESS from "./harness-source.js";
|
|
6
6
|
export { conformancePage } from "./page.js";
|
|
7
7
|
import { leakTests } from "./probes.js";
|
|
8
|
-
import { servedTests } from "./served.js";
|
|
8
|
+
import { servedTests, TAB_CASES, } from "./served.js";
|
|
9
9
|
const CANARY = "https://porthole-canary.example";
|
|
10
10
|
/** A page on no one's origin that frames what a case asks (routed by the test, like the canary). */
|
|
11
11
|
const FOREIGN = "http://porthole-foreign.example";
|
|
@@ -112,6 +112,7 @@ export function hostConformance(options) {
|
|
|
112
112
|
return request;
|
|
113
113
|
},
|
|
114
114
|
calls: () => invoke(page, "calls", id),
|
|
115
|
+
shown: () => invoke(page, "shown", id),
|
|
115
116
|
errors: () => invoke(page, "errors", id),
|
|
116
117
|
events: () => invoke(page, "events", id),
|
|
117
118
|
destroy: () => invoke(page, "destroy", id),
|
|
@@ -282,6 +283,7 @@ const URL_CASES = [
|
|
|
282
283
|
"served.url.ticket",
|
|
283
284
|
"served.url.tab",
|
|
284
285
|
"served.url.framed",
|
|
286
|
+
"served.url.siblings",
|
|
285
287
|
];
|
|
286
288
|
const PROXY_CASES = ["served.proxy.view", "served.proxy.parent-only", "served.proxy.egress"];
|
|
287
289
|
const DOMAIN_CASES = [
|
|
@@ -292,6 +294,8 @@ const DOMAIN_CASES = [
|
|
|
292
294
|
"served.domain.address",
|
|
293
295
|
"served.domain.storage-scope",
|
|
294
296
|
"served.domain.ticket-once",
|
|
297
|
+
"served.domain.self-navigation",
|
|
298
|
+
...TAB_CASES,
|
|
295
299
|
"served.domain.frame-ancestors",
|
|
296
300
|
"served.domain.egress",
|
|
297
301
|
];
|
|
@@ -48,6 +48,11 @@ export interface LaunchSpec {
|
|
|
48
48
|
};
|
|
49
49
|
/** Whether the host has a `confirm` function (default true): without one, gated calls are refused. */
|
|
50
50
|
readonly confirms?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the host has a `show` function (default true, P100): without one, `show`-gated calls
|
|
53
|
+
* (a model context update, by default) are refused.
|
|
54
|
+
*/
|
|
55
|
+
readonly shows?: boolean;
|
|
51
56
|
}
|
|
52
57
|
export interface RecordedCall {
|
|
53
58
|
readonly capability: CapabilityName;
|
|
@@ -78,6 +83,11 @@ export interface LaunchedDisplay {
|
|
|
78
83
|
}): Promise<ConfirmRequest>;
|
|
79
84
|
/** The calls that reached the host's handlers, in order. */
|
|
80
85
|
calls(): Promise<readonly RecordedCall[]>;
|
|
86
|
+
/**
|
|
87
|
+
* What the host showed the person for `show`-gated calls (P100: each model context update), in
|
|
88
|
+
* order. A host whose harness doesn't say has `12.model-context` reported inapplicable.
|
|
89
|
+
*/
|
|
90
|
+
shown?(): Promise<readonly ConfirmRequest[]>;
|
|
81
91
|
/** The errors the display reported. */
|
|
82
92
|
errors(): Promise<readonly string[]>;
|
|
83
93
|
/** Every event the display emitted, in order. */
|
|
@@ -118,6 +118,43 @@ export const LIMIT_PROBES = [
|
|
|
118
118
|
expect(await quiet.errors()).toEqual([]);
|
|
119
119
|
},
|
|
120
120
|
},
|
|
121
|
+
{
|
|
122
|
+
id: "14.error-shapes",
|
|
123
|
+
item: 14,
|
|
124
|
+
title: "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)",
|
|
125
|
+
async run(context) {
|
|
126
|
+
// A graph of 20 objects each holding the next twice: 2^20 leaves written as a tree.
|
|
127
|
+
const logs = `<script>
|
|
128
|
+
(() => {
|
|
129
|
+
const say = (data) => parent.postMessage({ jsonrpc: "2.0", method: "notifications/message", params: { level: "error", data } }, "*");
|
|
130
|
+
const cycle = { name: "porthole-cycle" };
|
|
131
|
+
cycle.self = cycle;
|
|
132
|
+
let graph = "leaf";
|
|
133
|
+
for (let i = 0; i < 20; i += 1) graph = { a: graph, b: graph };
|
|
134
|
+
say(cycle);
|
|
135
|
+
say({ big: 5n });
|
|
136
|
+
say(graph);
|
|
137
|
+
say("porthole-after");
|
|
138
|
+
})();
|
|
139
|
+
</script>`;
|
|
140
|
+
const page = `<!doctype html><html><head><title>View</title></head><body><p>x</p>${logs}</body></html>`;
|
|
141
|
+
for (const display of [
|
|
142
|
+
await context.launch({ config: inline(), content: `<p>x</p>${logs}` }),
|
|
143
|
+
await context.launch({ config: presets.mcpApp(), content: "", document: page }),
|
|
144
|
+
]) {
|
|
145
|
+
await expect
|
|
146
|
+
.poll(async () => (await display.errors()).includes("porthole-after"))
|
|
147
|
+
.toBe(true);
|
|
148
|
+
const errors = await display.errors();
|
|
149
|
+
expect(errors).toContain('{"name":"porthole-cycle","self":"[Circular]"}');
|
|
150
|
+
expect(errors).toContain('{"big":"5n"}');
|
|
151
|
+
const graph = errors.find((each) => each.startsWith('{"a":{"a":'));
|
|
152
|
+
expect(graph, "the shared graph, reported").toBeDefined();
|
|
153
|
+
expect(graph).toContain('"b":"[Repeated]"');
|
|
154
|
+
expect(graph?.length).toBeLessThanOrEqual(2_000);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
},
|
|
121
158
|
{
|
|
122
159
|
id: "14.silent",
|
|
123
160
|
item: 14,
|
|
@@ -523,7 +560,7 @@ export const LIMIT_PROBES = [
|
|
|
523
560
|
export const LIMIT_CHECKS = {
|
|
524
561
|
layout: ["11.size", "14.fill"],
|
|
525
562
|
theme: ["11.theme-flip", "11.document-theme", "14.theme-never"],
|
|
526
|
-
errors: ["14.errors"],
|
|
563
|
+
errors: ["14.errors", "14.error-shapes"],
|
|
527
564
|
silent: ["14.silent"],
|
|
528
565
|
network: ["1.connect", "2.resources"],
|
|
529
566
|
"inline-assets": ["14.inline-assets"],
|
|
@@ -44,6 +44,7 @@ export function defineRuntimeConformance(options) {
|
|
|
44
44
|
// Gates the person answers are the app's UI: a yes here, so the services are what's tested.
|
|
45
45
|
confirm: () => Promise.resolve(true),
|
|
46
46
|
consent: () => true,
|
|
47
|
+
show: () => { },
|
|
47
48
|
userActivation: () => true,
|
|
48
49
|
onEvent: () => { },
|
|
49
50
|
});
|
|
@@ -208,6 +209,15 @@ export function defineRuntimeConformance(options) {
|
|
|
208
209
|
expect(!view.ok, "a view-only person writes nothing, even past the bridge");
|
|
209
210
|
ok(await as(handlers, viewers.admin)("db", { op: "set", path: "config/main", data: {} }), "an admin writes it");
|
|
210
211
|
});
|
|
212
|
+
// P093: a store that folds case keeps `Config/main` where `config/main` is.
|
|
213
|
+
add("db: a rule holds for its collection in any case, at the bridge and in the app", async (handlers) => {
|
|
214
|
+
for (const path of ["Config/main", "CONFIG/main"]) {
|
|
215
|
+
expect(codeOf(await as(handlers, viewers.interact)("db", { op: "set", path, data: {} })) ===
|
|
216
|
+
"forbidden", `the rule for config holds at the bridge for ${path}`);
|
|
217
|
+
const past = await direct(handlers, "db", { op: "set", path, data: {} }, viewers.interact);
|
|
218
|
+
expect(!past.ok, `the app's handler holds the rule for config for ${path} itself`);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
211
221
|
}
|
|
212
222
|
if (config.capabilities.artifact !== undefined) {
|
|
213
223
|
add("artifact: get answers the current version; a publish from it makes the next", async (handlers) => {
|
|
@@ -72,6 +72,8 @@ export interface ServedSuiteOptions {
|
|
|
72
72
|
/** Case ids to skip, each with the reason (shown in the report). */
|
|
73
73
|
readonly skip?: Readonly<Record<string, string>>;
|
|
74
74
|
}
|
|
75
|
+
/** The cases of a served page on a tab of its own (P099), one per wall. */
|
|
76
|
+
export declare const TAB_CASES: readonly string[];
|
|
75
77
|
/** Registers every served-mode case as a test. */
|
|
76
78
|
/**
|
|
77
79
|
* Registers every served-mode case as a test. A host that wants to select them by its own spec
|