@onlyworlds/sdk 4.99.0 → 4.100.1

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/AGENTS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # For AI agents using @onlyworlds/sdk
2
2
 
3
- **Current as of**: SDK **4.x** · schema-dist **v0.33.0-dist.82** (canonical 00.33.00).
3
+ **Current as of**: SDK **4.x** · schema-dist **v0.33.0-dist.83** (canonical 00.33.00).
4
4
  This line is asserted by `codegen:check` in CI — if the pin moves and this file is not
5
5
  re-read against it, the check fails rather than letting this document rot quietly.
6
6
 
@@ -69,11 +69,14 @@ against live data). The v1 surface (`OnlyWorldsClient`, the `ElementType` enum)
69
69
  - Allowance (since 4.21.0, account token): `account.allowance()` reads the daily AI allowance
70
70
  without spending: `{ token_rating, tokens_used_today, tokens_remaining, resets_at }`.
71
71
  - Who am I (since 4.22.0, a world key): `client.me()` is `{ world, scope, kind, role,
72
- membership, character, front_door }` (`membership` is what `created_by` holds for what you
72
+ membership, character, front_door, reading_aids }` (`membership` is what `created_by` holds for what you
73
73
  create; null for the owner); `front_door` (since 4.60.0) names who answers for your
74
74
  seat (`sponsor`, `sponsor_character`), your Character, the AI and player seats you answer
75
75
  for (`my_seats`, since 4.82.0: `{ id, kind, name, character }`, agent seats first), and the
76
- world's Charter with up to five skill Objects: an agent reads `charter` first. `client.members()` is the roster's rows. An
76
+ world's Charter with up to five skill Objects: an agent reads `charter` first. `reading_aids`
77
+ (since 4.100.0, also on an agent's join) is the world's three things to read first:
78
+ `charter` (`{ id, name, rules, skill }`), `guide` and `domains` (`{ id, name, sentence, hubs }`);
79
+ `charterOf(world, reader)` reads the same packet from a snapshot or a folder. `client.members()` is the roster's rows. An
77
80
  account token is a TypeError.
78
81
  - Lenses chosen (a world key, or an account token): `worldLenses(worldId, { resolve })` lists the
79
82
  world's lenses; `setMyLenses(lensIds)` sets the ones you start with (an account token needs the
@@ -169,8 +172,8 @@ against live data). The v1 surface (`OnlyWorldsClient`, the `ElementType` enum)
169
172
  - A world with a parlor holds its room as ordinary elements: `isRoomElement(el)` is true when the
170
173
  type and supertype, trimmed and case-blind, match one of `ROOM_PAIRS` (narrative/Message,
171
174
  narrative/Board, relation/Work item, construct/Spec, relation/Heart, relation/Take,
172
- relation/Vote, event/Sitting, character/Member) AND the element carries `x_room_of`, a non-empty
173
- string. A Take also carries `x_room_item`, the work item's id. A pair
175
+ relation/Vote, event/Sitting, character/Member) AND the element carries `x_room_of`, any value but null (a string only when something
176
+ is left after trimming). A Take also carries `x_room_item`, the work item's id. A pair
174
177
  without the mark is lore (a novel's letters). The world's charter (a Law with supertype
175
178
  `Charter`), its guide and its domains (Constructs with supertype `Guide` or `Domain`) are reading
176
179
  aids when they carry `x_charter_of` (`isCharterElement(el)`): show them first, leave them out of a
package/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ earlier history lives in git log only.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [4.100.1] - 2026-10-28
9
+
10
+ ### Fixed
11
+
12
+ - **Lens rows below the public rung keep what the API serves about proposed elements, and no row carries a stored `x_served_trimmed`.** A proposed element (`x_review_proposed` anything but absent or null) is still in no reader's view: never a row, never hopped through. But a contributor or a guest that sees one is served the links to it, and a lens's note keyed to it, where `resolveLens` left both out; the public rung still drops them, unmarked. A body that carries `x_served_trimmed` as stored is served without it: the owner's rows lose it, and below the owner the mark names only what this reading trimmed (it was merged into the stored one). Eight more row cases hold these readings, 28 in all, the same file as the Python package's.
13
+
14
+ ## [4.100.0] - 2026-10-28
15
+
16
+ ### Added
17
+
18
+ - **`charterOf(world, reader)` and `domainsOf(world, reader)`**: the charter profile's reader, the world's three reading aids as one reader sees a world snapshot. `charter` is the newest marked Charter it sees (newest by `created_at` compared as instants, none sorting as the oldest, then the higher id), `{ id, name, rules, skill }`: `rules` its `x_checks_rules` as stored (`[]` when none), `skill` the ids its description names by any `ow://` form, a site address or a bare id, lowercase, each once in the order written, kept when it is an Object of this world the reader sees, the first five of those kept, as the API's `charter_skill` reads it. `guide` is the newest marked Guide the same way, `{ id, name }`. `domains` is every marked Domain the reader sees, `{ id, name, sentence, hubs }`, in the order the Guide's `constructs` names them as the reader is served the Guide (a Domain named twice keeps its first place), then by folded name and id; `sentence` is the description to its first line break, trimmed, and `hubs` the distinct `{ type, id }` its links name that the reader sees, in the schema's field order, never itself, none for a Domain known only as a stub. The reader is a lens reader; the public rung reads nothing of a world that is not `open`. `domainsOf` is the list alone. Every case of the distribution's charter fixture is its own test.
19
+ - **`CHARTER_PAIRS`**: the charter profile's three pairs (`law`/`Charter`, `construct`/`Guide`, `construct`/`Domain`), each with the aid it is, generated from the distribution's charter fixture and checked against the page and the lens fixture's pairs.
20
+ - **`reading_aids` on `OwMe` and `OwAgentJoined`**: `me()` and an agent's `redeemJoin` answer carry the same packet beside `front_door`, typed `OwReadingAids` (`OwReadingAidsCharter`, `OwReadingAidsGuide`, `OwReadingAidsDomain`, `OwReadingAidsHub`), as the API's document declares it.
21
+
22
+ ### Changed
23
+
24
+ - **Schema repinned to schema-dist `v0.33.0-dist.83`** (from dist.82; the same canonical 00.33.00, so `ONLYWORLDS_VERSION` stays `'00.33.00'` and no element field moved). Serial 83 adds the charter profile and its fixture, writes the room and charter marks' presence rule, and adds fifteen lens cases; the lens fixture holds 147 cases (71 resolve, 37 graph), the room fixture 32, every one passing.
25
+ - **`isRoomElement` reads `x_room_of` by presence**: the mark counts when its value is not null, a string only when something is left after trimming White_Space, any other value (a number, an object) as present, the value never compared. It wanted a non-empty string before, so a number read as no mark and a mark of spaces as one. `isCharterElement` already read `x_charter_of` this way.
26
+ - **An umbrella lens's children keep their own budget and mail rule**: each child keeps at most its own `budget` (the rest counted `budget`) and its own mail rule takes its messages out of the child's kept, uncounted, before the union takes the umbrella's mail rule and budget. The rows are made once, from the union, by the umbrella's `show`, and a child's `notes` never reach a row. The union drops an element only by its id, so a sibling lens a child's hop reaches stays kept.
27
+ - **Nothing is hopped out of what the fence cuts**: an element cut `after_as_of`, an anchor among them, is not hopped out of. The second hop's `hops_not_served` count leaves out a room element or a reading aid whose pair `types` does not name.
28
+ - **Lens rows below the owner come as the API serves that reader.** A link to an element the reader cannot see was already left out, and still is. What moves: `x_served_trimmed` is no longer added for the public rung, and on a Message it names only `characters` and `narrator`, in that order (it named every trimmed link field, `objects` and `locations` too). A Pin aimed at an element the reader cannot see reads `element_type` `""` and `element_id` null (the type stayed), and so does one whose `element_type` is not its element's type; an id of the wrong type for its link field is left out. The owner reading as itself gets the bodies as stored (an id outside its view, a missing or proposed one, was dropped). A public reader has no mail part.
29
+
30
+ ### Fixed
31
+
32
+ - **4.99.0 handed hidden elements' ids to a reader below the owner, in the notes of a lens kept as an element.** A lens a hop reaches is kept as an element, and its row carried `x_lens.notes` whole, so a contributor, a guest or the public got the ids of hidden anchors and other hidden elements as note keys, with the notes' text. The row now keeps a note only for an anchor it is served or another element the reader sees; for a contributor or a guest, `notes` joins `x_served_trimmed` when an anchor's note went with its anchor. Twenty row cases hold these readings, the same file as the Python package's.
33
+
8
34
  ## [4.99.0] - 2026-10-28
