@wazootech/worlds-sdk 0.0.0-stage → 0.11.3-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +288 -2
  3. package/THIRD_PARTY_NOTICES.md +279 -0
  4. package/dist/ai-sdk.d.ts +27 -0
  5. package/dist/ai-sdk.js +28 -0
  6. package/dist/build-search-result-id-qxdmXp0V.js +12 -0
  7. package/dist/chunk-and-embed-0crm0xLl.js +75 -0
  8. package/dist/client-BJ45zmXU.d.ts +74 -0
  9. package/dist/client-BWh0UAM0.js +45 -0
  10. package/dist/embedding-service-DebRMVmn.d.ts +15 -0
  11. package/dist/embedding-service.d.ts +3 -0
  12. package/dist/embedding-service.js +19 -0
  13. package/dist/index.d.ts +8 -0
  14. package/dist/index.js +9 -0
  15. package/dist/memory.d.ts +26 -0
  16. package/dist/memory.js +29 -0
  17. package/dist/mod-8Zh1f9vW.d.ts +24 -0
  18. package/dist/mod-BuF_B_xU.d.ts +362 -0
  19. package/dist/mod-CHiiyEER.d.ts +79 -0
  20. package/dist/mod-ClDFMN-C.d.ts +625 -0
  21. package/dist/mod-Dmrdrb03.d.ts +13 -0
  22. package/dist/quad-chunker.d.ts +2 -0
  23. package/dist/quad-chunker.js +1 -0
  24. package/dist/quad-store-BGCOUBxK.js +851 -0
  25. package/dist/quad-store.d.ts +2 -0
  26. package/dist/quad-store.js +3 -0
  27. package/dist/rdf-formats-BkGt5RDB.js +93 -0
  28. package/dist/rdfjs-BNVjLSNL.js +190 -0
  29. package/dist/rdfjs.d.ts +79 -0
  30. package/dist/rdfjs.js +1 -0
  31. package/dist/search-index.d.ts +2 -0
  32. package/dist/search-index.js +219 -0
  33. package/dist/sparql-engine.d.ts +2 -0
  34. package/dist/sparql-engine.js +0 -0
  35. package/dist/testing.d.ts +301 -0
  36. package/dist/testing.js +786 -0
  37. package/dist/tfjs-use.d.ts +42 -0
  38. package/dist/tfjs-use.js +315 -0
  39. package/dist/wazoo.d.ts +86 -0
  40. package/dist/wazoo.js +347 -0
  41. package/package.json +119 -4
