@fortemi/core 2026.6.3 → 2026.6.4
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 +1 -1
- package/dist/index.d.ts +302 -27
- package/dist/index.js +227 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Headless browser knowledge-management core powered by PGlite, typed repositories, semantic retrieval, and agent tool helpers**
|
|
6
6
|
|
|
7
|
-
Build local-first knowledge apps
|
|
7
|
+
Build local-first knowledge apps where data stays in the browser on the user's device — no server, no account — with PostgreSQL-compatible storage, production-ready repositories, hybrid search primitives, portable Knowledge Shard archives, opt-in bring-your-own AI wiring, and bridge-ready tool metadata.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pnpm add @fortemi/core
|
package/dist/index.d.ts
CHANGED
|
@@ -1468,19 +1468,19 @@ declare const CaptureKnowledgeInputSchema: z.ZodObject<{
|
|
|
1468
1468
|
}, {
|
|
1469
1469
|
content: string;
|
|
1470
1470
|
title?: string | undefined;
|
|
1471
|
-
tags?: string[] | undefined;
|
|
1472
1471
|
format?: "markdown" | "plain" | "html" | undefined;
|
|
1472
|
+
tags?: string[] | undefined;
|
|
1473
1473
|
}>, "many">>;
|
|
1474
1474
|
template: z.ZodOptional<z.ZodString>;
|
|
1475
1475
|
variables: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1476
1476
|
}, "strip", z.ZodTypeAny, {
|
|
1477
1477
|
source: string;
|
|
1478
1478
|
format: "markdown" | "plain" | "html";
|
|
1479
|
-
visibility: "private" | "
|
|
1479
|
+
visibility: "private" | "shared" | "public";
|
|
1480
1480
|
action: "create" | "bulk_create" | "from_template";
|
|
1481
1481
|
title?: string | undefined;
|
|
1482
|
-
tags?: string[] | undefined;
|
|
1483
1482
|
archive_id?: string | undefined;
|
|
1483
|
+
tags?: string[] | undefined;
|
|
1484
1484
|
content?: string | undefined;
|
|
1485
1485
|
notes?: {
|
|
1486
1486
|
format: "markdown" | "plain" | "html";
|
|
@@ -1494,16 +1494,16 @@ declare const CaptureKnowledgeInputSchema: z.ZodObject<{
|
|
|
1494
1494
|
action: "create" | "bulk_create" | "from_template";
|
|
1495
1495
|
source?: string | undefined;
|
|
1496
1496
|
title?: string | undefined;
|
|
1497
|
-
tags?: string[] | undefined;
|
|
1498
1497
|
archive_id?: string | undefined;
|
|
1499
1498
|
format?: "markdown" | "plain" | "html" | undefined;
|
|
1500
|
-
visibility?: "private" | "
|
|
1499
|
+
visibility?: "private" | "shared" | "public" | undefined;
|
|
1500
|
+
tags?: string[] | undefined;
|
|
1501
1501
|
content?: string | undefined;
|
|
1502
1502
|
notes?: {
|
|
1503
1503
|
content: string;
|
|
1504
1504
|
title?: string | undefined;
|
|
1505
|
-
tags?: string[] | undefined;
|
|
1506
1505
|
format?: "markdown" | "plain" | "html" | undefined;
|
|
1506
|
+
tags?: string[] | undefined;
|
|
1507
1507
|
}[] | undefined;
|
|
1508
1508
|
template?: string | undefined;
|
|
1509
1509
|
variables?: Record<string, string> | undefined;
|
|
@@ -1548,35 +1548,35 @@ declare const SearchInputSchema: z.ZodObject<{
|
|
|
1548
1548
|
visibility: z.ZodOptional<z.ZodEnum<["private", "shared", "public"]>>;
|
|
1549
1549
|
include_facets: z.ZodDefault<z.ZodBoolean>;
|
|
1550
1550
|
}, "strip", z.ZodTypeAny, {
|
|
1551
|
-
query: string;
|
|
1552
|
-
offset: number;
|
|
1553
1551
|
limit: number;
|
|
1552
|
+
offset: number;
|
|
1554
1553
|
include_facets: boolean;
|
|
1555
|
-
mode: "
|
|
1554
|
+
mode: "semantic" | "text" | "hybrid";
|
|
1555
|
+
query: string;
|
|
1556
1556
|
source?: string | undefined;
|
|
1557
|
-
tags?: string[] | undefined;
|
|
1558
1557
|
format?: "markdown" | "plain" | "html" | undefined;
|
|
1559
|
-
visibility?: "private" | "
|
|
1558
|
+
visibility?: "private" | "shared" | "public" | undefined;
|
|
1560
1559
|
is_starred?: boolean | undefined;
|
|
1561
1560
|
is_archived?: boolean | undefined;
|
|
1561
|
+
tags?: string[] | undefined;
|
|
1562
1562
|
collection_id?: string | undefined;
|
|
1563
1563
|
date_from?: Date | undefined;
|
|
1564
1564
|
date_to?: Date | undefined;
|
|
1565
1565
|
}, {
|
|
1566
1566
|
query: string;
|
|
1567
1567
|
source?: string | undefined;
|
|
1568
|
-
tags?: string[] | undefined;
|
|
1569
|
-
offset?: number | undefined;
|
|
1570
1568
|
format?: "markdown" | "plain" | "html" | undefined;
|
|
1571
|
-
visibility?: "private" | "
|
|
1569
|
+
visibility?: "private" | "shared" | "public" | undefined;
|
|
1572
1570
|
is_starred?: boolean | undefined;
|
|
1573
1571
|
is_archived?: boolean | undefined;
|
|
1572
|
+
tags?: string[] | undefined;
|
|
1574
1573
|
limit?: number | undefined;
|
|
1574
|
+
offset?: number | undefined;
|
|
1575
1575
|
collection_id?: string | undefined;
|
|
1576
1576
|
date_from?: Date | undefined;
|
|
1577
1577
|
date_to?: Date | undefined;
|
|
1578
1578
|
include_facets?: boolean | undefined;
|
|
1579
|
-
mode?: "
|
|
1579
|
+
mode?: "semantic" | "text" | "hybrid" | undefined;
|
|
1580
1580
|
}>;
|
|
1581
1581
|
type SearchInput = z.infer<typeof SearchInputSchema>;
|
|
1582
1582
|
|
|
@@ -1654,22 +1654,22 @@ declare const ListNotesInputSchema: z.ZodObject<{
|
|
|
1654
1654
|
collection_id: z.ZodOptional<z.ZodString>;
|
|
1655
1655
|
include_deleted: z.ZodOptional<z.ZodBoolean>;
|
|
1656
1656
|
}, "strip", z.ZodTypeAny, {
|
|
1657
|
-
sort: "
|
|
1658
|
-
offset: number;
|
|
1657
|
+
sort: "created_at" | "updated_at" | "title";
|
|
1659
1658
|
limit: number;
|
|
1659
|
+
offset: number;
|
|
1660
1660
|
order: "asc" | "desc";
|
|
1661
|
-
tags?: string[] | undefined;
|
|
1662
1661
|
is_starred?: boolean | undefined;
|
|
1663
1662
|
is_archived?: boolean | undefined;
|
|
1663
|
+
tags?: string[] | undefined;
|
|
1664
1664
|
include_deleted?: boolean | undefined;
|
|
1665
1665
|
collection_id?: string | undefined;
|
|
1666
1666
|
}, {
|
|
1667
|
-
|
|
1668
|
-
sort?: "title" | "updated_at" | "created_at" | undefined;
|
|
1669
|
-
offset?: number | undefined;
|
|
1667
|
+
sort?: "created_at" | "updated_at" | "title" | undefined;
|
|
1670
1668
|
is_starred?: boolean | undefined;
|
|
1671
1669
|
is_archived?: boolean | undefined;
|
|
1670
|
+
tags?: string[] | undefined;
|
|
1672
1671
|
limit?: number | undefined;
|
|
1672
|
+
offset?: number | undefined;
|
|
1673
1673
|
order?: "asc" | "desc" | undefined;
|
|
1674
1674
|
include_deleted?: boolean | undefined;
|
|
1675
1675
|
collection_id?: string | undefined;
|
|
@@ -1683,12 +1683,12 @@ declare const ManageTagsInputSchema: z.ZodObject<{
|
|
|
1683
1683
|
tag: z.ZodOptional<z.ZodString>;
|
|
1684
1684
|
}, "strip", z.ZodTypeAny, {
|
|
1685
1685
|
action: "add" | "remove" | "list_for_note" | "list_all";
|
|
1686
|
-
tag?: string | undefined;
|
|
1687
1686
|
note_id?: string | undefined;
|
|
1687
|
+
tag?: string | undefined;
|
|
1688
1688
|
}, {
|
|
1689
1689
|
action: "add" | "remove" | "list_for_note" | "list_all";
|
|
1690
|
-
tag?: string | undefined;
|
|
1691
1690
|
note_id?: string | undefined;
|
|
1691
|
+
tag?: string | undefined;
|
|
1692
1692
|
}>;
|
|
1693
1693
|
type ManageTagsInput = z.infer<typeof ManageTagsInputSchema>;
|
|
1694
1694
|
interface ManageTagsResult {
|
|
@@ -2041,13 +2041,142 @@ declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
|
2041
2041
|
*/
|
|
2042
2042
|
declare function suggestTags(noteEmbedding: number[], tagEmbeddings: Map<string, number[]>, threshold?: number, maxTags?: number): string[];
|
|
2043
2043
|
|
|
2044
|
+
/**
|
|
2045
|
+
* Off-main-thread query-embedding transport for the semantic capability.
|
|
2046
|
+
*
|
|
2047
|
+
* The semantic capability consumes a single `EmbedFunction`
|
|
2048
|
+
* (`(texts: string[]) => Promise<number[][]>`). With `executionMode="worker"`
|
|
2049
|
+
* (#146) the PGlite DB + HNSW query run off the main thread, but a
|
|
2050
|
+
* main-thread `EmbedFunction` closure still blocks the UI: model load janks
|
|
2051
|
+
* first paint of search, and every per-query embed blocks input.
|
|
2052
|
+
*
|
|
2053
|
+
* This module lets the host run the embed function inside a Worker (or behind
|
|
2054
|
+
* a MessagePort) so semantic search is off-thread end-to-end. Core posts
|
|
2055
|
+
* `{ texts }` to the port and awaits `number[][]`; the host owns the worker,
|
|
2056
|
+
* the model, and the model params (so build-time corpus embeddings stay an
|
|
2057
|
+
* exact match: `Xenova/all-MiniLM-L6-v2`, fp32, `{ pooling:'mean', normalize:true }`,
|
|
2058
|
+
* 384-d).
|
|
2059
|
+
*
|
|
2060
|
+
* Two halves:
|
|
2061
|
+
* - {@link createWorkerEmbedFunction} — main-thread side. Wraps a transport
|
|
2062
|
+
* into an `EmbedFunction` that round-trips each request to the worker.
|
|
2063
|
+
* - {@link handleEmbedRequests} — worker side. Wires a host-owned
|
|
2064
|
+
* `(texts) => Promise<number[][]>` to the message protocol.
|
|
2065
|
+
*
|
|
2066
|
+
* The existing main-thread `registerSemanticCapability(manager, embedFn)` path
|
|
2067
|
+
* is unchanged. This transport is additive and opt-in.
|
|
2068
|
+
*
|
|
2069
|
+
* @implements #180 off-main-thread / pluggable query-embedding transport
|
|
2070
|
+
*/
|
|
2071
|
+
|
|
2072
|
+
/**
|
|
2073
|
+
* Minimal transport contract satisfied by both `Worker` and `MessagePort`.
|
|
2074
|
+
* Core only needs to post messages and listen for replies.
|
|
2075
|
+
*/
|
|
2076
|
+
interface EmbedTransportPort {
|
|
2077
|
+
postMessage(message: unknown): void;
|
|
2078
|
+
addEventListener(type: 'message', listener: (event: {
|
|
2079
|
+
data: unknown;
|
|
2080
|
+
}) => void): void;
|
|
2081
|
+
removeEventListener(type: 'message', listener: (event: {
|
|
2082
|
+
data: unknown;
|
|
2083
|
+
}) => void): void;
|
|
2084
|
+
/** MessagePort requires start() when using addEventListener; Worker does not. */
|
|
2085
|
+
start?(): void;
|
|
2086
|
+
}
|
|
2087
|
+
/** Message discriminators for the embed protocol. */
|
|
2088
|
+
declare const EMBED_REQUEST_KIND: "fortemi:embed:request";
|
|
2089
|
+
declare const EMBED_RESPONSE_KIND: "fortemi:embed:response";
|
|
2090
|
+
/** Request posted by core (main thread) to the worker. */
|
|
2091
|
+
interface EmbedRequestMessage {
|
|
2092
|
+
kind: typeof EMBED_REQUEST_KIND;
|
|
2093
|
+
id: number;
|
|
2094
|
+
texts: string[];
|
|
2095
|
+
}
|
|
2096
|
+
/** Reply posted by the worker back to core. Exactly one of `vectors`/`error`. */
|
|
2097
|
+
interface EmbedResponseMessage {
|
|
2098
|
+
kind: typeof EMBED_RESPONSE_KIND;
|
|
2099
|
+
id: number;
|
|
2100
|
+
vectors?: number[][];
|
|
2101
|
+
error?: string;
|
|
2102
|
+
}
|
|
2103
|
+
/** Options for the main-thread worker embed function. */
|
|
2104
|
+
interface EmbedWorkerOptions {
|
|
2105
|
+
/**
|
|
2106
|
+
* Per-request timeout in milliseconds. A request that receives no reply
|
|
2107
|
+
* within this window rejects with a timeout error. Set to `0` to disable.
|
|
2108
|
+
* Default: 30000 (30s).
|
|
2109
|
+
*/
|
|
2110
|
+
timeoutMs?: number;
|
|
2111
|
+
}
|
|
2112
|
+
/**
|
|
2113
|
+
* Wrap a Worker/MessagePort transport into an `EmbedFunction` (main-thread side).
|
|
2114
|
+
*
|
|
2115
|
+
* Each `embed(texts)` call posts an {@link EmbedRequestMessage} with a unique id
|
|
2116
|
+
* and resolves when the matching {@link EmbedResponseMessage} arrives. The
|
|
2117
|
+
* message listener is attached immediately and removed by `dispose()`.
|
|
2118
|
+
*
|
|
2119
|
+
* @param port - A `Worker`, `MessagePort`, or any {@link EmbedTransportPort}.
|
|
2120
|
+
* @param options - Optional timeout configuration.
|
|
2121
|
+
* @returns The `embed` function and a `dispose` cleanup (removes the listener
|
|
2122
|
+
* and rejects any in-flight requests).
|
|
2123
|
+
*
|
|
2124
|
+
* @example
|
|
2125
|
+
* ```ts
|
|
2126
|
+
* const worker = new Worker(new URL('./queryEmbed.worker.ts', import.meta.url), { type: 'module' })
|
|
2127
|
+
* const { embed, dispose } = createWorkerEmbedFunction(worker)
|
|
2128
|
+
* setEmbedFunction(embed) // query + job embedding now run off-thread
|
|
2129
|
+
* // later: dispose(); worker.terminate()
|
|
2130
|
+
* ```
|
|
2131
|
+
*/
|
|
2132
|
+
declare function createWorkerEmbedFunction(port: EmbedTransportPort, options?: EmbedWorkerOptions): {
|
|
2133
|
+
embed: EmbedFunction;
|
|
2134
|
+
dispose: () => void;
|
|
2135
|
+
};
|
|
2136
|
+
/**
|
|
2137
|
+
* Wire a host-owned embed function to the message protocol (worker side).
|
|
2138
|
+
*
|
|
2139
|
+
* Call this inside the worker (or behind a MessagePort) with the function that
|
|
2140
|
+
* loads the model and runs inference. It answers each {@link EmbedRequestMessage}
|
|
2141
|
+
* with an {@link EmbedResponseMessage}.
|
|
2142
|
+
*
|
|
2143
|
+
* @param port - The worker scope (`self`) or a `MessagePort`.
|
|
2144
|
+
* @param embed - The host embed function `(texts) => Promise<number[][]>`.
|
|
2145
|
+
* @returns A disposer that removes the listener.
|
|
2146
|
+
*
|
|
2147
|
+
* @example
|
|
2148
|
+
* ```ts
|
|
2149
|
+
* // queryEmbed.worker.ts
|
|
2150
|
+
* import { handleEmbedRequests } from '@fortemi/core'
|
|
2151
|
+
* import { pipeline } from '@huggingface/transformers'
|
|
2152
|
+
*
|
|
2153
|
+
* const extractor = await pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2')
|
|
2154
|
+
* handleEmbedRequests(self as unknown as EmbedTransportPort, async (texts) => {
|
|
2155
|
+
* const out = await Promise.all(
|
|
2156
|
+
* texts.map(async (t) => {
|
|
2157
|
+
* const r = await extractor(t, { pooling: 'mean', normalize: true })
|
|
2158
|
+
* return Array.from(r.data as Float32Array)
|
|
2159
|
+
* }),
|
|
2160
|
+
* )
|
|
2161
|
+
* return out
|
|
2162
|
+
* })
|
|
2163
|
+
* ```
|
|
2164
|
+
*/
|
|
2165
|
+
declare function handleEmbedRequests(port: EmbedTransportPort, embed: EmbedFunction): () => void;
|
|
2166
|
+
|
|
2044
2167
|
/**
|
|
2045
2168
|
* Semantic capability loader — registers the embedding pipeline with CapabilityManager.
|
|
2046
2169
|
*
|
|
2047
2170
|
* In production (browser), this loads @huggingface/transformers in a Web Worker.
|
|
2048
2171
|
* In tests, call registerSemanticCapability() with a mock embed function.
|
|
2049
2172
|
*
|
|
2173
|
+
* Two registration paths, both additive:
|
|
2174
|
+
* - registerSemanticCapability(manager, embedFn) — main-thread embed closure.
|
|
2175
|
+
* - registerSemanticCapabilityWorker(manager, port) — off-main-thread embed
|
|
2176
|
+
* transport (#180), so semantic search runs off-thread end-to-end.
|
|
2177
|
+
*
|
|
2050
2178
|
* @implements #62 semantic capability loader
|
|
2179
|
+
* @implements #180 off-main-thread / pluggable query-embedding transport
|
|
2051
2180
|
*/
|
|
2052
2181
|
|
|
2053
2182
|
/**
|
|
@@ -2060,8 +2189,31 @@ declare function suggestTags(noteEmbedding: number[], tagEmbeddings: Map<string,
|
|
|
2060
2189
|
*/
|
|
2061
2190
|
declare function registerSemanticCapability(manager: CapabilityManager, embedFn: EmbedFunction, onProgress?: (pct: number) => void): void;
|
|
2062
2191
|
/**
|
|
2063
|
-
*
|
|
2064
|
-
*
|
|
2192
|
+
* Register the semantic capability backed by an off-main-thread transport (#180).
|
|
2193
|
+
*
|
|
2194
|
+
* The embed function round-trips each request to a host-owned Worker/MessagePort,
|
|
2195
|
+
* so model load and per-query inference never touch the main thread. The host
|
|
2196
|
+
* owns the worker and the model params (build-time corpus match stays exact).
|
|
2197
|
+
*
|
|
2198
|
+
* The loader runs when `capabilityManager.enable('semantic')` is invoked; the
|
|
2199
|
+
* message listener is attached then and removed on
|
|
2200
|
+
* {@link unregisterSemanticCapability} (i.e. on `disable`).
|
|
2201
|
+
*
|
|
2202
|
+
* @param manager - The CapabilityManager instance.
|
|
2203
|
+
* @param port - A `Worker`, `MessagePort`, or any {@link EmbedTransportPort}.
|
|
2204
|
+
* @param options - Optional transport options (e.g. per-request timeout).
|
|
2205
|
+
*
|
|
2206
|
+
* @example
|
|
2207
|
+
* ```ts
|
|
2208
|
+
* const worker = new Worker(new URL('./queryEmbed.worker.ts', import.meta.url), { type: 'module' })
|
|
2209
|
+
* registerSemanticCapabilityWorker(capabilityManager, worker)
|
|
2210
|
+
* await capabilityManager.enable('semantic') // off-thread end-to-end
|
|
2211
|
+
* ```
|
|
2212
|
+
*/
|
|
2213
|
+
declare function registerSemanticCapabilityWorker(manager: CapabilityManager, port: EmbedTransportPort, options?: EmbedWorkerOptions): void;
|
|
2214
|
+
/**
|
|
2215
|
+
* Unregister the semantic capability — clears the embed function and tears down
|
|
2216
|
+
* any active off-main-thread transport. Called when the capability is disabled.
|
|
2065
2217
|
*/
|
|
2066
2218
|
declare function unregisterSemanticCapability(): void;
|
|
2067
2219
|
|
|
@@ -2928,6 +3080,129 @@ declare function exportShard(db: DatabaseClient, options?: ExportOptions): Promi
|
|
|
2928
3080
|
*/
|
|
2929
3081
|
declare function importShard(db: DatabaseClient, data: Uint8Array | ArrayBuffer, options?: ImportOptions): Promise<ImportResult>;
|
|
2930
3082
|
|
|
2931
|
-
|
|
3083
|
+
/**
|
|
3084
|
+
* Shard warm / prefetch API — pre-stage and (optionally) verify shard bytes
|
|
3085
|
+
* without building the index.
|
|
3086
|
+
*
|
|
3087
|
+
* Staged corpus loading (text-first, then opt-in summary vectors, then opt-in
|
|
3088
|
+
* full content) wants the operator's hard rule honored: **no blocking waits**.
|
|
3089
|
+
* The HNSW index build has to happen on the user's click (it is heavy and is
|
|
3090
|
+
* shown with progress — that is correct). The *download* of the shard bytes
|
|
3091
|
+
* does not: it can be warmed in the background on idle so the click is purely
|
|
3092
|
+
* the index build.
|
|
3093
|
+
*
|
|
3094
|
+
* fortemi-react is server-free and local-first — shards are **static assets**
|
|
3095
|
+
* (typically generated at build time and served as static files, or bundled
|
|
3096
|
+
* and handed in directly as bytes). `prefetchShard` warms those static bytes;
|
|
3097
|
+
* it does not assume any API/server. The eventual `importShard` reads the warm
|
|
3098
|
+
* bytes via {@link fromPrefetched}, so import is just the index build.
|
|
3099
|
+
*
|
|
3100
|
+
* Two-layer integrity:
|
|
3101
|
+
* - `prefetchShard(url, { expectedSha256 })` verifies the whole-archive SHA-256
|
|
3102
|
+
* against a build-time-known hash (emitted alongside the static shard).
|
|
3103
|
+
* - `importShard` still validates the per-file checksums inside the manifest
|
|
3104
|
+
* on import. Both layers share core's `sha256Hex`.
|
|
3105
|
+
*
|
|
3106
|
+
* @implements #181 prefetchShard / shard warm API
|
|
3107
|
+
*/
|
|
3108
|
+
/** Options for {@link prefetchShard}. */
|
|
3109
|
+
interface PrefetchOptions {
|
|
3110
|
+
/**
|
|
3111
|
+
* Provide the shard bytes directly instead of fetching `url` — e.g. a
|
|
3112
|
+
* build-time-generated `.shard` imported as a bundled asset. The `url` is
|
|
3113
|
+
* still used as the warm-store key. When set, no network/disk fetch happens.
|
|
3114
|
+
*/
|
|
3115
|
+
bytes?: ArrayBuffer | Uint8Array;
|
|
3116
|
+
/**
|
|
3117
|
+
* Compute the SHA-256 of the warmed bytes (stored on the result and in the
|
|
3118
|
+
* warm store). Implied when `expectedSha256` is set.
|
|
3119
|
+
*/
|
|
3120
|
+
verify?: boolean;
|
|
3121
|
+
/**
|
|
3122
|
+
* Build-time-known SHA-256 (hex) of the whole shard archive. When set, the
|
|
3123
|
+
* warmed bytes are verified against it and a mismatch throws — nothing is
|
|
3124
|
+
* stored. Case-insensitive.
|
|
3125
|
+
*/
|
|
3126
|
+
expectedSha256?: string;
|
|
3127
|
+
/**
|
|
3128
|
+
* Fetch implementation to use. Defaults to `globalThis.fetch`. Inject for
|
|
3129
|
+
* tests or non-standard environments.
|
|
3130
|
+
*/
|
|
3131
|
+
fetchImpl?: typeof fetch;
|
|
3132
|
+
/**
|
|
3133
|
+
* Also persist the warmed bytes to the Cache Storage API so warmth survives
|
|
3134
|
+
* a reload. Feature-detected — a no-op when `caches` is unavailable (e.g.
|
|
3135
|
+
* Node, or a worker without Cache access).
|
|
3136
|
+
*/
|
|
3137
|
+
useCacheStorage?: boolean;
|
|
3138
|
+
/** Cache Storage cache name. Default: `'fortemi-shards'`. */
|
|
3139
|
+
cacheName?: string;
|
|
3140
|
+
/** Abort signal forwarded to the fetch. */
|
|
3141
|
+
signal?: AbortSignal;
|
|
3142
|
+
}
|
|
3143
|
+
/** Result of a {@link prefetchShard} call. */
|
|
3144
|
+
interface PrefetchResult {
|
|
3145
|
+
/** The warm-store key (the `url` passed to prefetchShard). */
|
|
3146
|
+
url: string;
|
|
3147
|
+
/** The warmed shard bytes (also retrievable via {@link fromPrefetched}). */
|
|
3148
|
+
bytes: Uint8Array;
|
|
3149
|
+
/** Convenience: `bytes.byteLength`. */
|
|
3150
|
+
byteLength: number;
|
|
3151
|
+
/** SHA-256 hex of the warmed bytes when computed (`verify` or `expectedSha256`), else `undefined`. */
|
|
3152
|
+
sha256?: string;
|
|
3153
|
+
/** True when the bytes came from the Cache Storage API rather than a fresh fetch. */
|
|
3154
|
+
fromCache: boolean;
|
|
3155
|
+
}
|
|
3156
|
+
/**
|
|
3157
|
+
* Pre-stage shard bytes into the warm store without building the index.
|
|
3158
|
+
*
|
|
3159
|
+
* Resolution order for the bytes:
|
|
3160
|
+
* 1. `options.bytes` (a directly-provided / bundled asset), else
|
|
3161
|
+
* 2. the Cache Storage API (when `useCacheStorage` and a prior write exists), else
|
|
3162
|
+
* 3. `fetch(url)` of the static asset.
|
|
3163
|
+
*
|
|
3164
|
+
* Concurrent calls for the same `url` (without `options.bytes`) share a single
|
|
3165
|
+
* fetch. On `expectedSha256` mismatch the call throws and nothing is stored.
|
|
3166
|
+
*
|
|
3167
|
+
* @param url - Static asset URL (also the warm-store key).
|
|
3168
|
+
* @param options - See {@link PrefetchOptions}.
|
|
3169
|
+
* @returns The warm result (bytes are also retrievable via {@link fromPrefetched}).
|
|
3170
|
+
*
|
|
3171
|
+
* @example
|
|
3172
|
+
* ```ts
|
|
3173
|
+
* // Warm on idle so the user's opt-in click is just the index build.
|
|
3174
|
+
* requestIdleCallback(() => {
|
|
3175
|
+
* void prefetchShard('/shards/research.shard', { expectedSha256: RESEARCH_SHARD_SHA256 })
|
|
3176
|
+
* })
|
|
3177
|
+
* // ...later, on click:
|
|
3178
|
+
* await importShard(db, fromPrefetched('/shards/research.shard'), { onProgress })
|
|
3179
|
+
* ```
|
|
3180
|
+
*/
|
|
3181
|
+
declare function prefetchShard(url: string, options?: PrefetchOptions): Promise<PrefetchResult>;
|
|
3182
|
+
/**
|
|
3183
|
+
* Return previously-warmed shard bytes for `url`, ready to hand to `importShard`.
|
|
3184
|
+
*
|
|
3185
|
+
* @throws If the url was not prefetched (call {@link prefetchShard} first).
|
|
3186
|
+
*
|
|
3187
|
+
* @example
|
|
3188
|
+
* ```ts
|
|
3189
|
+
* await importShard(db, fromPrefetched('/shards/research.shard'), { onProgress })
|
|
3190
|
+
* ```
|
|
3191
|
+
*/
|
|
3192
|
+
declare function fromPrefetched(url: string): Uint8Array;
|
|
3193
|
+
/** Whether `url` has warm bytes in the in-memory store. */
|
|
3194
|
+
declare function isShardPrefetched(url: string): boolean;
|
|
3195
|
+
/** The computed SHA-256 (hex) of a warmed shard, if it was verified/hashed. */
|
|
3196
|
+
declare function getPrefetchedSha256(url: string): string | undefined;
|
|
3197
|
+
/**
|
|
3198
|
+
* Evict warm bytes from the in-memory store. With no argument, clears all.
|
|
3199
|
+
*
|
|
3200
|
+
* Note: this does not delete Cache Storage entries — those persist by design
|
|
3201
|
+
* (that is the cross-reload warmth). Manage the Cache Storage cache directly if
|
|
3202
|
+
* you need to evict it.
|
|
3203
|
+
*/
|
|
3204
|
+
declare function clearPrefetchedShard(url?: string): void;
|
|
3205
|
+
|
|
3206
|
+
declare const VERSION = "2026.6.4";
|
|
2932
3207
|
|
|
2933
|
-
export { type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRow, type AttachmentRow, AttachmentsRepository, type BlobStore, type BridgeCapability, type BridgeProviderInfo, type BrowserNoteExport, CURRENT_SHARD_VERSION, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionRow, CollectionsRepository, CommunitiesRepository, type CommunityAssignmentView, type CommunityCreateInput, type CommunityFilterDefinition, type CommunityGraph, type CommunityOptions, type CommunitySourceDescriptor, type CommunitySourceType, type CommunitySummary, type CompletionRequest, type CompletionResponse, type ConditionResult, type ConflictStrategy, type CooldownConfig, type CooldownEvent, type CspDirectiveName, type CspDirectives, type CspViolationReport, type DatabaseClient, type DiscoveredProvider, type DiscoveryOptions, type EmbedFunction, type EmbedRequest, type EmbedResponse, type EmbeddingCompatibilityPolicy, type EmbeddingSetCreateInput, type EmbeddingSetCriteria, type EmbeddingSetDescriptor, type EmbeddingSetEmbeddingInput, type EmbeddingSetFreshness, type EmbeddingSetKind, type EmbeddingSetMode, type EmbeddingSetRow, type EmbeddingSetSelector, EmbeddingSetsRepository, type EnqueueJobInput, type ErrorCategory, type EventMap, type ExportOptions, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FortemiBridge, type FortemiBridgeCapabilities, type FortemiBridgeHost, type FortemiConfig, type FortemiCore, type FortemiInferenceRouter, type FortemiSecretStore, type FortemiToolDefinition, FortemiToolManifest, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type GraphNode, GraphRepository, type IDisposable, type ImportCounts, type ImportOptions, type ImportProgress, type ImportProgressPhase, type ImportResult, type InferenceCapabilities, type InferenceProvider, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, LOCAL_ENDPOINTS, type LinkRow, LinksRepository, type ListNotesInput, ListNotesInputSchema, type LlmCapabilityOptions, type LlmCompleteFn, type LoadedPluginScript, type LocalEndpoint, type ManageArchiveInput, ManageArchiveInputSchema, type ManageArchiveResult, type ManageAttachmentsInput, ManageAttachmentsInputSchema, type ManageAttachmentsResult, type ManageCapabilitiesInput, ManageCapabilitiesInputSchema, type ManageCapabilitiesResult, type ManageCollectionsInput, ManageCollectionsInputSchema, type ManageCollectionsResult, type ManageLinksInput, ManageLinksInputSchema, type ManageLinksResult, type ManageNoteInput, ManageNoteInputSchema, type ManageNoteResult, type ManageTagsInput, ManageTagsInputSchema, type ManageTagsResult, MemoryBlobStore, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteRevision, type NoteSummary, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, type PGliteWorkerStorageBackendFactoryOptions, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type ProbeResult, type ProbeStatus, type ProviderCapabilities, ProviderRegistry, type ProviderTier, type QueryExecutor, type QueryResult, type RecommendedTier, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RouteHandler, SHARD_FORMAT, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, type ShardCollection, type ShardComponent, type ShardEmbedding, type ShardEmbeddingSet, type ShardEmbeddingSetMember, type ShardLink, type ShardManifest, type ShardNote, type ShardNoteSkosTag, type ShardProvenanceEdge, type ShardSkosConcept, type ShardSkosRelation, type ShardSkosScheme, type ShardTag, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type SkosConcept, type SkosRelation, SkosRepository, type SkosScheme, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, TagsRepository, TransactionProxy, TypedEventBus, VERSION, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, allMigrations, appendPluginScript, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createBlobStore, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteInstance, createRoutes, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, fortemiManifest, generateId, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getLlmFunction, getNote, hasFortemiSecureSecrets, importShard, isPluginScriptAllowed, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, packTarGz, parseCspReport, provenanceEdgeToShard, registerLlmCapability, registerSemanticCapability, registerServiceWorker, searchTool, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateChecksums, verifySri };
|
|
3208
|
+
export { type ArchiveInfo, ArchiveManager, type AttachInput, type AttachmentBlobRow, type AttachmentRow, AttachmentsRepository, type BlobStore, type BridgeCapability, type BridgeProviderInfo, type BrowserNoteExport, CURRENT_SHARD_VERSION, type CapabilityInfo, CapabilityManager, type CapabilityName, type CapabilityState, type CaptureKnowledgeInput, CaptureKnowledgeInputSchema, type CaptureKnowledgeResult, type CollectionCreateInput, type CollectionRow, CollectionsRepository, CommunitiesRepository, type CommunityAssignmentView, type CommunityCreateInput, type CommunityFilterDefinition, type CommunityGraph, type CommunityOptions, type CommunitySourceDescriptor, type CommunitySourceType, type CommunitySummary, type CompletionRequest, type CompletionResponse, type ConditionResult, type ConflictStrategy, type CooldownConfig, type CooldownEvent, type CspDirectiveName, type CspDirectives, type CspViolationReport, type DatabaseClient, type DiscoveredProvider, type DiscoveryOptions, EMBED_REQUEST_KIND, EMBED_RESPONSE_KIND, type EmbedFunction, type EmbedRequest, type EmbedRequestMessage, type EmbedResponse, type EmbedResponseMessage, type EmbedTransportPort, type EmbedWorkerOptions, type EmbeddingCompatibilityPolicy, type EmbeddingSetCreateInput, type EmbeddingSetCriteria, type EmbeddingSetDescriptor, type EmbeddingSetEmbeddingInput, type EmbeddingSetFreshness, type EmbeddingSetKind, type EmbeddingSetMode, type EmbeddingSetRow, type EmbeddingSetSelector, EmbeddingSetsRepository, type EnqueueJobInput, type ErrorCategory, type EventMap, type ExportOptions, type FallbackEvent, FallbackRouter, type FallbackRouterConfig, type FortemiBridge, type FortemiBridgeCapabilities, type FortemiBridgeHost, type FortemiConfig, type FortemiCore, type FortemiInferenceRouter, type FortemiSecretStore, type FortemiToolDefinition, FortemiToolManifest, type GetNoteInput, GetNoteInputSchema, type GpuCapabilities, type GraphCommunity, type GraphEdge, type GraphNode, GraphRepository, type IDisposable, type ImportCounts, type ImportOptions, type ImportProgress, type ImportProgressPhase, type ImportResult, type InferenceCapabilities, type InferenceProvider, JOB_CAPABILITIES, JOB_PRIORITIES, type JobQueueOptions, JobQueueWorker, type JobStatus, type JobType, LOCAL_ENDPOINTS, type LinkRow, LinksRepository, type ListNotesInput, ListNotesInputSchema, type LlmCapabilityOptions, type LlmCompleteFn, type LoadedPluginScript, type LocalEndpoint, type ManageArchiveInput, ManageArchiveInputSchema, type ManageArchiveResult, type ManageAttachmentsInput, ManageAttachmentsInputSchema, type ManageAttachmentsResult, type ManageCapabilitiesInput, ManageCapabilitiesInputSchema, type ManageCapabilitiesResult, type ManageCollectionsInput, ManageCollectionsInputSchema, type ManageCollectionsResult, type ManageLinksInput, ManageLinksInputSchema, type ManageLinksResult, type ManageNoteInput, ManageNoteInputSchema, type ManageNoteResult, type ManageTagsInput, ManageTagsInputSchema, type ManageTagsResult, MemoryBlobStore, type Migration, MigrationRunner, type ModelCategory, type ModelFitResult, type ModelInfo, type NoteCreateInput, type NoteFull, type NoteListOptions, type NoteRevision, type NoteSummary, type NoteUpdateInput, NotesRepository, OpenAICompatibleProvider, type OpenAIProviderConfig, PGliteStorageBackend, PGliteStorageBackendFactory, PGliteWorkerClient, PGliteWorkerStorageBackend, PGliteWorkerStorageBackendFactory, type PGliteWorkerStorageBackendFactoryOptions, type PaginatedResult, type PersistenceMode, type PluginCspOptions, type PluginScriptDescriptor, type PluginScriptPolicy, type PrefetchOptions, type PrefetchResult, type ProbeResult, type ProbeStatus, type ProviderCapabilities, ProviderRegistry, type ProviderTier, type QueryExecutor, type QueryResult, type RecommendedTier, type ResolvedEmbeddingRow, type ResolvedEmbeddingSet, type RouteHandler, SHARD_FORMAT, type SWRegistrationResult, type SearchFacets, type SearchInput, SearchInputSchema, type SearchOptions, SearchRepository, type SearchResponse, type SearchResult, type ShardCollection, type ShardComponent, type ShardEmbedding, type ShardEmbeddingSet, type ShardEmbeddingSetMember, type ShardLink, type ShardManifest, type ShardNote, type ShardNoteSkosTag, type ShardProvenanceEdge, type ShardSkosConcept, type ShardSkosRelation, type ShardSkosScheme, type ShardTag, type SimilarityGraphCacheKey, type SimilarityGraphOptions, type SimilarityGraphRequest, type SimilarityGraphResult, type SkosConcept, type SkosRelation, SkosRepository, type SkosScheme, type StorageBackend, type StorageBackendFactory, type StorageOpenRequest, type StorageTopology, type StreamChunk, TagsRepository, TransactionProxy, TypedEventBus, VERSION, type VirtualEmbeddingSetDefinition, type VirtualEmbeddingSetSource, type VirtualEmbeddingSetValidationError, type VirtualMaterializationPolicy, type VramTier, type WorkerRequest, type WorkerResponse, aiRevisionHandler, allMigrations, appendPluginScript, buildNoteConditions, buildPluginCsp, captureKnowledge, chunkText, classifyError, classifyModel, clearPrefetchedShard, collectionFromShard, collectionToShard, computeHash, computeSri, conceptTaggingHandler, cosineSimilarity, createBlobStore, createCspReportHandler, createFortemi, createLegacyProvider, createPGliteInstance, createRoutes, createWorkerEmbedFunction, defaultStorageBackendFactory, detectCommunities, detectGpuCapabilities, detectInferenceCapabilities, discoverLocalProviders, embeddingFromShard, embeddingGenerationHandler, embeddingSetFromShard, embeddingSetMemberToShard, embeddingSetToShard, embeddingToShard, enqueueFullWorkflow, enqueueJob, enqueueNoteCreationJobs, estimateModelFit, estimateVramMB, estimateVramTier, exportShard, fetchPluginScript, fortemiManifest, fromPrefetched, generateId, getEmbedFunction, getFortemiBridge, getFortemiSecretStore, getJobQueueStatus, getLlmFunction, getNote, getPrefetchedSha256, handleEmbedRequests, hasFortemiSecureSecrets, importShard, isPluginScriptAllowed, isShardPrefetched, linkFromShard, linkToShard, linkingHandler, listNotes, manageArchive, manageAttachments, manageCapabilities, manageCollections, manageLinks, manageNote, manageTags, matchRoute, noteFromShard, noteSkosTagToShard, noteToShard, packTarGz, parseCspReport, prefetchShard, provenanceEdgeToShard, registerLlmCapability, registerSemanticCapability, registerSemanticCapabilityWorker, registerServiceWorker, searchTool, selectLlmModel, setEmbedFunction, setLlmFunction, sha256Hex, skosConceptToShard, skosRelationToShard, skosSchemeToShard, suggestTags, tagsFromShard, tagsToShard, titleGenerationHandler, unpackTarGz, unregisterLlmCapability, unregisterSemanticCapability, validateChecksums, verifySri };
|