9
35
 
10
36
  ### Added
package/README.md CHANGED
@@ -173,7 +173,7 @@ await account.revokeWorldLink(worldId, made.id);
173
173
  Once in, a world key can ask who it is and who else is there (since 4.22.0):
174
174
 
175
175
  ```typescript
176
- const me = await client.me(); // { world, scope, kind, role, membership, character, front_door }: front_door.charter is the house rules, read first
176
+ const me = await client.me(); // { world, scope, kind, role, membership, character, front_door, reading_aids }: reading_aids.charter is the house rules, read first
177
177
  const roster = await client.members(); // [{ id, kind, role, character, status }], the owner's id is null
178
178
  ```
179
179
 
@@ -362,7 +362,7 @@ The four colour families (agents, world, abstract, temporal) are checked for col
362
362
 
363
363
  ### The room
364
364
 
365
- A parlor (a chat room on a world) keeps its lines, board entries, work items, specs, hearts, votes, sittings and member cards in the world as ordinary elements, told apart by type and supertype and marked with `x_room_of` (the id of the world or sitting the room belongs to). `ROOM_PAIRS` is the room profile's list of those pairs, and `isRoomElement(el)` is true when an element matches one (type and supertype trimmed, case-blind, the whole word) and carries the mark. A pair without the mark is lore: a novel's letters are Narratives with supertype Message.
365
+ A parlor (a chat room on a world) keeps its lines, board entries, work items, specs, hearts, votes, sittings and member cards in the world as ordinary elements, told apart by type and supertype and marked with `x_room_of` (the id of the world or sitting the room belongs to). `ROOM_PAIRS` is the room profile's list of those pairs, and `isRoomElement(el)` is true when an element matches one (type and supertype trimmed, case-blind, the whole word) and carries the mark (read by presence since 4.100.0: any value but null, a string only when something is left after trimming). A pair without the mark is lore: a novel's letters are Narratives with supertype Message.
366
366
 
367
367
  ```typescript
368
368
  import { isRoomElement } from '@onlyworlds/sdk';
@@ -372,6 +372,8 @@ const lore = elements.filter(el => !isRoomElement(el)); // a lore view, unless t
372
372
 
373
373
  The world's charter (a Law with supertype `Charter`), its guide and its domains (Constructs with supertype `Guide` or `Domain`) are reading aids when they carry the mark `x_charter_of`, the id of the world they belong to: `isCharterElement(el)` is true for one (pair and mark, matched as `isRoomElement` matches). A tool's front door shows them first and a lore view leaves them out; the pair without the mark is lore (a kingdom's Charter in a novel's world). A reading aid is not a room element.
374
374
 
375
+ `charterOf(world, reader)` (since 4.100.0) reads the three as one reader sees a world snapshot, the packet keel serves as `reading_aids` beside `front_door` on `me()` and an agent's join: `charter` (`{ id, name, rules, skill }`, the newest marked Charter; `skill` the Objects its text names, at most five), `guide` (`{ id, name }`), and `domains` (`{ id, name, sentence, hubs }`, in the Guide's order, then by name). `domainsOf(world, reader)` is the list alone, and `CHARTER_PAIRS` the three pairs. The reader is a lens reader (below); the public reads nothing of a world unless it carries `open: true`. The profile: [`profiles/charter.md`](https://github.com/OnlyWorlds/schema-dist/blob/main/profiles/charter.md).
376
+
375
377
  A lore view (a list, a count, search, a graph, a link picker, a story's context) leaves room elements out unless the person asks to see them; the room's own views show them whole, and a tool that writes the world writes them like any element. A Law with supertype `Charter` is lore on purpose. The profile: [`profiles/room.md`](https://github.com/OnlyWorlds/schema-dist/blob/main/profiles/room.md) in the schema distribution.
376
378
 
377
379
  ### Messages
@@ -407,7 +409,7 @@ r.kept; r.rows; r.cut; // ids in order, rows as show makes them, e.g. { budget:
407
409
  if (r.unreadable) console.warn(`x_lens.${r.unreadable} is outside the profile's table`);
