@littlebigbrain/client 0.1.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.
@@ -0,0 +1,764 @@
1
+ import type { components } from "./schema.js";
2
+ /** Request/response types, generated from the committed OpenAPI spec. */
3
+ export type Schemas = components["schemas"];
4
+ /**
5
+ * The unified list-response envelope returned by every collection read
6
+ * (`/v1/graph/entities`, `/v1/graph/edges`, `/v1/graph/observations`): the rows
7
+ * in `data`, plus `next_cursor` (echo back as `cursor` for the next page) and
8
+ * the pre-page `total_count`. Walk pages with {@link LbbClient.listAll}.
9
+ */
10
+ export interface ListResponse<T> {
11
+ object: "list";
12
+ data: T[];
13
+ has_more: boolean;
14
+ next_cursor: string | null;
15
+ snapshot: Schemas["SnapshotView"];
16
+ total_count: number;
17
+ }
18
+ /**
19
+ * A flat `{ field: value }` property map. Values are coerced to each field's
20
+ * declared type server-side, so a string like `"2026-06-26"` lands in a
21
+ * `date_time` field and `"52"` in an `i64` field. The verbose
22
+ * `Schemas["PropertyInput"][]` form is also accepted.
23
+ */
24
+ export type FlatProperties = Record<string, string | number | boolean>;
25
+ /** A single entity-properties record for commit/import, with flat or verbose properties. */
26
+ export type EntityPropertiesLine = {
27
+ type: string;
28
+ name: string;
29
+ /** Optional stable external key; identity becomes `(type, key)`. */
30
+ key?: string;
31
+ properties: FlatProperties | Schemas["PropertyInput"][];
32
+ };
33
+ /** One bulk-import line: a triplet, or an entity-properties record. */
34
+ export type ImportLine = Schemas["TripletInput"] | EntityPropertiesLine;
35
+ export type AttributeFilterOp = "eq" | "ne" | "lt" | "le" | "gt" | "ge";
36
+ export type AttributeFilterValue = string | number | boolean | {
37
+ dateTime: string;
38
+ } | {
39
+ entity: Schemas["EntitySelector"];
40
+ };
41
+ export interface AttributeFilter {
42
+ /** Query variable whose typed property should be compared. Defaults to the first bound pattern variable. */
43
+ var?: string;
44
+ /** Ontology property field name, e.g. `status`, `score`, or `committed_at`. */
45
+ field: string;
46
+ /** Comparison operator. Defaults to `eq`. */
47
+ op?: AttributeFilterOp;
48
+ value: AttributeFilterValue;
49
+ }
50
+ export interface EntityAttributeFilterOptions {
51
+ /** Relation patterns that bind the entity variable(s) before attribute filters run. */
52
+ patterns: Schemas["AnalyticTriplePattern"][];
53
+ /** One or more typed-property comparisons. */
54
+ where: AttributeFilter | AttributeFilter[];
55
+ /** Additional raw structured-SPARQL filters to AND with `where`. */
56
+ filters?: Schemas["SparqlFilter"][];
57
+ select?: string[];
58
+ limit?: number;
59
+ offset?: number;
60
+ asOfValidTime?: string;
61
+ asOfCommitSeq?: number;
62
+ orderBy?: Schemas["SparqlOrderBy"][];
63
+ reason?: boolean;
64
+ maxSolutions?: number;
65
+ maxObjectReads?: number;
66
+ maxFetchedBytes?: number;
67
+ }
68
+ /**
69
+ * Minimal structural shape of `fetch`, so the client depends on neither the DOM
70
+ * lib nor a specific runtime. Native `fetch` (Node 18+, browsers, workers)
71
+ * satisfies it; tests can pass a fake.
72
+ */
73
+ export type FetchLike = (input: string, init?: {
74
+ method?: string;
75
+ headers?: Record<string, string>;
76
+ body?: string;
77
+ }) => Promise<{
78
+ ok: boolean;
79
+ status: number;
80
+ headers?: {
81
+ get(name: string): string | null;
82
+ };
83
+ text(): Promise<string>;
84
+ }>;
85
+ /** One term in a SPARQL result binding (the standard results-JSON term object). */
86
+ export interface SparqlTerm {
87
+ type: "uri" | "literal" | "bnode" | "typed-literal";
88
+ value: string;
89
+ datatype?: string;
90
+ "xml:lang"?: string;
91
+ }
92
+ /** The standard SPARQL 1.1 Query Results JSON document. */
93
+ export interface SparqlResultsJson {
94
+ head: {
95
+ vars?: string[];
96
+ link?: string[];
97
+ };
98
+ results?: {
99
+ bindings: Record<string, SparqlTerm>[];
100
+ };
101
+ boolean?: boolean;
102
+ }
103
+ /** Parsed SPARQL results: the head vars, the ASK boolean (or null), the raw
104
+ * typed bindings, and the bindings flattened to `{ variable: lexicalValue }`. */
105
+ export interface SparqlResults {
106
+ vars: string[];
107
+ boolean: boolean | null;
108
+ bindings: Record<string, SparqlTerm>[];
109
+ rows: Record<string, string>[];
110
+ }
111
+ /**
112
+ * Parse a {@link Schemas.SparqlTextResponse} (whose `results` field carries the
113
+ * SPARQL Results document as a JSON *string*) into typed bindings plus flat
114
+ * `{ variable: lexicalValue }` rows — the form most callers want, so they never
115
+ * have to `JSON.parse` and zip `head.vars` with binding values by hand.
116
+ */
117
+ export declare function parseSparqlResults(response: Schemas["SparqlTextResponse"]): SparqlResults;
118
+ export interface LbbClientOptions {
119
+ /** Base URL of the Little Big Brain server, e.g. `https://db.eu.littlebigbrain.com`. */
120
+ baseUrl: string;
121
+ /** Stack API key (`lbb_sk_test_…` / `lbb_sk_live_…`) or single-mode token. */
122
+ apiKey?: string;
123
+ /** Graph name (sent as `?graph=`; server default is `main`). */
124
+ graph?: string;
125
+ /** Branch name (sent as `?branch=`; server default is `main`). */
126
+ branch?: string;
127
+ /**
128
+ * Stack slug (sent as `?stack=`). Needed only with a session-token `apiKey`
129
+ * (`lbb_ses_…`), which authorizes an account rather than a single stack; a
130
+ * stack API key (`lbb_sk_test_…` / `lbb_sk_live_…`) already fixes the stack and ignores this.
131
+ */
132
+ stack?: string;
133
+ /** Override the fetch implementation (defaults to the global `fetch`). */
134
+ fetch?: FetchLike;
135
+ /** API version header sent on every request. Defaults to the beta reset contract. */
136
+ apiVersion?: string;
137
+ /** Retry count for 429/5xx responses and network failures. Defaults to 2. */
138
+ maxRetries?: number;
139
+ /** Base delay between retries. Defaults to 100ms. Tests can set 0. */
140
+ retryDelayMs?: number;
141
+ }
142
+ export interface LbbStackView {
143
+ stack_id: string;
144
+ owner_id?: string;
145
+ name: string;
146
+ slug: string;
147
+ tenant_id: string;
148
+ default_graph: string;
149
+ default_branch: string;
150
+ created_at_micros: number;
151
+ api_key_hint: string;
152
+ api_key_rotated_at_micros: number;
153
+ }
154
+ export interface LbbAdminStackCreateRequest {
155
+ owner_id: string;
156
+ name: string;
157
+ slug?: string;
158
+ }
159
+ export interface LbbAdminStackResponse {
160
+ ok: true;
161
+ stack: LbbStackView;
162
+ api_key?: string;
163
+ active_api_key_count?: number;
164
+ }
165
+ export type LbbStackActivityWindow = "1h" | "4h" | "12h" | "24h";
166
+ export interface LbbStackActivityResponse {
167
+ ok: true;
168
+ stack: {
169
+ slug: string;
170
+ name?: string;
171
+ };
172
+ window: {
173
+ range: LbbStackActivityWindow;
174
+ from_micros: number;
175
+ to_micros: number;
176
+ bucket_seconds: number;
177
+ freshness_seconds: number;
178
+ };
179
+ totals: {
180
+ requests: number;
181
+ errors: number;
182
+ p50_latency_ms: number;
183
+ p95_latency_ms: number;
184
+ p99_latency_ms: number;
185
+ storage_read_ops: number;
186
+ storage_read_bytes: number;
187
+ storage_write_ops: number;
188
+ storage_write_bytes: number;
189
+ index_read_ops: number;
190
+ index_read_bytes: number;
191
+ };
192
+ details: {
193
+ total_bucket_count: number;
194
+ active_bucket_count: number;
195
+ error_rate: number;
196
+ storage_total_ops: number;
197
+ storage_total_bytes: number;
198
+ non_index_storage_read_ops: number;
199
+ non_index_storage_read_bytes: number;
200
+ index_read_share: number;
201
+ first_activity_bucket_start_micros?: number;
202
+ last_activity_bucket_start_micros?: number;
203
+ };
204
+ series: Array<{
205
+ bucket_start_micros: number;
206
+ requests: number;
207
+ errors: number;
208
+ p50_latency_ms: number;
209
+ p95_latency_ms: number;
210
+ p99_latency_ms: number;
211
+ storage_read_ops: number;
212
+ storage_read_bytes: number;
213
+ storage_write_ops: number;
214
+ storage_write_bytes: number;
215
+ index_read_ops: number;
216
+ index_read_bytes: number;
217
+ }>;
218
+ routes: Array<{
219
+ family: string;
220
+ requests: number;
221
+ errors: number;
222
+ error_rate: number;
223
+ request_share: number;
224
+ p50_latency_ms: number;
225
+ p95_latency_ms: number;
226
+ p99_latency_ms: number;
227
+ }>;
228
+ storage: Array<{
229
+ family: string;
230
+ read_ops: number;
231
+ read_bytes: number;
232
+ write_ops: number;
233
+ write_bytes: number;
234
+ total_ops: number;
235
+ total_bytes: number;
236
+ op_share: number;
237
+ byte_share: number;
238
+ }>;
239
+ partial: boolean;
240
+ }
241
+ export interface LbbAdminSessionResponse {
242
+ ok: true;
243
+ /** A `lbb_ses_…` session token scoped to the account. */
244
+ token: string;
245
+ expires_at_micros: number;
246
+ }
247
+ export interface LbbAdminStackDeleteResponse {
248
+ ok: true;
249
+ deleted_stack: LbbStackView;
250
+ tenant_prefix: string;
251
+ objects_deleted: number;
252
+ bytes_deleted: number;
253
+ }
254
+ export interface LbbErrorPayload {
255
+ type?: string;
256
+ code?: string;
257
+ message?: string;
258
+ param?: string | null;
259
+ request_id?: string | null;
260
+ doc_url?: string | null;
261
+ }
262
+ export interface RawLbbResponse<T> {
263
+ data: T;
264
+ status: number;
265
+ requestId?: string;
266
+ version?: string;
267
+ headers?: {
268
+ get(name: string): string | null;
269
+ };
270
+ }
271
+ export interface RequestOptions {
272
+ query?: Query;
273
+ body?: unknown;
274
+ /** Pre-serialized request body (e.g. NDJSON). Takes precedence over `body`. */
275
+ rawBody?: string;
276
+ /** Overrides the default `application/json` content type (used with `rawBody`). */
277
+ contentType?: string;
278
+ idempotencyKey?: string;
279
+ }
280
+ /** Thrown when the server responds with a non-2xx status. */
281
+ export declare class LbbError extends Error {
282
+ readonly status: number;
283
+ readonly body: string;
284
+ readonly error?: LbbErrorPayload | undefined;
285
+ readonly type?: string;
286
+ readonly code?: string;
287
+ readonly param?: string | null;
288
+ readonly requestId?: string | null;
289
+ readonly docUrl?: string | null;
290
+ constructor(status: number, body: string, error?: LbbErrorPayload | undefined);
291
+ }
292
+ type QueryValue = string | number | boolean | undefined;
293
+ type Query = Record<string, QueryValue>;
294
+ /**
295
+ * A typed HTTP client for a Little Big Brain graph server. One instance is scoped to a
296
+ * single graph/branch; construct another for a different scope. All methods
297
+ * return the parsed JSON response and throw {@link LbbError} on failure.
298
+ */
299
+ export declare class LbbClient {
300
+ private readonly baseUrl;
301
+ private readonly apiKey?;
302
+ private readonly graphName?;
303
+ private readonly branchName?;
304
+ private readonly stack?;
305
+ private readonly fetchImpl;
306
+ private readonly apiVersion;
307
+ private readonly maxRetries;
308
+ private readonly retryDelayMs;
309
+ readonly search: SearchNamespace;
310
+ readonly indexes: IndexNamespace;
311
+ readonly entities: EntityNamespace;
312
+ readonly schema: SchemaNamespace;
313
+ constructor(options: LbbClientOptions);
314
+ graph(name: string, opts?: {
315
+ branch?: string;
316
+ stack?: string;
317
+ }): GraphNamespace;
318
+ /**
319
+ * A new client for a different graph/branch on the same server and credential.
320
+ * Each instance is scoped to one graph/branch, so use this to target another
321
+ * scope (e.g. creating a fresh graph) without mutating the current client.
322
+ */
323
+ withScope(scope: {
324
+ graph?: string;
325
+ branch?: string;
326
+ stack?: string;
327
+ }): LbbClient;
328
+ private buildUrl;
329
+ rawRequest<T>(method: string, path: string, opts?: RequestOptions): Promise<RawLbbResponse<T>>;
330
+ request<T>(method: string, path: string, opts?: RequestOptions): Promise<T>;
331
+ private mutationKey;
332
+ idempotencyKey(prefix?: string): string;
333
+ /** Commit triplets and optional entity embeddings. Prefer `client.graph("main").facts.create(...)`. */
334
+ commit(body: Schemas["TripletCommitFile"], opts?: {
335
+ idempotencyKey?: string;
336
+ }): Promise<Schemas["GraphCommitResponse"]>;
337
+ /**
338
+ * Validate-only preflight: run the same ontology/schema validation a real
339
+ * commit would and report the would-be effect (`op_count`, `written_properties`,
340
+ * `schema_validation`) without writing. A rejected request fails exactly as a
341
+ * real commit would, so this is a safe check before mutating. No idempotency
342
+ * key needed — nothing is persisted.
343
+ */
344
+ commitDryRun(body: Schemas["TripletCommitFile"]): Promise<Schemas["GraphCommitDryRunResponse"]>;
345
+ /**
346
+ * Bulk-ingest a dataset as NDJSON. Each line is either a triplet or an
347
+ * `{type,name,properties}` entity-properties record; lines are batched into
348
+ * bounded internal commits server-side, so a whole dataset loads in one
349
+ * streamed request without a single oversized commit. Pass `lines` as an array
350
+ * (serialized to NDJSON here) or a pre-built NDJSON string.
351
+ */
352
+ import(lines: ImportLine[] | string, opts?: {
353
+ batch?: number;
354
+ strict?: boolean;
355
+ observedAt?: string;
356
+ idempotencyKey?: string;
357
+ }): Promise<Schemas["GraphImportResponse"]>;
358
+ /**
359
+ * Bulk-ingest N-Triples without client-side conversion. Resource-object
360
+ * triples become keyed Resource edges; literal-object triples become text
361
+ * properties on the subject Resource.
362
+ */
363
+ importRdf(ntriples: string, opts?: {
364
+ batch?: number;
365
+ strict?: boolean;
366
+ observedAt?: string;
367
+ resourceType?: string;
368
+ edgeIdempotency?: "append" | "skip_unchanged";
369
+ idempotencyKey?: string;
370
+ }): Promise<Schemas["GraphRdfImportResponse"]>;
371
+ /**
372
+ * Retract specific edges and/or every edge touching given entities. Appends
373
+ * superseding retract events rather than deleting — history stays visible in an
374
+ * `as_of` read before the retraction, but the edges drop out of current state.
375
+ * The surgical alternative to {@link deleteGraph}.
376
+ */
377
+ retract(body: Schemas["GraphRetractRequest"], opts?: {
378
+ idempotencyKey?: string;
379
+ }): Promise<Schemas["GraphRetractResponse"]>;
380
+ /** Create the scoped graph/branch. Construct the client with the desired graph/branch first. */
381
+ createGraph(): Promise<Schemas["CreateGraphResponse"]>;
382
+ /** Fork the scoped branch from an existing branch in the same graph. */
383
+ createBranch(body: Schemas["GraphBranchCreateRequest"]): Promise<Schemas["GraphBranchCreateResponse"]>;
384
+ /**
385
+ * Delete every object under the scoped graph/branch — a destructive reset.
386
+ * `confirm` must equal the scoped graph id; the next commit re-initializes the
387
+ * graph. Branch-scoped: sibling branches are untouched.
388
+ */
389
+ deleteGraph(opts: {
390
+ confirm: string;
391
+ }): Promise<unknown>;
392
+ /** Full semantic hybrid search from a request body (`POST /v1/graph/search`). */
393
+ graphSearch(body: Schemas["SemanticGraphSearchRequest"]): Promise<Schemas["SemanticGraphSearchResponse"]>;
394
+ /** Reciprocal-rank-fusion across sub-queries. */
395
+ multiSearch(body: Schemas["HybridMultiSearchRequest"]): Promise<Schemas["HybridMultiSearchResponse"]>;
396
+ /**
397
+ * Append relevance labels for a set of search results — how Little Big Brain
398
+ * gathers customer-specific qrels. Grade results (3 ideal/good, 1 partial,
399
+ * 0 bad), referencing the search response's `search_id` so labels tie back to
400
+ * that ranking. Stored apart from customer facts and exported via
401
+ * {@link searchFeedbackExport} as training/eval data for embedding fine-tuning.
402
+ */
403
+ searchFeedback(body: Schemas["SearchFeedbackRequest"], opts?: {
404
+ idempotencyKey?: string;
405
+ }): Promise<Schemas["SearchFeedbackResponse"]>;
406
+ /** Export the stored relevance labels as qrels-style rows for training. */
407
+ searchFeedbackExport(): Promise<Schemas["SearchFeedbackExportResponse"]>;
408
+ /** BM25 search. */
409
+ fullTextSearch(body: Schemas["FullTextSearchRequest"]): Promise<Schemas["FullTextSearchResponse"]>;
410
+ /** ANN/vector search. */
411
+ embeddingSearch(body: Schemas["EmbeddingSearchRequest"]): Promise<Schemas["EmbeddingSearchResponse"]>;
412
+ /** Bounded k-hop graph traversal. */
413
+ traverse(body: Schemas["TraverseRequest"]): Promise<Schemas["TraverseResponse"]>;
414
+ /** Resolve a query to seed entities, then return bounded paths. */
415
+ semanticTraverse(body: Schemas["SemanticTraverseRequest"]): Promise<Schemas["SemanticTraverseResponse"]>;
416
+ /** Ranked incoming/outgoing neighborhood for a graph entity. */
417
+ entityNeighborhood(opts: {
418
+ id?: string;
419
+ type?: string;
420
+ name?: string;
421
+ relations?: string[];
422
+ asOf?: string;
423
+ }): Promise<Schemas["EntityNeighborhoodResponse"]>;
424
+ /** Stored entity object-ref status and index-coverage metadata (no
425
+ * attributes — read those from `entityDetail`'s top-level `attributes`). */
426
+ entityMetadata(opts: {
427
+ id?: string;
428
+ type?: string;
429
+ name?: string;
430
+ asOf?: string;
431
+ }): Promise<Schemas["EntityMetadataResponse"]>;
432
+ /**
433
+ * Entity detail: metadata, attributes, current state, edge history, and
434
+ * observations. Pass `asOf` / `asOfCommitSeq` to reproduce the node as of a
435
+ * past instant / commit (the state, edges, and history are pinned to it).
436
+ */
437
+ entityDetail(opts: {
438
+ id?: string;
439
+ type?: string;
440
+ name?: string;
441
+ asOf?: string;
442
+ asOfCommitSeq?: number;
443
+ }): Promise<Schemas["EntityDetailResponse"]>;
444
+ /**
445
+ * Paged edge listing. Scope to one node with `id` (or `type`+`name`) and a
446
+ * `direction` (`out`/`in`/`both`) to walk **every** edge of a high-degree node
447
+ * — `entityDetail` returns the full set but is awkward to page; this carries
448
+ * `offset`/`limit` and reports `total_count`. Optional `relation`/`q` filters
449
+ * and an `asOf`/`asOfCommitSeq` snapshot pin. Each row carries `valid_time`, so
450
+ * the page is enough to reconstruct a per-edge timeline.
451
+ */
452
+ graphEdges(opts?: {
453
+ id?: string;
454
+ type?: string;
455
+ name?: string;
456
+ direction?: "out" | "in" | "both";
457
+ relation?: string;
458
+ q?: string;
459
+ limit?: number;
460
+ /** Opaque cursor from a previous page's `next_cursor`. */
461
+ cursor?: string | number;
462
+ /** @deprecated Legacy alias for `cursor` (still accepted by the server). */
463
+ offset?: number;
464
+ asOf?: string;
465
+ asOfCommitSeq?: number;
466
+ }): Promise<ListResponse<Schemas["GraphEdgeRow"]>>;
467
+ /**
468
+ * Page through every row of a list endpoint, following `next_cursor` until
469
+ * exhausted. Pass a fetcher that takes a cursor and returns a
470
+ * {@link ListResponse}:
471
+ * ```ts
472
+ * for await (const e of client.listAll((cursor) =>
473
+ * client.entities.list({ cursor, fields: "title" }))) { … }
474
+ * ```
475
+ */
476
+ listAll<T>(fetchPage: (cursor?: string) => Promise<ListResponse<T>>): AsyncGenerator<T, void, unknown>;
477
+ /** Current state of an entity's relations, optionally as-of a timestamp. */
478
+ currentState(body: Schemas["CurrentStateRequest"]): Promise<Schemas["CurrentStateResponse"]>;
479
+ /** Full edge-event history for a relationship. */
480
+ history(body: Schemas["RelationshipHistoryRequest"]): Promise<Schemas["RelationshipHistoryResponse"]>;
481
+ /** Ordered state-transition log for an entity's relation, with dwell time. */
482
+ transitions(body: Schemas["EntityTransitionsRequest"]): Promise<Schemas["EntityTransitionsResponse"]>;
483
+ /** Lineage and evidence for a single edge. */
484
+ why(body: Schemas["WhyRequest"]): Promise<Schemas["WhyResponse"]>;
485
+ /** SHACL-style shape/pattern query. */
486
+ shacl(body: Schemas["ShaclQueryRequest"]): Promise<Schemas["ShaclQueryResponse"]>;
487
+ /**
488
+ * SPARQL-subset SELECT/ASK/aggregate query (FILTER, HAVING, ORDER BY, ASK,
489
+ * COUNT/SUM/AVG/MIN/MAX). GROUP BY is not limited to entity identity:
490
+ * `group_by` keys on a variable's entity, and `group_keys` adds typed scalar
491
+ * keys — a `property` value, or a `date_bucket` calendar truncation
492
+ * (`year`/`month`/`week`/`day`/`hour`) of a datetime property — so a
493
+ * per-category breakdown or a time series is one server-side query. Scalar
494
+ * keys come back per group in `groups[].value_keys[<as>]`, entity keys in
495
+ * `groups[].keys`.
496
+ */
497
+ sparql(body: Schemas["SparqlSelectRequest"]): Promise<Schemas["SparqlSelectResponse"]>;
498
+ /** SPARQL 1.1 query from text (SELECT/ASK) over the live graph; `results` is SPARQL 1.1 Query Results JSON. */
499
+ sparqlText(body: Schemas["SparqlTextRequest"]): Promise<Schemas["SparqlTextResponse"]>;
500
+ /**
501
+ * Run a SPARQL 1.1 text query and return parsed results — the ergonomic
502
+ * complement to {@link sparqlText} (which hands back the raw results string).
503
+ * Returns `{ vars, boolean, bindings, rows }` via {@link parseSparqlResults}:
504
+ * `rows` is the bindings flattened to `{ variable: lexicalValue }`, `boolean`
505
+ * is the ASK answer (or `null` for a SELECT).
506
+ */
507
+ sparqlRows(body: Schemas["SparqlTextRequest"]): Promise<SparqlResults>;
508
+ /**
509
+ * Basic-graph-pattern query with group-graph-pattern combinators
510
+ * (UNION / OPTIONAL / MINUS / EXISTS / NOT EXISTS) folded over the base
511
+ * patterns. The complement to {@link sparql}: this route carries the
512
+ * combinators (but not FILTER/aggregation), so use it when a query needs an
513
+ * optional/union/negated leg rather than a grouped aggregate.
514
+ */
515
+ analytics(body: Schemas["AnalyticQueryRequest"]): Promise<Schemas["AnalyticQueryResponse"]>;
516
+ /**
517
+ * Run inference rules (SHACL-AF `sh:TripleRule` shape) to a bounded fixpoint
518
+ * and return the derived edges as a **preview** — derived facts are never
519
+ * written to the asserted graph. Each rule is a BGP `body`/`where` plus a
520
+ * `head` triple template instantiated per binding.
521
+ */
522
+ infer(body: Schemas["InferenceRunRequest"]): Promise<Schemas["InferenceRunResponse"]>;
523
+ /**
524
+ * Define (replace) the versioned rule set stored on the scoped graph branch.
525
+ * The stored set is what SHACL `include_derived` and `infer` use when a
526
+ * request carries no inline rules. Returns the new `rules_version`.
527
+ */
528
+ defineRules(body: Schemas["RuleSetDefineRequest"]): Promise<Schemas["RuleSetDefineResponse"]>;
529
+ /** The rule set stored on the scoped graph branch (version + rules). */
530
+ graphRules(): Promise<Schemas["RuleSet"]>;
531
+ /**
532
+ * Stage G — derive edges from calibrated retrieval matches (preview): each
533
+ * candidate scored `P >= threshold` becomes a derived edge `(anchor, relation,
534
+ * matched)` with a typed `Retrieval` provenance leaf. Pass either explicit
535
+ * `candidates` or a `query` the server runs as BM25 entity retrieval.
536
+ */
537
+ retrievalPremises(body: Schemas["RetrievalPremiseRequest"]): Promise<Schemas["RetrievalPremiseResponse"]>;
538
+ /**
539
+ * The active ontology (entity types and relations) for the scoped graph.
540
+ * Pass `{ counts: true }` to include a per-relation current-edge count
541
+ * (`OntologyRelationView.edge_count`) so a caller can see which declared
542
+ * relations are actually populated — at the cost of a snapshot load.
543
+ */
544
+ ontologyView(opts?: {
545
+ counts?: boolean;
546
+ }): Promise<Schemas["OntologyView"]>;
547
+ /**
548
+ * Audit the current snapshot against the ontology's *implied* constraints —
549
+ * capped `cardinality` derived as `sh:maxCount` — returning a SHACL-shaped
550
+ * report. Whole-snapshot and never blocks a write. Unlike
551
+ * {@link SchemaNamespace.audit}, this needs no published shape bundle: the
552
+ * shapes come from the ontology itself. See the `decoration_status` catalog on
553
+ * {@link ontologyView} for which decorations are enforced.
554
+ */
555
+ ontologyConformance(): Promise<Schemas["SchemaAuditReport"]>;
556
+ /** Discover ontology concepts, terms, and relations. */
557
+ ontologySearch(body: Schemas["OntologySearchRequest"]): Promise<Schemas["OntologySearchResponse"]>;
558
+ /** Resolve mentions to concepts/entities. */
559
+ ontologyResolve(body: Schemas["OntologyResolveRequest"]): Promise<Schemas["OntologyResolveResponse"]>;
560
+ /** Define the active ontology before the scoped graph's first commit. */
561
+ ontologyDefine(body: Schemas["OntologyDefineRequest"]): Promise<Schemas["OntologyDefineResponse"]>;
562
+ /**
563
+ * Additively evolve the active ontology of an existing graph: widen relation
564
+ * domains/ranges and declare new entity types (all by name), bumping the
565
+ * ontology version. Additive-only — every existing record stays valid, so no
566
+ * migration is needed — and a request that changes nothing is a no-op.
567
+ */
568
+ evolveOntology(body: Schemas["OntologyEvolveRequest"]): Promise<Schemas["OntologyEvolveResponse"]>;
569
+ /**
570
+ * Build default ANN + BM25 indexes. With `{ background: true }` the build
571
+ * runs detached on the server and the call returns immediately — use it for
572
+ * large corpora whose synchronous build would exceed a fronting gateway's
573
+ * timeout (a 504), then poll `metadata()` for completion.
574
+ */
575
+ indexBuild(opts?: {
576
+ background?: boolean;
577
+ }): Promise<unknown>;
578
+ /**
579
+ * Build BM25, ANN/vector, and adjacency index families. With
580
+ * `{ background: true }` the build runs detached on the server and the call
581
+ * returns immediately — use it for large corpora whose synchronous build would
582
+ * exceed a fronting gateway's timeout, then poll `metadata()` for completion.
583
+ */
584
+ indexRun(opts?: {
585
+ background?: boolean;
586
+ }): Promise<unknown>;
587
+ /** Append a BM25 delta segment for the unindexed WAL tail. */
588
+ indexDelta(): Promise<Schemas["IndexDeltaResponse"]>;
589
+ /** Preview or delete superseded persisted index runs. */
590
+ indexGc(opts?: {
591
+ keepRuns?: number;
592
+ dryRun?: boolean;
593
+ }): Promise<Schemas["IndexGcResponse"]>;
594
+ /** Fold the WAL tail into snapshot segments. */
595
+ compact(opts?: {
596
+ minTailCommits?: number;
597
+ maxSegments?: number;
598
+ }): Promise<Schemas["WalCompactResponse"]>;
599
+ /** Server, graph, and persisted-index status. */
600
+ status(): Promise<unknown>;
601
+ /** Graph footprint, WAL tail, and index coverage. */
602
+ metadata(): Promise<Schemas["GraphMetadataResponse"]>;
603
+ /** Graph counts and type/relation buckets. */
604
+ summary(): Promise<Schemas["GraphSummaryResponse"]>;
605
+ /** List the graphs (and branches) under the scoped tenant. */
606
+ listGraphs(): Promise<Schemas["GraphListResponse"]>;
607
+ /** Create a database stack and return its one-time stack API key. */
608
+ adminCreateStack(body: LbbAdminStackCreateRequest): Promise<LbbAdminStackResponse>;
609
+ /** Inspect a database stack without returning secret key material. */
610
+ adminStack(slug: string): Promise<LbbAdminStackResponse>;
611
+ /** Rotate a database stack key and return the new one-time API key. */
612
+ adminRotateStackKey(slug: string): Promise<LbbAdminStackResponse>;
613
+ /** Delete a database stack after confirming the slug. */
614
+ adminDeleteStack(slug: string): Promise<LbbAdminStackDeleteResponse>;
615
+ /**
616
+ * Mint a short-lived `lbb_ses_…` session token for an account. A trusted
617
+ * co-located service uses it (with `?stack=<slug>`) to call the data plane on
618
+ * the account's behalf without handling the stack's mode-bearing stack key.
619
+ */
620
+ adminMintSession(accountId: string): Promise<LbbAdminSessionResponse>;
621
+ /** Customer-visible activity for one database stack. */
622
+ adminStackActivity(slug: string, window?: LbbStackActivityWindow): Promise<LbbStackActivityResponse>;
623
+ /** Activity for the stack selected by the bearer stack key or session. */
624
+ stackActivity(window?: LbbStackActivityWindow): Promise<LbbStackActivityResponse>;
625
+ }
626
+ export declare class GraphNamespace {
627
+ private readonly client;
628
+ readonly facts: FactsNamespace;
629
+ constructor(client: LbbClient);
630
+ branch(name: string): GraphNamespace;
631
+ create(): Promise<Schemas["CreateGraphResponse"]>;
632
+ delete(opts: {
633
+ confirm: string;
634
+ }): Promise<unknown>;
635
+ /** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
636
+ retract(body: Schemas["GraphRetractRequest"], opts?: {
637
+ idempotencyKey?: string;
638
+ }): Promise<Schemas["GraphRetractResponse"]>;
639
+ }
640
+ export declare class FactsNamespace {
641
+ private readonly client;
642
+ constructor(client: LbbClient);
643
+ create(body: Schemas["TripletCommitFile"], opts?: {
644
+ idempotencyKey?: string;
645
+ }): Promise<Schemas["GraphCommitResponse"]>;
646
+ /** Bulk-load a dataset as NDJSON. See {@link LbbClient.import}. */
647
+ import(lines: ImportLine[] | string, opts?: {
648
+ batch?: number;
649
+ strict?: boolean;
650
+ observedAt?: string;
651
+ idempotencyKey?: string;
652
+ }): Promise<Schemas["GraphImportResponse"]>;
653
+ /**
654
+ * Bulk-load N-Triples through the native RDF import endpoint.
655
+ *
656
+ * Statements are committed through the fixed RDF_TRIPLE relation; source RDF
657
+ * predicates and literal term details are preserved as edge metadata.
658
+ */
659
+ importRdf(ntriples: string, opts?: {
660
+ batch?: number;
661
+ strict?: boolean;
662
+ observedAt?: string;
663
+ resourceType?: string;
664
+ edgeIdempotency?: "append" | "skip_unchanged";
665
+ idempotencyKey?: string;
666
+ }): Promise<Schemas["GraphRdfImportResponse"]>;
667
+ }
668
+ export declare class SearchNamespace {
669
+ private readonly client;
670
+ constructor(client: LbbClient);
671
+ hybrid(query: string, opts?: {
672
+ topK?: number;
673
+ source?: string;
674
+ consistency?: string;
675
+ lexical?: boolean;
676
+ bm25?: boolean;
677
+ vector?: boolean;
678
+ targets?: string[];
679
+ profile?: string;
680
+ /** Opt-in impression logging (L1): durably record this search's full
681
+ * ranking context, keyed by `search_id`, so a later feedback label on it
682
+ * carries the ranking it was judged against. Off by default. */
683
+ logImpression?: boolean;
684
+ }): Promise<Schemas["SemanticGraphSearchResponse"]>;
685
+ hybrid(body: Schemas["SemanticGraphSearchRequest"]): Promise<Schemas["SemanticGraphSearchResponse"]>;
686
+ multi(body: Schemas["HybridMultiSearchRequest"]): Promise<Schemas["HybridMultiSearchResponse"]>;
687
+ feedback(body: Schemas["SearchFeedbackRequest"], opts?: {
688
+ idempotencyKey?: string;
689
+ }): Promise<Schemas["SearchFeedbackResponse"]>;
690
+ feedbackExport(): Promise<Schemas["SearchFeedbackExportResponse"]>;
691
+ fullText(body: Schemas["FullTextSearchRequest"]): Promise<Schemas["FullTextSearchResponse"]>;
692
+ vector(body: Schemas["EmbeddingSearchRequest"]): Promise<Schemas["EmbeddingSearchResponse"]>;
693
+ }
694
+ export declare class SchemaNamespace {
695
+ private readonly client;
696
+ constructor(client: LbbClient);
697
+ /** Active graph schema bundle: ontology plus activated SHACL shapes. */
698
+ view(opts?: {
699
+ audit?: boolean;
700
+ }): Promise<Schemas["SchemaBundleView"]>;
701
+ /** Preview a proposed RDF/SHACL schema bundle and audit current data. */
702
+ preview(body: Schemas["SchemaPreviewRequest"]): Promise<Schemas["SchemaPreviewResponse"]>;
703
+ /** Activate a previewed SHACL schema bundle for this graph branch. */
704
+ publish(body: Schemas["SchemaPublishRequest"]): Promise<Schemas["SchemaPublishResponse"]>;
705
+ /** Audit current data against the active SHACL schema bundle. */
706
+ audit(): Promise<Schemas["SchemaAuditReport"]>;
707
+ }
708
+ export declare class IndexNamespace {
709
+ private readonly client;
710
+ constructor(client: LbbClient);
711
+ run(opts?: {
712
+ wait?: boolean;
713
+ background?: boolean;
714
+ body?: unknown;
715
+ }): Promise<unknown>;
716
+ build(): Promise<unknown>;
717
+ delta(): Promise<Schemas["IndexDeltaResponse"]>;
718
+ gc(opts?: {
719
+ keepRuns?: number;
720
+ dryRun?: boolean;
721
+ }): Promise<Schemas["IndexGcResponse"]>;
722
+ }
723
+ export declare class EntityNamespace {
724
+ private readonly client;
725
+ constructor(client: LbbClient);
726
+ /**
727
+ * Browse entities as the unified list envelope. Pass `fields` (names or `*`)
728
+ * to inline each row's typed attributes as native JSON (under `attributes`) —
729
+ * "list entities and their titles" in one call instead of a list plus N point
730
+ * lookups — or `ids`
731
+ * to fetch a specific set. Page with `cursor` from the previous `next_cursor`.
732
+ */
733
+ list(opts?: {
734
+ type?: string;
735
+ limit?: number;
736
+ cursor?: string | number;
737
+ /** @deprecated Legacy alias for `cursor`. */
738
+ offset?: number;
739
+ query?: string;
740
+ /** Property names to inline per row (or `"*"` / `["*"]` for all). */
741
+ fields?: string | string[];
742
+ /** Specific entity ids to fetch in one call (bulk lookup). */
743
+ ids?: string | string[];
744
+ }): Promise<ListResponse<Schemas["EntityExplorerRow"]>>;
745
+ get(opts: {
746
+ id?: string;
747
+ type?: string;
748
+ name?: string;
749
+ asOf?: string;
750
+ }): Promise<Schemas["EntityMetadataResponse"]>;
751
+ detail(opts: {
752
+ id?: string;
753
+ type?: string;
754
+ name?: string;
755
+ }): Promise<Schemas["EntityDetailResponse"]>;
756
+ /**
757
+ * Filter entities already bound by relation patterns using typed attributes,
758
+ * without writing RDF property IRIs by hand. This is a convenience wrapper over
759
+ * the structured SPARQL route: relation `patterns` bind variables, and `where`
760
+ * compares ontology property fields on those bound variables.
761
+ */
762
+ filterByAttributes(opts: EntityAttributeFilterOptions): Promise<Schemas["SparqlSelectResponse"]>;
763
+ }
764
+ export {};