@@ -0,0 +1,625 @@
1
+ import { TurtleFormat } from "@wazootech/sparql-engine";
2
+ import { EventEmitter } from "node:events";
3
+ import * as rdfjs from "@rdfjs/types";
4
+ /**
5
+ * ProvenanceRecordType discriminates write provenance from removal tombstones.
6
+ */
7
+ type ProvenanceRecordType = "write" | "remove";
8
+ /**
9
+ * ImportProvenance is the application-supplied provenance metadata carried on
10
+ * an ImportRequest; it stamps every quad that import writes.
11
+ */
12
+ interface ImportProvenance {
13
+ /** writer optionally names the agent or process that performed the write. */
14
+ writer?: string;
15
+ /** source optionally names the feed, tool, or origin the data came from. */
16
+ source?: string;
17
+ }
18
+ /**
19
+ * ProvenanceRecord is a sidecar provenance entry keyed by a quad's
20
+ * content-addressed ID (see hashQuad). Records are optional per quad: a
21
+ * missing record means the quad was written before provenance recording
22
+ * existed, and provenance queries must return the quad without metadata
23
+ * rather than fail. No synthetic backfill timestamps are ever generated.
24
+ */
25
+ interface ProvenanceRecord {
26
+ /** quadId is the content-addressed ID of the quad this record describes. */
27
+ quadId: string;
28
+ /** recordedAt is the ISO 8601 timestamp of the write or removal event. */
29
+ recordedAt: string;
30
+ /** type distinguishes a write record from a removal tombstone (default "write"). */
31
+ type?: ProvenanceRecordType;
32
+ /** writer optionally names the agent or process that performed the write. */
33
+ writer?: string;
34
+ /** source optionally names the feed, tool, or origin the data came from. */
35
+ source?: string;
36
+ /**
37
+ * supersedesQuadId optionally links this record to the quad ID it replaces,
38
+ * forming the correction chain that history walks in both directions.
39
+ */
40
+ supersedesQuadId?: string;
41
+ }
42
+ /**
43
+ * ProvenanceRecordInput is the write shape for ProvenanceStore.record;
44
+ * recordedAt defaults to the write time inside the store.
45
+ */
46
+ interface ProvenanceRecordInput {
47
+ quadId: string;
48
+ recordedAt?: string;
49
+ type?: ProvenanceRecordType;
50
+ writer?: string;
51
+ source?: string;
52
+ supersedesQuadId?: string;
53
+ }
54
+ /**
55
+ * ProvenanceHistory is the supersedesQuadId chain around one quad, walked in
56
+ * both directions.
57
+ */
58
+ interface ProvenanceHistory {
59
+ /** quadId is the quad the chain was walked from. */
60
+ quadId: string;
61
+ /** supersedes lists ancestor records: quads this quad replaced, transitively. */
62
+ supersedes: ProvenanceRecord[];
63
+ /** supersededBy lists descendant records: quads that replaced this quad, transitively. */
64
+ supersededBy: ProvenanceRecord[];
65
+ }
66
+ /**
67
+ * ProvenanceListQuery narrows list to one quad or one record type.
68
+ */
69
+ interface ProvenanceListQuery {
70
+ quadId?: string;
71
+ type?: ProvenanceRecordType;
72
+ }
73
+ /**
74
+ * ProvenanceStore is the append-only persistence contract for provenance
75
+ * records. Durable backends implement this over their own storage (SQL
76
+ * tables, KV buckets); the in-memory implementation backs RdfjsQuadStore.
77
+ */
78
+ interface ProvenanceStore {
79
+ /**
80
+ * record appends one provenance record. recordedAt defaults to the write
81
+ * time. Appending is idempotent-friendly but never rewrites history.
82
+ */
83
+ record(input: ProvenanceRecordInput): Promise<ProvenanceRecord>;
84
+ /** list returns records matching the query, oldest first. */
85
+ list(query?: ProvenanceListQuery): Promise<ProvenanceRecord[]>;
86
+ /**
87
+ * history walks the supersedesQuadId chain for a quad in both directions:
88
+ * what it replaced and what replaced it. Unknown quad IDs return an empty
89
+ * chain, not an error.
90
+ */
91
+ history(quadId: string): Promise<ProvenanceHistory>;
92
+ }
93
+ /**
94
+ * ProvenanceQueryRequest selects quads by RDF pattern; omitted or null
95
+ * positions match anything, mirroring rdfjs Store.match.
96
+ */
97
+ interface ProvenanceQueryRequest {
98
+ subject?: import("@rdfjs/types").Term | null;
99
+ predicate?: import("@rdfjs/types").Term | null;
100
+ object?: import("@rdfjs/types").Term | null;
101
+ /**
102
+ * limit caps how many matching quads are returned, each with all of its
103
+ * records. It must be a positive integer; omitted returns every match.
104
+ */
105
+ limit?: number;
106
+ }
107
+ /**
108
+ * ProvenanceQueryResult pairs one matching quad with its sidecar records and
109
+ * supersedes chain. A quad with no records still appears, with empty arrays.
110
+ */
111
+ interface ProvenanceQueryResult {
112
+ quadId: string;
113
+ quad: import("@rdfjs/types").Quad;
114
+ records: ProvenanceRecord[];
115
+ history: ProvenanceHistory;
116
+ }
117
+ /**
118
+ * ProvenanceQueryResponse is the provenance query surface response.
119
+ */
120
+ interface ProvenanceQueryResponse {
121
+ results: ProvenanceQueryResult[];
122
+ }
123
+ /**
124
+ * ProvenanceQueryHandler is the capability any quad store or facade can offer
125
+ * so WorldsSdk.provenance can delegate to it.
126
+ */
127
+ interface ProvenanceQueryHandler {
128
+ provenanceQuery(request: ProvenanceQueryRequest): Promise<ProvenanceQueryResponse>;
129
+ }
130
+ /**
131
+ * InMemoryProvenanceStore is an append-only provenance store. Records are
132
+ * never mutated or deleted; indexes over quadId and supersedesQuadId keep
133
+ * list and history walks off linear scans.
134
+ */
135
+ declare class InMemoryProvenanceStore implements ProvenanceStore {
136
+ private readonly records;
137
+ private readonly byQuadId;
138
+ private readonly bySupersedes;
139
+ record(input: ProvenanceRecordInput): Promise<ProvenanceRecord>;
140
+ list(query?: ProvenanceListQuery): Promise<ProvenanceRecord[]>;
141
+ history(quadId: string): Promise<ProvenanceHistory>;
142
+ private walkAncestors;
143
+ private walkDescendants;
144
+ }
145
+ /**
146
+ * ImportMode is the type of import to perform.
147
+ */
148
+ type ImportMode = "merge" | "replace";
149
+ /** What data are we importing? */
150
+ type ImportSource = {
151
+ kind: "quads";
152
+ quads: Iterable<rdfjs.Quad>;
153
+ } | {
154
+ kind: "dataset";
155
+ dataset: rdfjs.DatasetCore;
156
+ } | {
157
+ kind: "serialized";
158
+ data: string;
159
+ contentType?: string;
160
+ };
161
+ interface ImportRequest {
162
+ /** mode of import (defaults to "merge") */
163
+ mode?: ImportMode;
164
+ /** source of data */
165
+ source: ImportSource;
166
+ /**
167
+ * provenance optionally stamps every quad written by this import with
168
+ * writer and source metadata. recordedAt defaults to the write time.
169
+ * Omitted provenance leaves imported quads without sidecar records, which
170
+ * provenance queries treat as "written pre-provenance".
171
+ */
172
+ provenance?: ImportProvenance;
173
+ }
174
+ /**
175
+ * ExportRequest is the request type for the export function.
176
+ */
177
+ interface ExportRequest {
178
+ /** Desired output format. */
179
+ format: {
180
+ kind: "quads";
181
+ } | {
182
+ kind: "serialized";
183
+ contentType?: string;
184
+ };
185
+ }
186
+ /**
187
+ * ExportResponse is the response type for the export function.
188
+ */
189
+ type ExportResponse = {
190
+ kind: "quads";
191
+ quads: rdfjs.Quad[];
192
+ } | {
193
+ kind: "serialized";
194
+ data: string;
195
+ contentType: string;
196
+ };
197
+ /**
198
+ * QuadStoreInterface defines the core capabilities for ingesting and venting
199
+ * graph data out of the system.
200
+ */
201
+ interface QuadStoreInterface {
202
+ /**
203
+ * import merges or replaces the underlying store with provided RDF source data.
204
+ *
205
+ * @param request The payload defining the ingestion source and overwrite mode.
206
+ */
207
+ import(request: ImportRequest): Promise<void>;
208
+ /**
209
+ * export extracts the graph contents in raw quads or serialized formats.
210
+ *
211
+ * @param request The desired format specifications.
212
+ */
213
+ export(request: ExportRequest): Promise<ExportResponse>;
214
+ }
215
+ /**
216
+ * Patch is a batch of quad-level store changes.
217
+ */
218
+ interface Patch {
219
+ /**
220
+ * insertions are the quads that were added to the store.
221
+ */
222
+ insertions: rdfjs.Quad[];
223
+ /**
224
+ * deletions are the quads that were removed from the store.
225
+ */
226
+ deletions: rdfjs.Quad[];
227
+ }
228
+ /**
229
+ * RdfjsEventSource is the part of a store mutation's return value the SDK
230
+ * uses: it only listens for `end` and `error`. Node's `EventEmitter` and the
231
+ * `@wazootech/sparql-engine` `RdfStream` both satisfy it.
232
+ */
233
+ interface RdfjsEventSource {
234
+ on(event: string | symbol, listener: (...args: unknown[]) => void): unknown;
235
+ }
236
+ /**
237
+ * RdfjsStoreLike is the store surface the SDK reads and writes through. It is
238
+ * RDF/JS `Store` with the mutation return types loosened to RdfjsEventSource,
239
+ * so a store whose mutations return a dependency-free stream (as
240
+ * `@wazootech/sparql-engine` 0.5 `MemoryStore` does, with no Node `EventEmitter`)
241
+ * is accepted alongside N3.Store, SqliteStore and LibsqlStore. Every
242
+ * `rdfjs.Store` is also an RdfjsStoreLike.
243
+ */
244
+ interface RdfjsStoreLike extends Omit<rdfjs.Store, "import" | "remove" | "removeMatches" | "deleteGraph"> {
245
+ import(stream: rdfjs.Stream<rdfjs.Quad>): RdfjsEventSource;
246
+ remove(stream: rdfjs.Stream<rdfjs.Quad>): RdfjsEventSource;
247
+ removeMatches(subject?: rdfjs.Term | RegExp | null, predicate?: rdfjs.Term | RegExp | null, object?: rdfjs.Term | RegExp | null, graph?: rdfjs.Term | RegExp | null): RdfjsEventSource;
248
+ deleteGraph(graph: rdfjs.Quad_Graph | string): RdfjsEventSource;
249
+ }
250
+ /**
251
+ * TransactionContext carries optional metadata for a buffered commit flush.
252
+ */
253
+ interface TransactionContext {
254
+ /** importMode signals bulk import replace semantics to durable commit handlers. */
255
+ importMode?: ImportMode;
256
+ /** provenance carries the import's writer/source metadata to provenance-recording commit handlers. */
257
+ provenance?: ImportProvenance;
258
+ }
259
+ /**
260
+ * PatchableStore is an RDFJS store that natively supports atomic bulk-mutations via Patches.
261
+ */
262
+ interface PatchableStore extends RdfjsStoreLike {
263
+ /** applyPatch persists a patch atomically. */
264
+ applyPatch(patch: Patch, context?: TransactionContext): Promise<void>;
265
+ }
266
+ /**
267
+ * isImportCommit returns true when commit context carries bulk import semantics.
268
+ */
269
+ declare function isImportCommit(context?: TransactionContext): boolean;
270
+ /**
271
+ * isReplaceImportCommit returns true when commit context requests replace import semantics.
272
+ */
273
+ declare function isReplaceImportCommit(context?: TransactionContext): boolean;
274
+ /**
275
+ * deduplicateBuffers removes quads that appear in both insert and delete buffers.
276
+ */
277
+ declare function deduplicateBuffers(insertBuffer: rdfjs.Quad[], deleteBuffer: rdfjs.Quad[]): void;
278
+ /**
279
+ * QuadFilter defines nested declarative boundaries used to partition, isolate, or route specific sub-graphs.
280
+ * It maps directly to standard relational inclusion/exclusion paradigms.
281
+ */
282
+ interface QuadFilter {
283
+ /** include defines positive boundary conditions. If specified, facts MUST satisfy all declared constraints. */
284
+ include?: QuadCriteria;
285
+ /** exclude defines negative boundary conditions. If specified, any facts matching ANY constraint are rejected. */
286
+ exclude?: QuadCriteria;
287
+ }
288
+ /**
289
+ * QuadCriteria groups common structural attributes together to form logical boundary conditions.
290
+ */
291
+ interface QuadCriteria {
292
+ /** subjects restricts matching to a discrete set of subject IRIs. */
293
+ subjects?: Array<string>;
294
+ /** predicates restricts matching to discrete attribute predicates. */
295
+ predicates?: Array<string>;
296
+ /** graphs restricts matching to specific Named Graphs. */
297
+ graphs?: Array<string>;
298
+ }
299
+ /**
300
+ * filterQuads compiles nested, declarative boundary conditions into a highly optimized, pre-compiled O(1) evaluation predicate.
301
+ *
302
+ * @param filter Optional declarative boundaries to evaluate.
303
+ * @returns A high-performance closure predicate compatible with Array.prototype.filter.
304
+ */
305
+ declare function filterQuads(filter?: QuadFilter): (quad: rdfjs.Quad) => boolean;
306
+ /**
307
+ * isTextualLiteral evaluates whether an RDF Term is a physical textual string.
308
+ * It returns true for untyped, xsd:string, and rdf:langString literals, and
309
+ * explicitly rejects structured numeric, boolean, or temporal data primitives.
310
+ *
311
+ * @param term The candidate RDF node.
312
+ * @returns boolean True if physical termType matches canonical string boundaries.
313
+ */
314
+ declare function isTextualLiteral(term: rdfjs.Term): boolean;
315
+ /**
316
+ * hashQuad computes a content-addressed ID for a single quad: the SHA-256
317
+ * digest of the quad's canonical N-Quads serialization, base64url-encoded
318
+ * and prefixed with the scheme tag (2 + 43 = 46 chars total).
319
+ *
320
+ * For blank-node-free quads the serialization is byte-identical to the
321
+ * RDFC-1.0 canonical form (rdf-canonize), so IDs are interoperable with
322
+ * RDFC-1.0-based content-addressed systems. Blank nodes are label-based
323
+ * (dataset-local), per the Statement Hash convention — see
324
+ * serializeQuadToCanonicalNQuads.
325
+ */
326
+ declare function hashQuad(quad: rdfjs.Quad): string;
327
+ /**
328
+ * hashQuads computes deterministic content-addressed IDs for multiple quads.
329
+ */
330
+ declare function hashQuads(quads: rdfjs.Quad[]): string[];
331
+ /**
332
+ * HexastoreIndexDescriptor names a single covering index on the quads table.
333
+ */
334
+ interface HexastoreIndexDescriptor {
335
+ /** name is the index identifier (e.g. idx_quads_spog). */
336
+ name: string;
337
+ /** columns lists the ordered column group for the index. */
338
+ columns: readonly [string, string, string] | readonly [string, string, string, string];
339
+ }
340
+ /**
341
+ * HEXASTORE_INDEXES defines the 7 covering composite indexes on the quads table
342
+ * enabling any quad pattern to be resolved via a single index seek.
343
+ */
344
+ declare const HEXASTORE_INDEXES: readonly HexastoreIndexDescriptor[];
345
+ /**
346
+ * QuadRowReader provides typed accessors for quads table column values from any backend driver row.
347
+ */
348
+ interface QuadRowReader {
349
+ /** s is the subject IRI or blank node label. */
350
+ s: string;
351
+ /** sType is the subject term type ("NamedNode" or "BlankNode"). */
352
+ sType: string;
353
+ /** p is the predicate IRI. */
354
+ p: string;
355
+ /** o is the object lexical value. */
356
+ o: string;
357
+ /** oType is the object term type ("NamedNode", "BlankNode", or "Literal"). */
358
+ oType: string;
359
+ /** oDatatype is the object datatype IRI for typed literals, or null. */
360
+ oDatatype: string | null;
361
+ /** oLang is the object language tag for language-tagged strings, or null. */
362
+ oLang: string | null;
363
+ /** g is the graph IRI or term value. */
364
+ g: string;
365
+ /** gType is the graph term type ("NamedNode" or "DefaultGraph"). */
366
+ gType: string;
367
+ }
368
+ /**
369
+ * quadFromRow reconstructs an RDF/JS quad from a QuadRowReader impl, eliminating per-backend row mapping duplication.
370
+ */
371
+ declare function quadFromRow(row: QuadRowReader): rdfjs.Quad;
372
+ /** Term is the backend-neutral serializable record for one RDF term. */
373
+ interface Term {
374
+ /** termType is the RDF/JS term type discriminator. */
375
+ termType: string;
376
+ /** value is the lexical or IRI value for the term. */
377
+ value: string;
378
+ /** language is the optional language tag for Literal terms. */
379
+ language?: string;
380
+ /** datatype is the optional datatype IRI for Literal terms. */
381
+ datatype?: string;
382
+ }
383
+ /**
384
+ * fromRdfjsTerm flattens an RDF/JS term into a backend-neutral Term.
385
+ */
386
+ declare function fromRdfjsTerm(rdfjsTerm: rdfjs.Term): Term;
387
+ /**
388
+ * toRdfjsTerm reconstitutes an RDF/JS term from a backend-neutral Term.
389
+ */
390
+ declare function toRdfjsTerm(storedTerm: Term): rdfjs.Term;
391
+ /** Quad is the backend-neutral serializable record for one RDF quad. */
392
+ interface Quad {
393
+ /** subject is the serialized RDF subject term. */
394
+ subject: Term;
395
+ /** predicate is the serialized RDF predicate term. */
396
+ predicate: Term;
397
+ /** object is the serialized RDF object term. */
398
+ object: Term;
399
+ /** graph is the serialized RDF graph term. */
400
+ graph: Term;
401
+ }
402
+ /**
403
+ * fromRdfjsQuad flattens an RDF/JS quad into a backend-neutral Quad.
404
+ */
405
+ declare function fromRdfjsQuad(rdfjsQuad: rdfjs.Quad): Quad;
406
+ /**
407
+ * toRdfjsQuad reconstitutes an RDF/JS quad from a backend-neutral Quad.
408
+ */
409
+ declare function toRdfjsQuad(storedQuad: Quad): rdfjs.Quad;
410
+ /**
411
+ * RdfFormat specifies content type configuration mapping for parser/writer facilities.
412
+ */
413
+ interface RdfFormat {
414
+ contentType: string;
415
+ engineFormat: TurtleFormat;
416
+ }
417
+ /**
418
+ * FORMATS is a map of content types to supported RdfFormats. The engine's
419
+ * TriG grammar is a Turtle/N-Triples/N-Quads superset, so parsing is uniform
420
+ * across formats; the dialect only constrains serialization. `text/n3` maps
421
+ * to the Turtle writer (the engine covers the N3 subset that is valid
422
+ * Turtle/TriG).
423
+ */
424
+ declare const FORMATS: Record<string, RdfFormat>;
425
+ /**
426
+ * getFormat resolves the appropriate RdfFormat mapping for the given content type, defaulting to N-Quads.
427
+ */
428
+ declare function getFormat(contentType: string | undefined): RdfFormat;
429
+ /**
430
+ * parseQuads parses serialized RDF into a quad stream for the given content type.
431
+ */
432
+ declare function parseQuads(data: string, contentType?: string): rdfjs.Stream<rdfjs.Quad>;
433
+ /**
434
+ * collectQuadsFromStream drains an RDF/JS quad stream into an array.
435
+ */
436
+ declare function collectQuadsFromStream(stream: rdfjs.Stream<rdfjs.Quad>): Promise<rdfjs.Quad[]>;
437
+ /**
438
+ * materializeImportQuads collects quads from an import source into an array.
439
+ */
440
+ declare function materializeImportQuads(source: ImportRequest["source"]): Promise<rdfjs.Quad[]>;
441
+ /**
442
+ * exportQuadsResponse formats collected quads according to an export request.
443
+ */
444
+ declare function exportQuadsResponse(quads: rdfjs.Quad[], request: ExportRequest): ExportResponse;
445
+ /**
446
+ * awaitDrainRemoveMatches waits for removeMatches(null, null, null, null) to finish.
447
+ * Used by createRdfjsStoreCommitHandler for replace import commits; durable backends
448
+ * honor isReplaceImportCommit in their commit patch handlers.
449
+ */
450
+ declare function awaitDrainRemoveMatches(store: RdfjsStoreLike): Promise<void>;
451
+ /**
452
+ * createRdfjsStoreCommitHandler returns a commit function that applies Patches
453
+ * directly to an underlying rdfjs.Store by using its native add/delete/remove methods.
454
+ * For robust usage, the underlying store should support synchronous add/delete.
455
+ */
456
+ declare function createRdfjsStoreCommitHandler(store: RdfjsStoreLike): (patch: Patch, context?: TransactionContext) => Promise<void>;
457
+ /** MatchFunction represents a stream-based query against a graph store. */
458
+ type MatchFunction = (subject?: rdfjs.Term | null, predicate?: rdfjs.Term | null, object?: rdfjs.Term | null, graph?: rdfjs.Term | null) => rdfjs.Stream<rdfjs.Quad>;
459
+ /**
460
+ * TransactionOptions configures the handlers used when a transaction commits.
461
+ */
462
+ interface TransactionOptions {
463
+ /** commit persists the deduplicated patch. */
464
+ commit?: (patch: Patch, context?: TransactionContext) => Promise<void>;
465
+ /** fallbackCommit runs when commit is omitted. */
466
+ fallbackCommit?: (patch: Patch, context?: TransactionContext) => Promise<void>;
467
+ }
468
+ /**
469
+ * Transaction collects mutations natively before flushing them as a deduplicated Patch.
470
+ * It deeply implements the mutation boundary for an rdfjs.Store, providing rich bulk
471
+ * ingestion without requiring wrapper classes.
472
+ */
473
+ declare class Transaction {
474
+ private readonly options;
475
+ private insertBuffer;
476
+ private deleteBuffer;
477
+ constructor(options: TransactionOptions);
478
+ /** add buffers a single quad for insertion on the next commit. */
479
+ add(quad: rdfjs.Quad): this;
480
+ /** addQuad buffers a single quad for insertion on the next commit. */
481
+ addQuad(quad: rdfjs.Quad): this;
482
+ /** addQuads buffers multiple quads for insertion on the next commit. */
483
+ addQuads(quads: rdfjs.Quad[]): this;
484
+ /** removeQuads buffers multiple quads for deletion on the next commit. */
485
+ removeQuads(quads: rdfjs.Quad[]): this;
486
+ /** delete buffers a single quad for deletion on the next commit. */
487
+ delete(quad: rdfjs.Quad): this;
488
+ /** removeQuad buffers a single quad for deletion on the next commit. */
489
+ removeQuad(quad: rdfjs.Quad): this;
490
+ /** import consumes an RDF/JS stream, buffering all quads for later commit. */
491
+ import(stream: rdfjs.Stream<rdfjs.Quad>): EventEmitter;
492
+ /** remove consumes a stream and buffers all quads from it for deletion on commit. */
493
+ remove(stream: rdfjs.Stream<rdfjs.Quad>): EventEmitter;
494
+ /** removeMatches buffers all quads matching the given quad pattern for deletion on commit. */
495
+ removeMatches(match: MatchFunction, subject?: rdfjs.Term | null, predicate?: rdfjs.Term | null, object?: rdfjs.Term | null, graph?: rdfjs.Term | null): EventEmitter;
496
+ /** deleteGraph buffers all quads in the named graph for deletion on commit. */
497
+ deleteGraph(match: MatchFunction, graph: rdfjs.Term | string): EventEmitter;
498
+ /** commit deduplicates buffers and persists through the configured commitHandler. */
499
+ commit(context?: TransactionContext): Promise<void>;
500
+ /** rollback discards any uncommitted insertions and deletions. */
501
+ rollback(): void;
502
+ private clearBuffer;
503
+ }
504
+ /**
505
+ * ImportViaBufferedRdfjsStoreOptions configures durable import over a Transaction.
506
+ */
507
+ interface ImportViaTransactionOptions {
508
+ /** createTransaction yields a scoped mutation interceptor (Transaction). */
509
+ createTransaction: () => Transaction;
510
+ }
511
+ /**
512
+ * importViaTransaction drains an ImportRequest directly into a transactional patch.
513
+ */
514
+ declare function importViaTransaction(request: ImportRequest, options: ImportViaTransactionOptions): Promise<void>;
515
+ /**
516
+ * RdfjsExportSource is the minimal RDF/JS surface required for quad export.
517
+ */
518
+ type RdfjsExportSource = Pick<RdfjsStoreLike, "match">;
519
+ /**
520
+ * exportFromRdfjsStore streams all quads from an RDF/JS store and serializes the export response.
521
+ */
522
+ declare function exportFromRdfjsStore(rdfjsStore: RdfjsExportSource, request: ExportRequest): Promise<ExportResponse>;
523
+ /**
524
+ * TransactionalRdfjsStoreOptions defines the dependencies for the store wrapper.
525
+ */
526
+ interface TransactionalRdfjsStoreOptions {
527
+ /** readStore is the underlying store used to resolve queries. */
528
+ readStore: ReadonlyStore;
529
+ /** transaction is the mutation buffer used to absorb updates. */
530
+ transaction: Transaction;
531
+ }
532
+ /**
533
+ * ReadonlyStore represents a minimal read-only RDFJS Store interface,
534
+ * often provided by durable backends like LibSQL or Deno KV that centralize
535
+ * mutations elsewhere.
536
+ */
537
+ interface ReadonlyStore {
538
+ /** match returns a stream of quads matching the given pattern. */
539
+ match(subject?: rdfjs.Term | null, predicate?: rdfjs.Term | null, object?: rdfjs.Term | null, graph?: rdfjs.Term | null): rdfjs.Stream<rdfjs.Quad>;
540
+ }
541
+ /**
542
+ * TransactionalRdfjsStore is an explicit wrapper that satisfies the full `rdfjs.Store`
543
+ * interface by routing reads to a ReadonlyStore and mutations to a Transaction buffer.
544
+ * It replaces proxy-based interception with a concrete class for better JIT optimization
545
+ * and clearer architectural boundaries.
546
+ */
547
+ declare class TransactionalRdfjsStore implements rdfjs.Store {
548
+ private readonly options;
549
+ constructor(options: TransactionalRdfjsStoreOptions);
550
+ match(subject?: rdfjs.Term | null, predicate?: rdfjs.Term | null, object?: rdfjs.Term | null, graph?: rdfjs.Term | null): rdfjs.Stream<rdfjs.Quad>;
551
+ add(quad: rdfjs.Quad): this;
552
+ addQuad(quad: rdfjs.Quad): this;
553
+ addQuads(quads: rdfjs.Quad[]): this;
554
+ delete(quad: rdfjs.Quad): this;
555
+ removeQuad(quad: rdfjs.Quad): this;
556
+ removeQuads(quads: rdfjs.Quad[]): this;
557
+ import(stream: rdfjs.Stream<rdfjs.Quad>): EventEmitter;
558
+ remove(stream: rdfjs.Stream<rdfjs.Quad>): EventEmitter;
559
+ removeMatches(subject?: rdfjs.Term | null, predicate?: rdfjs.Term | null, object?: rdfjs.Term | null, graph?: rdfjs.Term | null): EventEmitter;
560
+ deleteGraph(graph: rdfjs.Term | string): EventEmitter;
561
+ }
562
+ /**
563
+ * PreparedPatch is a patch after the pure, fallible work every durable commit
564
+ * starts with: the include/exclude filter and content-addressed hashing.
565
+ * Nothing in it has touched a store, so a throw while preparing leaves the
566
+ * store untouched (even before a replace-import wipe).
567
+ */
568
+ interface PreparedPatch {
569
+ /** deletions are the patch's deletions that passed the filter. */
570
+ deletions: rdfjs.Quad[];
571
+ /** deletionIds are the content hashes of `deletions`, index for index. */
572
+ deletionIds: string[];
573
+ /** insertions are the patch's insertions that passed the filter. */
574
+ insertions: rdfjs.Quad[];
575
+ /** insertionIds are the content hashes of `insertions`, index for index. */
576
+ insertionIds: string[];
577
+ }
578
+ /**
579
+ * preparePatch applies the include/exclude filter to both sides of a patch and
580
+ * hashes what is left. It does not deduplicate within a side: the same quad
581
+ * inserted twice appears twice, as in every durable backend today.
582
+ */
583
+ declare function preparePatch(patch: Patch, filter?: QuadFilter): PreparedPatch;
584
+ /** SelectNovelQuadsOptions tells selectNovelQuads how to ask a store what it already holds. */
585
+ interface SelectNovelQuadsOptions {
586
+ /**
587
+ * lookupExisting returns which of `keys` the store already holds. It is
588
+ * called once with every insertion key (duplicates included), so a backend
589
+ * does its own chunking by `maxLookupChunkSize`. It is not called when there
590
+ * are no insertions or when `replacing` is true.
591
+ */
592
+ lookupExisting: (keys: string[]) => Promise<Set<string>>;
593
+ /**
594
+ * keyOf is the identity the store uses to recognise a quad. Defaults to the
595
+ * content hash. A backend keyed on something else (SQLite's term-keyed
596
+ * rows) returns that key here, and `lookupExisting` receives the same keys.
597
+ */
598
+ keyOf?: (quad: rdfjs.Quad, id: string) => string;
599
+ /**
600
+ * replacing is true for a replace-mode import. The commit wipes the store, so
601
+ * nothing existing counts and no lookup is made. A backend that wipes before
602
+ * it looks up gets the same result without this flag.
603
+ */
604
+ replacing?: boolean;
605
+ }
606
+ /** NovelQuads are the insertions a commit must actually write, with their hashes. */
607
+ interface NovelQuads {
608
+ /** novelInsertions are the quads to write. */
609
+ novelInsertions: rdfjs.Quad[];
610
+ /** novelQuadIds are the content hashes of `novelInsertions`, index for index. */
611
+ novelQuadIds: string[];
612
+ }
613
+ /**
614
+ * selectNovelQuads keeps an insertion when the store does not hold it yet, or
615
+ * when the same patch also deletes it (delete-then-re-add must write it back).
616
+ * This is the deduplication rule of `@wazootech/worlds-libsql`, the reference backend.
617
+ */
618
+ declare function selectNovelQuads(prepared: PreparedPatch, options: SelectNovelQuadsOptions): Promise<NovelQuads>;
619
+ /**
620
+ * computeNovelQuads is preparePatch followed by selectNovelQuads, for backends
621
+ * with no write between the two. Backends that wipe on replace-import hash
622
+ * first and look up after the wipe call the two steps separately.
623
+ */
624
+ declare function computeNovelQuads(patch: Patch, options: SelectNovelQuadsOptions & QuadFilter): Promise<PreparedPatch & NovelQuads>;
625
+ export { ImportRequest as $, fromRdfjsTerm as A, QuadFilter as B, getFormat as C, fromRdfjsQuad as D, Quad as E, HexastoreIndexDescriptor as F, isImportCommit as G, PatchableStore as H, hashQuad as I, RdfjsStoreLike as J, isReplaceImportCommit as K, hashQuads as L, QuadRowReader as M, quadFromRow as N, toRdfjsQuad as O, HEXASTORE_INDEXES as P, ImportMode as Q, isTextualLiteral as R, exportQuadsResponse as S, parseQuads as T, TransactionContext as U, filterQuads as V, deduplicateBuffers as W, ExportRequest as X, Patch as Y, ExportResponse as Z, createRdfjsStoreCommitHandler as _, preparePatch as a, ProvenanceListQuery as at, awaitDrainRemoveMatches as b, TransactionalRdfjsStore as c, ProvenanceQueryResponse as ct, RdfjsExportSource as d, ProvenanceRecordInput as dt, ImportSource as et, exportFromRdfjsStore as f, ProvenanceRecordType as ft, TransactionOptions as g, Transaction as h, computeNovelQuads as i, ProvenanceHistory as it, toRdfjsTerm as j, Term as k, TransactionalRdfjsStoreOptions as l, ProvenanceQueryResult as lt, MatchFunction as m, PreparedPatch as n, InMemoryProvenanceStore as nt, selectNovelQuads as o, ProvenanceQueryHandler as ot, importViaTransaction as p, ProvenanceStore as pt, RdfjsEventSource as q, SelectNovelQuadsOptions as r, ImportProvenance as rt, ReadonlyStore as s, ProvenanceQueryRequest as st, NovelQuads as t, QuadStoreInterface as tt, ImportViaTransactionOptions as u, ProvenanceRecord as ut, FORMATS as v, materializeImportQuads as w, collectQuadsFromStream as x, RdfFormat as y, QuadCriteria as z };
@@ -0,0 +1,13 @@
1
+ import { t as EmbeddingService } from "./embedding-service-DebRMVmn.js";
2
+ /**
3
+ * FakeEmbeddingService implements a reliable dummy projection model usable
4
+ * during automated integration tests to avoid live API consumption.
5
+ * It constantly outputs valid fixed-dimension Float32 tensors.
6
+ */
7
+ declare class FakeEmbeddingService implements EmbeddingService {
8
+ /**
9
+ * Construct static deterministic embedding vectors of the required length.
10
+ */
11
+ embed(texts: string[]): Promise<Array<Float32Array>>;
12
+ }
13
+ export { FakeEmbeddingService as t };
@@ -0,0 +1,2 @@
1
+ import { a as ChunkRowPayload, c as chunkQuads, i as chunkAndEmbedQuads, n as ChunkAndEmbedResult, o as Document, r as EmbeddedChunk, s as TextSplitterInterface, t as ChunkAndEmbedOptions } from "./mod-CHiiyEER.js";
2
+ export { ChunkAndEmbedOptions, ChunkAndEmbedResult, ChunkRowPayload, Document, EmbeddedChunk, TextSplitterInterface, chunkAndEmbedQuads, chunkQuads };
@@ -0,0 +1 @@
1
+ export { t as chunkAndEmbedQuads, n as chunkQuads } from "./chunk-and-embed-0crm0xLl.js";