408
410
  ```
409
411
 
410
- The world holds the elements as the owner is served them; the reader's `rung` (`owner`, `contributor`, `guest` with its `whole` and `known_of` ids, `public`) decides what it sees, and an owner reading `as` another reader keeps the owner's two counts (`anchor_not_visible`, `not_visible`), which no other reader ever carries. The profile: [`profiles/lens.md`](https://github.com/OnlyWorlds/schema-dist/blob/main/profiles/lens.md).
412
+ The world holds the elements as the owner is served them; the reader's `rung` (`owner`, `contributor`, `guest` with its `whole` and `known_of` ids, `public`) decides what it sees, and an owner reading `as` another reader keeps the owner's two counts (`anchor_not_visible`, `not_visible`), which no other reader ever carries. A row is the body as the reader is served it: below the owner, every link holds only ids the reader sees (a Pin's pair aimed elsewhere reads `""` and null), and `x_served_trimmed` names a Message's trimmed `characters` or `narrator` and a lens's trimmed anchors, never for the public; the owner's rows are the bodies as stored. The profile: [`profiles/lens.md`](https://github.com/OnlyWorlds/schema-dist/blob/main/profiles/lens.md).
411
413
 
412
414
  `DATE_FIELD` is the profile's date table (each dated type's date field; the ten timeless types are not in it), and `dateOf(el)` is an element's date as that table reads it: the whole number in its type's date field, else null. A timeline or a horizon dates elements exactly as the lens reader's fence does.
413
415
 
package/SCHEMA.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # OnlyWorlds Schema Reference
2
2
 
3
- **Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.33.0-dist.82** — canonical schema **00.33.00**, published 2026-10-28.
3
+ **Source**: https://github.com/OnlyWorlds/schema-dist @ **v0.33.0-dist.83** — canonical schema **00.33.00**, published 2026-10-28.
4
4
 
5
5
  GENERATED from the canonical schema YAML — do not hand-edit (regenerate: `python codegen/generate_types.py`).
6
6
  Written for both humans and AI agents reading this package locally.
package/dist/index.d.ts CHANGED
@@ -104,6 +104,17 @@ declare const ROOM_PAIRS: ReadonlyArray<{
104
104
  readonly type: ElementType;
105
105
  readonly supertype: string;
106
106
  }>;
107
+ /** The charter profile's three pairs (schema-dist `profiles/charter.md`): the Charter (the rules here), the
108
+ * Guide (start here) and the Domains (the places in the world), each with the aid it is. An element is a
109
+ * reading aid when its type and supertype, each trimmed and compared without regard to case, match one
110
+ * of these AND it carries the mark `x_charter_of`, read by presence: match with isCharterElement, read
111
+ * the packet with charterOf. Source: `profiles/charter.fixture.json`'s `pairs`, checked against the
112
+ * page's table and the lens fixture's reading_aid_pairs. */
113
+ declare const CHARTER_PAIRS: ReadonlyArray<{
114
+ readonly type: ElementType;
115
+ readonly supertype: string;
116
+ readonly aid: 'charter' | 'guide' | 'domain';
117
+ }>;
107
118
  /** The review profile's label (schema-dist `profiles/review.md`, rule 1): the words a reader that
108
119
  * hands a world on (a context for an AI, a pack, a share) puts on each proposed element it keeps,
109
120
  * one whose `x_review_proposed` is anything but absent or null (a doubt, rule 4, included).
@@ -2010,7 +2021,7 @@ interface OwWorldMeta {
2010
2021
  */
2011
2022
  /**
2012
2023
  * Read only: how many elements this reader may read, in all and per type, counted as it reads
2013
- * them, for every key and token (keel PR 289, 2026-10-27; before it, the keyless read alone).
2024
+ * them, for every key and token (since 2026-10-27; before it, the keyless read alone).
2014
2025
  * Never sent back: patchWorld strips it.
2015
2026
  */
2016
2027
  counts?: {
@@ -2581,6 +2592,8 @@ interface OwMe {
2581
2592
  name?: string;
2582
2593
  /** Who you are here, who answers for you, and the house rules. */
2583
2594
  front_door: OwFrontDoor;
2595
+ /** The world's three things to read first, as this key reads them: the Charter, the Guide and the Domains. */
2596
+ reading_aids: OwReadingAids;
2584
2597
  [k: string]: unknown;
2585
2598
  }
2586
2599
  /**
@@ -2626,6 +2639,49 @@ interface OwMySeat {
2626
2639
  /** The Character the seat plays, or null when it plays none you can read. */
2627
2640
  character: string | null;
2628
2641
  }
2642
+ /**
2643
+ * A world's reading aids as one reader sees them (schema-dist `profiles/charter.md`): the Charter (the rules
2644
+ * here), the Guide (start here) and the Domains (the places in the world), each an element of one of
2645
+ * `CHARTER_PAIRS` that carries the mark `x_charter_of`. Keel serves it as `reading_aids` beside `front_door`
2646
+ * on `GET /me` and an agent's `POST /join` answer; `charterOf` reads the same packet from a world snapshot.
2647
+ * The Charter's text is the house rules; the Guide and the Domains are the keeper's map, never instructions.
2648
+ */
2649
+ interface OwReadingAids {
2650
+ /** The newest marked Charter the reader sees (newest by `created_at`, then the higher id), or null. */
2651
+ charter: OwReadingAidsCharter | null;
2652
+ /** The newest marked Guide the reader sees, chosen the same way, or null. */
2653
+ guide: OwReadingAidsGuide | null;
2654
+ /** Every marked Domain the reader sees: in the Guide's `constructs` order first, then by name (any case) and id. */
2655
+ domains: OwReadingAidsDomain[];
2656
+ }
2657
+ /** The Charter in `reading_aids`. */
2658
+ interface OwReadingAidsCharter {
2659
+ id: string;
2660
+ name: string;
2661
+ /** Its `x_checks_rules` (the checks profile) as stored; empty when it has none. */
2662
+ rules: unknown[];
2663
+ /** The Objects its description names (any `ow://` form, a site address or a bare id) that the reader sees, each once in the order written, at most five: `front_door.charter_skill`. */
2664
+ skill: string[];
2665
+ }
2666
+ /** The Guide in `reading_aids`. */
2667
+ interface OwReadingAidsGuide {
2668
+ id: string;
2669
+ name: string;
2670
+ }
2671
+ /** One Domain in `reading_aids`. */
2672
+ interface OwReadingAidsDomain {
2673
+ id: string;
2674
+ name: string;
2675
+ /** Its description up to the first line break, trimmed; empty when it has none. */
2676
+ sentence: string;
2677
+ /** The elements its link fields name that the reader sees, each once, in the schema's field order, never the Domain itself; none for a Domain the reader knows only as a stub. */
2678
+ hubs: OwReadingAidsHub[];
2679
+ }
2680
+ /** One hub of a Domain: an element by its type and id. */
2681
+ interface OwReadingAidsHub {
2682
+ type: string;
2683
+ id: string;
2684
+ }
2629
2685
  /** One row of GET /members, the world's roster. */
