@semiont/core 0.5.23 → 0.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/chunk-FMFOBVTE.js +334 -0
- package/dist/chunk-FMFOBVTE.js.map +1 -0
- package/dist/chunk-I3ZOWCTH.js +143 -0
- package/dist/chunk-I3ZOWCTH.js.map +1 -0
- package/dist/chunk-XQTWEBJ5.js +293 -0
- package/dist/chunk-XQTWEBJ5.js.map +1 -0
- package/dist/config/node-config-loader.d.ts +44 -11
- package/dist/config/node-config-loader.js +20 -294
- package/dist/config/node-config-loader.js.map +1 -1
- package/dist/index.d.ts +707 -6
- package/dist/index.js +245 -627
- package/dist/index.js.map +1 -1
- package/dist/testing/axioms.d.ts +180 -0
- package/dist/testing/axioms.js +365 -0
- package/dist/testing/axioms.js.map +1 -0
- package/dist/testing.d.ts +16 -178
- package/dist/testing.js +2 -761
- package/dist/testing.js.map +1 -1
- package/package.json +8 -3
package/dist/index.d.ts
CHANGED
|
@@ -1540,6 +1540,242 @@ interface paths {
|
|
|
1540
1540
|
patch?: never;
|
|
1541
1541
|
trace?: never;
|
|
1542
1542
|
};
|
|
1543
|
+
"/resources/{id}/anchored-text": {
|
|
1544
|
+
parameters: {
|
|
1545
|
+
query?: never;
|
|
1546
|
+
header?: never;
|
|
1547
|
+
path?: never;
|
|
1548
|
+
cookie?: never;
|
|
1549
|
+
};
|
|
1550
|
+
/**
|
|
1551
|
+
* Get a resource's anchored text
|
|
1552
|
+
* @description The coordinate map derived from a resource's bytes: its recovered text plus the positioned runs that index it. Assembled via the bus gateway.
|
|
1553
|
+
*
|
|
1554
|
+
* Whole-resource, not paginated — a producer iterates page by page, but every consumer wants one map: a browser quoting the text under a hand-drawn rectangle, a headless client analysing a document.
|
|
1555
|
+
*
|
|
1556
|
+
* This endpoint never runs recognition. The Smelter is the sole producer and publishes at ingest; a read that finds nothing waits for that resource's content generation to settle and then answers 204. A 204 is the common case and not an error — a native text layer is read in the browser, and a media type with no extractor never produces a map at all. Callers degrade: for a PDF annotation that means geometry with no quoted text.
|
|
1557
|
+
*/
|
|
1558
|
+
get: {
|
|
1559
|
+
parameters: {
|
|
1560
|
+
query?: never;
|
|
1561
|
+
header?: never;
|
|
1562
|
+
path: {
|
|
1563
|
+
id: string;
|
|
1564
|
+
};
|
|
1565
|
+
cookie?: never;
|
|
1566
|
+
};
|
|
1567
|
+
requestBody?: never;
|
|
1568
|
+
responses: {
|
|
1569
|
+
/** @description The stored extraction outcome: the coordinate map with its provenance (method, PDF class, OCR confidence, unread pages), or a named decline. */
|
|
1570
|
+
200: {
|
|
1571
|
+
headers: {
|
|
1572
|
+
[name: string]: unknown;
|
|
1573
|
+
};
|
|
1574
|
+
content: {
|
|
1575
|
+
"application/json": components["schemas"]["ExtractionOutcome"];
|
|
1576
|
+
};
|
|
1577
|
+
};
|
|
1578
|
+
/** @description No map has been derived for this resource. The ordinary answer for a native text layer or a media type with no extractor — not an error, and distinct from 404, which means the resource itself is absent. Carried as an empty body rather than a JSON `null` body so that a generated client's typed 200 field stays absent: unmarshalling `null` into a struct is a no-op in several languages, which would make "no map" indistinguishable from an empty one. */
|
|
1579
|
+
204: {
|
|
1580
|
+
headers: {
|
|
1581
|
+
[name: string]: unknown;
|
|
1582
|
+
};
|
|
1583
|
+
content?: never;
|
|
1584
|
+
};
|
|
1585
|
+
/** @description Resource not found */
|
|
1586
|
+
404: {
|
|
1587
|
+
headers: {
|
|
1588
|
+
[name: string]: unknown;
|
|
1589
|
+
};
|
|
1590
|
+
content: {
|
|
1591
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1592
|
+
};
|
|
1593
|
+
};
|
|
1594
|
+
/** @description Request timed out (bus gateway) */
|
|
1595
|
+
504: {
|
|
1596
|
+
headers: {
|
|
1597
|
+
[name: string]: unknown;
|
|
1598
|
+
};
|
|
1599
|
+
content: {
|
|
1600
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1601
|
+
};
|
|
1602
|
+
};
|
|
1603
|
+
};
|
|
1604
|
+
};
|
|
1605
|
+
put?: never;
|
|
1606
|
+
post?: never;
|
|
1607
|
+
delete?: never;
|
|
1608
|
+
options?: never;
|
|
1609
|
+
head?: never;
|
|
1610
|
+
patch?: never;
|
|
1611
|
+
trace?: never;
|
|
1612
|
+
};
|
|
1613
|
+
"/anchored-text/keys": {
|
|
1614
|
+
parameters: {
|
|
1615
|
+
query?: never;
|
|
1616
|
+
header?: never;
|
|
1617
|
+
path?: never;
|
|
1618
|
+
cookie?: never;
|
|
1619
|
+
};
|
|
1620
|
+
/**
|
|
1621
|
+
* List the keys under which anchored text is currently stored
|
|
1622
|
+
* @description The anchored-text store's would-hit keys — the reconcile planner's bulk existence read (PERSIST-ANCHORS P0). The Smelter diffs this against the catalog to find resources whose derived coordinate map was lost (a transient store, a failed publish) and plans re-derivation; one request per reconcile, keys only, because each map is ~32 KB per scanned page and only presence is being asked.
|
|
1623
|
+
*
|
|
1624
|
+
* Keys are resource ids today; after PERSIST-ANCHORS P1 they are content checksums. Only entries a read would actually serve are listed — stale-stamped or unreadable entries are excluded, exactly as a read would exclude them.
|
|
1625
|
+
*
|
|
1626
|
+
* Agents only: this is projection-maintenance planning data, same trust boundary as publishing a map.
|
|
1627
|
+
*/
|
|
1628
|
+
get: {
|
|
1629
|
+
parameters: {
|
|
1630
|
+
query?: never;
|
|
1631
|
+
header?: never;
|
|
1632
|
+
path?: never;
|
|
1633
|
+
cookie?: never;
|
|
1634
|
+
};
|
|
1635
|
+
requestBody?: never;
|
|
1636
|
+
responses: {
|
|
1637
|
+
/** @description Every key under which anchored text would currently be served. */
|
|
1638
|
+
200: {
|
|
1639
|
+
headers: {
|
|
1640
|
+
[name: string]: unknown;
|
|
1641
|
+
};
|
|
1642
|
+
content: {
|
|
1643
|
+
"application/json": {
|
|
1644
|
+
keys: string[];
|
|
1645
|
+
};
|
|
1646
|
+
};
|
|
1647
|
+
};
|
|
1648
|
+
/** @description Caller is not an agent */
|
|
1649
|
+
403: {
|
|
1650
|
+
headers: {
|
|
1651
|
+
[name: string]: unknown;
|
|
1652
|
+
};
|
|
1653
|
+
content: {
|
|
1654
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1655
|
+
};
|
|
1656
|
+
};
|
|
1657
|
+
};
|
|
1658
|
+
};
|
|
1659
|
+
put?: never;
|
|
1660
|
+
post?: never;
|
|
1661
|
+
delete?: never;
|
|
1662
|
+
options?: never;
|
|
1663
|
+
head?: never;
|
|
1664
|
+
patch?: never;
|
|
1665
|
+
trace?: never;
|
|
1666
|
+
};
|
|
1667
|
+
"/anchored-text/{checksum}": {
|
|
1668
|
+
parameters: {
|
|
1669
|
+
query?: never;
|
|
1670
|
+
header?: never;
|
|
1671
|
+
path?: never;
|
|
1672
|
+
cookie?: never;
|
|
1673
|
+
};
|
|
1674
|
+
/**
|
|
1675
|
+
* Read a representation's stored extraction outcome by content checksum
|
|
1676
|
+
* @description The cache-consult read (PERSIST-ANCHORS P2c): the extraction seam asks "has this exact byte content already been extracted?" — and every cache consumer runs out of process (the smelter worker, the detection workers), so the consult must cross the wire or the cache is write-only from exactly the processes it exists to serve.
|
|
1677
|
+
*
|
|
1678
|
+
* Checksum-addressed and barrier-free, deliberately: presence at this instant is the question, the same semantics as the keys listing. The read-your-writes settle barrier belongs to the resource-addressed reader (GET /resources/{id}/anchored-text), which resolves a mutable resource id through the view index; a caller holding the checksum already holds the content identity and needs no resolution and no wait.
|
|
1679
|
+
*
|
|
1680
|
+
* Agents only — projection-maintenance traffic, the same trust boundary as the PUT beside it.
|
|
1681
|
+
*/
|
|
1682
|
+
get: {
|
|
1683
|
+
parameters: {
|
|
1684
|
+
query?: never;
|
|
1685
|
+
header?: never;
|
|
1686
|
+
path: {
|
|
1687
|
+
/** @description Hex SHA-256 checksum of the representation bytes. */
|
|
1688
|
+
checksum: string;
|
|
1689
|
+
};
|
|
1690
|
+
cookie?: never;
|
|
1691
|
+
};
|
|
1692
|
+
requestBody?: never;
|
|
1693
|
+
responses: {
|
|
1694
|
+
/** @description The stored extraction outcome — a success with provenance, or a cached decline. */
|
|
1695
|
+
200: {
|
|
1696
|
+
headers: {
|
|
1697
|
+
[name: string]: unknown;
|
|
1698
|
+
};
|
|
1699
|
+
content: {
|
|
1700
|
+
"application/json": components["schemas"]["ExtractionOutcome"];
|
|
1701
|
+
};
|
|
1702
|
+
};
|
|
1703
|
+
/** @description No entry under this checksum. The ordinary cache miss — carried as an empty body rather than a JSON null for the same generated-client reason as the resource-addressed GET. */
|
|
1704
|
+
204: {
|
|
1705
|
+
headers: {
|
|
1706
|
+
[name: string]: unknown;
|
|
1707
|
+
};
|
|
1708
|
+
content?: never;
|
|
1709
|
+
};
|
|
1710
|
+
/** @description Caller is not an agent */
|
|
1711
|
+
403: {
|
|
1712
|
+
headers: {
|
|
1713
|
+
[name: string]: unknown;
|
|
1714
|
+
};
|
|
1715
|
+
content: {
|
|
1716
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1717
|
+
};
|
|
1718
|
+
};
|
|
1719
|
+
};
|
|
1720
|
+
};
|
|
1721
|
+
/**
|
|
1722
|
+
* Publish anchored text for a representation, keyed by its content checksum
|
|
1723
|
+
* @description Store the coordinate map derived from a representation's bytes, under the SHA-256 checksum of those bytes (PERSIST-ANCHORS decision A: one artifact per representation, and a representation is its bytes). The producer supplies the checksum because it alone knows which bytes it actually read — deriving the key server-side from the resource's current representation would file old geometry under a new checksum when a byte change races the publish, and that entry would read as present to the reconcile planner forever. Reads remain resource-addressed (GET /resources/{id}/anchored-text); the server resolves the resource to its current representation's checksum.
|
|
1724
|
+
*
|
|
1725
|
+
* The Smelter is the sole producer: it is the only process that reads those bytes at ingest, so it is the only one positioned to derive a map cheaply, and it runs separately from the backend.
|
|
1726
|
+
*
|
|
1727
|
+
* Agents only. A map is derived data every consumer trusts to place annotation geometry, so a browser session must not be able to write one.
|
|
1728
|
+
*/
|
|
1729
|
+
put: {
|
|
1730
|
+
parameters: {
|
|
1731
|
+
query?: never;
|
|
1732
|
+
header?: never;
|
|
1733
|
+
path: {
|
|
1734
|
+
/** @description Hex SHA-256 checksum of the representation bytes the map was derived from. */
|
|
1735
|
+
checksum: string;
|
|
1736
|
+
};
|
|
1737
|
+
cookie?: never;
|
|
1738
|
+
};
|
|
1739
|
+
requestBody: {
|
|
1740
|
+
content: {
|
|
1741
|
+
"application/json": components["schemas"]["ExtractionOutcome"];
|
|
1742
|
+
};
|
|
1743
|
+
};
|
|
1744
|
+
responses: {
|
|
1745
|
+
/** @description Stored */
|
|
1746
|
+
204: {
|
|
1747
|
+
headers: {
|
|
1748
|
+
[name: string]: unknown;
|
|
1749
|
+
};
|
|
1750
|
+
content?: never;
|
|
1751
|
+
};
|
|
1752
|
+
/** @description Body is not a valid ExtractionOutcome */
|
|
1753
|
+
400: {
|
|
1754
|
+
headers: {
|
|
1755
|
+
[name: string]: unknown;
|
|
1756
|
+
};
|
|
1757
|
+
content: {
|
|
1758
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1759
|
+
};
|
|
1760
|
+
};
|
|
1761
|
+
/** @description Caller is not an agent */
|
|
1762
|
+
403: {
|
|
1763
|
+
headers: {
|
|
1764
|
+
[name: string]: unknown;
|
|
1765
|
+
};
|
|
1766
|
+
content: {
|
|
1767
|
+
"application/json": components["schemas"]["ErrorResponse"];
|
|
1768
|
+
};
|
|
1769
|
+
};
|
|
1770
|
+
};
|
|
1771
|
+
};
|
|
1772
|
+
post?: never;
|
|
1773
|
+
delete?: never;
|
|
1774
|
+
options?: never;
|
|
1775
|
+
head?: never;
|
|
1776
|
+
patch?: never;
|
|
1777
|
+
trace?: never;
|
|
1778
|
+
};
|
|
1543
1779
|
"/resources/{id}/jsonld": {
|
|
1544
1780
|
parameters: {
|
|
1545
1781
|
query?: never;
|
|
@@ -2069,6 +2305,36 @@ interface components {
|
|
|
2069
2305
|
oldIndex: number;
|
|
2070
2306
|
newIndex: number;
|
|
2071
2307
|
};
|
|
2308
|
+
/** @description Text paired with the geometry that indexes it — the minimum needed to turn a character range into a selection, or a rectangle into a quote. Whole-resource: a producer iterates page by page, but every consumer wants one map. */
|
|
2309
|
+
AnchoredText: {
|
|
2310
|
+
/** @description Reading-order text of the whole resource. */
|
|
2311
|
+
text: string;
|
|
2312
|
+
/** @description Positioned runs indexing `text`, roughly one per word. */
|
|
2313
|
+
items: components["schemas"]["PdfTextItem"][];
|
|
2314
|
+
};
|
|
2315
|
+
/** @description One positioned text run. Coordinates are PDF points with the origin at the bottom-left of the page, Y increasing upward; the flip to canvas pixels happens in the browser. */
|
|
2316
|
+
PdfTextItem: {
|
|
2317
|
+
/** @description Char offset into AnchoredText.text, inclusive. */
|
|
2318
|
+
start: number;
|
|
2319
|
+
/** @description Char offset into AnchoredText.text, exclusive. */
|
|
2320
|
+
end: number;
|
|
2321
|
+
/** @description 1-indexed page number. */
|
|
2322
|
+
page: number;
|
|
2323
|
+
x: number;
|
|
2324
|
+
y: number;
|
|
2325
|
+
width: number;
|
|
2326
|
+
height: number;
|
|
2327
|
+
};
|
|
2328
|
+
/** @description Request a resource's derived coordinate map — the text recovered from its bytes plus the geometry indexing it. Read-only: the Smelter is the sole producer and publishes through the content transport, never over this channel. */
|
|
2329
|
+
BrowseAnchoredTextRequest: {
|
|
2330
|
+
correlationId: string;
|
|
2331
|
+
resourceId: string;
|
|
2332
|
+
};
|
|
2333
|
+
/** @description A resource's stored extraction outcome — the coordinate map with its provenance, or a named decline — or null when none has been derived. Null is the common case and not an error: a native text layer is read in the browser, and a media type with no extractor never produces one. */
|
|
2334
|
+
BrowseAnchoredTextResult: {
|
|
2335
|
+
correlationId: string;
|
|
2336
|
+
response: components["schemas"]["ExtractionOutcome"] | null;
|
|
2337
|
+
};
|
|
2072
2338
|
/** @description Request to browse a single resource */
|
|
2073
2339
|
BrowseResourceRequest: {
|
|
2074
2340
|
correlationId: string;
|
|
@@ -2303,6 +2569,35 @@ interface components {
|
|
|
2303
2569
|
data: string;
|
|
2304
2570
|
id?: string;
|
|
2305
2571
|
};
|
|
2572
|
+
/** @description The full outcome of text extraction for one representation — the record the anchored-text store holds and the wire serves (PERSIST-ANCHORS decision D1). Either a success (the anchored text plus its provenance: how it was extracted, what class of PDF it came from, how confident OCR was, which pages could not be read) or a named decline. A decline is a first-class, cacheable outcome: 'we ran and there was nothing' costs a full recognition pass to discover. ocrConfidence is extraction quality for operators, deliberately not anchor confidence. */
|
|
2573
|
+
ExtractionOutcome: (components["schemas"]["AnchoredText"] & {
|
|
2574
|
+
/**
|
|
2575
|
+
* @description How the text was extracted.
|
|
2576
|
+
* @enum {string}
|
|
2577
|
+
*/
|
|
2578
|
+
method: "text-passthrough" | "pdf-text-layer" | "table" | "form" | "ocr";
|
|
2579
|
+
/**
|
|
2580
|
+
* @description PDF classification, when the source was a PDF.
|
|
2581
|
+
* @enum {string}
|
|
2582
|
+
*/
|
|
2583
|
+
pdfClass?: "A" | "B" | "C" | "D" | "E" | "F" | "G";
|
|
2584
|
+
/** @description How well the engine read the pixels, when any of this text came from OCR. */
|
|
2585
|
+
ocrConfidence?: {
|
|
2586
|
+
/** @description Mean per-word confidence, 0-100. */
|
|
2587
|
+
mean: number;
|
|
2588
|
+
/** @description Words the engine was unsure of. */
|
|
2589
|
+
lowConfidenceWords: number;
|
|
2590
|
+
totalWords: number;
|
|
2591
|
+
};
|
|
2592
|
+
/** @description 1-indexed pages this extraction could not read — present only for partially covered documents (class C). */
|
|
2593
|
+
unreadPages?: number[];
|
|
2594
|
+
}) | {
|
|
2595
|
+
/**
|
|
2596
|
+
* @description Why extraction yielded nothing, by class.
|
|
2597
|
+
* @enum {string}
|
|
2598
|
+
*/
|
|
2599
|
+
declined: "no-text-layer" | "encrypted" | "corrupt" | "too-large";
|
|
2600
|
+
};
|
|
2306
2601
|
FileEntry: {
|
|
2307
2602
|
/** @enum {string} */
|
|
2308
2603
|
type: "file";
|
|
@@ -2647,6 +2942,21 @@ interface components {
|
|
|
2647
2942
|
annotationId?: string;
|
|
2648
2943
|
error: string;
|
|
2649
2944
|
};
|
|
2945
|
+
/** @description Result of a job that completed without doing its work because the resource could not be read. Distinct from a failure: nothing went wrong, there was simply no text to work with — an encrypted or damaged PDF, a scan whose text could not be recognized, or a document that yielded nothing. The reasons are the extraction vocabulary the Smelter reports on `smelt:settled`, MINUS `no-extractor`: a media type that can never yield text (a zip, an image) is a bad request rather than a decline, so a worker asked to detect over one throws and the job reports `job:fail`. Everything here is a resource-specific outcome — the same media type would have succeeded on a different document. */
|
|
2946
|
+
JobDeclinedResult: {
|
|
2947
|
+
/**
|
|
2948
|
+
* @description Discriminant. Always true — a job that did its work reports one of the other result shapes.
|
|
2949
|
+
* @enum {boolean}
|
|
2950
|
+
*/
|
|
2951
|
+
declined: true;
|
|
2952
|
+
/**
|
|
2953
|
+
* @description Why the resource could not be read.
|
|
2954
|
+
* @enum {string}
|
|
2955
|
+
*/
|
|
2956
|
+
reason: "no-text-layer" | "encrypted" | "corrupt" | "too-large" | "empty";
|
|
2957
|
+
/** @description Human-readable explanation, suitable for showing to the user. */
|
|
2958
|
+
message: string;
|
|
2959
|
+
};
|
|
2650
2960
|
/** @description Payload for job:failed domain event */
|
|
2651
2961
|
JobFailedPayload: {
|
|
2652
2962
|
jobId: string;
|
|
@@ -2752,7 +3062,7 @@ interface components {
|
|
|
2752
3062
|
progress?: components["schemas"]["JobProgress"];
|
|
2753
3063
|
};
|
|
2754
3064
|
/** @description Discriminated union of all job result types. */
|
|
2755
|
-
JobResult: components["schemas"]["JobGenerationResult"] | components["schemas"]["JobReferenceAnnotationResult"] | components["schemas"]["JobHighlightAnnotationResult"] | components["schemas"]["JobAssessmentAnnotationResult"] | components["schemas"]["JobCommentAnnotationResult"] | components["schemas"]["JobTagAnnotationResult"];
|
|
3065
|
+
JobResult: components["schemas"]["JobGenerationResult"] | components["schemas"]["JobReferenceAnnotationResult"] | components["schemas"]["JobHighlightAnnotationResult"] | components["schemas"]["JobAssessmentAnnotationResult"] | components["schemas"]["JobCommentAnnotationResult"] | components["schemas"]["JobTagAnnotationResult"] | components["schemas"]["JobDeclinedResult"];
|
|
2756
3066
|
/** @description Command to start a job */
|
|
2757
3067
|
JobStartCommand: {
|
|
2758
3068
|
/** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
|
|
@@ -3225,6 +3535,8 @@ interface components {
|
|
|
3225
3535
|
score: number;
|
|
3226
3536
|
/** @description Entity types on the matched passage */
|
|
3227
3537
|
entityTypes?: string[];
|
|
3538
|
+
/** @description True when this passage's text was recognized from pixels (OCR of a scanned page) rather than read from the document. Absent means read directly — the common case — so the flag is only present where it changes how the text should be trusted. It travels with the passage because a consumer receives the chunk with no document attached and cannot recompute how the text was obtained. */
|
|
3539
|
+
machineRead?: boolean;
|
|
3228
3540
|
};
|
|
3229
3541
|
/** @description Emitted when the hover delay setting changes */
|
|
3230
3542
|
SettingsHoverDelayChangedEvent: {
|
|
@@ -3397,6 +3709,15 @@ interface components {
|
|
|
3397
3709
|
/** @description The validated JWT token string for the current session */
|
|
3398
3710
|
token: string;
|
|
3399
3711
|
};
|
|
3712
|
+
/** @description Bus command to rebuild anchored-text artifacts by re-running extraction — every geometry-capable resource when resourceId is absent, one resource when present. Served by the Smelter, serialized (each unit can be a multi-second OCR pass), and never destructive: nothing is deleted first, stale entries are simply overwritten. Re-anchoring makes zero embedding calls — the vectors are already correct; only the derived map is re-made. Partial completion replies failed, with counts: a rebuild that quietly skipped resources would present exactly like a document with no text. */
|
|
3713
|
+
SmeltRebuildAnchorsCommand: {
|
|
3714
|
+
/** @description Correlation id for request/reply matching, set by busRequest so the ok/failed reply routes back. */
|
|
3715
|
+
correlationId?: string;
|
|
3716
|
+
/** @description When present, re-anchor only this resource; otherwise every geometry-capable resource in the catalog. */
|
|
3717
|
+
resourceId?: string;
|
|
3718
|
+
/** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
|
|
3719
|
+
_userId?: string;
|
|
3720
|
+
};
|
|
3400
3721
|
/** @description Bus command to rebuild the graph projection from the event log — the whole graph when resourceId is absent, one resource when present. Served by the Weaver; replaces direct rebuild access, which does not survive the Weaver's container split. */
|
|
3401
3722
|
WeaveRebuildCommand: {
|
|
3402
3723
|
/** @description Correlation id for request/reply matching, set by busRequest so the ok/failed reply routes back. */
|
|
@@ -4012,6 +4333,14 @@ type EventMap = {
|
|
|
4012
4333
|
'browse:resource-failed': {
|
|
4013
4334
|
correlationId: string;
|
|
4014
4335
|
} & components['schemas']['CommandError'];
|
|
4336
|
+
'browse:anchored-text-requested': components['schemas']['BrowseAnchoredTextRequest'];
|
|
4337
|
+
'browse:anchored-text-result': {
|
|
4338
|
+
correlationId: string;
|
|
4339
|
+
response: components['schemas']['ExtractionOutcome'] | null;
|
|
4340
|
+
};
|
|
4341
|
+
'browse:anchored-text-failed': {
|
|
4342
|
+
correlationId: string;
|
|
4343
|
+
} & components['schemas']['CommandError'];
|
|
4015
4344
|
'browse:resources-requested': components['schemas']['BrowseResourcesRequest'];
|
|
4016
4345
|
'browse:resources-result': {
|
|
4017
4346
|
correlationId: string;
|
|
@@ -4160,6 +4489,7 @@ type EventMap = {
|
|
|
4160
4489
|
resourceId: string;
|
|
4161
4490
|
contentChecksum: string;
|
|
4162
4491
|
outcome: 'indexed' | 'skipped';
|
|
4492
|
+
reason?: 'no-extractor' | 'empty' | 'no-text-layer' | 'encrypted' | 'corrupt' | 'too-large';
|
|
4163
4493
|
};
|
|
4164
4494
|
'weave:rebuild': components['schemas']['WeaveRebuildCommand'];
|
|
4165
4495
|
'weave:rebuild-ok': {
|
|
@@ -4169,6 +4499,14 @@ type EventMap = {
|
|
|
4169
4499
|
correlationId?: string;
|
|
4170
4500
|
message: string;
|
|
4171
4501
|
};
|
|
4502
|
+
'smelt:rebuild-anchors': components['schemas']['SmeltRebuildAnchorsCommand'];
|
|
4503
|
+
'smelt:rebuild-anchors-ok': {
|
|
4504
|
+
correlationId?: string;
|
|
4505
|
+
};
|
|
4506
|
+
'smelt:rebuild-anchors-failed': {
|
|
4507
|
+
correlationId?: string;
|
|
4508
|
+
message: string;
|
|
4509
|
+
};
|
|
4172
4510
|
'settings:theme-changed': components['schemas']['SettingsThemeChangedEvent'];
|
|
4173
4511
|
'settings:line-numbers-toggled': void;
|
|
4174
4512
|
'settings:locale-changed': components['schemas']['SettingsLocaleChangedEvent'];
|
|
@@ -4350,6 +4688,9 @@ declare const CHANNEL_SCHEMAS: {
|
|
|
4350
4688
|
readonly 'browse:resource-requested': "BrowseResourceRequest";
|
|
4351
4689
|
readonly 'browse:resource-result': "BrowseResourceResult";
|
|
4352
4690
|
readonly 'browse:resource-failed': null;
|
|
4691
|
+
readonly 'browse:anchored-text-requested': "BrowseAnchoredTextRequest";
|
|
4692
|
+
readonly 'browse:anchored-text-result': "BrowseAnchoredTextResult";
|
|
4693
|
+
readonly 'browse:anchored-text-failed': null;
|
|
4353
4694
|
readonly 'browse:resources-requested': "BrowseResourcesRequest";
|
|
4354
4695
|
readonly 'browse:resources-result': "BrowseResourcesResult";
|
|
4355
4696
|
readonly 'browse:resources-failed': null;
|
|
@@ -4428,6 +4769,9 @@ declare const CHANNEL_SCHEMAS: {
|
|
|
4428
4769
|
readonly 'weave:rebuild': "WeaveRebuildCommand";
|
|
4429
4770
|
readonly 'weave:rebuild-ok': null;
|
|
4430
4771
|
readonly 'weave:rebuild-failed': null;
|
|
4772
|
+
readonly 'smelt:rebuild-anchors': "SmeltRebuildAnchorsCommand";
|
|
4773
|
+
readonly 'smelt:rebuild-anchors-ok': null;
|
|
4774
|
+
readonly 'smelt:rebuild-anchors-failed': null;
|
|
4431
4775
|
readonly 'stream-connected': null;
|
|
4432
4776
|
readonly 'replay-window-exceeded': null;
|
|
4433
4777
|
readonly 'bus:resume-gap': null;
|
|
@@ -5124,6 +5468,163 @@ declare function parseFragmentSelector(fragment: string): PdfCoordinate | null;
|
|
|
5124
5468
|
/** Extract the 1-indexed page number from a FragmentSelector value. */
|
|
5125
5469
|
declare function getPageFromFragment(fragment: string): number | null;
|
|
5126
5470
|
|
|
5471
|
+
/**
|
|
5472
|
+
* Text ↔ geometry anchoring for PDFs.
|
|
5473
|
+
*
|
|
5474
|
+
* Two directions over the same pairing of text and the runs that index it:
|
|
5475
|
+
* `locate` turns a character span into rectangles (an annotation the model
|
|
5476
|
+
* produced by quoting text), `textUnder` turns a rectangle into characters (an
|
|
5477
|
+
* annotation a person produced by dragging a box). They are inverses and live
|
|
5478
|
+
* together deliberately.
|
|
5479
|
+
*
|
|
5480
|
+
* This is pure arithmetic over plain data, so it sits here beside
|
|
5481
|
+
* `PdfCoordinate` and the viewrect codec rather than in `@semiont/content`:
|
|
5482
|
+
* the browser canvas needs `textUnder` at drag time and cannot import
|
|
5483
|
+
* `@semiont/content`, which carries pdf.js, Tesseract and `node:fs`.
|
|
5484
|
+
* *Producing* an `AnchoredText` — from a text layer or from OCR — stays there.
|
|
5485
|
+
*
|
|
5486
|
+
* Coordinates are PDF points with the origin at the bottom-left of the page,
|
|
5487
|
+
* Y increasing upward. The Y-flip to canvas pixels lives in the browser.
|
|
5488
|
+
*/
|
|
5489
|
+
|
|
5490
|
+
/**
|
|
5491
|
+
* A single text item (one text run, roughly a word) from a PDF.
|
|
5492
|
+
* Character offsets refer to positions in the paired `AnchoredText.text`.
|
|
5493
|
+
*/
|
|
5494
|
+
interface PdfTextItem {
|
|
5495
|
+
start: number;
|
|
5496
|
+
end: number;
|
|
5497
|
+
page: number;
|
|
5498
|
+
x: number;
|
|
5499
|
+
y: number;
|
|
5500
|
+
width: number;
|
|
5501
|
+
height: number;
|
|
5502
|
+
}
|
|
5503
|
+
/**
|
|
5504
|
+
* Text paired with the geometry that indexes it — the minimum needed to turn a
|
|
5505
|
+
* character range into a Selection, or a rectangle into a quote.
|
|
5506
|
+
*
|
|
5507
|
+
* This is the contract `locate`, `textUnder` and the annotation builders
|
|
5508
|
+
* actually require; they do not need pages, form fields, or anything else a
|
|
5509
|
+
* full `PdfTextLayer` carries. Naming it separately lets OCR'd content
|
|
5510
|
+
* (recovered from pixels, so not a "text layer" in the PDF sense) satisfy the
|
|
5511
|
+
* same anchoring path.
|
|
5512
|
+
*/
|
|
5513
|
+
interface AnchoredText {
|
|
5514
|
+
text: string;
|
|
5515
|
+
items: PdfTextItem[];
|
|
5516
|
+
}
|
|
5517
|
+
/**
|
|
5518
|
+
* The full outcome of text extraction for one representation — the record
|
|
5519
|
+
* the anchored-text store holds and the wire serves (PERSIST-ANCHORS
|
|
5520
|
+
* decision D1): an `AnchoredText` plus its provenance (`method`, `pdfClass`,
|
|
5521
|
+
* `ocrConfidence`, `unreadPages`), or a named decline. `AnchoredText` stays
|
|
5522
|
+
* the anchoring vocabulary; this is the stored/served record. Aliased from
|
|
5523
|
+
* the generated spec type so the wire shape has exactly one authority.
|
|
5524
|
+
*/
|
|
5525
|
+
type ExtractionOutcome = components['schemas']['ExtractionOutcome'];
|
|
5526
|
+
/**
|
|
5527
|
+
* One text run as pdf.js reports it, narrowed to the fields anchoring reads.
|
|
5528
|
+
* Structural on purpose: core takes no dependency on pdfjs-dist, so each
|
|
5529
|
+
* producer filters marked-content items at its own boundary and passes the
|
|
5530
|
+
* text runs through.
|
|
5531
|
+
*/
|
|
5532
|
+
interface PdfTextRun {
|
|
5533
|
+
str: string;
|
|
5534
|
+
/** pdf.js text matrix `[a, b, c, d, x, y]`; only x/y are read. */
|
|
5535
|
+
transform: number[];
|
|
5536
|
+
width: number;
|
|
5537
|
+
height: number;
|
|
5538
|
+
hasEOL?: boolean;
|
|
5539
|
+
}
|
|
5540
|
+
/**
|
|
5541
|
+
* pdf.js interleaves marked-content items with text runs in `getTextContent()`;
|
|
5542
|
+
* only the latter carry `str`. Both producers filter with this before calling
|
|
5543
|
+
* `anchorRuns`, so the boundary rule is stated once.
|
|
5544
|
+
*/
|
|
5545
|
+
declare function isTextRun<T>(item: T): item is T & PdfTextRun;
|
|
5546
|
+
/**
|
|
5547
|
+
* Turns one page's pdf.js text runs into `AnchoredText`.
|
|
5548
|
+
*
|
|
5549
|
+
* This is the offset and separator convention — what `text` says, and where
|
|
5550
|
+
* each item points into it. Both producers share it: the server extractor
|
|
5551
|
+
* reading a whole document, and the browser canvas reading the page under a
|
|
5552
|
+
* drag. Divergence would mean the same rectangle quoting differently depending
|
|
5553
|
+
* on which side captured it.
|
|
5554
|
+
*
|
|
5555
|
+
* Offsets are page-local. A caller assembling a multi-page document shifts them
|
|
5556
|
+
* by the length of the text already accumulated.
|
|
5557
|
+
*/
|
|
5558
|
+
declare function anchorRuns(runs: PdfTextRun[], page: number): AnchoredText;
|
|
5559
|
+
/**
|
|
5560
|
+
* Locates bounding rectangles for a span of text in an AnchoredText
|
|
5561
|
+
* (single-line or multi-line).
|
|
5562
|
+
*
|
|
5563
|
+
* Finds all overlapping items [start, end), groups them by page and line, and
|
|
5564
|
+
* records one bounding rectangle per line as a PdfCoordinate.
|
|
5565
|
+
*
|
|
5566
|
+
* Returns both the per-line `rects` and the `overlap` items they were computed
|
|
5567
|
+
* from — so a caller that also needs the covered text (e.g. buildPdfAnnotation's
|
|
5568
|
+
* geometry↔text containment invariant) reuses this single `items` scan
|
|
5569
|
+
* instead of re-filtering. Both arrays are empty if no item overlaps the span.
|
|
5570
|
+
*/
|
|
5571
|
+
declare function locate(anchored: AnchoredText, start: number, end: number): {
|
|
5572
|
+
rects: PdfCoordinate[];
|
|
5573
|
+
overlap: PdfTextItem[];
|
|
5574
|
+
};
|
|
5575
|
+
/**
|
|
5576
|
+
* The inverse of `locate`: given a rectangle, returns the text under it.
|
|
5577
|
+
*
|
|
5578
|
+
* A hand-drawn PDF rectangle otherwise carries no quoted text at all, so every
|
|
5579
|
+
* panel that quotes an annotation shows it blank
|
|
5580
|
+
* (.plans/PDF-MANUAL-ANNOTATION-TEXT.md).
|
|
5581
|
+
*
|
|
5582
|
+
* `rect` is in the same PDF-point, bottom-left-origin space as `PdfTextItem`,
|
|
5583
|
+
* so a canvas drag rectangle passes straight in. A run counts as covered when
|
|
5584
|
+
* the rectangle overlaps `RUN_COVERAGE_THRESHOLD` of its area — see there for
|
|
5585
|
+
* why any-intersection is not survivable for a hand-drawn box.
|
|
5586
|
+
*
|
|
5587
|
+
* Covered runs are emitted in reading order (`text` offset order), which
|
|
5588
|
+
* inherits the extractor's known column-major ordering on multi-column pages
|
|
5589
|
+
* rather than answering it a second, different way.
|
|
5590
|
+
*
|
|
5591
|
+
* Returns `''` when nothing is covered — over an image, over whitespace, or
|
|
5592
|
+
* over a scanned page with no text layer. Callers must then emit no
|
|
5593
|
+
* `TextQuoteSelector` at all: an empty quote would assert the box was drawn
|
|
5594
|
+
* around nothing.
|
|
5595
|
+
*/
|
|
5596
|
+
declare function textUnder(anchored: AnchoredText, rect: PdfCoordinate): string;
|
|
5597
|
+
|
|
5598
|
+
/**
|
|
5599
|
+
* Two-stage citation search over an extracted PDF text layer
|
|
5600
|
+
* (PDF-GENERATION P4).
|
|
5601
|
+
*
|
|
5602
|
+
* A citation's `exact` claim text comes from the authored source; the rendered
|
|
5603
|
+
* text layer diverges from it in exactly two measured ways (the P0 spike):
|
|
5604
|
+
* line breaks (`anchorRuns` joins runs with " \n") and hyphenation (soft
|
|
5605
|
+
* hyphens are DROPPED — a hyphenated word yields its two halves with no hyphen
|
|
5606
|
+
* character anywhere).
|
|
5607
|
+
*
|
|
5608
|
+
* Two stages, in this order, never collapsed to one matcher:
|
|
5609
|
+
*
|
|
5610
|
+
* 1. STRICT — search a whitespace-normalized copy, offsets mapped back.
|
|
5611
|
+
* Bridges plain line breaks (" \n" collapses to " ").
|
|
5612
|
+
* 2. BREAK-AWARE — only on a strict miss. The line break becomes a distinct
|
|
5613
|
+
* marker character that may be absorbed in any inter-character gap, with
|
|
5614
|
+
* an optional space on either side (anchorRuns emits a space *then* the
|
|
5615
|
+
* newline). Ordinary spaces are NEVER wildcards, so "abc" cannot match
|
|
5616
|
+
* "a b c" — only a real break is absorbable.
|
|
5617
|
+
*
|
|
5618
|
+
* The ordering is the safety property: the permissive matcher runs only where
|
|
5619
|
+
* the strict one already failed, so it can never turn a working citation into
|
|
5620
|
+
* a wrong one — only a failure into an unlikely mismatch.
|
|
5621
|
+
*/
|
|
5622
|
+
|
|
5623
|
+
declare function findClaimSpan(anchored: AnchoredText, exact: string): {
|
|
5624
|
+
start: number;
|
|
5625
|
+
end: number;
|
|
5626
|
+
} | null;
|
|
5627
|
+
|
|
5127
5628
|
/**
|
|
5128
5629
|
* Helper functions for working with W3C ResourceDescriptor
|
|
5129
5630
|
*/
|
|
@@ -5560,6 +6061,85 @@ interface IContentTransport {
|
|
|
5560
6061
|
getResourceGraph(resourceId: ResourceId, options?: {
|
|
5561
6062
|
auth?: AccessToken;
|
|
5562
6063
|
}): Promise<GetResourceResponse>;
|
|
6064
|
+
/**
|
|
6065
|
+
* Store anchored text — the coordinate map a producer derived from a
|
|
6066
|
+
* representation's bytes (OCR, a native text layer, a table or form
|
|
6067
|
+
* reader) — under **the content checksum of those bytes** (PERSIST-ANCHORS
|
|
6068
|
+
* decision A: one artifact per representation, and a representation IS its
|
|
6069
|
+
* bytes).
|
|
6070
|
+
*
|
|
6071
|
+
* The producer supplies the checksum because it alone knows which bytes it
|
|
6072
|
+
* actually read. That is a correctness rule, not a convenience: if the
|
|
6073
|
+
* store derived the key from the resource's CURRENT representation at
|
|
6074
|
+
* write time, a byte change racing the publish would file old geometry
|
|
6075
|
+
* under the new checksum — wrong quotes served, and the reconcile diff
|
|
6076
|
+
* sees "artifact present" so it never heals. Producer-supplied, the same
|
|
6077
|
+
* race files the map under the OLD checksum: an unreachable orphan, and
|
|
6078
|
+
* the new checksum's missing artifact is exactly what the third drift
|
|
6079
|
+
* class re-derives (SMELTER-AXIOMS S15).
|
|
6080
|
+
*
|
|
6081
|
+
* Its own method rather than a `putBinary` of some derived media type: a
|
|
6082
|
+
* coordinate map is not a *representation* of the resource, and dressing it
|
|
6083
|
+
* as one would make a derived artifact indistinguishable from content a user
|
|
6084
|
+
* uploaded.
|
|
6085
|
+
*
|
|
6086
|
+
* Whole-representation, like `getResourceGraph` is whole-resource. The
|
|
6087
|
+
* producer iterates page by page; every consumer wants one map.
|
|
6088
|
+
*/
|
|
6089
|
+
putAnchoredText(checksum: string, outcome: ExtractionOutcome, options?: {
|
|
6090
|
+
auth?: AccessToken;
|
|
6091
|
+
}): Promise<void>;
|
|
6092
|
+
/**
|
|
6093
|
+
* The resource's anchored text, or `null` when none has been derived.
|
|
6094
|
+
*
|
|
6095
|
+
* Deliberately resource-addressed while `putAnchoredText` is
|
|
6096
|
+
* checksum-addressed: readers hold a resource id, and the server resolves
|
|
6097
|
+
* it to the current representation's checksum through the view — the
|
|
6098
|
+
* `resourceId → checksum` index of PERSIST-ANCHORS decision A. A reader
|
|
6099
|
+
* therefore can never receive geometry for bytes the resource no longer
|
|
6100
|
+
* has: the pointer moves, the artifacts stay, the index always follows
|
|
6101
|
+
* the pointer.
|
|
6102
|
+
*
|
|
6103
|
+
* `null` is not an error and is the common case: a native text layer is read
|
|
6104
|
+
* in the browser, and a resource whose media type has no extractor never
|
|
6105
|
+
* produces a map at all. Callers degrade — for a PDF annotation that means
|
|
6106
|
+
* geometry with no quoted text, which is the behaviour that shipped before
|
|
6107
|
+
* any of this existed.
|
|
6108
|
+
*/
|
|
6109
|
+
getAnchoredText(resourceId: ResourceId, options?: {
|
|
6110
|
+
auth?: AccessToken;
|
|
6111
|
+
}): Promise<ExtractionOutcome | null>;
|
|
6112
|
+
/**
|
|
6113
|
+
* The stored extraction outcome for exactly this byte content, or `null`
|
|
6114
|
+
* for a miss — the cache-consult read (PERSIST-ANCHORS P2c). Every cache
|
|
6115
|
+
* consumer runs out of process (the smelter worker, the detection
|
|
6116
|
+
* workers), so the `extract()` seam's consult crosses the wire through
|
|
6117
|
+
* this method; without it the cache would be write-only from exactly the
|
|
6118
|
+
* processes it exists to serve.
|
|
6119
|
+
*
|
|
6120
|
+
* Checksum-addressed and barrier-free, unlike `getAnchoredText`:
|
|
6121
|
+
* presence at this instant is the question (the keys listing's
|
|
6122
|
+
* semantics), and a caller holding the checksum already holds the
|
|
6123
|
+
* content identity — nothing to resolve, nothing to wait for.
|
|
6124
|
+
*/
|
|
6125
|
+
getAnchoredTextByChecksum(checksum: string, options?: {
|
|
6126
|
+
auth?: AccessToken;
|
|
6127
|
+
}): Promise<ExtractionOutcome | null>;
|
|
6128
|
+
/**
|
|
6129
|
+
* Every key under which anchored text would currently be served — the
|
|
6130
|
+
* reconcile planner's bulk existence read (PERSIST-ANCHORS P0). The
|
|
6131
|
+
* Smelter diffs this against the catalog to find resources whose artifact
|
|
6132
|
+
* was lost (a transient store, a failed publish) and plans re-derivation;
|
|
6133
|
+
* one call per reconcile, never a `getAnchoredText` probe per resource,
|
|
6134
|
+
* because each map is ~32 KB per scanned page and only presence is asked.
|
|
6135
|
+
*
|
|
6136
|
+
* Keys are resource ids today; after PERSIST-ANCHORS P1 they are content
|
|
6137
|
+
* checksums. Callers compare against whichever handle the store is keyed
|
|
6138
|
+
* by — the diff moves with the rekey, this contract does not.
|
|
6139
|
+
*/
|
|
6140
|
+
listAnchoredTextKeys(options?: {
|
|
6141
|
+
auth?: AccessToken;
|
|
6142
|
+
}): Promise<string[]>;
|
|
5563
6143
|
dispose(): void;
|
|
5564
6144
|
}
|
|
5565
6145
|
|
|
@@ -5599,6 +6179,10 @@ declare const BUS_OPERATIONS: {
|
|
|
5599
6179
|
readonly result: "browse:resource-result";
|
|
5600
6180
|
readonly failure: "browse:resource-failed";
|
|
5601
6181
|
};
|
|
6182
|
+
readonly 'browse:anchored-text-requested': {
|
|
6183
|
+
readonly result: "browse:anchored-text-result";
|
|
6184
|
+
readonly failure: "browse:anchored-text-failed";
|
|
6185
|
+
};
|
|
5602
6186
|
readonly 'browse:resources-requested': {
|
|
5603
6187
|
readonly result: "browse:resources-result";
|
|
5604
6188
|
readonly failure: "browse:resources-failed";
|
|
@@ -5708,6 +6292,10 @@ declare const BUS_OPERATIONS: {
|
|
|
5708
6292
|
readonly result: "weave:rebuild-ok";
|
|
5709
6293
|
readonly failure: "weave:rebuild-failed";
|
|
5710
6294
|
};
|
|
6295
|
+
readonly 'smelt:rebuild-anchors': {
|
|
6296
|
+
readonly result: "smelt:rebuild-anchors-ok";
|
|
6297
|
+
readonly failure: "smelt:rebuild-anchors-failed";
|
|
6298
|
+
};
|
|
5711
6299
|
readonly 'yield:create': {
|
|
5712
6300
|
readonly result: "yield:create-ok";
|
|
5713
6301
|
readonly failure: "yield:create-failed";
|
|
@@ -6275,6 +6863,10 @@ interface MediaTypeCapabilities {
|
|
|
6275
6863
|
extractText: TextExtraction;
|
|
6276
6864
|
authorable: boolean;
|
|
6277
6865
|
uploadable: boolean;
|
|
6866
|
+
/** Whether the generation worker can produce this type as a yield artifact.
|
|
6867
|
+
* Gate for `outputMediaType` — unsupported requests fail loudly, never
|
|
6868
|
+
* fall back to markdown under a mislabeled format. */
|
|
6869
|
+
generatable: boolean;
|
|
6278
6870
|
}
|
|
6279
6871
|
/**
|
|
6280
6872
|
* The registry. `satisfies Record<SupportedMediaType, …>` is the
|
|
@@ -6294,6 +6886,7 @@ declare const MEDIA_TYPES: {
|
|
|
6294
6886
|
extractText: "decode";
|
|
6295
6887
|
authorable: true;
|
|
6296
6888
|
uploadable: true;
|
|
6889
|
+
generatable: true;
|
|
6297
6890
|
};
|
|
6298
6891
|
'text/plain': {
|
|
6299
6892
|
extension: ".txt";
|
|
@@ -6303,6 +6896,7 @@ declare const MEDIA_TYPES: {
|
|
|
6303
6896
|
extractText: "decode";
|
|
6304
6897
|
authorable: true;
|
|
6305
6898
|
uploadable: true;
|
|
6899
|
+
generatable: true;
|
|
6306
6900
|
};
|
|
6307
6901
|
'text/html': {
|
|
6308
6902
|
extension: ".html";
|
|
@@ -6312,6 +6906,7 @@ declare const MEDIA_TYPES: {
|
|
|
6312
6906
|
extractText: "decode";
|
|
6313
6907
|
authorable: true;
|
|
6314
6908
|
uploadable: true;
|
|
6909
|
+
generatable: false;
|
|
6315
6910
|
};
|
|
6316
6911
|
'application/json': {
|
|
6317
6912
|
extension: ".json";
|
|
@@ -6321,6 +6916,7 @@ declare const MEDIA_TYPES: {
|
|
|
6321
6916
|
extractText: "decode";
|
|
6322
6917
|
authorable: false;
|
|
6323
6918
|
uploadable: true;
|
|
6919
|
+
generatable: false;
|
|
6324
6920
|
};
|
|
6325
6921
|
'image/png': {
|
|
6326
6922
|
extension: ".png";
|
|
@@ -6330,6 +6926,7 @@ declare const MEDIA_TYPES: {
|
|
|
6330
6926
|
extractText: "none";
|
|
6331
6927
|
authorable: false;
|
|
6332
6928
|
uploadable: true;
|
|
6929
|
+
generatable: false;
|
|
6333
6930
|
};
|
|
6334
6931
|
'image/jpeg': {
|
|
6335
6932
|
extension: ".jpg";
|
|
@@ -6339,6 +6936,7 @@ declare const MEDIA_TYPES: {
|
|
|
6339
6936
|
extractText: "none";
|
|
6340
6937
|
authorable: false;
|
|
6341
6938
|
uploadable: true;
|
|
6939
|
+
generatable: false;
|
|
6342
6940
|
};
|
|
6343
6941
|
'application/pdf': {
|
|
6344
6942
|
extension: ".pdf";
|
|
@@ -6348,6 +6946,7 @@ declare const MEDIA_TYPES: {
|
|
|
6348
6946
|
extractText: "pdf-text-layer";
|
|
6349
6947
|
authorable: false;
|
|
6350
6948
|
uploadable: true;
|
|
6949
|
+
generatable: true;
|
|
6351
6950
|
};
|
|
6352
6951
|
'text/css': MediaTypeCapabilities;
|
|
6353
6952
|
'text/csv': MediaTypeCapabilities;
|
|
@@ -6444,6 +7043,9 @@ declare const AUTHORABLE_MEDIA_TYPES: readonly SupportedMediaType[];
|
|
|
6444
7043
|
/** Registry rows whose text the Smelter can extract. Rows only — the
|
|
6445
7044
|
* text/* fallback in `textExtractionOf` isn't enumerable. */
|
|
6446
7045
|
declare const EMBEDDABLE_MEDIA_TYPES: readonly SupportedMediaType[];
|
|
7046
|
+
/** Types the generation worker can produce as a yield artifact — the
|
|
7047
|
+
* `outputMediaType` gate reads this, not a local table. */
|
|
7048
|
+
declare const GENERATABLE_MEDIA_TYPES: readonly SupportedMediaType[];
|
|
6447
7049
|
|
|
6448
7050
|
/**
|
|
6449
7051
|
* Resource input/output types
|
|
@@ -6496,12 +7098,58 @@ interface GoogleAuthRequest {
|
|
|
6496
7098
|
}
|
|
6497
7099
|
|
|
6498
7100
|
/**
|
|
6499
|
-
* ID generation utilities
|
|
7101
|
+
* ID generation utilities.
|
|
7102
|
+
*
|
|
7103
|
+
* Built on `crypto.getRandomValues()`, NOT `crypto.randomUUID()`: browsers
|
|
7104
|
+
* expose `randomUUID` only in secure contexts (https, `http://localhost`,
|
|
7105
|
+
* `http://127.0.0.1`), so a page served over plain http from any other host
|
|
7106
|
+
* has no `randomUUID` and calling it throws — which broke the frontend from
|
|
7107
|
+
* the host-gateway IP (.plans/bugs/crypto-randomuuid-insecure-context.md).
|
|
7108
|
+
* `getRandomValues` is cryptographically sound and available in ALL contexts,
|
|
7109
|
+
* Node and browser, secure or not.
|
|
6500
7110
|
*/
|
|
6501
7111
|
/**
|
|
6502
|
-
* Generate a UUID v4 string (
|
|
7112
|
+
* Generate a UUID v4 string WITHOUT dashes (32 hex chars).
|
|
7113
|
+
*
|
|
7114
|
+
* The dashless form is data shape: persisted annotation/resource/job ids are
|
|
7115
|
+
* built from it and land in URIs. Do not change the format.
|
|
6503
7116
|
*/
|
|
6504
7117
|
declare function generateUuid(): string;
|
|
7118
|
+
/**
|
|
7119
|
+
* Generate a canonical dashed UUID v4 (36 chars, 8-4-4-4-12) — the format
|
|
7120
|
+
* `crypto.randomUUID()` produces, without its secure-context requirement.
|
|
7121
|
+
*
|
|
7122
|
+
* Use for ephemeral wire ids (`correlationId`s and the like).
|
|
7123
|
+
*/
|
|
7124
|
+
declare function uuidV4(): string;
|
|
7125
|
+
|
|
7126
|
+
/**
|
|
7127
|
+
* Text Chunking Utilities
|
|
7128
|
+
*
|
|
7129
|
+
* Splits long text into overlapping chunks for embedding.
|
|
7130
|
+
* Each chunk is a passage that fits within the embedding model's context window.
|
|
7131
|
+
*/
|
|
7132
|
+
interface ChunkingConfig {
|
|
7133
|
+
chunkSize: number;
|
|
7134
|
+
overlap: number;
|
|
7135
|
+
}
|
|
7136
|
+
declare const DEFAULT_CHUNKING_CONFIG: ChunkingConfig;
|
|
7137
|
+
/**
|
|
7138
|
+
* Rough token count estimate: ~4 characters per token for English text.
|
|
7139
|
+
*
|
|
7140
|
+
* Exported as the single token-estimation heuristic: `chunkText` sizes chunks
|
|
7141
|
+
* with it, and inference/detection budget arithmetic must use the same
|
|
7142
|
+
* heuristic so estimates and chunk sizes agree.
|
|
7143
|
+
*/
|
|
7144
|
+
declare function estimateTokens(text: string): number;
|
|
7145
|
+
/**
|
|
7146
|
+
* Split text into overlapping chunks.
|
|
7147
|
+
*
|
|
7148
|
+
* Splits on paragraph boundaries when possible, falling back to sentence
|
|
7149
|
+
* boundaries, then word boundaries. Each chunk overlaps with the previous
|
|
7150
|
+
* by `overlap` tokens worth of text.
|
|
7151
|
+
*/
|
|
7152
|
+
declare function chunkText(text: string, config?: ChunkingConfig): string[];
|
|
6505
7153
|
|
|
6506
7154
|
/**
|
|
6507
7155
|
* Marker for the state-unit pattern: a stateful, lifecycled object with an
|
|
@@ -7276,7 +7924,7 @@ type TomlFileReader = {
|
|
|
7276
7924
|
*
|
|
7277
7925
|
* @param projectRoot - Path to the project root (contains .semiont/config)
|
|
7278
7926
|
* @param environment - Environment name (e.g. 'local', 'production'); when
|
|
7279
|
-
* undefined, resolved from
|
|
7927
|
+
* undefined, resolved from `[defaults] environment`
|
|
7280
7928
|
* @param globalConfigPath - Path to ~/.semiontconfig (caller resolves ~ expansion)
|
|
7281
7929
|
* @param reader - File reader abstraction
|
|
7282
7930
|
* @param env - Environment variables for ${VAR} resolution
|
|
@@ -7434,6 +8082,59 @@ declare function isTransientFetchError(error: unknown): boolean;
|
|
|
7434
8082
|
*/
|
|
7435
8083
|
declare function retryWithBackoff<T>(fn: () => Promise<T>, isRetryable: (error: unknown) => boolean, policy: RetryPolicy, onRetry?: (info: RetryAttemptInfo) => void): Promise<T>;
|
|
7436
8084
|
|
|
8085
|
+
/**
|
|
8086
|
+
* Sharding Utilities
|
|
8087
|
+
*
|
|
8088
|
+
* Shared utilities for consistent sharding across all storage layers —
|
|
8089
|
+
* the event log and view storage (@semiont/event-sourcing) and the
|
|
8090
|
+
* anchored-text store (@semiont/content) all lay files out as
|
|
8091
|
+
* `{ab}/{cd}/<key>` through `getShardPath`. Hoisted here (PERSIST-ANCHORS
|
|
8092
|
+
* P1a) so both importers share one implementation: a second sharding
|
|
8093
|
+
* implementation is how two trees end up disagreeing about where
|
|
8094
|
+
* something lives.
|
|
8095
|
+
*
|
|
8096
|
+
* Pure string/number math — no node dependencies — so it is safe on
|
|
8097
|
+
* core's browser-facing root export.
|
|
8098
|
+
*/
|
|
8099
|
+
/**
|
|
8100
|
+
* TEMPORARY: Simple modulo-based hash sharding
|
|
8101
|
+
*
|
|
8102
|
+
* ⚠️ TODO: Replace with proper Jump Consistent Hash implementation
|
|
8103
|
+
*
|
|
8104
|
+
* This is a TEMPORARY implementation using simple modulo. It works and provides
|
|
8105
|
+
* good distribution, but does NOT provide the minimal reshuffling property of
|
|
8106
|
+
* Jump Consistent Hash when changing bucket counts.
|
|
8107
|
+
*
|
|
8108
|
+
* The proper implementation should use Google's Jump Consistent Hash algorithm:
|
|
8109
|
+
* Reference: "A Fast, Minimal Memory, Consistent Hash Algorithm" by Lamping & Veach (2014)
|
|
8110
|
+
* https://arxiv.org/abs/1406.2294
|
|
8111
|
+
*
|
|
8112
|
+
* Working implementations exist in npm packages like:
|
|
8113
|
+
* - jumphash (https://www.npmjs.com/package/jumphash)
|
|
8114
|
+
* - jump-gouache (https://github.com/bhoudu/jump-gouache)
|
|
8115
|
+
*
|
|
8116
|
+
* The algorithm requires proper 64-bit integer handling with BigInt to avoid
|
|
8117
|
+
* precision loss in JavaScript. The previous attempt failed due to incorrect
|
|
8118
|
+
* BigInt arithmetic in the while loop condition.
|
|
8119
|
+
*
|
|
8120
|
+
* Until replaced, this modulo approach will cause ALL data to be reshuffled
|
|
8121
|
+
* if bucket count changes, rather than the optimal O(n/k) reshuffling that
|
|
8122
|
+
* Jump Consistent Hash provides.
|
|
8123
|
+
*
|
|
8124
|
+
* @param key - The key to hash (a resource id or content checksum)
|
|
8125
|
+
* @param numBuckets - Number of shards/buckets (default: 65536 for 4-hex sharding)
|
|
8126
|
+
* @returns Shard number (0 to numBuckets-1)
|
|
8127
|
+
*/
|
|
8128
|
+
declare function jumpConsistentHash(key: string, numBuckets?: number): number;
|
|
8129
|
+
/**
|
|
8130
|
+
* Get 4-hex shard path for a key
|
|
8131
|
+
*
|
|
8132
|
+
* @param key - The key to hash (a resource id or content checksum)
|
|
8133
|
+
* @param numBuckets - Number of shards (default: 65536)
|
|
8134
|
+
* @returns Path segments like ['ab', 'cd']
|
|
8135
|
+
*/
|
|
8136
|
+
declare function getShardPath(key: string, numBuckets?: number): [string, string];
|
|
8137
|
+
|
|
7437
8138
|
/**
|
|
7438
8139
|
* Browser ↔ launcher KB discovery (BROWSER-KB-DISCOVERY).
|
|
7439
8140
|
*
|
|
@@ -7447,5 +8148,5 @@ declare function retryWithBackoff<T>(fn: () => Promise<T>, isRetryable: (error:
|
|
|
7447
8148
|
*/
|
|
7448
8149
|
declare const DISCOVERY_URL_PATH = "/discovery/kbs.json";
|
|
7449
8150
|
|
|
7450
|
-
export { AUTHORABLE_MEDIA_TYPES, BRIDGED_CHANNELS, BUS_OPERATIONS, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, DISCOVERY_URL_PATH, EMBEDDABLE_MEDIA_TYPES, EventBus, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, STARTUP_FETCH_RETRY, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, anchorAnnotation, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseMediaType, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, busRequest, capabilitiesOf, cloneToken, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, deriveViews, didToAgent, email, entityType, errField, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isTransientFetchError, isUndefined, isValidEmail, isValidPlatformType, jobId, kbDid, loadTomlConfig, mcpToken, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, retryWithBackoff, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, textExtractionOf, userDID, userId, userToAgent, userToDid, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
|
|
7451
|
-
export type { AccessToken, AnchorConfidence, AnchorMethod, AnchorRect, AnchorSelectors, AnchorStrategy, AnchoringModel, Annotation, AnnotationCategory, AnnotationId, AnnotationUri, AnthropicProviderConfig, AppConfig, AssembledAnnotation, AuthCode, BackendDownload, BackendServiceConfig, BaseUrl, BodyItem, BodyItemIdentity, BodyOperation, BoundingBox, Brand, BridgedChannel, BurstBufferOptions, BusOp, BusOperationKey, BusOperationSpec, BusRequestErrorCode, BusRequestPrimitive, CloneToken, CollaboratorEntry, ConnectionState, ContentCache, ContentFormat, CreateAnnotationInternal, DatabaseServiceConfig, DiscoveredKB, DiscoveryDocument, Email, EmbeddingServiceConfig, EmittableChannel, EntityType, EntityTypeStats, Environment, EnvironmentConfig, EventBase, EventInput, EventMap, EventMetadata, EventName, EventOfType, EventQuery, EventSignature, FragmentSelector, FrontendServiceConfig, GatheredContext, GoogleAuthRequest, GoogleCredential, GraphConnection, GraphDatabaseType, GraphPath, GraphServiceConfig, GraphViews, HealthCheckResponse, IBackendOperations, IContentTransport, ITransport, InferenceProvidersConfig, JobId, JobType, ListUsersResponse, LlmSelectorInput, LocaleInfo, Logger, MCPToken, MatchQuality, McpServiceConfig, MediaTypeCapabilities, Motivation, OllamaProviderConfig, PdfCoordinate, PersistedEvent, PersistedEventType, PlatformType, Point, ProgressCallback, ProgressEvent, PutBinaryOptions, PutBinaryProgress, PutBinaryRequest, ReconciledSelector, RefreshToken, RenderMode, RenderedAnchor, ResourceAnnotationUri, ResourceAnnotations, ResourceBroadcastType, ResourceDescriptor, ResourceFilter, ResourceId, ResourceUri, RetryAttemptInfo, RetryPolicy, SearchQuery, SelectionData, Selector, SemiontConfig, ServicePlatformConfig, ServicesConfig, SiteConfig, StateUnit, StatusResponse, StoredEvent, StoredEventLike, SupportedMediaType, SvgSelector, TagCategory, TagSchema, TextExtraction, TextPosition, TextPositionSelector, TextQuoteSelector, ActorInferenceConfig as TomlActorInferenceConfig, TomlFileReader, InferenceConfig as TomlInferenceConfig, WorkerInferenceConfig as TomlWorkerInferenceConfig, TransportErrorCode, UpdateResourceInput, UpdateUserRequest, UpdateUserResponse, UserDID, UserId, UserResponse, ValidationFailure, ValidationResult, ValidationSuccess, VectorsServiceConfig, components, operations, paths };
|
|
8151
|
+
export { AUTHORABLE_MEDIA_TYPES, BRIDGED_CHANNELS, BUS_OPERATIONS, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, DEFAULT_CHUNKING_CONFIG, DISCOVERY_URL_PATH, EMBEDDABLE_MEDIA_TYPES, EventBus, GENERATABLE_MEDIA_TYPES, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, STARTUP_FETCH_RETRY, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, anchorAnnotation, anchorRuns, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseMediaType, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, busRequest, capabilitiesOf, chunkText, cloneToken, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, deriveViews, didToAgent, email, entityType, errField, estimateTokens, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, findClaimSpan, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getShardPath, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isTextRun, isTransientFetchError, isUndefined, isValidEmail, isValidPlatformType, jobId, jumpConsistentHash, kbDid, loadTomlConfig, locate, mcpToken, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, retryWithBackoff, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, textExtractionOf, textUnder, userDID, userId, userToAgent, userToDid, uuidV4, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
|
|
8152
|
+
export type { AccessToken, AnchorConfidence, AnchorMethod, AnchorRect, AnchorSelectors, AnchorStrategy, AnchoredText, AnchoringModel, Annotation, AnnotationCategory, AnnotationId, AnnotationUri, AnthropicProviderConfig, AppConfig, AssembledAnnotation, AuthCode, BackendDownload, BackendServiceConfig, BaseUrl, BodyItem, BodyItemIdentity, BodyOperation, BoundingBox, Brand, BridgedChannel, BurstBufferOptions, BusOp, BusOperationKey, BusOperationSpec, BusRequestErrorCode, BusRequestPrimitive, ChunkingConfig, CloneToken, CollaboratorEntry, ConnectionState, ContentCache, ContentFormat, CreateAnnotationInternal, DatabaseServiceConfig, DiscoveredKB, DiscoveryDocument, Email, EmbeddingServiceConfig, EmittableChannel, EntityType, EntityTypeStats, Environment, EnvironmentConfig, EventBase, EventInput, EventMap, EventMetadata, EventName, EventOfType, EventQuery, EventSignature, ExtractionOutcome, FragmentSelector, FrontendServiceConfig, GatheredContext, GoogleAuthRequest, GoogleCredential, GraphConnection, GraphDatabaseType, GraphPath, GraphServiceConfig, GraphViews, HealthCheckResponse, IBackendOperations, IContentTransport, ITransport, InferenceProvidersConfig, JobId, JobType, ListUsersResponse, LlmSelectorInput, LocaleInfo, Logger, MCPToken, MatchQuality, McpServiceConfig, MediaTypeCapabilities, Motivation, OllamaProviderConfig, PdfCoordinate, PdfTextItem, PdfTextRun, PersistedEvent, PersistedEventType, PlatformType, Point, ProgressCallback, ProgressEvent, PutBinaryOptions, PutBinaryProgress, PutBinaryRequest, ReconciledSelector, RefreshToken, RenderMode, RenderedAnchor, ResourceAnnotationUri, ResourceAnnotations, ResourceBroadcastType, ResourceDescriptor, ResourceFilter, ResourceId, ResourceUri, RetryAttemptInfo, RetryPolicy, SearchQuery, SelectionData, Selector, SemiontConfig, ServicePlatformConfig, ServicesConfig, SiteConfig, StateUnit, StatusResponse, StoredEvent, StoredEventLike, SupportedMediaType, SvgSelector, TagCategory, TagSchema, TextExtraction, TextPosition, TextPositionSelector, TextQuoteSelector, ActorInferenceConfig as TomlActorInferenceConfig, TomlFileReader, InferenceConfig as TomlInferenceConfig, WorkerInferenceConfig as TomlWorkerInferenceConfig, TransportErrorCode, UpdateResourceInput, UpdateUserRequest, UpdateUserResponse, UserDID, UserId, UserResponse, ValidationFailure, ValidationResult, ValidationSuccess, VectorsServiceConfig, components, operations, paths };
|