@littlebigbrain/client 0.13.2 → 0.15.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/dist/client.d.ts +25 -92
- package/dist/client.js +32 -131
- package/dist/namespaces.d.ts +3 -21
- package/dist/namespaces.js +3 -23
- package/dist/schema.d.ts +731 -3457
- package/dist/transport.d.ts +17 -2
- package/dist/transport.js +14 -0
- package/dist/types.d.ts +8 -3
- package/dist/types.js +3 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DurableImportSource, ImportLine, LbbClientOptions, ListResponse, RawLbbResponse, ReadConsistencyOptions, RdfImportDocument, RdfImportManyResult, RdfImportOptions, Schemas, SearchConsistency, SparqlResults } from "./types.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type RequestOptions } from "./transport.js";
|
|
3
3
|
import { EntityNamespace, GraphNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, EvalsNamespace, EmbeddingsNamespace } from "./namespaces.js";
|
|
4
4
|
export { parseSparqlResults } from "./types.js";
|
|
5
5
|
export type { AttributeFilter, AttributeFilterOp, AttributeFilterValue, EntityAttributeFilterOptions, EntityPropertiesLine, DurableImportLine, DurableImportSource, FetchLike, FlatProperties, ImportLine, LbbClientOptions, LbbRequestEvent, LbbResponseEvent, LbbRetryEvent, LbbErrorPayload, ListResponse, RawLbbResponse, ReadConsistencyOptions, RdfImportDocument, RdfImportManyResult, RdfImportOptions, Schemas, SearchConsistency, SparqlResults, SparqlResultsJson, SparqlTerm, CommitRequest, CommitResponse, Entity, EntitySelector, GraphMetadata, GraphSummary, SchemaView, Snapshot, } from "./types.js";
|
|
@@ -8,14 +8,13 @@ export type { CallOptions, Query, QueryValue, RequestOptions, } from "./transpor
|
|
|
8
8
|
export { EntityNamespace, FactsNamespace, GraphNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, } from "./namespaces.js";
|
|
9
9
|
/**
|
|
10
10
|
* A typed HTTP client for a little big brain graph server. One instance is scoped to a
|
|
11
|
-
* single graph
|
|
11
|
+
* single graph; construct another for a different scope. All methods
|
|
12
12
|
* return the parsed JSON response and throw {@link LbbError} on failure.
|
|
13
13
|
*/
|
|
14
14
|
export declare class LbbClient {
|
|
15
15
|
private readonly baseUrl;
|
|
16
16
|
private readonly apiKey?;
|
|
17
17
|
private readonly graphName?;
|
|
18
|
-
private readonly branchName?;
|
|
19
18
|
private readonly stack?;
|
|
20
19
|
private readonly fetchImpl;
|
|
21
20
|
private readonly apiVersion;
|
|
@@ -38,17 +37,15 @@ export declare class LbbClient {
|
|
|
38
37
|
readonly embeddings: EmbeddingsNamespace;
|
|
39
38
|
constructor(options: LbbClientOptions);
|
|
40
39
|
graph(name: string, opts?: {
|
|
41
|
-
branch?: string;
|
|
42
40
|
stack?: string;
|
|
43
41
|
}): GraphNamespace;
|
|
44
42
|
/**
|
|
45
|
-
* A new client for a different graph
|
|
46
|
-
* Each instance is scoped to one graph
|
|
43
|
+
* A new client for a different graph on the same server and credential.
|
|
44
|
+
* Each instance is scoped to one graph, so use this to target another
|
|
47
45
|
* scope (e.g. creating a fresh graph) without mutating the current client.
|
|
48
46
|
*/
|
|
49
47
|
withScope(scope: {
|
|
50
48
|
graph?: string;
|
|
51
|
-
branch?: string;
|
|
52
49
|
stack?: string;
|
|
53
50
|
}): LbbClient;
|
|
54
51
|
/**
|
|
@@ -142,8 +139,8 @@ export declare class LbbClient {
|
|
|
142
139
|
idempotencyKey?: string;
|
|
143
140
|
}): Promise<Schemas["GraphRetractResponse"]>;
|
|
144
141
|
/**
|
|
145
|
-
* Create the scoped graph
|
|
146
|
-
* with the desired graph
|
|
142
|
+
* Create the scoped graph with an empty ontology. Construct the client
|
|
143
|
+
* with the desired graph first, then call `ontology.define` before
|
|
147
144
|
* writing typed data.
|
|
148
145
|
*/
|
|
149
146
|
createGraph(): Promise<Schemas["CreateGraphResponse"]>;
|
|
@@ -183,33 +180,10 @@ export declare class LbbClient {
|
|
|
183
180
|
observedAt?: string;
|
|
184
181
|
idempotencyKey?: string;
|
|
185
182
|
}): Promise<Schemas["GraphReloadResponse"]>;
|
|
186
|
-
/**
|
|
187
|
-
createBranch(body: Schemas["GraphBranchCreateRequest"]): Promise<Schemas["GraphBranchCreateResponse"]>;
|
|
188
|
-
/**
|
|
189
|
-
* Validate-then-merge: replay `from_branch`'s post-fork commits onto the
|
|
190
|
-
* SCOPED branch (its fork parent) as one new commit. A write — sends an
|
|
191
|
-
* Idempotency-Key so a retry replays instead of re-applying.
|
|
192
|
-
*/
|
|
193
|
-
mergeBranch(body: Schemas["GraphBranchMergeRequest"], opts?: {
|
|
194
|
-
idempotencyKey?: string;
|
|
195
|
-
}): Promise<Schemas["GraphBranchMergeResponse"]>;
|
|
196
|
-
/**
|
|
197
|
-
* Observe: store a conversation episode verbatim as EPISODE evidence,
|
|
198
|
-
* anchor + gate extracted facts on an observe branch, and optionally
|
|
199
|
-
* auto-merge when validation is clean. Flag-gated server-side
|
|
200
|
-
* (`--enable-observe`). A write — carries an Idempotency-Key.
|
|
201
|
-
*/
|
|
202
|
-
observe(body: Schemas["ObserveRequest"], opts?: {
|
|
203
|
-
idempotencyKey?: string;
|
|
204
|
-
}): Promise<Schemas["ObserveResponse"]>;
|
|
205
|
-
/** Delete the scoped graph, including every branch, feedback, and active graph-scoped job. */
|
|
183
|
+
/** Delete the scoped graph, including its feedback and active graph-scoped jobs. */
|
|
206
184
|
deleteGraph(opts: {
|
|
207
185
|
confirm: string;
|
|
208
186
|
}): Promise<Schemas["GraphDeleteResponse"]>;
|
|
209
|
-
/** Delete only the scoped branch. The server refuses to delete a graph's final live branch. */
|
|
210
|
-
deleteBranch(opts: {
|
|
211
|
-
confirm: string;
|
|
212
|
-
}): Promise<Schemas["GraphBranchDeleteResponse"]>;
|
|
213
187
|
/**
|
|
214
188
|
* Captured signals by flush-seq range, oldest first — the model-training
|
|
215
189
|
* feed. The `seq` on each signal is the temporal-split coordinate (train ≤ T,
|
|
@@ -285,16 +259,6 @@ export declare class LbbClient {
|
|
|
285
259
|
externalPlannerTrace(payload: Schemas["ExternalPlannerTraceV1"], opts?: {
|
|
286
260
|
idempotencyKey?: string;
|
|
287
261
|
}): Promise<Schemas["SignalIngestResponse"]>;
|
|
288
|
-
/** Planner training examples at or before an optional signal split. */
|
|
289
|
-
plannerDataset(opts?: {
|
|
290
|
-
limit?: number;
|
|
291
|
-
splitSeq?: number;
|
|
292
|
-
}): Promise<Schemas["PlannerDatasetResponse"]>;
|
|
293
|
-
/** Planner preference pairs at or before an optional signal split. */
|
|
294
|
-
plannerPreferenceDataset(opts?: {
|
|
295
|
-
limit?: number;
|
|
296
|
-
splitSeq?: number;
|
|
297
|
-
}): Promise<Schemas["PlannerPreferenceDatasetResponse"]>;
|
|
298
262
|
/** Suggest-ranker examples at or before an optional signal split. */
|
|
299
263
|
suggestDataset(opts?: {
|
|
300
264
|
limit?: number;
|
|
@@ -314,14 +278,6 @@ export declare class LbbClient {
|
|
|
314
278
|
runId: string;
|
|
315
279
|
allowRegression?: boolean;
|
|
316
280
|
}): Promise<unknown>;
|
|
317
|
-
/**
|
|
318
|
-
* Promote a finished `planner_lora` training run: gated on held-out slot
|
|
319
|
-
* exactness and recorded as a `kind=planner` training run.
|
|
320
|
-
*/
|
|
321
|
-
promotePlanner(opts: {
|
|
322
|
-
runId: string;
|
|
323
|
-
allowRegression?: boolean;
|
|
324
|
-
}): Promise<unknown>;
|
|
325
281
|
/**
|
|
326
282
|
* Append relevance labels for a set of ranked results — how little big brain
|
|
327
283
|
* gathers customer-specific qrels. Grade results (3 ideal/good, 1 partial,
|
|
@@ -334,34 +290,6 @@ export declare class LbbClient {
|
|
|
334
290
|
}): Promise<Schemas["SearchFeedbackResponse"]>;
|
|
335
291
|
/** Export the stored relevance labels as qrels-style rows for training. */
|
|
336
292
|
searchFeedbackExport(): Promise<Schemas["SearchFeedbackExportResponse"]>;
|
|
337
|
-
/**
|
|
338
|
-
* Ranked incoming/outgoing neighborhood for a graph entity.
|
|
339
|
-
*
|
|
340
|
-
* `edges` caps the edges returned per direction (default 1000, maximum
|
|
341
|
-
* 10000). When a cap cuts a direction the response carries a `truncation`
|
|
342
|
-
* block; an uncut response omits it entirely.
|
|
343
|
-
*/
|
|
344
|
-
entityNeighborhood(opts: {
|
|
345
|
-
id?: string;
|
|
346
|
-
type?: string;
|
|
347
|
-
name?: string;
|
|
348
|
-
relations?: string[];
|
|
349
|
-
asOf?: string;
|
|
350
|
-
edges?: number;
|
|
351
|
-
}): Promise<Schemas["EntityNeighborhoodResponse"]>;
|
|
352
|
-
/** Exact type cardinality plus a bounded deterministic sample from Base. */
|
|
353
|
-
entityTypeSample(opts: {
|
|
354
|
-
type: string;
|
|
355
|
-
limit?: number;
|
|
356
|
-
} & CallOptions): Promise<Schemas["EntityTypeSampleResponse"]>;
|
|
357
|
-
/** Stored entity object-ref status and index-coverage metadata (no
|
|
358
|
-
* attributes — read those from `entityDetail`'s top-level `attributes`). */
|
|
359
|
-
entityMetadata(opts: {
|
|
360
|
-
id?: string;
|
|
361
|
-
type?: string;
|
|
362
|
-
name?: string;
|
|
363
|
-
asOf?: string;
|
|
364
|
-
}): Promise<Schemas["EntityMetadataResponse"]>;
|
|
365
293
|
/**
|
|
366
294
|
* Read projected attributes and current relationships from one RDF snapshot.
|
|
367
295
|
* Inspect `unavailable_sections` before interpreting legacy provenance arrays.
|
|
@@ -385,14 +313,6 @@ export declare class LbbClient {
|
|
|
385
313
|
* The caller supplies a bounded collection endpoint and its cursor.
|
|
386
314
|
*/
|
|
387
315
|
listAll<T>(fetchPage: (cursor?: string) => Promise<ListResponse<T>>): AsyncGenerator<T, void, unknown>;
|
|
388
|
-
/** Current state of an entity's relations, optionally as-of a timestamp. */
|
|
389
|
-
currentState(body: Schemas["CurrentStateRequest"]): Promise<Schemas["CurrentStateResponse"]>;
|
|
390
|
-
/** Full edge-event history for a relationship. */
|
|
391
|
-
history(body: Schemas["RelationshipHistoryRequest"]): Promise<Schemas["RelationshipHistoryResponse"]>;
|
|
392
|
-
/** Ordered state-transition log for an entity's relation, with dwell time. */
|
|
393
|
-
transitions(body: Schemas["EntityTransitionsRequest"]): Promise<Schemas["EntityTransitionsResponse"]>;
|
|
394
|
-
/** Lineage and evidence for a single edge. */
|
|
395
|
-
why(body: Schemas["WhyRequest"]): Promise<Schemas["WhyResponse"]>;
|
|
396
316
|
/**
|
|
397
317
|
* SPARQL-subset SELECT/ASK/aggregate query (FILTER, HAVING, ORDER BY, ASK,
|
|
398
318
|
* COUNT/SUM/AVG/MIN/MAX). GROUP BY is not limited to entity identity:
|
|
@@ -404,14 +324,27 @@ export declare class LbbClient {
|
|
|
404
324
|
* `groups[].keys`.
|
|
405
325
|
*/
|
|
406
326
|
sparql(body: Schemas["SparqlSelectRequest"], opts?: ReadConsistencyOptions): Promise<Schemas["SparqlSelectResponse"]>;
|
|
407
|
-
/**
|
|
327
|
+
/**
|
|
328
|
+
* SPARQL 1.1 query from text (SELECT/ASK) over the live graph; `results` is
|
|
329
|
+
* SPARQL 1.1 Query Results JSON. The text dialect carries
|
|
330
|
+
* `consistency`/`min_indexed_seq` on the URL; a floor with no explicit
|
|
331
|
+
* consistency implies a strong base-plus-delta read. `as_of_commit_seq` in
|
|
332
|
+
* the body reads the retained published generation of that exact commit.
|
|
333
|
+
*
|
|
334
|
+
* The query is read-only, so a retryable `429` (for example
|
|
335
|
+
* `read_your_writes_pending` while publication catches up to the floor) is
|
|
336
|
+
* retried within the retry budget. A `5xx` is not retried: a query that
|
|
337
|
+
* timed out would run again.
|
|
338
|
+
*/
|
|
408
339
|
sparqlText(body: Schemas["SparqlTextRequest"], opts?: ReadConsistencyOptions): Promise<Schemas["SparqlTextResponse"]>;
|
|
409
340
|
/**
|
|
410
341
|
* Run a SPARQL 1.1 text query and return parsed results — the ergonomic
|
|
411
342
|
* complement to {@link sparqlText} (which hands back the raw results string).
|
|
412
|
-
* Returns `{ vars, boolean, bindings, rows }` via
|
|
413
|
-
* `rows` is the bindings flattened to
|
|
414
|
-
* is the ASK answer (or `null` for a
|
|
343
|
+
* Returns `{ vars, boolean, bindings, rows, snapshot }` via
|
|
344
|
+
* {@link parseSparqlResults}: `rows` is the bindings flattened to
|
|
345
|
+
* `{ variable: lexicalValue }`, `boolean` is the ASK answer (or `null` for a
|
|
346
|
+
* SELECT), and `snapshot.served_at_seq` is the commit an eventual or pinned
|
|
347
|
+
* read answered from (`snapshot` is `null` for a plain strong read).
|
|
415
348
|
*/
|
|
416
349
|
sparqlRows(body: Schemas["SparqlTextRequest"], opts?: ReadConsistencyOptions): Promise<SparqlResults>;
|
|
417
350
|
/**
|
|
@@ -489,6 +422,6 @@ export declare class LbbClient {
|
|
|
489
422
|
* rebuild fills it.
|
|
490
423
|
*/
|
|
491
424
|
schemaSummary(): Promise<Schemas["RdfSchemaSummaryResponse"]>;
|
|
492
|
-
/** List the graphs
|
|
425
|
+
/** List the graphs under the scoped tenant. */
|
|
493
426
|
listGraphs(): Promise<Schemas["GraphListResponse"]>;
|
|
494
427
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseSparqlResults } from "./types.js";
|
|
2
|
-
import { bodyMarksTerminal, errorCodeFromBody, fullJitterBackoffMs, parseLbbError, parseResponseJson, retryAllowed, retryableStatus, retryDelayMs, sleep, } from "./transport.js";
|
|
2
|
+
import { bodyMarksTerminal, errorCodeFromBody, fullJitterBackoffMs, parseLbbError, parseResponseJson, retriesNetworkFailure, retriesStatus, retryAllowed, retryableStatus, retryDelayMs, sleep, } from "./transport.js";
|
|
3
3
|
import { LbbCapabilityError } from "./transport.js";
|
|
4
4
|
import { EntityNamespace, GraphNamespace, OntologyNamespace, QueryNamespace, SchemaNamespace, SearchNamespace, EvalsNamespace, EmbeddingsNamespace, } from "./namespaces.js";
|
|
5
5
|
export { parseSparqlResults } from "./types.js";
|
|
@@ -84,14 +84,13 @@ async function durableImportBody(source) {
|
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* A typed HTTP client for a little big brain graph server. One instance is scoped to a
|
|
87
|
-
* single graph
|
|
87
|
+
* single graph; construct another for a different scope. All methods
|
|
88
88
|
* return the parsed JSON response and throw {@link LbbError} on failure.
|
|
89
89
|
*/
|
|
90
90
|
export class LbbClient {
|
|
91
91
|
baseUrl;
|
|
92
92
|
apiKey;
|
|
93
93
|
graphName;
|
|
94
|
-
branchName;
|
|
95
94
|
stack;
|
|
96
95
|
fetchImpl;
|
|
97
96
|
apiVersion;
|
|
@@ -120,7 +119,6 @@ export class LbbClient {
|
|
|
120
119
|
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
121
120
|
this.apiKey = options.apiKey;
|
|
122
121
|
this.graphName = options.graph;
|
|
123
|
-
this.branchName = options.branch;
|
|
124
122
|
this.stack = options.stack;
|
|
125
123
|
this.apiVersion = options.apiVersion ?? "2026-07-23";
|
|
126
124
|
this.maxRetries = options.maxRetries ?? 6;
|
|
@@ -160,13 +158,12 @@ export class LbbClient {
|
|
|
160
158
|
graph(name, opts = {}) {
|
|
161
159
|
return new GraphNamespace(this.withScope({
|
|
162
160
|
graph: name,
|
|
163
|
-
branch: opts.branch ?? this.branchName,
|
|
164
161
|
stack: opts.stack ?? this.stack,
|
|
165
162
|
}));
|
|
166
163
|
}
|
|
167
164
|
/**
|
|
168
|
-
* A new client for a different graph
|
|
169
|
-
* Each instance is scoped to one graph
|
|
165
|
+
* A new client for a different graph on the same server and credential.
|
|
166
|
+
* Each instance is scoped to one graph, so use this to target another
|
|
170
167
|
* scope (e.g. creating a fresh graph) without mutating the current client.
|
|
171
168
|
*/
|
|
172
169
|
withScope(scope) {
|
|
@@ -174,7 +171,6 @@ export class LbbClient {
|
|
|
174
171
|
baseUrl: this.baseUrl,
|
|
175
172
|
apiKey: this.apiKey,
|
|
176
173
|
graph: scope.graph ?? this.graphName,
|
|
177
|
-
branch: scope.branch ?? this.branchName,
|
|
178
174
|
stack: scope.stack ?? this.stack,
|
|
179
175
|
fetch: this.fetchImpl,
|
|
180
176
|
apiVersion: this.apiVersion,
|
|
@@ -222,8 +218,6 @@ export class LbbClient {
|
|
|
222
218
|
const push = (key, value) => params.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
223
219
|
if (this.graphName !== undefined)
|
|
224
220
|
push("graph", this.graphName);
|
|
225
|
-
if (this.branchName !== undefined)
|
|
226
|
-
push("branch", this.branchName);
|
|
227
221
|
if (this.stack !== undefined)
|
|
228
222
|
push("stack", this.stack);
|
|
229
223
|
for (const [key, value] of Object.entries(query ?? {})) {
|
|
@@ -243,7 +237,7 @@ export class LbbClient {
|
|
|
243
237
|
if (opts.idempotencyKey !== undefined)
|
|
244
238
|
headers["idempotency-key"] = opts.idempotencyKey;
|
|
245
239
|
Object.assign(headers, opts.headers ?? {});
|
|
246
|
-
const
|
|
240
|
+
const retry = opts.retry ?? retryAllowed(method, opts.idempotencyKey);
|
|
247
241
|
const body = opts.rawBody !== undefined
|
|
248
242
|
? opts.rawBody
|
|
249
243
|
: opts.body !== undefined
|
|
@@ -308,7 +302,9 @@ export class LbbClient {
|
|
|
308
302
|
cause: error,
|
|
309
303
|
}), { name: "TimeoutError" })
|
|
310
304
|
: error;
|
|
311
|
-
if (!callerAborted &&
|
|
305
|
+
if (!callerAborted &&
|
|
306
|
+
retriesNetworkFailure(retry) &&
|
|
307
|
+
attempt < maxRetries) {
|
|
312
308
|
const delayMs = fullJitterBackoffMs(this.retryDelayMs, attempt);
|
|
313
309
|
if (Date.now() + delayMs <= deadline) {
|
|
314
310
|
this.onRetry?.({
|
|
@@ -335,7 +331,7 @@ export class LbbClient {
|
|
|
335
331
|
attempt === maxRetries) {
|
|
336
332
|
break;
|
|
337
333
|
}
|
|
338
|
-
if (!
|
|
334
|
+
if (!retriesStatus(retry, response.status)) {
|
|
339
335
|
break;
|
|
340
336
|
}
|
|
341
337
|
// Honor the server's typed body verdict: a terminal error
|
|
@@ -604,8 +600,8 @@ export class LbbClient {
|
|
|
604
600
|
});
|
|
605
601
|
}
|
|
606
602
|
/**
|
|
607
|
-
* Create the scoped graph
|
|
608
|
-
* with the desired graph
|
|
603
|
+
* Create the scoped graph with an empty ontology. Construct the client
|
|
604
|
+
* with the desired graph first, then call `ontology.define` before
|
|
609
605
|
* writing typed data.
|
|
610
606
|
*/
|
|
611
607
|
createGraph() {
|
|
@@ -658,46 +654,13 @@ export class LbbClient {
|
|
|
658
654
|
idempotencyKey: opts.idempotencyKey ?? this.idempotencyKey("reload"),
|
|
659
655
|
});
|
|
660
656
|
}
|
|
661
|
-
/**
|
|
662
|
-
createBranch(body) {
|
|
663
|
-
return this.request("POST", "/v1/graph/branch", { body });
|
|
664
|
-
}
|
|
665
|
-
/**
|
|
666
|
-
* Validate-then-merge: replay `from_branch`'s post-fork commits onto the
|
|
667
|
-
* SCOPED branch (its fork parent) as one new commit. A write — sends an
|
|
668
|
-
* Idempotency-Key so a retry replays instead of re-applying.
|
|
669
|
-
*/
|
|
670
|
-
mergeBranch(body, opts = {}) {
|
|
671
|
-
return this.request("POST", "/v1/graph/branch/merge", {
|
|
672
|
-
body,
|
|
673
|
-
idempotencyKey: opts.idempotencyKey ?? this.idempotencyKey("branch-merge"),
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* Observe: store a conversation episode verbatim as EPISODE evidence,
|
|
678
|
-
* anchor + gate extracted facts on an observe branch, and optionally
|
|
679
|
-
* auto-merge when validation is clean. Flag-gated server-side
|
|
680
|
-
* (`--enable-observe`). A write — carries an Idempotency-Key.
|
|
681
|
-
*/
|
|
682
|
-
observe(body, opts = {}) {
|
|
683
|
-
return this.request("POST", "/v1/memory/observe", {
|
|
684
|
-
body,
|
|
685
|
-
idempotencyKey: opts.idempotencyKey ?? this.idempotencyKey("observe"),
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
/** Delete the scoped graph, including every branch, feedback, and active graph-scoped job. */
|
|
657
|
+
/** Delete the scoped graph, including its feedback and active graph-scoped jobs. */
|
|
689
658
|
deleteGraph(opts) {
|
|
690
659
|
return this.request("POST", "/v1/graph/delete", {
|
|
691
660
|
query: { confirm: opts.confirm },
|
|
692
661
|
retry: true,
|
|
693
662
|
});
|
|
694
663
|
}
|
|
695
|
-
/** Delete only the scoped branch. The server refuses to delete a graph's final live branch. */
|
|
696
|
-
deleteBranch(opts) {
|
|
697
|
-
return this.request("DELETE", "/v1/graph/branch", {
|
|
698
|
-
query: { confirm: opts.confirm },
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
664
|
// --- models as runs (training-run registry + eval machinery) ---
|
|
702
665
|
/**
|
|
703
666
|
* Captured signals by flush-seq range, oldest first — the model-training
|
|
@@ -803,18 +766,6 @@ export class LbbClient {
|
|
|
803
766
|
],
|
|
804
767
|
}, opts);
|
|
805
768
|
}
|
|
806
|
-
/** Planner training examples at or before an optional signal split. */
|
|
807
|
-
plannerDataset(opts = {}) {
|
|
808
|
-
return this.request("GET", "/v1/models/planner-dataset", {
|
|
809
|
-
query: { limit: opts.limit, split_seq: opts.splitSeq },
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
/** Planner preference pairs at or before an optional signal split. */
|
|
813
|
-
plannerPreferenceDataset(opts = {}) {
|
|
814
|
-
return this.request("GET", "/v1/models/planner-preference-dataset", {
|
|
815
|
-
query: { limit: opts.limit, split_seq: opts.splitSeq },
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
769
|
/** Suggest-ranker examples at or before an optional signal split. */
|
|
819
770
|
suggestDataset(opts = {}) {
|
|
820
771
|
return this.request("GET", "/v1/models/suggest-dataset", {
|
|
@@ -837,15 +788,6 @@ export class LbbClient {
|
|
|
837
788
|
query: { run_id: opts.runId, allow_regression: opts.allowRegression },
|
|
838
789
|
});
|
|
839
790
|
}
|
|
840
|
-
/**
|
|
841
|
-
* Promote a finished `planner_lora` training run: gated on held-out slot
|
|
842
|
-
* exactness and recorded as a `kind=planner` training run.
|
|
843
|
-
*/
|
|
844
|
-
promotePlanner(opts) {
|
|
845
|
-
return this.request("POST", "/v1/models/promote-planner", {
|
|
846
|
-
query: { run_id: opts.runId, allow_regression: opts.allowRegression },
|
|
847
|
-
});
|
|
848
|
-
}
|
|
849
791
|
// --- relevance feedback ---
|
|
850
792
|
/**
|
|
851
793
|
* Append relevance labels for a set of ranked results — how little big brain
|
|
@@ -864,45 +806,6 @@ export class LbbClient {
|
|
|
864
806
|
searchFeedbackExport() {
|
|
865
807
|
return this.request("GET", "/v1/search/feedback/export");
|
|
866
808
|
}
|
|
867
|
-
/**
|
|
868
|
-
* Ranked incoming/outgoing neighborhood for a graph entity.
|
|
869
|
-
*
|
|
870
|
-
* `edges` caps the edges returned per direction (default 1000, maximum
|
|
871
|
-
* 10000). When a cap cuts a direction the response carries a `truncation`
|
|
872
|
-
* block; an uncut response omits it entirely.
|
|
873
|
-
*/
|
|
874
|
-
entityNeighborhood(opts) {
|
|
875
|
-
return this.request("GET", "/v1/graph/entity/neighborhood", {
|
|
876
|
-
query: {
|
|
877
|
-
id: opts.id,
|
|
878
|
-
type: opts.type,
|
|
879
|
-
name: opts.name,
|
|
880
|
-
relations: opts.relations?.join(","),
|
|
881
|
-
as_of: opts.asOf,
|
|
882
|
-
edges: opts.edges,
|
|
883
|
-
},
|
|
884
|
-
});
|
|
885
|
-
}
|
|
886
|
-
/** Exact type cardinality plus a bounded deterministic sample from Base. */
|
|
887
|
-
entityTypeSample(opts) {
|
|
888
|
-
const { type, limit, ...request } = opts;
|
|
889
|
-
return this.request("GET", "/v1/graph/entities/sample", {
|
|
890
|
-
...request,
|
|
891
|
-
query: { type, limit },
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
/** Stored entity object-ref status and index-coverage metadata (no
|
|
895
|
-
* attributes — read those from `entityDetail`'s top-level `attributes`). */
|
|
896
|
-
entityMetadata(opts) {
|
|
897
|
-
return this.request("GET", "/v1/graph/entity/metadata", {
|
|
898
|
-
query: {
|
|
899
|
-
id: opts.id,
|
|
900
|
-
type: opts.type,
|
|
901
|
-
name: opts.name,
|
|
902
|
-
as_of: opts.asOf,
|
|
903
|
-
},
|
|
904
|
-
});
|
|
905
|
-
}
|
|
906
809
|
/**
|
|
907
810
|
* Read projected attributes and current relationships from one RDF snapshot.
|
|
908
811
|
* Inspect `unavailable_sections` before interpreting legacy provenance arrays.
|
|
@@ -939,23 +842,7 @@ export class LbbClient {
|
|
|
939
842
|
cursor = page.next_cursor;
|
|
940
843
|
}
|
|
941
844
|
}
|
|
942
|
-
// ---
|
|
943
|
-
/** Current state of an entity's relations, optionally as-of a timestamp. */
|
|
944
|
-
currentState(body) {
|
|
945
|
-
return this.request("POST", "/v1/query/state", { body });
|
|
946
|
-
}
|
|
947
|
-
/** Full edge-event history for a relationship. */
|
|
948
|
-
history(body) {
|
|
949
|
-
return this.request("POST", "/v1/query/history", { body });
|
|
950
|
-
}
|
|
951
|
-
/** Ordered state-transition log for an entity's relation, with dwell time. */
|
|
952
|
-
transitions(body) {
|
|
953
|
-
return this.request("POST", "/v1/query/transitions", { body });
|
|
954
|
-
}
|
|
955
|
-
/** Lineage and evidence for a single edge. */
|
|
956
|
-
why(body) {
|
|
957
|
-
return this.request("POST", "/v1/query/why", { body });
|
|
958
|
-
}
|
|
845
|
+
// --- query ---
|
|
959
846
|
/**
|
|
960
847
|
* SPARQL-subset SELECT/ASK/aggregate query (FILTER, HAVING, ORDER BY, ASK,
|
|
961
848
|
* COUNT/SUM/AVG/MIN/MAX). GROUP BY is not limited to entity identity:
|
|
@@ -971,19 +858,33 @@ export class LbbClient {
|
|
|
971
858
|
body: this.mergeReadConsistency(body, opts),
|
|
972
859
|
});
|
|
973
860
|
}
|
|
974
|
-
/**
|
|
861
|
+
/**
|
|
862
|
+
* SPARQL 1.1 query from text (SELECT/ASK) over the live graph; `results` is
|
|
863
|
+
* SPARQL 1.1 Query Results JSON. The text dialect carries
|
|
864
|
+
* `consistency`/`min_indexed_seq` on the URL; a floor with no explicit
|
|
865
|
+
* consistency implies a strong base-plus-delta read. `as_of_commit_seq` in
|
|
866
|
+
* the body reads the retained published generation of that exact commit.
|
|
867
|
+
*
|
|
868
|
+
* The query is read-only, so a retryable `429` (for example
|
|
869
|
+
* `read_your_writes_pending` while publication catches up to the floor) is
|
|
870
|
+
* retried within the retry budget. A `5xx` is not retried: a query that
|
|
871
|
+
* timed out would run again.
|
|
872
|
+
*/
|
|
975
873
|
sparqlText(body, opts) {
|
|
976
874
|
return this.request("POST", "/v1/query/sparql-text", {
|
|
977
875
|
body,
|
|
978
876
|
query: this.readConsistencyQuery(opts),
|
|
877
|
+
retry: "rate_limited",
|
|
979
878
|
});
|
|
980
879
|
}
|
|
981
880
|
/**
|
|
982
881
|
* Run a SPARQL 1.1 text query and return parsed results — the ergonomic
|
|
983
882
|
* complement to {@link sparqlText} (which hands back the raw results string).
|
|
984
|
-
* Returns `{ vars, boolean, bindings, rows }` via
|
|
985
|
-
* `rows` is the bindings flattened to
|
|
986
|
-
* is the ASK answer (or `null` for a
|
|
883
|
+
* Returns `{ vars, boolean, bindings, rows, snapshot }` via
|
|
884
|
+
* {@link parseSparqlResults}: `rows` is the bindings flattened to
|
|
885
|
+
* `{ variable: lexicalValue }`, `boolean` is the ASK answer (or `null` for a
|
|
886
|
+
* SELECT), and `snapshot.served_at_seq` is the commit an eventual or pinned
|
|
887
|
+
* read answered from (`snapshot` is `null` for a plain strong read).
|
|
987
888
|
*/
|
|
988
889
|
async sparqlRows(body, opts) {
|
|
989
890
|
return parseSparqlResults(await this.sparqlText(body, opts));
|
|
@@ -1128,7 +1029,7 @@ export class LbbClient {
|
|
|
1128
1029
|
schemaSummary() {
|
|
1129
1030
|
return this.request("GET", "/v1/graph/schema-summary");
|
|
1130
1031
|
}
|
|
1131
|
-
/** List the graphs
|
|
1032
|
+
/** List the graphs under the scoped tenant. */
|
|
1132
1033
|
listGraphs() {
|
|
1133
1034
|
return this.request("GET", "/v1/graphs");
|
|
1134
1035
|
}
|
package/dist/namespaces.d.ts
CHANGED
|
@@ -12,10 +12,9 @@ export declare class GraphNamespace {
|
|
|
12
12
|
readonly evals: EvalsNamespace;
|
|
13
13
|
readonly embeddings: EmbeddingsNamespace;
|
|
14
14
|
constructor(client: LbbClient);
|
|
15
|
-
|
|
16
|
-
/** Publication lifecycle for this graph/branch, including pre-first-publish state. */
|
|
15
|
+
/** Publication lifecycle for this graph, including pre-first-publish state. */
|
|
17
16
|
publicationStatus(): Promise<Schemas["PublicationStatusResponse"]>;
|
|
18
|
-
/** Wait until this graph
|
|
17
|
+
/** Wait until this graph has an exact generation covering `targetSeq`. */
|
|
19
18
|
waitForPublished(targetSeq: number, opts?: {
|
|
20
19
|
timeoutMs?: number;
|
|
21
20
|
pollIntervalMs?: number;
|
|
@@ -24,9 +23,6 @@ export declare class GraphNamespace {
|
|
|
24
23
|
delete(opts: {
|
|
25
24
|
confirm: string;
|
|
26
25
|
} & CallOptions): Promise<Schemas["GraphDeleteResponse"]>;
|
|
27
|
-
deleteBranch(opts: {
|
|
28
|
-
confirm: string;
|
|
29
|
-
} & CallOptions): Promise<Schemas["GraphBranchDeleteResponse"]>;
|
|
30
26
|
/** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
|
|
31
27
|
retract(body: Schemas["GraphRetractRequest"], opts?: CallOptions): Promise<Schemas["GraphRetractResponse"]>;
|
|
32
28
|
}
|
|
@@ -65,20 +61,6 @@ export declare class SearchNamespace {
|
|
|
65
61
|
export declare class EntityNamespace {
|
|
66
62
|
private readonly client;
|
|
67
63
|
constructor(client: LbbClient);
|
|
68
|
-
/**
|
|
69
|
-
* Return the exact type cardinality and a bounded deterministic sample from
|
|
70
|
-
* the Base family pinned by the published generation.
|
|
71
|
-
*/
|
|
72
|
-
sample(opts: {
|
|
73
|
-
type: string;
|
|
74
|
-
limit?: number;
|
|
75
|
-
} & CallOptions): Promise<Schemas["EntityTypeSampleResponse"]>;
|
|
76
|
-
get(opts: {
|
|
77
|
-
id?: string;
|
|
78
|
-
type?: string;
|
|
79
|
-
name?: string;
|
|
80
|
-
asOf?: string;
|
|
81
|
-
}): Promise<Schemas["EntityMetadataResponse"]>;
|
|
82
64
|
detail(opts: Parameters<LbbClient["entityDetail"]>[0]): Promise<Schemas["EntityDetailResponse"]>;
|
|
83
65
|
/**
|
|
84
66
|
* Filter entities already bound by relation patterns using typed attributes,
|
|
@@ -96,7 +78,7 @@ export declare class EntityNamespace {
|
|
|
96
78
|
export declare class EmbeddingsNamespace {
|
|
97
79
|
private readonly client;
|
|
98
80
|
constructor(client: LbbClient);
|
|
99
|
-
/** Every embedding of the
|
|
81
|
+
/** Every embedding of the graph with its status. */
|
|
100
82
|
list(opts?: CallOptions): Promise<Schemas["EmbeddingListResponse"]>;
|
|
101
83
|
/** One embedding: serving and building version, backfill, lag, recall. */
|
|
102
84
|
get(name: string, opts?: CallOptions): Promise<Schemas["EmbeddingStatus"]>;
|
package/dist/namespaces.js
CHANGED
|
@@ -37,14 +37,11 @@ export class GraphNamespace {
|
|
|
37
37
|
this.evals = client.evals;
|
|
38
38
|
this.embeddings = client.embeddings;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
return new GraphNamespace(this.client.withScope({ branch: name }));
|
|
42
|
-
}
|
|
43
|
-
/** Publication lifecycle for this graph/branch, including pre-first-publish state. */
|
|
40
|
+
/** Publication lifecycle for this graph, including pre-first-publish state. */
|
|
44
41
|
publicationStatus() {
|
|
45
42
|
return this.client.publicationStatus();
|
|
46
43
|
}
|
|
47
|
-
/** Wait until this graph
|
|
44
|
+
/** Wait until this graph has an exact generation covering `targetSeq`. */
|
|
48
45
|
waitForPublished(targetSeq, opts = {}) {
|
|
49
46
|
return this.client.waitForPublished(targetSeq, opts);
|
|
50
47
|
}
|
|
@@ -59,13 +56,6 @@ export class GraphNamespace {
|
|
|
59
56
|
retry: request.retry ?? true,
|
|
60
57
|
});
|
|
61
58
|
}
|
|
62
|
-
deleteBranch(opts) {
|
|
63
|
-
const { confirm, ...request } = opts;
|
|
64
|
-
return this.client.request("DELETE", "/v1/graph/branch", {
|
|
65
|
-
...request,
|
|
66
|
-
query: { confirm },
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
59
|
/** Retract edges/entities from the scoped graph. See {@link LbbClient.retract}. */
|
|
70
60
|
retract(body, opts = {}) {
|
|
71
61
|
return this.client.request("POST", "/v1/graph/retract", {
|
|
@@ -165,16 +155,6 @@ export class EntityNamespace {
|
|
|
165
155
|
constructor(client) {
|
|
166
156
|
this.client = client;
|
|
167
157
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Return the exact type cardinality and a bounded deterministic sample from
|
|
170
|
-
* the Base family pinned by the published generation.
|
|
171
|
-
*/
|
|
172
|
-
sample(opts) {
|
|
173
|
-
return this.client.entityTypeSample(opts);
|
|
174
|
-
}
|
|
175
|
-
get(opts) {
|
|
176
|
-
return this.client.entityMetadata(opts);
|
|
177
|
-
}
|
|
178
158
|
detail(opts) {
|
|
179
159
|
return this.client.entityDetail(opts);
|
|
180
160
|
}
|
|
@@ -214,7 +194,7 @@ export class EmbeddingsNamespace {
|
|
|
214
194
|
constructor(client) {
|
|
215
195
|
this.client = client;
|
|
216
196
|
}
|
|
217
|
-
/** Every embedding of the
|
|
197
|
+
/** Every embedding of the graph with its status. */
|
|
218
198
|
list(opts = {}) {
|
|
219
199
|
return this.client.request("GET", "/v1/embeddings", opts);
|
|
220
200
|
}
|