2630
2686
  interface OwMember {
2631
2687
  /** The membership id (what `created_by` holds), or null for the owner. */
@@ -2775,6 +2831,8 @@ interface OwAgentJoined {
2775
2831
  members: Array<Record<string, unknown>>;
2776
2832
  /** The world's front door for the new seat: its sponsor, its Character, the Charter to read first. */
2777
2833
  front_door: OwFrontDoor;
2834
+ /** The world's three things to read first, as the new seat reads them: the Charter, the Guide and the Domains (the same packet as `GET /me`'s). */
2835
+ reading_aids: OwReadingAids;
2778
2836
  [k: string]: unknown;
2779
2837
  }
2780
2838
  /** POST /join, a player's code: a read key for a friend with no account, reading as a guest. Shown once. */
@@ -4836,8 +4894,9 @@ declare function getElementLabel(elementType: ElementType): string;
4836
4894
 
4837
4895
  /**
4838
4896
  * True when the element is a room element: its type and supertype, each trimmed and compared
4839
- * without regard to case, match one of ROOM_PAIRS, AND it carries the mark `x_room_of` as a
4840
- * non-empty string (the id of the world or the sitting the room belongs to). Both, always:
4897
+ * without regard to case, match one of ROOM_PAIRS, AND it carries the mark `x_room_of` (the id of
4898
+ * the world or the sitting the room belongs to), read by presence: any value but null, a string only
4899
+ * when something is left after trimming, the value never compared. Both, always:
4841
4900
  * a pair without the mark is lore (a novel's letters are Narratives with supertype Message),
4842
4901
  * and a mark without a pair is not a room element (a malformed mark: report it, never hide it).
4843
4902
  * The pair match is the whole word: a Narrative with supertype `Messages` is lore. The charter
@@ -4857,7 +4916,7 @@ declare function getElementLabel(elementType: ElementType): string;
4857
4916
  declare function isRoomElement(el: {
4858
4917
  type?: string;
4859
4918
  supertype?: string | null;
4860
- x_room_of?: string | null;
4919
+ x_room_of?: unknown;
4861
4920
  }): boolean;
4862
4921
  /**
4863
4922
  * True when the element is a reading aid (schema-dist profiles/room.md, profiles/lens.md rule 4): the
@@ -5032,49 +5091,13 @@ declare function unreadFor<T extends object>(messages: readonly T[], characterId
5032
5091
  declare function threadOf<T extends object>(messages: readonly T[], rootId: string): T[];
5033
5092
  declare function noteOf(narratives: readonly object[], characterId: string, members: Members): string | null;
5034
5093
 
5035
- /**
5036
- * The review profile's proposed mark (schema-dist profiles/review.md): an element whose
5037
- * `x_review_proposed` is an object was written as proposed (an AI seat's new element on a world
5038
- * whose keeper reviews them) and is not canon until a keeper settles it: accept writes the mark
5039
- * null, decline deletes the element.
5040
- *
5041
- * Two readings, as the profile's rule 1 and rule 4 give them. A reader that shows a world to its
5042
- * people shows the mark when it is an object (`proposedMarkOf`); any other value is not a mark and
5043
- * is reported by a lint, never repaired. A reader that hands a world on leaves out every element
5044
- * whose `x_review_proposed` is anything but absent or null (`handsOnAsProposed`), so a doubt never
5045
- * reaches an AI as canon.
5046
- */
5047
- /** The review profile's proposed mark, an extension key. */
5048
- declare const PROPOSED_MARK = "x_review_proposed";
5049
- /** A proposed element's mark as a reader shows it. */
5050
- interface OwProposedMark {
5051
- /** The membership or seat that proposed it, trimmed of Unicode White_Space as the room profile trims, when the mark names one. */
5052
- by: string | null;
5053
- /** The day it lapses (YYYY-MM-DD), trimmed, when the mark gives one in that shape. */
5054
- expires: string | null;
5055
- /** `expires` has come (on or before `today`): shown as lapsed, never deleted on its own (rule 2). */
5056
- lapsed: boolean;
5057
- }
5058
- /**
5059
- * The proposed mark of an element as a reader that shows a world shows it, or null for a settled
5060
- * element: `x_review_proposed` absent, null, or a value that is not an object (an array included).
5061
- * `today` is a day as the profile writes one (YYYY-MM-DD), by default today in UTC; anything else
5062
- * is a TypeError.
5063
- */
5064
- declare function proposedMarkOf(element: unknown, today?: string): OwProposedMark | null;
5065
- /**
5066
- * Whether a reader that hands a world on (a pack, a context packet, an AI's context) leaves this
5067
- * element out as proposed: `x_review_proposed` with any value but absent or null, a value that is
5068
- * not a proper mark included (a doubt, counted with the proposed).
5069
- */
5070
- declare function handsOnAsProposed(element: unknown): boolean;
5071
-
5072
5094
  /** A reader of a lens: the rung decides what of the world it sees. */
5073
5095
  interface OwLensReader {
5074
5096
  /**
5075
5097
  * `owner` (the whole world), `contributor` (the world less the hidden), `guest` (exactly the ids in
5076
5098
  * `whole`, and those in `known_of` as stubs) or `public` (the world less the hidden and the room
5077
- * elements). A proposed element is in no reader's view.
5099
+ * elements). A proposed element is in no reader's view, but below the public rung a served body keeps
5100
+ * a link to one the rung sees, and a lens's note keyed to it.
5078
5101
  */
5079
5102
  rung: 'owner' | 'contributor' | 'guest' | 'public';
5080
5103
  /** The reader's Character, for the mail rule; null or absent: no Character, no mail. */
@@ -5187,7 +5210,7 @@ declare function lensesInUse(membership: readonly string[] | null | undefined, x
5187
5210
  *
5188
5211
  * The rules, in short: visibility first (a hidden or proposed element is not there to hop through; a
5189
5212
  * known-of stub is kept as served and nothing hops out of it); a hop reaches both ways, and on through
5190
- * a Relation to its parties; an umbrella enters each child lens once; a hop never crosses a room
5213
+ * a Relation to its parties; an umbrella enters each child lens once, each child keeping its own budget and mail rule, the rows made by the umbrella's `show`; a hop never crosses a room
5191
5214
  * element; a reading aid (the charter, its guide, a domain: `isCharterElement`) a hop reaches is kept, and
5192
5215
  * hopped on from, only when `types` names its pair, while one the lens names as an anchor is kept and
5193
5216
  * followed; anchors first in link order, then by type in the schema's order, newest first, then by id;
@@ -5198,6 +5221,74 @@ declare function lensesInUse(membership: readonly string[] | null | undefined, x
5198
5221
  */
5199
5222
  declare function resolveLens(world: OwLensWorld, lens: object | string, reader: OwLensReader, options?: OwLensOptions): OwLensReading;
5200
5223
 
5224
+ /** The world snapshot the reading aids are read from: the lens reader's world, and whether it is open to anyone. */
5225
+ interface OwCharterWorld extends OwLensWorld {
5226
+ /** True for a world open to anyone: only then does the public rung read anything of it. */
5227
+ open?: boolean | null;
5228
+ }
5229
+ /**
5230
+ * A world's reading aids as `reader` sees it (schema-dist profiles/charter.md): `{charter, guide, domains}`,
5231
+ * the packet every front door shows first, in that order.
5232
+ *
5233
+ * `charter` is the newest marked Charter the reader sees (newest by `created_at`, compared as instants, none
5234
+ * sorting as the oldest; then the higher id by code point), as `{id, name, rules, skill}`: `rules` its
5235
+ * `x_checks_rules` as stored (`[]` when it has none), `skill` the ids its description names (any `ow://`
5236
+ * form, a site address or a bare id), lowercase, each once in the order written, kept when it is an Object
5237
+ * of this world the reader sees, the first five of those kept (keel's `charter_skill`). `guide` is the
5238
+ * newest marked Guide the same way, `{id, name}`. `domains` is every marked Domain the reader sees, each
5239
+ * `{id, name, sentence, hubs}`: in the order the Guide's `constructs` names them as the reader is served the
5240
+ * Guide (a Domain named twice keeps its first place; an entry that is no marked Domain it sees is skipped),
5241
+ * then the rest by folded name and id; with no Guide seen, by folded name and id alone. `sentence` is the
5242
+ * description up to its first line break, trimmed; `hubs` the distinct `{type, id}` its link fields name that
5243
+ * the reader sees, in the schema's field order, never itself, and none for a Domain it knows only as a stub.
5244
+ *
5245
+ * `world` holds the elements as the owner is served them (the hidden in `hidden` or each element's own
5246
+ * `hidden`), and `open: true` for a world open to anyone; `reader` is a lens reader (`OwLensReader`): the
5247
+ * owner, a contributor, a guest (its `whole` and `known_of` ids) or the public, which reads nothing of a
5248
+ * world that is not open. Whether an element is an aid is read from the element as the owner is served it,
5249
+ * since a stub serves no extension field; what the packet shows of it is what the reader is served. Pure.
5250
+ */
5251
+ declare function charterOf(world: OwCharterWorld, reader: OwLensReader): OwReadingAids;
5252
+ /** The marked Domains alone, as `charterOf` lists them for the same reader. */
5253
+ declare function domainsOf(world: OwCharterWorld, reader: OwLensReader): OwReadingAidsDomain[];
5254
+
5255
+ /**
5256
+ * The review profile's proposed mark (schema-dist profiles/review.md): an element whose
5257
+ * `x_review_proposed` is an object was written as proposed (an AI seat's new element on a world
5258
+ * whose keeper reviews them) and is not canon until a keeper settles it: accept writes the mark
5259
+ * null, decline deletes the element.
5260
+ *
5261
+ * Two readings, as the profile's rule 1 and rule 4 give them. A reader that shows a world to its
5262
+ * people shows the mark when it is an object (`proposedMarkOf`); any other value is not a mark and
5263
+ * is reported by a lint, never repaired. A reader that hands a world on leaves out every element
5264
+ * whose `x_review_proposed` is anything but absent or null (`handsOnAsProposed`), so a doubt never
5265
+ * reaches an AI as canon.
5266
+ */
5267
+ /** The review profile's proposed mark, an extension key. */
5268
+ declare const PROPOSED_MARK = "x_review_proposed";
5269
+ /** A proposed element's mark as a reader shows it. */
5270
+ interface OwProposedMark {
5271
+ /** The membership or seat that proposed it, trimmed of Unicode White_Space as the room profile trims, when the mark names one. */
5272
+ by: string | null;
5273
+ /** The day it lapses (YYYY-MM-DD), trimmed, when the mark gives one in that shape. */
5274
+ expires: string | null;
5275
+ /** `expires` has come (on or before `today`): shown as lapsed, never deleted on its own (rule 2). */
5276
+ lapsed: boolean;
5277
+ }
5278
+ /**
5279
+ * The proposed mark of an element as a reader that shows a world shows it, or null for a settled
5280
+ * element: `x_review_proposed` absent, null, or a value that is not an object (an array included).
5281
+ * `today` is a day as the profile writes one (YYYY-MM-DD), by default today in UTC; anything else
5282
+ * is a TypeError.
5283
+ */
5284
+ declare function proposedMarkOf(element: unknown, today?: string): OwProposedMark | null;
5285
+ /**
5286
+ * Whether a reader that hands a world on (a pack, a context packet, an AI's context) leaves this
5287
+ * element out as proposed: `x_review_proposed` with any value but absent or null, a value that is
5288
+ * not a proper mark included (a doubt, counted with the proposed).
5289
+ */
5290
+ declare function handsOnAsProposed(element: unknown): boolean;
5291
+
5201
5292
  /** `worldGraph`'s options. Each flag is a boolean, false by default, and brings back one kind of element that is out by default. */
5202
5293
  interface OwGraphOptions {
5203
5294
  /** A lens body, or the id of a lens in the world the reader can see: the nodes are then exactly what it kept, and no flag adds to them. */
@@ -6435,4 +6526,4 @@ declare class TokenResource {
6435
6526
  getEncryptionInfo(): Promise<EncryptionInfo>;
6436
6527
  }
6437
6528
 
6438
- export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, DATE_FIELD, ELEMENT_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GameTier, type ListParams, MESSAGE_PAIR, NOTE_PAIR, ONLYWORLDS_VERSION, type OwAccountWorld, type OwAddress, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwGraphCutReason, type OwGraphEdge, type OwGraphMark, type OwGraphNode, type OwGraphOptions, type OwHiddenRow, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLensCutReason, type OwLensMail, type OwLensOptions, type OwLensReader, type OwLensReading, type OwLensWorld, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldLens, type OwWorldLensReading, type OwWorldLenses, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, dateOf, degreeOf, detectKeyKind, displayYear, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, handsOnAsProposed, hasUnseenRecipients, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, lensesInUse, lookupWorld, monthStartSteps, nfc, noteOf, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, recipientsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
6529
+ export { AGENT_DOORS, ASK_LIMITS, type AccessKeyResponse, CALENDAR_FIELD, CALENDAR_SUPERTYPE, CHARTER_PAIRS, type CalendarConfig, type CalendarEra, type CalendarIntercalary, type CalendarMonths, type CalendarWeek, DATE_FIELD, ELEMENT_FAMILIES, ELEMENT_ICONS, ELEMENT_LABELS, ELEMENT_SECTIONS, ELEMENT_TYPES, type ElementFamily, type ElementType, type EncryptionInfo, type EraDomain, FAMILY_COLORS, FAMILY_ORDER, FIELD_ACRONYMS, FIELD_SCHEMA, FILE_EXTENSIONS, type FieldInfo, type FieldType, GameTier, type ListParams, MESSAGE_PAIR, NOTE_PAIR, ONLYWORLDS_VERSION, type OwAccountWorld, type OwAddress, OwAddressError, type OwAddressForm, type OwAddressReading, type OwAddressReason, type OwAddressingOptions, type OwAgentJoined, type OwAllowance, OwApiError, type OwAskAnswer, type OwAskContext, type OwAskContextOptions, type OwAskLeftOut, type OwAuthErrorCode, type OwBulkItem, type OwBulkItemResult, type OwBulkResponse, type OwCalendarElement, type OwChange, type OwChangeDelete, type OwChangeUpsert, type OwChangesPage, type OwCharterWorld, type OwClientConfig, type OwCreateAccountWorldInput, type OwCreatedAccountWorld, type OwCreatedWorldLink, type OwDeleteReason, type OwDraught, type OwDraughtCompact, type OwDraughtComponent, type OwDraughtItem, type OwDraughtLens, type OwDraughtPolicy, type OwEdited, type OwElement, type OwElementBase, type OwErrorBody, type OwFileAddedBy, type OwFileDownload, type OwFileKind, type OwFileRow, type OwFileTicket, type OwFrontDoor, type OwGraphCutReason, type OwGraphEdge, type OwGraphMark, type OwGraphNode, type OwGraphOptions, type OwHiddenRow, type OwJoinPreview, type OwJoined, type OwJoinedMembership, type OwKeyKind, type OwLensCutReason, type OwLensMail, type OwLensOptions, type OwLensReader, type OwLensReading, type OwLensWorld, type OwLinkEdit, type OwLookupElement, type OwLookupHit, type OwLookupLink, type OwLookupOptions, type OwLookupReason, type OwMe, type OwMediaTicket, type OwMember, type OwMemberLenses, type OwMemberRole, type OwMessageMember, type OwMintedKey, type OwMySeat, type OwNamesMap, OwNetworkError, type OwPage, type OwPhotoOptions, type OwPhotoPlan, type OwPlayerJoined, OwPreconditionFailedError, type OwPreparedPhoto, type OwProposal, type OwProposalAccepted, type OwProposalConflict, type OwProposalList, type OwProposalQuery, type OwProposalState, type OwProposeInput, type OwProposed, OwProposedError, type OwProposedMark, type OwProposedNewElement, type OwReadWorldFile, type OwReadWorldFileOptions, type OwReadingAids, type OwReadingAidsCharter, type OwReadingAidsDomain, type OwReadingAidsGuide, type OwReadingAidsHub, type OwRemovalTicket, type OwRemovedImage, type OwRenderOptions, type OwResyncReason, type OwReviewInput, type OwReviewed, type OwSeat, type OwSeatCreated, type OwSender, type OwSenderStatus, type OwSignInBegin, type OwSignInBegun, type OwSignInComplete, OwSignInError, type OwSignInReason, type OwSignInResult, type OwSignInStorage, type OwSignedIn, type OwSortAddToRow, type OwSortAnswer, type OwSortAskRow, type OwSortLinkRow, type OwSortMakeRow, type OwSortNote, type OwSortRef, type OwSortRow, OwStaleProposalError, type OwUploadedFile, type OwUploadedImage, OwV2Client, type OwWordPair, type OwWorldFileEntry, OwWorldFileError, type OwWorldFileReason, type OwWorldFileRow, type OwWorldFiles, type OwWorldGraph, type OwWorldIndex, type OwWorldLens, type OwWorldLensReading, type OwWorldLenses, type OwWorldLink, type OwWorldMeta, type OwWorldOrigin, type OwWorldProducer, type OwWorldProposalList, type OwWorldProposalQuery, type OwWorldProposalRow, type OwWorldPublicPage, type OwWorldSource, type OwWriteDoor, type OwWriteWorldFileOptions, type OwWriteWorldFileReport, PHOTO_MAX_BYTES, PHOTO_TYPES, PROPOSED_MARK, PUBLIC_FIELDS, type ParseError, type ParseOptions, type ParseResult, REVIEW_PROPOSED_LABEL, ROOM_PAIRS, type RevokeAllSessionsResponse, type RevokeSessionResponse, SPATIAL_TYPES, type SectionInfo, type StepBreakdown, type TokenConsumeParams, type TokenConsumeResponse, TokenResource, type TokenStatus, type TokenTransport, WORLD_FILE_MAX_BYTES, WORLD_FILE_MAX_ENTRIES, WORLD_FILE_MEDIA_TYPE, type WorldCalendar, absYearForEraYear, absoluteYear, approxYearLength, base64url, breakdownStep, buildAskContext, buildWorldIndex, charterOf, dateOf, degreeOf, detectKeyKind, displayYear, domainsOf, draughtText, editedBy, elementAddress, elementColor, eraForStep, errorFromResponse, familyOf, fieldLabel, fileKindOf, floorDiv, floorMod, formatDuration, formatMidLabel, formatStep, formatYearLabel, getElementIcon, getElementLabel, handsOnAsProposed, hasUnseenRecipients, intercalaryInYear, isAddressedTo, isAgentDoor, isCharterElement, isDemoKey, isKnownOf, isLeapYear, isLens, isMessage, isNote, isParseError, isRoomElement, isSentBy, isTemplate, isToEveryone, kindCanWrite, lensesInUse, lookupWorld, monthStartSteps, nfc, noteOf, outDegreeOf, parseDate, parseErrorEnvelope, parseOwLink, pinExpectation, pkceChallenge, planPhoto, preparePhoto, proposedMarkOf, readCalendarConfig, readCalendarValue, readMarkOf, readWorldFile, recipientsOf, renderElement, resolveCalendar, resolveCalendarLens, resolveEraDomains, resolveLens, senderStatus, simpleCaseFold, threadOf, typeWord, unreadFor, validateCalendarConfig, weekdayForStep, worldCalendars, worldGraph, writeWorldFile, yearLength, yearStartStep };
package/dist/index.js CHANGED
@@ -2441,6 +2441,11 @@ var READING_AID_PAIRS = [
2441
2441
  { type: "construct", supertype: "domain" }
2442
2442
  ];
2443
2443
  var READING_AID_MARK = "x_charter_of";
2444
+ var CHARTER_PAIRS = [
2445
+ { type: "law", supertype: "Charter", aid: "charter" },
2446
+ { type: "construct", supertype: "Guide", aid: "guide" },
2447
+ { type: "construct", supertype: "Domain", aid: "domain" }
2448
+ ];
2444
2449
  var REVIEW_PROPOSED_LABEL = "proposed, not yet reviewed";
2445
2450
  var MESSAGE_PAIR = { type: "narrative", supertype: "Message" };
2446
2451
  var MESSAGE_READ_MARK = {
@@ -3823,10 +3828,14 @@ function trimWhiteSpace(text2) {
3823
3828
  return text2.slice(start, end);
3824
3829
  }
3825
3830
  var fold = (text2) => simpleCaseFold(trimWhiteSpace(text2));
3831
+ function hasMark(el, field) {
3832
+ const mark = Object.prototype.hasOwnProperty.call(el, field) ? el[field] : void 0;
3833
+ if (mark === void 0 || mark === null) return false;
3834
+ return typeof mark !== "string" || trimWhiteSpace(mark) !== "";
3835
+ }
3826
3836
  function isRoomElement(el) {
3827
- if (el == null || typeof el.type !== "string" || typeof el.supertype !== "string") return false;
3828
- const mark = el[ROOM_MARK];
3829
- if (typeof mark !== "string" || mark === "") return false;
3837
+ if (el == null || typeof el !== "object" || typeof el.type !== "string" || typeof el.supertype !== "string") return false;
3838
+ if (!hasMark(el, ROOM_MARK)) return false;
3830
3839
  const type = fold(el.type);
3831
3840
  const supertype = fold(el.supertype);
3832
3841
  return ROOM_PAIRS.some((p) => fold(p.type) === type && fold(p.supertype) === supertype);
@@ -3838,9 +3847,7 @@ function readingAidKey(element) {
3838
3847
  if (typeof el.type !== "string" || typeof el.supertype !== "string") return null;
3839
3848
  const key = `${fold(el.type)}/${fold(el.supertype)}`;
3840
3849
  if (!READING_AID_KEYS.has(key)) return null;
3841
- const mark = Object.prototype.hasOwnProperty.call(el, READING_AID_MARK) ? el[READING_AID_MARK] : void 0;
3842
- if (mark === void 0 || mark === null || typeof mark === "string" && trimWhiteSpace(mark) === "") return null;
3843
- return key;
3850
+ return hasMark(el, READING_AID_MARK) ? key : null;
3844
3851
  }
3845
3852
  function isCharterElement(element) {
3846
3853
  return readingAidKey(element) !== null;
@@ -4129,6 +4136,7 @@ var CUT_REASONS = [
4129
4136
  var OWNER_ONLY = /* @__PURE__ */ new Set(["anchor_not_visible", "not_visible"]);
4130
4137
  var ROOM_KEYS = new Set(ROOM_PAIRS.map((p) => `${fold(p.type)}/${fold(p.supertype)}`));
4131
4138
  var MAIL_SECONDS = 30 * 86400;
4139
+ var MESSAGE_ADDRESSING = ["characters", "narrator"];
4132
4140
  var STUB_FIELDS = ["id", "type", "name", "description", "supertype", "subtype", "image_url", "created_at", "updated_at"];
4133
4141
  var LINK_FIELDS = new Map(
4134
4142
  Object.entries(FIELD_SCHEMA).map(([type, fields]) => [
@@ -4257,6 +4265,8 @@ var Reading = class {
4257
4265
  this.hidden = /* @__PURE__ */ new Set();
4258
4266
  /** The ids written as proposed, which no reader's view holds. */
4259
4267
  this.proposed = /* @__PURE__ */ new Set();
4268
+ /** The ids a body this reader is served may link to: the view, and the proposed elements its rung sees (keel's `scoped` leaves them out for the public rung alone). */
4269
+ this.linkable = /* @__PURE__ */ new Set();
4260
4270
  this.served = /* @__PURE__ */ new Map();
4261
4271
  this.inView = /* @__PURE__ */ new Map();
4262
4272
  this.inFull = /* @__PURE__ */ new Map();
@@ -4279,16 +4289,15 @@ var Reading = class {
4279
4289
  this.owner = reader.rung === "owner";
4280
4290
  const seen = this.owner && reader.as != null ? reader.as : reader;
4281
4291
  this.seenRung = seen.rung;
4292
+ this.stored = seen.rung === "owner";
4282
4293
  this.character = typeof seen.character === "string" && seen.character !== "" ? seen.character : null;
4283
4294
  const listed = (v) => new Set(Array.isArray(v) ? v.filter((i) => typeof i === "string") : []);
4284
4295
  const wholeIds = listed(seen.whole);
4285
4296
  const knownOf = listed(seen.known_of);
4286
4297
  for (const id of this.order) {
4287
4298
  const el = this.byId.get(id);
4288
- if (handsOnAsProposed(el)) {
4289
- this.proposed.add(id);
4290
- continue;
4291
- }
4299
+ const proposed = handsOnAsProposed(el);
4300
+ if (proposed) this.proposed.add(id);
4292
4301
  let sees;
4293
4302
  switch (seen.rung) {
4294
4303
  case "owner":
@@ -4298,13 +4307,14 @@ var Reading = class {
4298
4307
  sees = !hidden.has(id);
4299
4308
  break;
4300
4309
  case "public":
4301
- sees = !hidden.has(id) && !this.room.has(id);
4310
+ sees = !hidden.has(id) && !this.room.has(id) && !proposed;
4302
4311
  break;
4303
4312
  default:
4304
4313
  sees = wholeIds.has(id) || knownOf.has(id);
4305
- if (!wholeIds.has(id) && knownOf.has(id)) this.stubs.add(id);
4314
+ if (!proposed && !wholeIds.has(id) && knownOf.has(id)) this.stubs.add(id);
4306
4315
  }
4307
- if (sees) this.view.add(id);
4316
+ if (sees) this.linkable.add(id);
4317
+ if (sees && !proposed) this.view.add(id);
4308
4318
  }
4309
4319
  this.members = Array.isArray(world.members) ? world.members : null;
4310
4320
  this.asOf = asOf;
@@ -4338,7 +4348,7 @@ var Reading = class {
4338
4348
  if (this.stubs.has(id)) return [];
4339
4349
  return this.fullLinks(id).filter((t) => this.view.has(t));
4340
4350
  }
4341
- /** The body this reader is served: a stub for a known-of element, the links outside the view left out (and named in `x_served_trimmed` on a message or a lens). */
4351
+ /** The body this reader is served: a stub for a known-of element; the owner's own view the body as stored; any other reader's with the links it cannot see left out (`trim`). */
4342
4352
  body(id) {
4343
4353
  let b = this.served.get(id);
4344
4354
  if (b !== void 0) return b;
@@ -4352,29 +4362,62 @@ var Reading = class {
4352
4362
  b.known_of = true;
4353
4363
  } else {
4354
4364
  b = copy(el);
4355
- const trimmed = [];
4356
- for (const [field, many] of LINK_FIELDS.get(type) ?? []) {
4357
- if (!own(b, field)) continue;
4358
- const v = b[field];
4359
- if (many) {
4360
- if (!Array.isArray(v)) continue;
4361
- const kept = v.filter((t) => typeof t === "string" && this.view.has(t));
4362
- if (v.some((t) => typeof t === "string" && !this.view.has(t))) trimmed.push(field);
4363
- b[field] = kept;
4364
- } else if (typeof v === "string" && !this.view.has(v)) {
4365
- b[field] = null;
4366
- trimmed.push(field);
4367
- }
4368
- }
4369
- if (trimmed.length > 0 && (isMessage(b) || isLens(b))) {
4370
- const mark = Array.isArray(b.x_served_trimmed) ? b.x_served_trimmed.slice() : [];
4371
- for (const f of trimmed) if (!mark.includes(f)) mark.push(f);
4372
- b.x_served_trimmed = mark;
4373
- }
4365
+ delete b.x_served_trimmed;
4366
+ if (!this.stored) this.trim(type, b);
4374
4367
  }
4375
4368
  this.served.set(id, b);
4376
4369
  return b;
4377
4370
  }
4371
+ /**
4372
+ * A whole body as a reader below the owner is served it, as keel's `redact` and `serialize` serve it: every
4373
+ * link id the reader cannot see (or that names an element of another type than the field's) left out, a
4374
+ * single link to null, a generic pair (a Pin's `element_type` and `element_id`) to the empty pair, `""` and
4375
+ * null; a lens's `x_lens.notes` keeps the entries keyed to an anchor it is served or another element it
4376
+ * sees. `x_served_trimmed` names what was trimmed only where keel adds it: a Message's `characters` and
4377
+ * `narrator`, a lens's anchor fields and `notes` (when an anchor's note went with it), for a contributor
4378
+ * or a guest, never the public rung.
4379
+ */
4380
+ trim(type, b) {
4381
+ const sees = (t, target) => typeof t === "string" && this.linkable.has(t) && (target === "any" || this.typeOf.get(t) === target);
4382
+ const schema = FIELD_SCHEMA[type] ?? {};
4383
+ const isLensBody = isLens(b);
4384
+ const anchorsBefore = isLensBody ? new Set(ANCHOR_FIELDS.flatMap((f) => Array.isArray(b[f]) ? b[f] : [])) : null;
4385
+ const trimmed = [];
4386
+ for (const [field, many] of LINK_FIELDS.get(type) ?? []) {
4387
+ if (!own(b, field)) continue;
4388
+ const v = b[field];
4389
+ const target = schema[field]?.target ?? "any";
4390
+ if (many) {
4391
+ if (!Array.isArray(v) || v.length === 0) continue;
4392
+ const kept = v.filter((t) => sees(t, target));
4393
+ if (kept.length !== v.length) trimmed.push(field);
4394
+ b[field] = kept;
4395
+ } else if (target === "any" && field.endsWith("_id")) {
4396
+ const typeField = `${field.slice(0, -3)}_type`;
4397
+ if (typeof v !== "string" || v === "" || sees(v, typeof b[typeField] === "string" ? b[typeField] : "")) continue;
4398
+ if (own(b, typeField)) b[typeField] = "";
4399
+ b[field] = null;
4400
+ trimmed.push(field);
4401
+ } else if (typeof v === "string" && v !== "" && !sees(v, target)) {
4402
+ b[field] = null;
4403
+ trimmed.push(field);
4404
+ }
4405
+ }
4406
+ let notesGone = false;
4407
+ if (anchorsBefore !== null && isBody2(b.x_lens) && isBody2(b.x_lens.notes)) {
4408
+ const notes = b.x_lens.notes;
4409
+ const served = new Set(ANCHOR_FIELDS.flatMap((f) => Array.isArray(b[f]) ? b[f] : []));
4410
+ const kept = {};
4411
+ for (const k of Object.keys(notes)) {
4412
+ if (served.has(k) || !anchorsBefore.has(k) && this.linkable.has(k)) kept[k] = notes[k];
4413
+ else if (anchorsBefore.has(k)) notesGone = true;
4414
+ }
4415
+ if (Object.keys(kept).length !== Object.keys(notes).length) b.x_lens = { ...b.x_lens, notes: kept };
4416
+ }
4417
+ if (this.seenRung === "public") return;
4418
+ const named = isMessage(b) ? MESSAGE_ADDRESSING.filter((f) => trimmed.includes(f)) : isLensBody ? [...ANCHOR_FIELDS.filter((f) => trimmed.includes(f)), ...notesGone ? ["notes"] : []] : [];
4419
+ if (named.length > 0) b.x_served_trimmed = named;
4420
+ }
4378
4421
  /**
4379
4422
  * One hop from each element of `from`, both ways, and on through each Relation it lands on to that Relation's
4380
4423
  * parties. Nothing hops out of a stub or a room element, nor out of an element `stops` names.
@@ -4520,8 +4563,7 @@ function resolveOne(lens, recipe, r, visited, wall) {
4520
4563
  };
4521
4564
  const { anchors, children, unseen, anchored } = anchorsOf(lens, r);
4522
4565
  const anchorSet = new Set(anchors);
4523
- const childSet = new Set(children);
4524
- const list = [];
4566
+ let list = [];
4525
4567
  const frontier = [];
4526
4568
  for (const id of anchors) {
4527
4569
  if (visited.has(id) || !r.byId.has(id)) continue;
@@ -4529,8 +4571,8 @@ function resolveOne(lens, recipe, r, visited, wall) {
4529
4571
  addCut(id, "anchor_not_visible");
4530
4572
  continue;
4531
4573
  }
4532
- frontier.push(id);
4533
4574
  const why = r.fenceCut(id, recipe);
4575
+ if (why !== "after_as_of") frontier.push(id);
4534
4576
  if (why !== null) addCut(id, why);
4535
4577
  else list.push(id);
4536
4578
  }
@@ -4543,16 +4585,18 @@ function resolveOne(lens, recipe, r, visited, wall) {
4543
4585
  const selected = r.order.filter((id) => r.view.has(id) && !visited.has(id) && r.kept(id, recipe));
4544
4586
  list.push(...r.sort(selected.filter(passes)));
4545
4587
  } else if (recipe.depth >= 1) {
4546
- const excluded = (id) => anchorSet.has(id) || childSet.has(id) || visited.has(id);
4588
+ const excluded = (id) => anchorSet.has(id) || visited.has(id);
4547
4589
  const { reached: hop, edges } = r.reach(frontier, excluded);
4548
4590
  list.push(...r.sort([...hop].filter(passes)));
4549
4591
  if (r.owner) for (const id of r.unseen(frontier, edges, excluded)) addCut(id, "not_visible");
4550
4592
  if (recipe.depth === 2) {
4551
- const stops = (id) => r.stopsAt(id, recipe);
4552
- for (const id of r.reach(hop, (id2) => excluded(id2) || hop.has(id2), stops).reached) addCut(id, "hops_not_served");
4593
+ const stops = (id) => r.stopsAt(id, recipe) || r.fenceCut(id, recipe) === "after_as_of";
4594
+ for (const id of r.reach(hop, (id2) => excluded(id2) || hop.has(id2), stops).reached) {
4595
+ if ((r.room.has(id) || r.aid.has(id)) && !r.kept(id, recipe)) continue;
4596
+ addCut(id, "hops_not_served");
4597
+ }
4553
4598
  }
4554
4599
  }
4555
- const out = list.map((id) => ({ id, row: r.row(id, recipe.show, anchorSet.has(id) ? recipe.notes : null) }));
4556
4600
  for (const child of children) {
4557
4601
  if (visited.has(child)) continue;
4558
4602
  visited.add(child);
@@ -4560,14 +4604,23 @@ function resolveOne(lens, recipe, r, visited, wall) {
4560
4604
  const read = readRecipe(body.x_lens);
4561
4605
  if (!("recipe" in read) || isTemplate(body)) continue;
4562
4606
  const sub = resolveOne(body, read.recipe, r, visited, wall);
4563
- out.push(...sub.list);
4607
+ const have = new Set(list);
4608
+ list.push(...sub.list.filter((id) => !have.has(id)));
4564
4609
  for (const [id, why] of sub.cut) addCut(id, why);
4565
4610
  }
4566
- return { list: out, cut: cut2 };
4611
+ const mail = recipe.mail === "none" ? null : mailPart(r, recipe.mail, recipe.budget, wall);
4612
+ if (mail !== null) {
4613
+ const inMail = /* @__PURE__ */ new Set([...mail.unread, ...mail.read]);
4614
+ list = list.filter((id) => !inMail.has(id));
4615
+ }
4616
+ for (const id of list.slice(recipe.budget)) cut2.set(id, "budget");
4617
+ list = list.slice(0, recipe.budget);
4618
+ for (const id of list) cut2.delete(id);
4619
+ return { list, cut: cut2, mail };
4567
4620
  }
4568
4621
  function mailPart(r, mode, budget, clock) {
4569
4622
  const empty = { unread: [], read: [], rows: [], cut: {}, totals: { unread: 0, read: 0 } };
4570
- if (r.character === null) return empty;
4623
+ if (r.character === null || r.seenRung === "public") return empty;
4571
4624
  const inView = r.order.filter((id) => r.view.has(id));
4572
4625
  const messages = inView.filter((id) => !r.stubs.has(id)).map((id) => r.body(id)).filter((b) => isMessage(b));
4573
4626
  const relations = inView.filter((id) => r.typeOf.get(id) === "relation").map((id) => r.body(id));
@@ -4633,20 +4686,9 @@ function lensReading(r, lens, clockV) {
4633
4686
  const wall = timeKey(clockV ?? (/* @__PURE__ */ new Date()).toISOString());
4634
4687
  const visited = /* @__PURE__ */ new Set();
4635
4688
  if (typeof body.id === "string") visited.add(body.id);
4636
- const resolved = resolveOne(body, recipe, r, visited, wall);
4637
- const mail = recipe.mail === "none" ? null : mailPart(r, recipe.mail, recipe.budget, wall);
4638
- const inMail = new Set(mail === null ? [] : [...mail.unread, ...mail.read]);
4639
- const seen = /* @__PURE__ */ new Set();
4640
- const union = resolved.list.filter((e) => {
4641
- if (seen.has(e.id) || visited.has(e.id) || inMail.has(e.id)) return false;
4642
- seen.add(e.id);
4643
- return true;
4644
- });
4645
- const keep = union.slice(0, recipe.budget);
4646
- const cut2 = resolved.cut;
4647
- for (const e of union.slice(recipe.budget)) cut2.set(e.id, "budget");
4648
- for (const e of keep) cut2.delete(e.id);
4649
- for (const id of visited) cut2.delete(id);
4689
+ const { list: keep, cut: cut2, mail } = resolveOne(body, recipe, r, visited, wall);
4690
+ const { anchors } = anchorsOf(body, r);
4691
+ const rows = keep.map((id) => r.row(id, recipe.show, anchors.includes(id) ? recipe.notes : null));
4650
4692
  const counts = {};
4651
4693
  for (const why of CUT_REASONS) {
4652
4694
  if (OWNER_ONLY.has(why) && !r.owner) continue;
@@ -4654,9 +4696,106 @@ function lensReading(r, lens, clockV) {
4654
4696
  for (const w of cut2.values()) if (w === why) n++;
4655
4697
  if (n > 0) counts[why] = n;
4656
4698
  }
4657
- const { anchors } = anchorsOf(body, r);
4658
4699
  const notesIgnored = Object.keys(recipe.notes).filter((k) => !anchors.includes(k) && r.view.has(k)).length;
4659
- return { reading: { kept: keep.map((e) => e.id), rows: keep.map((e) => e.row), cut: counts, notesIgnored, mail, unreadable: null }, cutById: cut2 };
4700
+ return { reading: { kept: keep, rows, cut: counts, notesIgnored, mail, unreadable: null }, cutById: cut2 };
4701
+ }
4702
+
4703
+ // src/charter.ts
4704
+ var SKILL_MAX = 5;
4705
+ var ID = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g;
4706
+ var BREAK = /\r\n|\r|\n/;
4707
+ function firstLine(text2) {
4708
+ if (typeof text2 !== "string") return "";
4709
+ return trimWhiteSpace(trimWhiteSpace(text2).split(BREAK, 1)[0]);
4710
+ }
4711
+ function newest(ids, r) {
4712
+ let best = null;
4713
+ let bestAt = null;
4714
+ for (const id of ids) {
4715
+ const at = timeKey(r.byId.get(id).created_at);
4716
+ if (best !== null) {
4717
+ const c = at && bestAt ? compareKeys(at, bestAt) : at ? 1 : bestAt ? -1 : 0;
4718
+ if (c < 0 || c === 0 && byCodePoint2(id, best) < 0) continue;
4719
+ }
4720
+ best = id;
4721
+ bestAt = at;
4722
+ }
4723
+ return best;
4724
+ }
4725
+ function idsIn(text2) {
4726
+ const out = [];
4727
+ if (typeof text2 !== "string") return out;
4728
+ for (const m of text2.matchAll(ID)) {
4729
+ const id = m[0].toLowerCase();
4730
+ if (!out.includes(id)) out.push(id);
4731
+ }
4732
+ return out;
4733
+ }
4734
+ function hubsOf(id, r) {
4735
+ const body = r.body(id);
4736
+ if (body.known_of === true) return [];
4737
+ const schema = FIELD_SCHEMA.construct;
4738
+ const out = [];
4739
+ const seen = /* @__PURE__ */ new Set([`construct/${id}`]);
4740
+ for (const [field, many] of LINK_FIELDS.get("construct") ?? []) {
4741
+ const v = body[field];
4742
+ const target = schema[field]?.target ?? "";
4743
+ for (const t of many ? Array.isArray(v) ? v : [] : [v]) {
4744
+ if (typeof t !== "string" || t === "" || seen.has(`${target}/${t}`)) continue;
4745
+ seen.add(`${target}/${t}`);
4746
+ out.push({ type: target, id: t });
4747
+ }
4748
+ }
4749
+ return out;
4750
+ }
4751
+ var NONE = () => ({ charter: null, guide: null, domains: [] });
4752
+ function charterOf(world, reader) {
4753
+ if (!isBody2(world) || !Array.isArray(world.elements)) {
4754
+ throw new TypeError("charterOf: world is an object with an elements list.");
4755
+ }
4756
+ checkReader(reader, "charterOf: reader");
4757
+ const r = new Reading(world, reader, null);
4758
+ if (r.seenRung === "public" && world.open !== true) return NONE();
4759
+ const seen = (pair) => r.order.filter((id) => r.view.has(id) && r.aid.get(id) === pair);
4760
+ const out = NONE();
4761
+ const law = newest(seen("law/charter"), r);
4762
+ if (law !== null) {
4763
+ const el = r.byId.get(law);
4764
+ const rules = el.x_checks_rules;
4765
+ const skill = idsIn(el.description).filter((id) => r.view.has(id) && r.typeOf.get(id) === "object").slice(0, SKILL_MAX);
4766
+ out.charter = {
4767
+ id: law,
4768
+ name: typeof el.name === "string" ? el.name : "",
4769
+ rules: Array.isArray(rules) ? JSON.parse(JSON.stringify(rules)) : [],
4770
+ skill
4771
+ };
4772
+ }
4773
+ const guide = newest(seen("construct/guide"), r);
4774
+ if (guide !== null) {
4775
+ const el = r.byId.get(guide);
4776
+ out.guide = { id: guide, name: typeof el.name === "string" ? el.name : "" };
4777
+ }
4778
+ const domains = new Set(seen("construct/domain"));
4779
+ const order = [];
4780
+ const named = guide === null ? void 0 : r.body(guide).constructs;
4781
+ for (const id of Array.isArray(named) ? named : []) {
4782
+ if (typeof id === "string" && domains.has(id) && !order.includes(id)) order.push(id);
4783
+ }
4784
+ const nameOf = (id) => {
4785
+ const name = r.body(id).name;
4786
+ return typeof name === "string" ? name : "";
4787
+ };
4788
+ const rest = [...domains].filter((id) => !order.includes(id)).sort((a, b) => byCodePoint2(fold(nameOf(a)), fold(nameOf(b))) || byCodePoint2(a, b));
4789
+ out.domains = [...order, ...rest].map((id) => ({
4790
+ id,
4791
+ name: nameOf(id),
4792
+ sentence: firstLine(r.body(id).description),
4793
+ hubs: hubsOf(id, r)
4794
+ }));
4795
+ return out;
4796
+ }
4797
+ function domainsOf(world, reader) {
4798
+ return charterOf(world, reader).domains;
4660
4799
  }
4661
4800
 
4662
4801
  // src/graph.ts
@@ -6571,6 +6710,7 @@ export {
6571
6710
  ASK_LIMITS,
6572
6711
  CALENDAR_FIELD,
6573
6712
  CALENDAR_SUPERTYPE,
6713
+ CHARTER_PAIRS,
6574
6714
  DATE_FIELD,
6575
6715
  ELEMENT_FAMILIES,
6576
6716
  ELEMENT_ICONS,
@@ -6613,10 +6753,12 @@ export {
6613
6753
  breakdownStep,
6614
6754
  buildAskContext,
6615
6755
  buildWorldIndex,
6756
+ charterOf,
6616
6757
  dateOf,
6617
6758
  degreeOf,
6618
6759
  detectKeyKind,
6619
6760
  displayYear,
6761
+ domainsOf,
6620
6762
  draughtText,
6621
6763
  editedBy,
6622
6764
  elementAddress,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlyworlds/sdk",
3
- "version": "4.99.0",
3
+ "version": "4.100.1",
4
4
  "description": "TypeScript SDK for the OnlyWorlds API - build world-building applications with type safety",
5
5
  "type": "module",
6
6
  "exports": {