@littlebigbrain/client 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/client.d.ts +34 -43
- package/dist/client.js +73 -62
- package/dist/index.d.ts +1 -1
- package/dist/namespaces.d.ts +17 -21
- package/dist/namespaces.js +48 -31
- package/dist/schema.d.ts +1220 -144
- package/dist/types.d.ts +22 -37
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @littlebigbrain/client
|
|
2
2
|
|
|
3
|
-
TypeScript client for the [
|
|
3
|
+
TypeScript client for the [little big brain](https://littlebigbrain.com) graph + hybrid search HTTP
|
|
4
4
|
API. Request and response types are generated from the committed
|
|
5
5
|
[`contracts/openapi.json`](https://github.com/littlebigbrains/lbb-typescript/blob/main/contracts/openapi.json) (the single source of
|
|
6
6
|
truth, derived from the Rust `lbb-api` types); the client itself is a thin,
|
|
@@ -95,17 +95,17 @@ and `elapsedMs`.
|
|
|
95
95
|
| Area | Methods |
|
|
96
96
|
| --- | --- |
|
|
97
97
|
| Write | `graph("main").facts.create` |
|
|
98
|
+
| Managed embeddings | `graph("main").embeddingConfig`, `graph("main").setEmbeddingConfig`, `graph("main").backfillEmbeddings`, `graph("main").promoteEmbedding` |
|
|
98
99
|
| Search | `search.hybrid`, `search.multi`, `search.fullText`, `search.vector` |
|
|
99
100
|
| Context substrate | `context.ask`, `context.suggest`, `context.resolve`, `context.decode`, `context.groundability` |
|
|
100
101
|
| Search feedback (training data) | `search.feedback`, `search.feedbackExport` |
|
|
101
102
|
| Traversal | `traverse`, `semanticTraverse` |
|
|
102
103
|
| Temporal / lineage / shapes | `currentState`, `history`, `why`, `shacl` |
|
|
103
104
|
| Query | `query.sparql`, `query.structured`, `query.analytics`, `query.shacl`, `query.infer`, `query.premises` |
|
|
104
|
-
| Ontology | `ontology.view`, `ontology.conformance`, `ontology.search`, `ontology.resolve`, `ontology.define`, `ontology.evolve` |
|
|
105
|
+
| Ontology | `ontology.view`, `ontology.conformance`, `ontology.search`, `ontology.resolve`, `ontology.define`, `ontology.evolve`, `ontology.induce` |
|
|
105
106
|
| Index lifecycle | `indexes.run`, `indexes.build`, `indexes.delta`, `indexes.gc`, `compact` |
|
|
106
107
|
| Inspection | `entities.list`, `entities.filterByAttributes`, `status`, `metadata`, `summary` |
|
|
107
108
|
| Schema activation | `schema.view`, `schema.preview`, `schema.publish`, `schema.audit` |
|
|
108
|
-
| Database admin | `admin.createStack`, `admin.stack`, `admin.rotateStackKey`, `admin.deleteStack` |
|
|
109
109
|
|
|
110
110
|
Common request/response shapes have direct imports such as `SearchRequest`,
|
|
111
111
|
`SearchResponse`, `Entity`, `GraphSummary`, `CommitRequest`, `AskResponse`, and
|
package/dist/client.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { ImportLine,
|
|
1
|
+
import type { ImportLine, LbbClientOptions, LbbStackActivityResponse, LbbStackActivityWindow, ListResponse, RawLbbResponse, RdfExportOptions, RdfImportOptions, Schemas, SparqlResults } from "./types.js";
|
|
2
2
|
import { type RequestOptions } from "./transport.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ContextNamespace, EntityNamespace, GraphNamespace, IndexNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace } from "./namespaces.js";
|
|
4
4
|
export { parseSparqlResults } from "./types.js";
|
|
5
|
-
export type { AttributeFilter, AttributeFilterOp, AttributeFilterValue, EntityAttributeFilterOptions, EntityPropertiesLine, FetchLike, FlatProperties, ImportLine,
|
|
5
|
+
export type { AttributeFilter, AttributeFilterOp, AttributeFilterValue, EntityAttributeFilterOptions, EntityPropertiesLine, FetchLike, FlatProperties, ImportLine, LbbClientOptions, LbbRequestEvent, LbbResponseEvent, LbbErrorPayload, LbbStackActivityResponse, LbbStackActivityWindow, ListResponse, RawLbbResponse, RdfExportOptions, RdfImportOptions, Schemas, SparqlResults, SparqlResultsJson, SparqlTerm, AskRequest, AskResponse, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, SearchRequest, SearchResponse, SearchResult, Snapshot, } from "./types.js";
|
|
6
6
|
export { LbbError } from "./transport.js";
|
|
7
7
|
export type { CallOptions, Query, QueryValue, RequestOptions, } from "./transport.js";
|
|
8
8
|
export type { EntityListOptions, HybridSearchOptions } from "./namespaces.js";
|
|
9
|
-
export {
|
|
9
|
+
export { ContextNamespace, EntityNamespace, FactsNamespace, GraphNamespace, IndexNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, } from "./namespaces.js";
|
|
10
10
|
/**
|
|
11
|
-
* A typed HTTP client for a
|
|
11
|
+
* A typed HTTP client for a little big brain graph server. One instance is scoped to a
|
|
12
12
|
* single graph/branch; construct another for a different scope. All methods
|
|
13
13
|
* return the parsed JSON response and throw {@link LbbError} on failure.
|
|
14
14
|
*/
|
|
@@ -25,7 +25,6 @@ export declare class LbbClient {
|
|
|
25
25
|
private readonly timeoutMs;
|
|
26
26
|
private readonly onRequest?;
|
|
27
27
|
private readonly onResponse?;
|
|
28
|
-
readonly admin: AdminNamespace;
|
|
29
28
|
readonly context: ContextNamespace;
|
|
30
29
|
readonly search: SearchNamespace;
|
|
31
30
|
readonly indexes: IndexNamespace;
|
|
@@ -87,18 +86,13 @@ export declare class LbbClient {
|
|
|
87
86
|
idempotencyKey?: string;
|
|
88
87
|
}): Promise<Schemas["GraphImportResponse"]>;
|
|
89
88
|
/**
|
|
90
|
-
* Bulk-ingest N-Triples without client-side conversion. Resource-object
|
|
89
|
+
* Bulk-ingest N-Triples, Turtle, N-Quads, or TriG without client-side conversion. Resource-object
|
|
91
90
|
* triples become keyed Resource edges; literal-object triples become text
|
|
92
91
|
* properties on the subject Resource.
|
|
93
92
|
*/
|
|
94
|
-
importRdf(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
observedAt?: string;
|
|
98
|
-
resourceType?: string;
|
|
99
|
-
edgeIdempotency?: "append" | "skip_unchanged";
|
|
100
|
-
idempotencyKey?: string;
|
|
101
|
-
}): Promise<Schemas["GraphRdfImportResponse"]>;
|
|
93
|
+
importRdf(rdf: string, opts?: RdfImportOptions): Promise<Schemas["GraphRdfImportResponse"]>;
|
|
94
|
+
/** Export the snapshot-visible RDF projection as Turtle, N-Triples, TriG, or N-Quads. */
|
|
95
|
+
exportRdf(opts?: RdfExportOptions): Promise<string>;
|
|
102
96
|
/**
|
|
103
97
|
* Retract specific edges and/or every edge touching given entities. Appends
|
|
104
98
|
* superseding retract events rather than deleting — history stays visible in an
|
|
@@ -113,7 +107,7 @@ export declare class LbbClient {
|
|
|
113
107
|
/** Fork the scoped branch from an existing branch in the same graph. */
|
|
114
108
|
createBranch(body: Schemas["GraphBranchCreateRequest"]): Promise<Schemas["GraphBranchCreateResponse"]>;
|
|
115
109
|
/**
|
|
116
|
-
*
|
|
110
|
+
* Validate-then-merge: replay `from_branch`'s post-fork commits onto the
|
|
117
111
|
* SCOPED branch (its fork parent) as one new commit. A write — sends an
|
|
118
112
|
* Idempotency-Key so a retry replays instead of re-applying.
|
|
119
113
|
*/
|
|
@@ -121,7 +115,7 @@ export declare class LbbClient {
|
|
|
121
115
|
idempotencyKey?: string;
|
|
122
116
|
}): Promise<Schemas["GraphBranchMergeResponse"]>;
|
|
123
117
|
/**
|
|
124
|
-
*
|
|
118
|
+
* Observe: store a conversation episode verbatim as EPISODE evidence,
|
|
125
119
|
* anchor + gate extracted facts on an observe branch, and optionally
|
|
126
120
|
* auto-merge when validation is clean. Flag-gated server-side
|
|
127
121
|
* (`--enable-observe`). A write — carries an Idempotency-Key.
|
|
@@ -137,6 +131,17 @@ export declare class LbbClient {
|
|
|
137
131
|
deleteGraph(opts: {
|
|
138
132
|
confirm: string;
|
|
139
133
|
}): Promise<unknown>;
|
|
134
|
+
embeddingConfig(): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
135
|
+
setEmbeddingConfig(body: Schemas["ManagedEmbeddingConfigRequest"]): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
136
|
+
backfillEmbeddings(opts?: {
|
|
137
|
+
batchSize?: number;
|
|
138
|
+
limit?: number;
|
|
139
|
+
full?: boolean;
|
|
140
|
+
}): Promise<Schemas["ManagedEmbeddingBackfillResponse"]>;
|
|
141
|
+
promoteEmbedding(opts: {
|
|
142
|
+
runId: string;
|
|
143
|
+
allowRegression?: boolean;
|
|
144
|
+
}): Promise<Schemas["ManagedEmbeddingPromoteResponse"]>;
|
|
140
145
|
/**
|
|
141
146
|
* The graph's grounding vocabulary as byte-sorted, deduped string sections —
|
|
142
147
|
* the canonical input for a decoder-side automaton (FST/trie) and the
|
|
@@ -147,7 +152,7 @@ export declare class LbbClient {
|
|
|
147
152
|
limit?: number;
|
|
148
153
|
}): Promise<Schemas["VocabExportResponse"]>;
|
|
149
154
|
/**
|
|
150
|
-
* Captured signals by flush-seq range, oldest first — the
|
|
155
|
+
* Captured signals by flush-seq range, oldest first — the model-training
|
|
151
156
|
* feed. The `seq` on each signal is the temporal-split coordinate (train ≤ T,
|
|
152
157
|
* eval > T).
|
|
153
158
|
*/
|
|
@@ -256,7 +261,7 @@ export declare class LbbClient {
|
|
|
256
261
|
}): Promise<Schemas["ExtractorDatasetResponse"]>;
|
|
257
262
|
/**
|
|
258
263
|
* Promote a finished `extractor_lora` training run: gated on held-out fact
|
|
259
|
-
* F1, recorded as a
|
|
264
|
+
* F1, recorded as a `kind=extractor` training run whose adapter resident
|
|
260
265
|
* extraction then serves.
|
|
261
266
|
*/
|
|
262
267
|
promoteExtractor(opts: {
|
|
@@ -265,7 +270,7 @@ export declare class LbbClient {
|
|
|
265
270
|
}): Promise<unknown>;
|
|
266
271
|
/**
|
|
267
272
|
* Promote a finished `planner_lora` training run: gated on held-out slot
|
|
268
|
-
* exactness, recorded as a
|
|
273
|
+
* exactness, recorded as a `kind=planner` training run whose adapter `/v1/ask`
|
|
269
274
|
* then serves.
|
|
270
275
|
*/
|
|
271
276
|
promotePlanner(opts: {
|
|
@@ -278,29 +283,29 @@ export declare class LbbClient {
|
|
|
278
283
|
multiSearch(body: Schemas["HybridMultiSearchRequest"]): Promise<Schemas["HybridMultiSearchResponse"]>;
|
|
279
284
|
/**
|
|
280
285
|
* Grounded prefix completion from the index vocabulary + ontology. Optionally
|
|
281
|
-
* narrow relation completions by a type-signature `context`
|
|
286
|
+
* narrow relation completions by a type-signature `context` — a type
|
|
282
287
|
* pair that admits a single relation flags `signature_forced`.
|
|
283
288
|
*/
|
|
284
289
|
suggest(body: Schemas["SearchSuggestRequest"]): Promise<Schemas["SearchSuggestResponse"]>;
|
|
285
290
|
/**
|
|
286
|
-
* Snap free text to the nearest real vocabulary item
|
|
291
|
+
* Snap free text to the nearest real vocabulary item. Embedding cosine
|
|
287
292
|
* on a managed graph, else lexical; never fabricates a term.
|
|
288
293
|
*/
|
|
289
294
|
resolveTerm(body: Schemas["ResolveTermRequest"]): Promise<Schemas["ResolveTermResponse"]>;
|
|
290
295
|
/**
|
|
291
296
|
* Ground a natural-language question to the graph's real vocabulary, retrieve
|
|
292
|
-
* against the pinned snapshot, and answer with citations (
|
|
297
|
+
* against the pinned snapshot, and answer with citations (`/v1/ask`).
|
|
293
298
|
*/
|
|
294
299
|
ask(body: Schemas["AskRequest"]): Promise<Schemas["AskResponse"]>;
|
|
295
300
|
/**
|
|
296
301
|
* Name the relation between two entities (`/v1/decode`): the DB narrows the
|
|
297
|
-
* candidates to the type pair's admissible relations
|
|
302
|
+
* candidates to the type pair's admissible relations, answers alone
|
|
298
303
|
* when the pair forces a single relation, and otherwise decodes it with the
|
|
299
304
|
* graph-native fine-tuned model — the "DB narrows, cheap model decodes" call.
|
|
300
305
|
*/
|
|
301
306
|
decode(body: Schemas["DecodeRequest"]): Promise<Schemas["DecodeResponse"]>;
|
|
302
307
|
/**
|
|
303
|
-
* Report which completion mechanisms will carry on this graph
|
|
308
|
+
* Report which completion mechanisms will carry on this graph:
|
|
304
309
|
* signature sparsity, name semantics, sampled narrowing recall, and a
|
|
305
310
|
* narrow / narrow+finetune / lexical-first recommendation.
|
|
306
311
|
*/
|
|
@@ -308,7 +313,7 @@ export declare class LbbClient {
|
|
|
308
313
|
sample?: number;
|
|
309
314
|
}): Promise<Schemas["GroundabilityReport"]>;
|
|
310
315
|
/**
|
|
311
|
-
* Append relevance labels for a set of search results — how
|
|
316
|
+
* Append relevance labels for a set of search results — how little big brain
|
|
312
317
|
* gathers customer-specific qrels. Grade results (3 ideal/good, 1 partial,
|
|
313
318
|
* 0 bad), referencing the search response's `search_id` so labels tie back to
|
|
314
319
|
* that ranking. Stored apart from customer facts and exported via
|
|
@@ -443,7 +448,7 @@ export declare class LbbClient {
|
|
|
443
448
|
/** The rule set stored on the scoped graph branch (version + rules). */
|
|
444
449
|
graphRules(): Promise<Schemas["RuleSet"]>;
|
|
445
450
|
/**
|
|
446
|
-
*
|
|
451
|
+
* Derive edges from calibrated retrieval matches (preview): each
|
|
447
452
|
* candidate scored `P >= threshold` becomes a derived edge `(anchor, relation,
|
|
448
453
|
* matched)` with a typed `Retrieval` provenance leaf. Pass either explicit
|
|
449
454
|
* `candidates` or a `query` the server runs as BM25 entity retrieval.
|
|
@@ -480,6 +485,8 @@ export declare class LbbClient {
|
|
|
480
485
|
* migration is needed — and a request that changes nothing is a no-op.
|
|
481
486
|
*/
|
|
482
487
|
evolveOntology(body: Schemas["OntologyEvolveRequest"]): Promise<Schemas["OntologyEvolveResponse"]>;
|
|
488
|
+
/** Suggest ontology additions from the current graph without mutating it. */
|
|
489
|
+
induceOntology(body: Schemas["OntologyInduceRequest"]): Promise<Schemas["OntologyInduceResponse"]>;
|
|
483
490
|
/**
|
|
484
491
|
* Build default ANN + BM25 indexes. With `{ background: true }` the build
|
|
485
492
|
* runs detached on the server and the call returns immediately — use it for
|
|
@@ -518,22 +525,6 @@ export declare class LbbClient {
|
|
|
518
525
|
summary(): Promise<Schemas["GraphSummaryResponse"]>;
|
|
519
526
|
/** List the graphs (and branches) under the scoped tenant. */
|
|
520
527
|
listGraphs(): Promise<Schemas["GraphListResponse"]>;
|
|
521
|
-
/** Create a database stack and return its one-time stack API key. */
|
|
522
|
-
adminCreateStack(body: LbbAdminStackCreateRequest): Promise<LbbAdminStackResponse>;
|
|
523
|
-
/** Inspect a database stack without returning secret key material. */
|
|
524
|
-
adminStack(slug: string): Promise<LbbAdminStackResponse>;
|
|
525
|
-
/** Rotate a database stack key and return the new one-time API key. */
|
|
526
|
-
adminRotateStackKey(slug: string): Promise<LbbAdminStackResponse>;
|
|
527
|
-
/** Delete a database stack after confirming the slug. */
|
|
528
|
-
adminDeleteStack(slug: string): Promise<LbbAdminStackDeleteResponse>;
|
|
529
|
-
/**
|
|
530
|
-
* Mint a short-lived `lbb_ses_…` session token for an account. A trusted
|
|
531
|
-
* co-located service uses it (with `?stack=<slug>`) to call the data plane on
|
|
532
|
-
* the account's behalf without handling the stack's mode-bearing stack key.
|
|
533
|
-
*/
|
|
534
|
-
adminMintSession(accountId: string, ttlSeconds?: number): Promise<LbbAdminSessionResponse>;
|
|
535
|
-
/** Customer-visible activity for one database stack. */
|
|
536
|
-
adminStackActivity(slug: string, window?: LbbStackActivityWindow): Promise<LbbStackActivityResponse>;
|
|
537
528
|
/** Activity for the stack selected by the bearer stack key or session. */
|
|
538
529
|
stackActivity(window?: LbbStackActivityWindow): Promise<LbbStackActivityResponse>;
|
|
539
530
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parseSparqlResults } from "./types.js";
|
|
2
2
|
import { parseLbbError, parseResponseJson, retryAllowed, retryDelayForAttempt, retryableStatus, sleep, } from "./transport.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ContextNamespace, EntityNamespace, GraphNamespace, IndexNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, } from "./namespaces.js";
|
|
4
4
|
export { parseSparqlResults } from "./types.js";
|
|
5
5
|
export { LbbError } from "./transport.js";
|
|
6
|
-
export {
|
|
6
|
+
export { ContextNamespace, EntityNamespace, FactsNamespace, GraphNamespace, IndexNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, } from "./namespaces.js";
|
|
7
7
|
/**
|
|
8
|
-
* A typed HTTP client for a
|
|
8
|
+
* A typed HTTP client for a little big brain graph server. One instance is scoped to a
|
|
9
9
|
* single graph/branch; construct another for a different scope. All methods
|
|
10
10
|
* return the parsed JSON response and throw {@link LbbError} on failure.
|
|
11
11
|
*/
|
|
@@ -22,7 +22,6 @@ export class LbbClient {
|
|
|
22
22
|
timeoutMs;
|
|
23
23
|
onRequest;
|
|
24
24
|
onResponse;
|
|
25
|
-
admin;
|
|
26
25
|
context;
|
|
27
26
|
search;
|
|
28
27
|
indexes;
|
|
@@ -57,7 +56,6 @@ export class LbbClient {
|
|
|
57
56
|
throw new Error("no fetch implementation available; pass options.fetch");
|
|
58
57
|
}
|
|
59
58
|
this.fetchImpl = chosen;
|
|
60
|
-
this.admin = new AdminNamespace(this);
|
|
61
59
|
this.context = new ContextNamespace(this);
|
|
62
60
|
this.search = new SearchNamespace(this);
|
|
63
61
|
this.indexes = new IndexNamespace(this);
|
|
@@ -213,9 +211,16 @@ export class LbbClient {
|
|
|
213
211
|
});
|
|
214
212
|
if (!response.ok)
|
|
215
213
|
throw parseLbbError(response.status, text.trim(), requestId);
|
|
214
|
+
const responseContentType = response.headers?.get("content-type")?.toLowerCase() ?? "";
|
|
215
|
+
const isRdfText = responseContentType.includes("text/turtle") ||
|
|
216
|
+
responseContentType.includes("application/n-triples") ||
|
|
217
|
+
responseContentType.includes("application/trig") ||
|
|
218
|
+
responseContentType.includes("application/n-quads");
|
|
216
219
|
return {
|
|
217
220
|
data: text
|
|
218
|
-
?
|
|
221
|
+
? isRdfText
|
|
222
|
+
? text
|
|
223
|
+
: parseResponseJson(text, response.status, requestId)
|
|
219
224
|
: undefined,
|
|
220
225
|
status: response.status,
|
|
221
226
|
requestId,
|
|
@@ -289,25 +294,48 @@ export class LbbClient {
|
|
|
289
294
|
});
|
|
290
295
|
}
|
|
291
296
|
/**
|
|
292
|
-
* Bulk-ingest N-Triples without client-side conversion. Resource-object
|
|
297
|
+
* Bulk-ingest N-Triples, Turtle, N-Quads, or TriG without client-side conversion. Resource-object
|
|
293
298
|
* triples become keyed Resource edges; literal-object triples become text
|
|
294
299
|
* properties on the subject Resource.
|
|
295
300
|
*/
|
|
296
|
-
importRdf(
|
|
301
|
+
importRdf(rdf, opts = {}) {
|
|
302
|
+
const format = opts.format ?? "ntriples";
|
|
303
|
+
const contentTypes = {
|
|
304
|
+
ntriples: "application/n-triples",
|
|
305
|
+
turtle: "text/turtle",
|
|
306
|
+
nquads: "application/n-quads",
|
|
307
|
+
trig: "application/trig",
|
|
308
|
+
};
|
|
297
309
|
return this.request("POST", "/v1/graph/import/rdf", {
|
|
298
|
-
rawBody:
|
|
299
|
-
contentType:
|
|
310
|
+
rawBody: rdf,
|
|
311
|
+
contentType: contentTypes[format],
|
|
300
312
|
query: {
|
|
301
313
|
batch: opts.batch,
|
|
302
314
|
strict: opts.strict,
|
|
303
315
|
observed_at: opts.observedAt,
|
|
304
|
-
format
|
|
316
|
+
format,
|
|
317
|
+
base_iri: opts.baseIri,
|
|
318
|
+
graph_uri: opts.graphUri,
|
|
319
|
+
blank_node_scope: opts.blankNodeScope,
|
|
305
320
|
resource_type: opts.resourceType,
|
|
306
321
|
edge_idempotency: opts.edgeIdempotency,
|
|
307
322
|
},
|
|
308
323
|
idempotencyKey: opts.idempotencyKey ?? this.idempotencyKey("import-rdf"),
|
|
309
324
|
});
|
|
310
325
|
}
|
|
326
|
+
/** Export the snapshot-visible RDF projection as Turtle, N-Triples, TriG, or N-Quads. */
|
|
327
|
+
exportRdf(opts = {}) {
|
|
328
|
+
return this.request("GET", "/v1/graph/export/rdf", {
|
|
329
|
+
query: {
|
|
330
|
+
format: opts.format === "ntriples" ? "nt" : opts.format,
|
|
331
|
+
max_triples: opts.maxTriples,
|
|
332
|
+
as_of_valid_time: opts.asOfValidTime,
|
|
333
|
+
as_of_commit_seq: opts.asOfCommitSeq,
|
|
334
|
+
entailment: opts.entailment,
|
|
335
|
+
reason: opts.reason,
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
}
|
|
311
339
|
/**
|
|
312
340
|
* Retract specific edges and/or every edge touching given entities. Appends
|
|
313
341
|
* superseding retract events rather than deleting — history stays visible in an
|
|
@@ -329,7 +357,7 @@ export class LbbClient {
|
|
|
329
357
|
return this.request("POST", "/v1/graph/branch", { body });
|
|
330
358
|
}
|
|
331
359
|
/**
|
|
332
|
-
*
|
|
360
|
+
* Validate-then-merge: replay `from_branch`'s post-fork commits onto the
|
|
333
361
|
* SCOPED branch (its fork parent) as one new commit. A write — sends an
|
|
334
362
|
* Idempotency-Key so a retry replays instead of re-applying.
|
|
335
363
|
*/
|
|
@@ -340,7 +368,7 @@ export class LbbClient {
|
|
|
340
368
|
});
|
|
341
369
|
}
|
|
342
370
|
/**
|
|
343
|
-
*
|
|
371
|
+
* Observe: store a conversation episode verbatim as EPISODE evidence,
|
|
344
372
|
* anchor + gate extracted facts on an observe branch, and optionally
|
|
345
373
|
* auto-merge when validation is clean. Flag-gated server-side
|
|
346
374
|
* (`--enable-observe`). A write — carries an Idempotency-Key.
|
|
@@ -361,7 +389,23 @@ export class LbbClient {
|
|
|
361
389
|
query: { confirm: opts.confirm },
|
|
362
390
|
});
|
|
363
391
|
}
|
|
364
|
-
|
|
392
|
+
embeddingConfig() {
|
|
393
|
+
return this.request("GET", "/v1/graph/embedding");
|
|
394
|
+
}
|
|
395
|
+
setEmbeddingConfig(body) {
|
|
396
|
+
return this.request("POST", "/v1/graph/embedding", { body });
|
|
397
|
+
}
|
|
398
|
+
backfillEmbeddings(opts = {}) {
|
|
399
|
+
return this.request("POST", "/v1/graph/embedding/backfill", {
|
|
400
|
+
query: { batch_size: opts.batchSize, limit: opts.limit, full: opts.full },
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
promoteEmbedding(opts) {
|
|
404
|
+
return this.request("POST", "/v1/graph/embedding/promote", {
|
|
405
|
+
query: { run_id: opts.runId, allow_regression: opts.allowRegression },
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
// --- models as runs (training-run registry + eval machinery) ---
|
|
365
409
|
/**
|
|
366
410
|
* The graph's grounding vocabulary as byte-sorted, deduped string sections —
|
|
367
411
|
* the canonical input for a decoder-side automaton (FST/trie) and the
|
|
@@ -373,7 +417,7 @@ export class LbbClient {
|
|
|
373
417
|
});
|
|
374
418
|
}
|
|
375
419
|
/**
|
|
376
|
-
* Captured signals by flush-seq range, oldest first — the
|
|
420
|
+
* Captured signals by flush-seq range, oldest first — the model-training
|
|
377
421
|
* feed. The `seq` on each signal is the temporal-split coordinate (train ≤ T,
|
|
378
422
|
* eval > T).
|
|
379
423
|
*/
|
|
@@ -505,7 +549,7 @@ export class LbbClient {
|
|
|
505
549
|
}
|
|
506
550
|
/**
|
|
507
551
|
* Promote a finished `extractor_lora` training run: gated on held-out fact
|
|
508
|
-
* F1, recorded as a
|
|
552
|
+
* F1, recorded as a `kind=extractor` training run whose adapter resident
|
|
509
553
|
* extraction then serves.
|
|
510
554
|
*/
|
|
511
555
|
promoteExtractor(opts) {
|
|
@@ -515,7 +559,7 @@ export class LbbClient {
|
|
|
515
559
|
}
|
|
516
560
|
/**
|
|
517
561
|
* Promote a finished `planner_lora` training run: gated on held-out slot
|
|
518
|
-
* exactness, recorded as a
|
|
562
|
+
* exactness, recorded as a `kind=planner` training run whose adapter `/v1/ask`
|
|
519
563
|
* then serves.
|
|
520
564
|
*/
|
|
521
565
|
promotePlanner(opts) {
|
|
@@ -534,14 +578,14 @@ export class LbbClient {
|
|
|
534
578
|
}
|
|
535
579
|
/**
|
|
536
580
|
* Grounded prefix completion from the index vocabulary + ontology. Optionally
|
|
537
|
-
* narrow relation completions by a type-signature `context`
|
|
581
|
+
* narrow relation completions by a type-signature `context` — a type
|
|
538
582
|
* pair that admits a single relation flags `signature_forced`.
|
|
539
583
|
*/
|
|
540
584
|
suggest(body) {
|
|
541
585
|
return this.request("POST", "/v1/search/suggest", { body });
|
|
542
586
|
}
|
|
543
587
|
/**
|
|
544
|
-
* Snap free text to the nearest real vocabulary item
|
|
588
|
+
* Snap free text to the nearest real vocabulary item. Embedding cosine
|
|
545
589
|
* on a managed graph, else lexical; never fabricates a term.
|
|
546
590
|
*/
|
|
547
591
|
resolveTerm(body) {
|
|
@@ -549,14 +593,14 @@ export class LbbClient {
|
|
|
549
593
|
}
|
|
550
594
|
/**
|
|
551
595
|
* Ground a natural-language question to the graph's real vocabulary, retrieve
|
|
552
|
-
* against the pinned snapshot, and answer with citations (
|
|
596
|
+
* against the pinned snapshot, and answer with citations (`/v1/ask`).
|
|
553
597
|
*/
|
|
554
598
|
ask(body) {
|
|
555
599
|
return this.request("POST", "/v1/ask", { body });
|
|
556
600
|
}
|
|
557
601
|
/**
|
|
558
602
|
* Name the relation between two entities (`/v1/decode`): the DB narrows the
|
|
559
|
-
* candidates to the type pair's admissible relations
|
|
603
|
+
* candidates to the type pair's admissible relations, answers alone
|
|
560
604
|
* when the pair forces a single relation, and otherwise decodes it with the
|
|
561
605
|
* graph-native fine-tuned model — the "DB narrows, cheap model decodes" call.
|
|
562
606
|
*/
|
|
@@ -564,7 +608,7 @@ export class LbbClient {
|
|
|
564
608
|
return this.request("POST", "/v1/decode", { body });
|
|
565
609
|
}
|
|
566
610
|
/**
|
|
567
|
-
* Report which completion mechanisms will carry on this graph
|
|
611
|
+
* Report which completion mechanisms will carry on this graph:
|
|
568
612
|
* signature sparsity, name semantics, sampled narrowing recall, and a
|
|
569
613
|
* narrow / narrow+finetune / lexical-first recommendation.
|
|
570
614
|
*/
|
|
@@ -574,7 +618,7 @@ export class LbbClient {
|
|
|
574
618
|
});
|
|
575
619
|
}
|
|
576
620
|
/**
|
|
577
|
-
* Append relevance labels for a set of search results — how
|
|
621
|
+
* Append relevance labels for a set of search results — how little big brain
|
|
578
622
|
* gathers customer-specific qrels. Grade results (3 ideal/good, 1 partial,
|
|
579
623
|
* 0 bad), referencing the search response's `search_id` so labels tie back to
|
|
580
624
|
* that ranking. Stored apart from customer facts and exported via
|
|
@@ -772,7 +816,7 @@ export class LbbClient {
|
|
|
772
816
|
return this.request("GET", "/v1/inference/rules");
|
|
773
817
|
}
|
|
774
818
|
/**
|
|
775
|
-
*
|
|
819
|
+
* Derive edges from calibrated retrieval matches (preview): each
|
|
776
820
|
* candidate scored `P >= threshold` becomes a derived edge `(anchor, relation,
|
|
777
821
|
* matched)` with a typed `Retrieval` provenance leaf. Pass either explicit
|
|
778
822
|
* `candidates` or a `query` the server runs as BM25 entity retrieval.
|
|
@@ -824,6 +868,10 @@ export class LbbClient {
|
|
|
824
868
|
evolveOntology(body) {
|
|
825
869
|
return this.request("POST", "/v1/ontology/evolve", { body });
|
|
826
870
|
}
|
|
871
|
+
/** Suggest ontology additions from the current graph without mutating it. */
|
|
872
|
+
induceOntology(body) {
|
|
873
|
+
return this.request("POST", "/v1/ontology/induce", { body, retry: true });
|
|
874
|
+
}
|
|
827
875
|
// --- index lifecycle ---
|
|
828
876
|
/**
|
|
829
877
|
* Build default ANN + BM25 indexes. With `{ background: true }` the build
|
|
@@ -883,44 +931,7 @@ export class LbbClient {
|
|
|
883
931
|
listGraphs() {
|
|
884
932
|
return this.request("GET", "/v1/graphs");
|
|
885
933
|
}
|
|
886
|
-
// ---
|
|
887
|
-
/** Create a database stack and return its one-time stack API key. */
|
|
888
|
-
adminCreateStack(body) {
|
|
889
|
-
return this.request("POST", "/api/admin/stacks", { body });
|
|
890
|
-
}
|
|
891
|
-
/** Inspect a database stack without returning secret key material. */
|
|
892
|
-
adminStack(slug) {
|
|
893
|
-
return this.request("GET", "/api/admin/stacks", { query: { stack: slug } });
|
|
894
|
-
}
|
|
895
|
-
/** Rotate a database stack key and return the new one-time API key. */
|
|
896
|
-
adminRotateStackKey(slug) {
|
|
897
|
-
return this.request("POST", "/api/admin/stacks/rotate-key", {
|
|
898
|
-
query: { stack: slug },
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
|
-
/** Delete a database stack after confirming the slug. */
|
|
902
|
-
adminDeleteStack(slug) {
|
|
903
|
-
return this.request("DELETE", "/api/admin/stacks", {
|
|
904
|
-
query: { stack: slug, confirm: slug },
|
|
905
|
-
});
|
|
906
|
-
}
|
|
907
|
-
/**
|
|
908
|
-
* Mint a short-lived `lbb_ses_…` session token for an account. A trusted
|
|
909
|
-
* co-located service uses it (with `?stack=<slug>`) to call the data plane on
|
|
910
|
-
* the account's behalf without handling the stack's mode-bearing stack key.
|
|
911
|
-
*/
|
|
912
|
-
adminMintSession(accountId, ttlSeconds) {
|
|
913
|
-
const body = { account_id: accountId };
|
|
914
|
-
if (ttlSeconds !== undefined)
|
|
915
|
-
body.ttl_seconds = ttlSeconds;
|
|
916
|
-
return this.request("POST", "/api/admin/sessions", { body });
|
|
917
|
-
}
|
|
918
|
-
/** Customer-visible activity for one database stack. */
|
|
919
|
-
adminStackActivity(slug, window = "24h") {
|
|
920
|
-
return this.request("GET", "/api/admin/stacks/activity", {
|
|
921
|
-
query: { stack: slug, window },
|
|
922
|
-
});
|
|
923
|
-
}
|
|
934
|
+
// --- stack activity ---
|
|
924
935
|
/** Activity for the stack selected by the bearer stack key or session. */
|
|
925
936
|
stackActivity(window = "24h") {
|
|
926
937
|
return this.request("GET", "/v1/stack/activity", { query: { window } });
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { LbbClient, LbbError, parseSparqlResults } from "./client.js";
|
|
2
|
-
export type {
|
|
2
|
+
export type { LbbClientOptions, CallOptions, RequestOptions, EntityListOptions, HybridSearchOptions, LbbRequestEvent, LbbResponseEvent, LbbStackActivityResponse, LbbStackActivityWindow, FetchLike, Schemas, SparqlResults, SparqlResultsJson, SparqlTerm, AskRequest, AskResponse, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, SearchRequest, SearchResponse, SearchResult, Snapshot, } from "./client.js";
|
|
3
3
|
export type { components, paths, operations } from "./schema.js";
|
package/dist/namespaces.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LbbClient } from "./client.js";
|
|
2
2
|
import type { CallOptions } from "./transport.js";
|
|
3
|
-
import { type EntityAttributeFilterOptions, type ImportLine, type ListResponse, type Schemas } from "./types.js";
|
|
3
|
+
import { type EntityAttributeFilterOptions, type ImportLine, type ListResponse, type RdfExportOptions, type RdfImportOptions, type Schemas } from "./types.js";
|
|
4
4
|
export interface HybridSearchOptions extends CallOptions {
|
|
5
5
|
topK?: number;
|
|
6
6
|
source?: string;
|
|
@@ -33,8 +33,21 @@ export declare class GraphNamespace {
|
|
|
33
33
|
delete(opts: {
|
|
34
34
|
confirm: string;
|
|
35
35
|
} & CallOptions): Promise<unknown>;
|
|
36
|
+
embeddingConfig(opts?: CallOptions): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
37
|
+
setEmbeddingConfig(body: Schemas["ManagedEmbeddingConfigRequest"], opts?: CallOptions): Promise<Schemas["ManagedEmbeddingConfigResponse"]>;
|
|
38
|
+
backfillEmbeddings(options?: CallOptions & {
|
|
39
|
+
batchSize?: number;
|
|
40
|
+
limit?: number;
|
|
41
|
+
full?: boolean;
|
|
42
|
+
}): Promise<Schemas["ManagedEmbeddingBackfillResponse"]>;
|
|
43
|
+
promoteEmbedding(options: CallOptions & {
|
|
44
|
+
runId: string;
|
|
45
|
+
allowRegression?: boolean;
|
|
46
|
+
}): Promise<Schemas["ManagedEmbeddingPromoteResponse"]>;
|
|
36
47
|
/** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
|
|
37
48
|
retract(body: Schemas["GraphRetractRequest"], opts?: CallOptions): Promise<Schemas["GraphRetractResponse"]>;
|
|
49
|
+
/** Export this graph's current snapshot as Turtle, N-Triples, TriG, or N-Quads. */
|
|
50
|
+
exportRdf(opts?: RdfExportOptions): Promise<string>;
|
|
38
51
|
}
|
|
39
52
|
export declare class FactsNamespace {
|
|
40
53
|
private readonly client;
|
|
@@ -49,19 +62,12 @@ export declare class FactsNamespace {
|
|
|
49
62
|
idempotencyKey?: string;
|
|
50
63
|
}): Promise<Schemas["GraphImportResponse"]>;
|
|
51
64
|
/**
|
|
52
|
-
* Bulk-load N-Triples through the native RDF import endpoint.
|
|
65
|
+
* Bulk-load N-Triples, Turtle, N-Quads, or TriG through the native RDF import endpoint.
|
|
53
66
|
*
|
|
54
67
|
* Statements are committed through the fixed RDF_TRIPLE relation; source RDF
|
|
55
68
|
* predicates and literal term details are preserved as edge metadata.
|
|
56
69
|
*/
|
|
57
|
-
importRdf(
|
|
58
|
-
batch?: number;
|
|
59
|
-
strict?: boolean;
|
|
60
|
-
observedAt?: string;
|
|
61
|
-
resourceType?: string;
|
|
62
|
-
edgeIdempotency?: "append" | "skip_unchanged";
|
|
63
|
-
idempotencyKey?: string;
|
|
64
|
-
}): Promise<Schemas["GraphRdfImportResponse"]>;
|
|
70
|
+
importRdf(rdf: string, opts?: CallOptions & RdfImportOptions): Promise<Schemas["GraphRdfImportResponse"]>;
|
|
65
71
|
}
|
|
66
72
|
export declare class SearchNamespace {
|
|
67
73
|
private readonly client;
|
|
@@ -175,6 +181,7 @@ export declare class OntologyNamespace {
|
|
|
175
181
|
resolve(body: Schemas["OntologyResolveRequest"], opts?: CallOptions): Promise<Schemas["OntologyResolveResponse"]>;
|
|
176
182
|
define(body: Schemas["OntologyDefineRequest"], opts?: CallOptions): Promise<Schemas["OntologyDefineResponse"]>;
|
|
177
183
|
evolve(body: Schemas["OntologyEvolveRequest"], opts?: CallOptions): Promise<Schemas["OntologyEvolveResponse"]>;
|
|
184
|
+
induce(body: Schemas["OntologyInduceRequest"], opts?: CallOptions): Promise<Schemas["OntologyInduceResponse"]>;
|
|
178
185
|
}
|
|
179
186
|
/** Structured, SPARQL-text, reasoning, and analytical query operations. */
|
|
180
187
|
export declare class QueryNamespace {
|
|
@@ -188,14 +195,3 @@ export declare class QueryNamespace {
|
|
|
188
195
|
infer(body: Schemas["InferenceRunRequest"], opts?: CallOptions): Promise<Schemas["InferenceRunResponse"]>;
|
|
189
196
|
premises(body: Schemas["RetrievalPremiseRequest"], opts?: CallOptions): Promise<Schemas["RetrievalPremiseResponse"]>;
|
|
190
197
|
}
|
|
191
|
-
/** Database administration. Keep stack credentials on trusted servers only. */
|
|
192
|
-
export declare class AdminNamespace {
|
|
193
|
-
private readonly client;
|
|
194
|
-
constructor(client: LbbClient);
|
|
195
|
-
createStack(body: import("./types.js").LbbAdminStackCreateRequest): Promise<import("./types.js").LbbAdminStackResponse>;
|
|
196
|
-
stack(slug: string): Promise<import("./types.js").LbbAdminStackResponse>;
|
|
197
|
-
rotateStackKey(slug: string): Promise<import("./types.js").LbbAdminStackResponse>;
|
|
198
|
-
deleteStack(slug: string): Promise<import("./types.js").LbbAdminStackDeleteResponse>;
|
|
199
|
-
mintSession(accountId: string, ttlSeconds?: number): Promise<import("./types.js").LbbAdminSessionResponse>;
|
|
200
|
-
stackActivity(slug: string, window?: import("./types.js").LbbStackActivityWindow): Promise<import("./types.js").LbbStackActivityResponse>;
|
|
201
|
-
}
|