@estiva-app/interop 0.68.0 → 0.69.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/CHANGELOG.md CHANGED
@@ -6,6 +6,39 @@ how a declaration is read, is a MAJOR — in `0.x`, a MINOR — even when no
6
6
  TypeScript signature moved. A consumer upgrading must be able to tell whether
7
7
  manifests already published still mean what they meant.
8
8
 
9
+ ## 0.69.0 — 2026-10-27
10
+
11
+ **Wire behaviour: a comment built from a manifest carries the `a`, `q` and
12
+ `part` tags its caller hands it; an edit says what the message links now**
13
+ (PEEKM-7; SPEC §6.8, §13.1; record *an-edit-says-what-the-message-links-now*).
14
+
15
+ - `linkReader({ query, manifests? })`: what an app link names (§7.7), once for
16
+ every app. Peek, Ship, Leaf and the agent each kept a copy; now each passes
17
+ its relay read. `ask`, `known` (a `LinkResolver`), `knownBlock`, `answered`,
18
+ `changed`/`version` for drawing again as answers land, `opener` (https only,
19
+ on a host an app declares, for every app; was Leaf's rule), and `tagsFor`,
20
+ which asks, waits at most 5 s, and returns the tags `linkTagsOf` gives. One
21
+ author for a `d` as before, and now only addressable kinds are asked (the
22
+ agent's rule): a manifest pointing a path at `kind:1` names nothing. A
23
+ manifest read that failed or came back empty is asked again.
24
+ - `linkTagsOf(blocks, own, resolve, blockOf?)`: an `a` per address and a `q`
25
+ per message the body names, by `nostr:` reference or app link, none in code,
26
+ `[A](B)` naming B only; never the comment's own file nor the message it
27
+ answers; one `part` per file on a send, at most conversation's `MAX_PARTS`
28
+ as the box shows, none on an edit.
29
+ - `buildActionEvent({ …, linkTags })`: a `comment` appends them after its
30
+ people, so the agent's comments list under Mentioned in as the apps' do.
31
+ Without `linkTags` the event is byte for byte as before.
32
+ - `readMentionedIn(query, address, { links })` and the pure `mentionedInOf`:
33
+ a file's Mentioned in, read from comments, messages **and edits** pointing at
34
+ it (`mentionedInFilter`), each edit standing for its message and each message
35
+ confirmed against its latest words. A message the reader cannot read lists
36
+ nothing; an edit by anyone but the author is not read; a row whose link could
37
+ not be asked about stays while its latest version points at the file.
38
+ - `within(work, ms)`: wait for `work`, at most `ms`, never rejecting — the
39
+ bound `tagsFor` and `readMentionedIn` wait by, for an app's own asks.
40
+ - Needs conversation 0.20 and protocol 0.44.
41
+
9
42
  ## 0.68.0 — 2026-10-26
10
43
 
11
44
  **Manifests: nothing changes.** A reader pays only for the kinds it draws
package/dist/index.d.ts CHANGED
@@ -43,6 +43,13 @@ export { fileCandidates, REFERENCE_FILE_TYPES, searchFileReferences, type FileCa
43
43
  * empties it. No signing, no requests.
44
44
  */
45
45
  export { planCreateFolder, planRenameFolder, planDeleteFolder, planPlaceFile, planUnlistFile, planMoveFile, planMoveFromFolders, planArchiveFolder, listedBeneath, type FolderRef, type MovableFile, type MovePlan, type MoveFromFoldersPlan, type MoveRefusal, } from './folders.js';
46
+ /**
47
+ * What an app link names, and where a file is mentioned — once for every app
48
+ * (SPEC §7.7, §13.1, §6.8; PEEKM-7). Each app passes its relay read; none
49
+ * keeps a resolver of its own.
50
+ */
51
+ export { linkReader, linkTagsOf, linksIn, writtenOpenerOf, within, MAX_LINKS_ASKED, type LinkAnswer, type LinkReader, type LinkReaderOptions, type OwnPlace, } from './links.js';
52
+ export { mentionedInFilter, mentionedInOf, readMentionedIn, MENTIONED_IN_LIMIT, type MentionedIn } from './mentions.js';
46
53
  /**
47
54
  * RFC 0.5 §7's URL grammar — how an object is named in an address bar, and how
48
55
  * a pasted link is matched back to one.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd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,2BAA2B,GACjC,MAAM,iBAAiB,CAAA;AAExB;;;;;GAKG;AACH,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAA;AAErB;;;;;;;GAOG;AACH,OAAO,EACL,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,EACd,UAAU,EACV,KAAK,UAAU,EACf,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,sBAAsB,EACtB,OAAO,EACP,KAAK,MAAM,EACX,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,KAAK,mBAAmB,EACxB,SAAS,EACT,KAAK,OAAO,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,KAAK,eAAe,EACpB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,eAA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d,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAEvH;;;;;;;GAOG;AACH,OAAO,EACL,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,EACd,UAAU,EACV,KAAK,UAAU,EACf,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -43,6 +43,13 @@ export { fileCandidates, REFERENCE_FILE_TYPES, searchFileReferences, } from './r
43
43
  * empties it. No signing, no requests.
44
44
  */
45
45
  export { planCreateFolder, planRenameFolder, planDeleteFolder, planPlaceFile, planUnlistFile, planMoveFile, planMoveFromFolders, planArchiveFolder, listedBeneath, } from './folders.js';
46
+ /**
47
+ * What an app link names, and where a file is mentioned — once for every app
48
+ * (SPEC §7.7, §13.1, §6.8; PEEKM-7). Each app passes its relay read; none
49
+ * keeps a resolver of its own.
50
+ */
51
+ export { linkReader, linkTagsOf, linksIn, writtenOpenerOf, within, MAX_LINKS_ASKED, } from './links.js';
52
+ export { mentionedInFilter, mentionedInOf, readMentionedIn, MENTIONED_IN_LIMIT } from './mentions.js';
46
53
  /**
47
54
  * RFC 0.5 §7's URL grammar — how an object is named in an address bar, and how
48
55
  * a pasted link is matched back to one.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,aAAa,EAIb,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,sBAAsB,EACtB,OAAO,EAEP,cAAc,EACd,oBAAoB,EACpB,eAAe,EAEf,SAAS,EAET,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EAEjB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,SAAS,EACT,kBAAkB,EAClB,qBAAqB,EAErB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EAmBnB,cAAc,GAEf,MAAM,iBAAiB,CAAA;AAExB;;;GAGG;AACH,OAAO,EAAE,SAAS,EAA+B,MAAM,cAAc,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD;;;GAGG;AACH,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,oBAAoB,GAGrB,MAAM,iBAAiB,CAAA;AAExB;;;;;GAKG;AACH,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,GAMd,MAAM,cAAc,CAAA;AAErB;;;;;;;GAOG;AACH,OAAO,EACL,OAAO,EACP,SAAS,EACT,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,cAAc,EACd,UAAU,GAGX,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,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AM,gBAAgB,CAAA"}
@@ -0,0 +1,100 @@
1
+ import { type LinkResolver, type PartPointer, type RenderBlock } from '@estiva-app/protocol';
2
+ import type { QueryFn } from './projection.js';
3
+ /** What one link names: an address or a message's event id, and the block when it links to one. */
4
+ export interface LinkAnswer {
5
+ value: string | null;
6
+ block?: PartPointer;
7
+ }
8
+ /** The comment a body is written in: its file and the message it replies to, which its tags never repeat as a mention. */
9
+ export interface OwnPlace {
10
+ /** The file the comment is on, `kind:pubkey:d`: its `A`, never also an `a` for a link to it. */
11
+ file?: string;
12
+ /** The event id it replies to: its `e`, never also a `q`. */
13
+ parent?: string;
14
+ }
15
+ export interface LinkReaderOptions {
16
+ /** A read as the viewer. Throws when the relay could not be asked. */
17
+ query: QueryFn;
18
+ /**
19
+ * The published manifests, `kind:31990` (§7.2). Omitted: one read of every
20
+ * manifest through `query`, kept for the reader's life and forgotten when it
21
+ * fails. An app that already holds them passes its own.
22
+ */
23
+ manifests?: () => Promise<readonly {
24
+ tags: string[][];
25
+ }[]>;
26
+ /** How many times a failed read is said as a change, after 5, 10, 20… seconds. Default 3; 0 says none. */
27
+ retries?: number;
28
+ }
29
+ export interface LinkReader {
30
+ /** What one link names; rejects when the relay could not be asked (and the next ask tries again). */
31
+ answerOf(url: string): Promise<LinkAnswer>;
32
+ /**
33
+ * Ask what each of these links names; settles when every answer is in, and
34
+ * rejects when a read failed (it left no answer), so a `LinkChips` forgets
35
+ * those links and asks again.
36
+ */
37
+ ask(urls: readonly string[]): Promise<void>;
38
+ /** What a link names, from what has come back: undefined until it has, and for nothing. A `LinkResolver`. */
39
+ known: LinkResolver;
40
+ /** The file and block a link to one block names, from what has come back. */
41
+ knownBlock(url: string): PartPointer | undefined;
42
+ /** Whether a link's answer has come back, naming something or nothing. */
43
+ answered(url: string): boolean;
44
+ /** Called each time an answer comes back, or a failed one may be asked again. Returns the unsubscribe. */
45
+ changed(listener: () => void): () => void;
46
+ /** How many times {@link changed} has fired: a snapshot for `useSyncExternalStore`. */
47
+ version(): number;
48
+ /**
49
+ * The `a`, `q` and `part` tags a body earns ({@link linkTagsOf}), asking
50
+ * first what its links name and waiting at most `waitMs` (default 5 s): a
51
+ * link not answered by then earns nothing, and the body keeps it.
52
+ */
53
+ tagsFor(blocks: readonly RenderBlock[], own: OwnPlace, options?: {
54
+ waitMs?: number;
55
+ edit?: boolean;
56
+ }): Promise<string[][]>;
57
+ /** {@link writtenOpenerOf} against the hosts the manifests read so far declare. */
58
+ opener(url: string | undefined, opens: string | undefined, origin: string): string | undefined;
59
+ /** Every host an app declares its paths on, as the manifests read so far said. */
60
+ declaredOrigins(): ReadonlySet<string>;
61
+ }
62
+ /** Wait for `work`, but no longer than `ms`; never rejects. */
63
+ export declare function within(work: Promise<unknown>, ms: number): Promise<void>;
64
+ /** How many links one body asks about, the first ones — as `LinkChips`' `limit`: each answer can cost a relay query. */
65
+ export declare const MAX_LINKS_ASKED = 24;
66
+ /** One link reader for an app: its relay reads, and the manifests it holds. */
67
+ export declare function linkReader(options: LinkReaderOptions): LinkReader;
68
+ /**
69
+ * Every link a body names something by, in the order it names them: the URLs
70
+ * {@link valuesIn} asks a `LinkResolver` about — bare, or a link on words'
71
+ * target, and none in code. What a sender asks about before it tags.
72
+ */
73
+ export declare function linksIn(blocks: readonly RenderBlock[]): string[];
74
+ /**
75
+ * The tags a message's body earns for what it names (§13.1, §13.6.1): an `a`
76
+ * per address and a `q` per message, by a `nostr:` reference or an app link
77
+ * `resolve` answers, in the order the body first names them; then one `part`
78
+ * per file a link to one of its blocks names, the first link's, when
79
+ * `blockOf` is given. The comment's own file earns neither an `a` nor a part
80
+ * (it is the `A`), and the message it replies to no `q` (it is the `e`).
81
+ *
82
+ * A send and an edit carry the same `a` and `q` set: an edit says what the
83
+ * message links now. An edit carries no `part` (pass no `blockOf`), and a
84
+ * person is never here: `p` and `urgent` stay as the send wrote them.
85
+ *
86
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-says-what-the-message-links-now.md
87
+ */
88
+ export declare function linkTagsOf(blocks: readonly RenderBlock[], own: OwnPlace, resolve: LinkResolver, blockOf?: (url: string) => PartPointer | undefined): string[][];
89
+ /**
90
+ * Where a card or chip written as a URL opens: the address as written, in the
91
+ * app it names (§7.7, LTX-6), so `leaf.estiva.app/issue/…` opens Leaf, not
92
+ * Ship. Undefined for anything but https, and for a host that is neither this
93
+ * app's (`origin`), the one its file opens on (`opens`), nor one an app
94
+ * declares: a card that draws one file never opens a site no app serves from
95
+ * (WBM-11 security review). The same rule in every app.
96
+ *
97
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-files-path-is-the-same-on-every-apps-host.md
98
+ */
99
+ export declare function writtenOpenerOf(url: string | undefined, opens: string | undefined, origin: string, declared: ReadonlySet<string>): string | undefined;
100
+ //# sourceMappingURL=links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAqB,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAE/G,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,mGAAmG;AACnG,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,CAAC,EAAE,WAAW,CAAA;CACpB;AAED,0HAA0H;AAC1H,MAAM,WAAW,QAAQ;IACvB,gGAAgG;IAChG,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,KAAK,EAAE,OAAO,CAAA;IACd;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,SAAS;QAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;KAAE,EAAE,CAAC,CAAA;IAC1D,0GAA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AAA;AAQjC,+EAA+E;AAC/E,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAgHjE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,EAAE,CAOhE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,GAAG,EAAE,QAAQ,EACb,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,WAAW,GAAG,SAAS,GACjD,MAAM,EAAE,EAAE,CAmBZ;AAQD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,SAAS,CASrJ"}
package/dist/links.js ADDED
@@ -0,0 +1,241 @@
1
+ /**
2
+ * What an app link names, once for every app — SPEC §7.7, §13.1, §13.6.2
3
+ * (PEEKM-7). The chip a pasted link becomes, the card under a comment, the
4
+ * block a link to one block shows, the `a` and `q` tags a send or an edit
5
+ * carries, and where a card written as a URL opens: Peek, Ship, Leaf and the
6
+ * agent each kept a copy of this, and they drifted (Leaf retried, Ship tagged
7
+ * a URL in code, only Leaf's opener was https only).
8
+ *
9
+ * A URL names an object when a published manifest's `urls` pattern claims its
10
+ * host and `<type>`, and then **one author** holds that `d`: the `#d` query
11
+ * asks for two, and a `d` two authors hold names nothing, so somebody
12
+ * publishing the same `(kind, d)` cannot put their object's card or its
13
+ * mention under a link to another's. Only an addressable kind is asked: a
14
+ * manifest anyone can publish could otherwise point a path at a kind where a
15
+ * `d` is no identity. A link to one block (`#block-<id>`) names its file, and
16
+ * the block is its part (§13.6.1). A URL that names an event names its id.
17
+ *
18
+ * Asked once per link for the reader's life: a link names the same object for
19
+ * as long as its owner's manifest does. A read that failed is forgotten, so the
20
+ * next ask tries again, and is said as a change after 5, 10 and 20 seconds so
21
+ * whoever still draws from it asks.
22
+ *
23
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-files-path-is-the-same-on-every-apps-host.md
24
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-says-what-the-message-links-now.md
25
+ */
26
+ import { MAX_PARTS } from '@estiva-app/conversation';
27
+ import { partTag, valuesIn } from '@estiva-app/protocol';
28
+ import { matchObjectUrl, urlPatternsOf } from './objectUrl.js';
29
+ /** Wait for `work`, but no longer than `ms`; never rejects. */
30
+ export async function within(work, ms) {
31
+ let timer;
32
+ await Promise.race([
33
+ work.then(() => { }, () => { }),
34
+ new Promise((resolve) => {
35
+ timer = setTimeout(resolve, ms);
36
+ }),
37
+ ]);
38
+ clearTimeout(timer);
39
+ }
40
+ /** How many links one body asks about, the first ones — as `LinkChips`' `limit`: each answer can cost a relay query. */
41
+ export const MAX_LINKS_ASKED = 24;
42
+ const EVENT_ID = /^[0-9a-f]{64}$/i;
43
+ const RETRY_MS = 5000;
44
+ /** NIP-89's handler information, where an app publishes its manifest and `urls` (§7.2). */
45
+ const KIND_APP_HANDLER = 31990;
46
+ /** One link reader for an app: its relay reads, and the manifests it holds. */
47
+ export function linkReader(options) {
48
+ const { query, retries = 3 } = options;
49
+ const origins = new Set();
50
+ let shapes = null;
51
+ const shapesOf = () => {
52
+ if (shapes)
53
+ return shapes;
54
+ const read = (options.manifests ?? (() => query([{ kinds: [KIND_APP_HANDLER], limit: 500 }])))().then((manifests) => {
55
+ const found = manifests.flatMap((manifest) => urlPatternsOf(manifest));
56
+ for (const shape of found) {
57
+ try {
58
+ origins.add(new URL(shape.pattern).origin);
59
+ }
60
+ catch {
61
+ // A shape that is not a URL declares no host.
62
+ }
63
+ }
64
+ return found;
65
+ });
66
+ shapes = read;
67
+ // A failed read must not poison the reader, nor an empty one (a relay still
68
+ // starting, a read before sign-in): the next link asks again.
69
+ read.then((found) => {
70
+ if (found.length === 0 && shapes === read)
71
+ shapes = null;
72
+ }, () => {
73
+ if (shapes === read)
74
+ shapes = null;
75
+ });
76
+ return read;
77
+ };
78
+ const answer = async (url) => {
79
+ const shapes = await shapesOf();
80
+ // No manifest read yet is no answer: kept as one, the link would name nothing for the reader's life.
81
+ if (shapes.length === 0)
82
+ throw new Error('No app manifest has been read yet.');
83
+ const hit = matchObjectUrl(url, shapes);
84
+ if (!hit)
85
+ return { value: null };
86
+ if (hit.by === 'id')
87
+ return { value: EVENT_ID.test(hit.identifier) ? hit.identifier.toLowerCase() : null };
88
+ // A path on another app's host can read as several kinds (§7.7, LTX-6): ask under each addressable one.
89
+ const kinds = (hit.kinds ?? (hit.kind === undefined ? undefined : [hit.kind]))?.filter((kind) => kind >= 30000 && kind < 40000);
90
+ if (kinds?.length === 0)
91
+ return { value: null };
92
+ // A shape that names no kind asks every one; only an addressable answer counts.
93
+ const found = (await query([{ '#d': [hit.identifier], limit: 2, ...(kinds ? { kinds } : {}) }])).filter((event) => event.kind >= 30000 && event.kind < 40000);
94
+ const authors = new Set(found.map((event) => `${event.kind}:${event.pubkey.toLowerCase()}`));
95
+ if (authors.size !== 1)
96
+ return { value: null };
97
+ const address = `${[...authors][0]}:${hit.identifier}`;
98
+ return hit.block === undefined ? { value: address } : { value: address, block: { address, block: hit.block } };
99
+ };
100
+ const asked = new Map();
101
+ const known = new Map();
102
+ const failures = new Map();
103
+ const listeners = new Set();
104
+ let answered = 0;
105
+ const changed = () => {
106
+ answered += 1;
107
+ for (const listener of listeners)
108
+ listener();
109
+ };
110
+ const answerOf = (url) => {
111
+ let pending = asked.get(url);
112
+ if (!pending) {
113
+ pending = answer(url).then((found) => {
114
+ known.set(url, found);
115
+ changed();
116
+ return found;
117
+ }, (error) => {
118
+ asked.delete(url);
119
+ const failed = failures.get(url) ?? 0;
120
+ failures.set(url, failed + 1);
121
+ if (failed < retries)
122
+ setTimeout(changed, RETRY_MS * 2 ** failed);
123
+ throw error;
124
+ });
125
+ asked.set(url, pending);
126
+ }
127
+ return pending;
128
+ };
129
+ const knownValue = (url) => known.get(url)?.value ?? undefined;
130
+ const knownBlock = (url) => known.get(url)?.block;
131
+ return {
132
+ answerOf,
133
+ async ask(urls) {
134
+ const waiting = [...new Set(urls)].filter((url) => !known.has(url));
135
+ await Promise.allSettled(waiting.map(answerOf));
136
+ if (waiting.some((url) => !known.has(url)))
137
+ throw new Error('A link could not be asked about; asked again later.');
138
+ },
139
+ known: knownValue,
140
+ knownBlock,
141
+ answered: (url) => known.has(url),
142
+ changed(listener) {
143
+ listeners.add(listener);
144
+ return () => {
145
+ listeners.delete(listener);
146
+ };
147
+ },
148
+ version: () => answered,
149
+ async tagsFor(blocks, own, { waitMs = 5000, edit = false } = {}) {
150
+ const urls = linksIn(blocks).slice(0, MAX_LINKS_ASKED);
151
+ const waiting = urls.filter((url) => !known.has(url));
152
+ if (waiting.length > 0)
153
+ await within(Promise.allSettled(waiting.map(answerOf)), waitMs);
154
+ const first = new Set(urls);
155
+ const resolve = (url) => (first.has(url) ? knownValue(url) : undefined);
156
+ return linkTagsOf(blocks, own, resolve, edit ? undefined : (url) => (first.has(url) ? knownBlock(url) : undefined));
157
+ },
158
+ opener: (url, opens, origin) => writtenOpenerOf(url, opens, origin, origins),
159
+ declaredOrigins: () => origins,
160
+ };
161
+ }
162
+ /**
163
+ * Every link a body names something by, in the order it names them: the URLs
164
+ * {@link valuesIn} asks a `LinkResolver` about — bare, or a link on words'
165
+ * target, and none in code. What a sender asks about before it tags.
166
+ */
167
+ export function linksIn(blocks) {
168
+ const urls = [];
169
+ valuesIn(blocks, (url) => {
170
+ urls.push(url);
171
+ return undefined;
172
+ });
173
+ return [...new Set(urls)];
174
+ }
175
+ /**
176
+ * The tags a message's body earns for what it names (§13.1, §13.6.1): an `a`
177
+ * per address and a `q` per message, by a `nostr:` reference or an app link
178
+ * `resolve` answers, in the order the body first names them; then one `part`
179
+ * per file a link to one of its blocks names, the first link's, when
180
+ * `blockOf` is given. The comment's own file earns neither an `a` nor a part
181
+ * (it is the `A`), and the message it replies to no `q` (it is the `e`).
182
+ *
183
+ * A send and an edit carry the same `a` and `q` set: an edit says what the
184
+ * message links now. An edit carries no `part` (pass no `blockOf`), and a
185
+ * person is never here: `p` and `urgent` stay as the send wrote them.
186
+ *
187
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-says-what-the-message-links-now.md
188
+ */
189
+ export function linkTagsOf(blocks, own, resolve, blockOf) {
190
+ const file = own.file && sameValue(own.file);
191
+ const parent = own.parent?.toLowerCase();
192
+ const tags = [];
193
+ for (const value of valuesIn(blocks, resolve)) {
194
+ if (EVENT_ID.test(value)) {
195
+ if (value !== parent)
196
+ tags.push(['q', value]);
197
+ }
198
+ else if (value !== file)
199
+ tags.push(['a', value]);
200
+ }
201
+ if (blockOf) {
202
+ const parts = new Map();
203
+ for (const url of linksIn(blocks)) {
204
+ const part = blockOf(url);
205
+ if (part && sameValue(part.address) !== file && !parts.has(part.address))
206
+ parts.set(part.address, part.block);
207
+ }
208
+ // As many as a box shows under it (conversation's `boxLinksOf`): a part the box did not draw is not sent.
209
+ for (const [address, block] of [...parts].slice(0, MAX_PARTS))
210
+ tags.push(partTag(address, block));
211
+ }
212
+ return tags;
213
+ }
214
+ /** An address as `valuesIn` spells it: the kind and pubkey as hex, the `d` as written. */
215
+ function sameValue(address) {
216
+ const [kind, pubkey = '', ...d] = address.split(':');
217
+ return `${kind}:${pubkey.toLowerCase()}:${d.join(':')}`;
218
+ }
219
+ /**
220
+ * Where a card or chip written as a URL opens: the address as written, in the
221
+ * app it names (§7.7, LTX-6), so `leaf.estiva.app/issue/…` opens Leaf, not
222
+ * Ship. Undefined for anything but https, and for a host that is neither this
223
+ * app's (`origin`), the one its file opens on (`opens`), nor one an app
224
+ * declares: a card that draws one file never opens a site no app serves from
225
+ * (WBM-11 security review). The same rule in every app.
226
+ *
227
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-files-path-is-the-same-on-every-apps-host.md
228
+ */
229
+ export function writtenOpenerOf(url, opens, origin, declared) {
230
+ if (!url || !/^https:\/\//i.test(url))
231
+ return undefined;
232
+ try {
233
+ const at = new URL(url).origin;
234
+ const opensAt = opens ? new URL(opens, origin).origin : undefined;
235
+ return at === origin || at === opensAt || declared.has(at) ? url : undefined;
236
+ }
237
+ catch {
238
+ return undefined;
239
+ }
240
+ }
241
+ //# sourceMappingURL=links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.js","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAyD,MAAM,sBAAsB,CAAA;AAC/G,OAAO,EAAE,cAAc,EAAE,aAAa,EAAmB,MAAM,gBAAgB,CAAA;AAkE/E,+DAA+D;AAC/D,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAsB,EAAE,EAAU;IAC7D,IAAI,KAAc,CAAA;IAClB,MAAM,OAAO,CAAC,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,CACP,GAAG,EAAE,GAAE,CAAC,EACR,GAAG,EAAE,GAAE,CAAC,CACT;QACD,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAC5B,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;QACjC,CAAC,CAAC;KACH,CAAC,CAAA;IACF,YAAY,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC;AAED,wHAAwH;AACxH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAA;AAEjC,MAAM,QAAQ,GAAG,iBAAiB,CAAA;AAClC,MAAM,QAAQ,GAAG,IAAI,CAAA;AAErB,2FAA2F;AAC3F,MAAM,gBAAgB,GAAG,KAAK,CAAA;AAE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AAI,IAAI,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;AACzD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,GAAuB,EAAE,KAAyB,EAAE,MAAc,EAAE,QAA6B;IAC/H,IAAI,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAA;IACvD,IAAI,CAAC;QACH,MAAM,EAAE,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAA;QAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;QACjE,OAAO,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,OAAO,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { type LinkResolver, type SignedEvent } from '@estiva-app/protocol';
2
+ import { type LinkReader } from './links.js';
3
+ import type { QueryFn } from './projection.js';
4
+ /** One message that mentions the file, as its latest words say. */
5
+ export interface MentionedIn {
6
+ /** The message as sent: a `kind:1111` comment or a `kind:9` message. Where it was said, its thread, its author. */
7
+ event: SignedEvent;
8
+ /** Its latest words: the latest edit's, or its own. */
9
+ body: string;
10
+ /** The latest edit, when there is one: its files and cards replace the message's (§6.8). */
11
+ edit?: SignedEvent;
12
+ }
13
+ /** Enough for a list that is scanned, not read; the oldest pointers are what a cap drops. */
14
+ export declare const MENTIONED_IN_LIMIT = 200;
15
+ /** The one filter for the candidates: every message, comment and edit pointing at the file. */
16
+ export declare function mentionedInFilter(address: string, limit?: number): Record<string, unknown>;
17
+ /**
18
+ * The messages among `events` that list under the file, newest first.
19
+ *
20
+ * `events` holds the candidates ({@link mentionedInFilter}), the messages their
21
+ * edits edit, and every edit of each message; `resolveLink` what the app links
22
+ * in their words name. `commentKinds` is the file's owner's comment kinds
23
+ * (`isCommentOn`): a message on the file itself is not a mention of it.
24
+ * `unanswered` says which links could not be asked about: a message whose
25
+ * latest version points at the file and holds one keeps its row until the
26
+ * link can be read, rather than lose it to a failed read.
27
+ */
28
+ export declare function mentionedInOf(events: readonly SignedEvent[], address: string, resolveLink?: LinkResolver, commentKinds?: readonly number[], unanswered?: (url: string) => boolean): MentionedIn[];
29
+ /**
30
+ * {@link mentionedInOf} as the viewer: the candidates, then the messages their
31
+ * edits edit and every edit of each message, then what the links in their
32
+ * latest words name, asked through `links` and waited for at most `waitMs`.
33
+ * Throws when a read is refused, so an unreadable relay and a file nobody
34
+ * mentions are not the same empty list.
35
+ */
36
+ export declare function readMentionedIn(query: QueryFn, address: string, options?: {
37
+ links?: LinkReader;
38
+ limit?: number;
39
+ waitMs?: number;
40
+ commentKinds?: readonly number[];
41
+ }): Promise<MentionedIn[]>;
42
+ //# sourceMappingURL=mentions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentions.d.ts","sourceRoot":"","sources":["../src/mentions.ts"],"names":[],"mappings":"AAkBA,OAAO,EAA0B,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClG,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE9C,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,mHAAmH;IACnH,KAAK,EAAE,WAAW,CAAA;IAClB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,4FAA4F;IAC5F,IAAI,CAAC,EAAE,WAAW,CAAA;CACnB;AAED,6FAA6F;AAC7F,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAErC,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEtG;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,YAAY,EAC1B,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,EAChC,UAAU,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAqB,GACjD,WAAW,EAAE,CAyBf;AAED;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,UAAU,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GACtG,OAAO,CAAC,WAAW,EAAE,CAAC,CAexB"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Where a file is mentioned — its "Mentioned in", once for every app (SPEC
3
+ * §6.4, §6.8, PEEKM-7). Peek's file panel and Ship's Activity each read it
4
+ * their own way: Peek dropped a row an edit took a `nostr:` reference out of,
5
+ * Ship kept every first version, and neither saw a link an edit added.
6
+ *
7
+ * A file lists a message while the message's **latest words** link it. The
8
+ * candidates are every message, comment and edit pointing at the file by `a`
9
+ * (an edit carries the `a` its new words earn); an edit stands for the message
10
+ * it edits; and each is confirmed against the folded body, by a `nostr:`
11
+ * reference or an app link that names the file. A message the reader cannot
12
+ * read lists nothing, whatever its edits point at. The file's own conversation
13
+ * is not a mention of it.
14
+ *
15
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/an-edit-says-what-the-message-links-now.md
16
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/activity-lists-only-mentions-from-elsewhere.md
17
+ */
18
+ import { anchorsOf, editsByTarget, editTargetOf, isCommentOn, KIND_COMMENT, KIND_EDIT, KIND_MESSAGE } from '@estiva-app/conversation';
19
+ import { toRenderTree, valuesIn } from '@estiva-app/protocol';
20
+ import { linksIn, within } from './links.js';
21
+ /** Enough for a list that is scanned, not read; the oldest pointers are what a cap drops. */
22
+ export const MENTIONED_IN_LIMIT = 200;
23
+ /** The one filter for the candidates: every message, comment and edit pointing at the file. */
24
+ export function mentionedInFilter(address, limit = MENTIONED_IN_LIMIT) {
25
+ return { kinds: [KIND_COMMENT, KIND_MESSAGE, KIND_EDIT], '#a': [address], limit };
26
+ }
27
+ const isMessage = (event) => event.kind === KIND_COMMENT || event.kind === KIND_MESSAGE;
28
+ /**
29
+ * The messages among `events` that list under the file, newest first.
30
+ *
31
+ * `events` holds the candidates ({@link mentionedInFilter}), the messages their
32
+ * edits edit, and every edit of each message; `resolveLink` what the app links
33
+ * in their words name. `commentKinds` is the file's owner's comment kinds
34
+ * (`isCommentOn`): a message on the file itself is not a mention of it.
35
+ * `unanswered` says which links could not be asked about: a message whose
36
+ * latest version points at the file and holds one keeps its row until the
37
+ * link can be read, rather than lose it to a failed read.
38
+ */
39
+ export function mentionedInOf(events, address, resolveLink, commentKinds, unanswered = () => false) {
40
+ const messages = new Map();
41
+ for (const event of events)
42
+ if (isMessage(event))
43
+ messages.set(event.id.toLowerCase(), event);
44
+ const edits = editsByTarget(events);
45
+ const pointed = new Set();
46
+ for (const event of events) {
47
+ if (!event.tags.some((t) => t[0] === 'a' && t[1] === address))
48
+ continue;
49
+ const id = event.kind === KIND_EDIT ? editTargetOf(event) : isMessage(event) ? event.id.toLowerCase() : undefined;
50
+ if (id)
51
+ pointed.add(id);
52
+ }
53
+ const file = valueOf(address);
54
+ const out = [];
55
+ for (const id of pointed) {
56
+ const event = messages.get(id);
57
+ if (!event)
58
+ continue;
59
+ if (anchorsOf(event).includes(address) || isCommentOn(event, address, commentKinds))
60
+ continue;
61
+ // An edit by anyone but the author is not the message's (the relay refuses one; a reader does not trust that).
62
+ const edit = edits.get(id)?.filter((e) => e.pubkey === event.pubkey).at(-1);
63
+ const body = edit?.content ?? event.content;
64
+ const tree = toRenderTree(body, 'marker');
65
+ const pointsNow = (edit ?? event).tags.some((t) => t[0] === 'a' && t[1] === address);
66
+ if (!valuesIn(tree, resolveLink).includes(file) && !(pointsNow && linksIn(tree).some(unanswered)))
67
+ continue;
68
+ out.push(edit ? { event, body, edit } : { event, body });
69
+ }
70
+ return out.sort((a, b) => b.event.created_at - a.event.created_at);
71
+ }
72
+ /**
73
+ * {@link mentionedInOf} as the viewer: the candidates, then the messages their
74
+ * edits edit and every edit of each message, then what the links in their
75
+ * latest words name, asked through `links` and waited for at most `waitMs`.
76
+ * Throws when a read is refused, so an unreadable relay and a file nobody
77
+ * mentions are not the same empty list.
78
+ */
79
+ export async function readMentionedIn(query, address, options = {}) {
80
+ const candidates = await query([mentionedInFilter(address, options.limit)]);
81
+ const held = new Set(candidates.filter(isMessage).map((e) => e.id.toLowerCase()));
82
+ const missing = [...new Set(candidates.filter((e) => e.kind === KIND_EDIT).map(editTargetOf))].filter((id) => !!id && !held.has(id));
83
+ const targets = missing.length ? await query([{ ids: missing, kinds: [KIND_COMMENT, KIND_MESSAGE] }]) : [];
84
+ const ids = [...held, ...targets.map((e) => e.id.toLowerCase())];
85
+ const edits = ids.length ? await query([{ kinds: [KIND_EDIT], '#e': ids, limit: 1000 }]) : [];
86
+ const events = [...candidates, ...targets, ...edits];
87
+ const links = options.links;
88
+ if (!links)
89
+ return mentionedInOf(events, address, undefined, options.commentKinds, () => true);
90
+ // Every link in a candidate's latest words: read as if each named the file, so each candidate holding one is kept to ask.
91
+ const urls = [...new Set(mentionedInOf(events, address, () => address, options.commentKinds).flatMap((m) => linksIn(toRenderTree(m.body, 'marker'))))];
92
+ const waiting = urls.filter((url) => !links.answered(url));
93
+ if (waiting.length)
94
+ await within(links.ask(waiting), options.waitMs ?? 5000);
95
+ return mentionedInOf(events, address, links.known, options.commentKinds, (url) => !links.answered(url));
96
+ }
97
+ /** The address as `valuesIn` spells it. */
98
+ function valueOf(address) {
99
+ const [kind, pubkey = '', ...d] = address.split(':');
100
+ return `${kind}:${pubkey.toLowerCase()}:${d.join(':')}`;
101
+ }
102
+ //# sourceMappingURL=mentions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mentions.js","sourceRoot":"","sources":["../src/mentions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACrI,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAuC,MAAM,sBAAsB,CAAA;AAClG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAmB,MAAM,YAAY,CAAA;AAa7D,6FAA6F;AAC7F,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAA;AAErC,+FAA+F;AAC/F,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,KAAK,GAAG,kBAAkB;IAC3E,OAAO,EAAE,KAAK,EAAE,CAAC,YAAY,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAA;AACnF,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAA;AAEpG;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAC3B,MAA8B,EAC9B,OAAe,EACf,WAA0B,EAC1B,YAAgC,EAChC,aAAuC,GAAG,EAAE,CAAC,KAAK;IAElD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAuB,CAAA;IAC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face ActionEventArgs {
1686
1686
  author: string;
1687
1687
  place?: readonly string[][];
1688
1688
  };
1689
+ /**
1690
+ * The `a`, `q` and `part` tags a comment's body earns for what it names, by a
1691
+ * `nostr:` reference or an app link — {@link LinkReader.tagsFor}, asked by
1692
+ * the caller, which holds the relay (SPEC §13.1). Only for `comment`; any
1693
+ * other tag here is left out, and so is one naming the comment's own file or
1694
+ * the comment it answers.
1695
+ */
1696
+ linkTags?: readonly string[][];
1689
1697
  /**
1690
1698
  * The format the action's prose value is in, when it is not marker text —
1691
1699
  * `'estiva-blocks-1'` for a block document (SPEC §7.3's `format`, MAN-1).