@botiverse/porthole 0.14.8 → 0.14.9

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 (54) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/bridge/bridge.d.ts +6 -0
  3. package/dist/bridge/bridge.js +5 -0
  4. package/dist/check/page-source.js +1 -1
  5. package/dist/config/capabilities.d.ts +16 -2
  6. package/dist/config/capabilities.js +8 -0
  7. package/dist/conformance/harness-source.js +1 -1
  8. package/dist/find/types.d.ts +83 -0
  9. package/dist/find/types.js +29 -0
  10. package/dist/find/validate.d.ts +17 -0
  11. package/dist/find/validate.js +82 -0
  12. package/dist/guide/guide.js +2 -1
  13. package/dist/host/create-host.js +214 -0
  14. package/dist/host/pass-on.js +3 -2
  15. package/dist/host/types.d.ts +51 -0
  16. package/dist/index.d.ts +3 -1
  17. package/dist/index.js +3 -0
  18. package/dist/react/frame.d.ts +43 -0
  19. package/dist/react/frame.js +107 -3
  20. package/dist/react/view.js +2 -0
  21. package/dist/runtime/contract.d.ts +1 -1
  22. package/dist/runtime/contract.js +1 -1
  23. package/dist/shell/annotate.js +2 -95
  24. package/dist/shell/document.d.ts +3 -3
  25. package/dist/shell/document.js +5 -3
  26. package/dist/shell/find.d.ts +82 -0
  27. package/dist/shell/find.js +725 -0
  28. package/dist/shell/runtime.js +4 -1
  29. package/dist/shell/text.d.ts +17 -0
  30. package/dist/shell/text.js +140 -0
  31. package/docs/ADOPTING.md +83 -0
  32. package/docs/ARCHITECTURE.md +10 -3
  33. package/docs/DECISIONS.md +219 -1
  34. package/docs/DESIGN.md +33 -0
  35. package/docs/THREAT_MODEL.md +48 -4
  36. package/docs/insertion-entry-points.md +17 -0
  37. package/package.json +1 -1
  38. package/src/bridge/bridge.ts +7 -0
  39. package/src/config/capabilities.ts +13 -1
  40. package/src/find/types.ts +86 -0
  41. package/src/find/validate.ts +101 -0
  42. package/src/guide/guide.ts +3 -1
  43. package/src/host/create-host.ts +230 -0
  44. package/src/host/pass-on.ts +3 -2
  45. package/src/host/types.ts +52 -0
  46. package/src/index.ts +12 -0
  47. package/src/react/frame.tsx +160 -1
  48. package/src/react/view.tsx +3 -0
  49. package/src/runtime/contract.ts +1 -1
  50. package/src/shell/annotate.ts +3 -95
  51. package/src/shell/document.ts +5 -3
  52. package/src/shell/find.ts +731 -0
  53. package/src/shell/runtime.ts +4 -1
  54. package/src/shell/text.ts +140 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,33 @@
4
4
  section); the reasons for every change are in [docs/DECISIONS.md](docs/DECISIONS.md), by the
5
5
  P-numbers below.
6
6
 
7
+ ## 0.14.9
8
+
9
+ - **Find in page (P131):** a host's own find bar over a display. Declare `find`
10
+ (`capabilities: { find: {} }`; in no preset by default) and use `display.find`: `query(query, {
11
+ direction, caseSensitive })` finds the query in the page's text (case-insensitive, any spacing,
12
+ what is drawn only, at most 1,000), highlights every match and the current one in a layer of the
13
+ shell's own, brings the current one into view, and resolves with `{ total, active, capped?,
14
+ rect? }` or `"unsupported"` (no `find`, an older shell, no answer in 3 s, superseded by a later
15
+ query: the shell searches only the latest of a burst); `clear()`;
16
+ `takeShortcut(true)` makes Cmd+F or Ctrl+F in the frame open the host's bar (`findRequested`)
17
+ instead of the browser's, unless the page handles the key itself. `findUpdated` tells new numbers
18
+ when the page changes. A query holds only for the content it was asked of: a reload, a restart
19
+ after a navigation away, or other content forgets it (clear the host's find bar then), as does
20
+ the React handle for another `content`, `generation`, `document`, `instance` or `config`. Hosts
21
+ should send queries on a pause or Enter, not at every key (ADOPTING). React: `onFindRequested`,
22
+ `onFindUpdated`, and `find`/`clearFind` on the frame's handle. New exports: `FIND_METHODS`,
23
+ `FIND_LIMITS`, `parseFindResult`, `parseFindReport` and their types. The manual tells the agent people may search the page's words.
24
+ - **Security (P131):** the page reads every query the host sends (the search runs in its
25
+ document), so declare `find` only where it may learn what the person searches for; P131 records
26
+ that exposure as accepted. What the frame says back is the page's word; the host
27
+ takes `findRequested` only with the page's focus in the frame (negative control
28
+ `find-requested-focus`). No CSP, sandbox or egress changes. A host must upgrade its content
29
+ server (the shell) for find to work; an older one answers `"unsupported"`. The find runtime and
30
+ the text index it shares with annotations call only built-ins captured before content runs,
31
+ through `callOf` (P129), and the find layer's nodes go in only through the guarded insertion
32
+ methods (P130; listed in [docs/insertion-entry-points.md](docs/insertion-entry-points.md)).
33
+
7
34
  ## 0.14.8
8
35
 
9
36
  - **Frame guard: broader coverage of DOM insertion and parsing entry points (P130),** listed in
@@ -1,5 +1,6 @@
1
1
  import { type CapabilityName } from "../config/capabilities.ts";
2
2
  import type { AnnotationReport } from "../annotate/types.ts";
3
+ import type { FindReport } from "../find/types.ts";
3
4
  import type { PortholeConfig } from "../config/schema.ts";
4
5
  import { type PageDeclaration } from "../runtime/declaration.ts";
5
6
  import { type ViewerInfo } from "../runtime/levels.ts";
@@ -34,6 +35,11 @@ export type BridgeEvent = {
34
35
  } | {
35
36
  readonly type: "annotation";
36
37
  readonly report: AnnotationReport;
38
+ }
39
+ /** What the frame said of find in page unasked (P131), checked. */
40
+ | {
41
+ readonly type: "find";
42
+ readonly report: FindReport;
37
43
  } | {
38
44
  readonly type: "refused";
39
45
  readonly capability: CapabilityName;
@@ -1,5 +1,6 @@
1
1
  import { MAX_CONTEXT_CHARS, MAX_COPY_CHARS, capabilitySpec, } from "../config/capabilities.js";
2
2
  import { parseReport } from "../annotate/validate.js";
3
+ import { parseFindReport } from "../find/validate.js";
3
4
  import { callGates, effectiveGates } from "../compile/policy.js";
4
5
  import { boundedText } from "./bounded-text.js";
5
6
  import { isJsonData } from "./json-data.js";
@@ -178,6 +179,7 @@ const VALIDATORS = {
178
179
  : null;
179
180
  },
180
181
  annotate: (args) => parseReport(args),
182
+ find: (args) => parseFindReport(args),
181
183
  // The runtime's own (P088-P090): their shapes and limits, before any gate.
182
184
  user: (args) => (args === undefined || isRecord(args) ? {} : null),
183
185
  comments: (args) => parseCommentRequest(args),
@@ -590,6 +592,9 @@ export function createBridge(options) {
590
592
  else if (capability === "annotate") {
591
593
  onEvent({ type: "annotation", report: args });
592
594
  }
595
+ else if (capability === "find") {
596
+ onEvent({ type: "find", report: args });
597
+ }
593
598
  else {
594
599
  const report = args;
595
600
  if (report.navigationBlocked !== undefined) {