cograph 0.1.25 → 0.1.28
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 +32 -0
- package/dist/chunk-BJAFJGFV.js +1166 -0
- package/dist/chunk-BJAFJGFV.js.map +1 -0
- package/dist/cli.js +63 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +220 -1
- package/dist/index.js +423 -2
- package/dist/index.js.map +1 -1
- package/dist/{shell-ILZ322LT.js → shell-PSKIKRXO.js} +62 -4
- package/dist/shell-PSKIKRXO.js.map +1 -0
- package/package.json +6 -3
- package/dist/chunk-O3L4FCRY.js +0 -558
- package/dist/chunk-O3L4FCRY.js.map +0 -1
- package/dist/shell-ILZ322LT.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,9 +47,39 @@ declare class Client {
|
|
|
47
47
|
apiKey: string | undefined;
|
|
48
48
|
baseUrl: string;
|
|
49
49
|
tenant: string;
|
|
50
|
+
/**
|
|
51
|
+
* Raw / passthrough API — one method per canonical backend operation, with
|
|
52
|
+
* the path encoded inside the SDK. Each method returns the backend
|
|
53
|
+
* {@link Response} VERBATIM: it does NOT throw on non-2xx and does NOT reshape
|
|
54
|
+
* the body. This is the seam the webapp's proxy layer adopts so per-operation
|
|
55
|
+
* paths live in one place (here) instead of being hand-rolled at each call
|
|
56
|
+
* site. See {@link RawApi}. The typed methods on this class (which throw on
|
|
57
|
+
* non-2xx and reshape some payloads) are left unchanged — this is additive.
|
|
58
|
+
*/
|
|
59
|
+
readonly raw: RawApi;
|
|
50
60
|
constructor(opts?: ClientOptions);
|
|
51
61
|
private headers;
|
|
52
62
|
private base;
|
|
63
|
+
/**
|
|
64
|
+
* Low-level passthrough request. Centralizes the absolute URL (already built
|
|
65
|
+
* by a path-builder, so it carries the base URL + `/graphs/{tenant}` prefix),
|
|
66
|
+
* the `X-API-Key` header, JSON content-type, body stringification, and a
|
|
67
|
+
* timeout/abort — then returns the backend {@link Response} UNCHANGED.
|
|
68
|
+
*
|
|
69
|
+
* Unlike {@link request}, this does NOT inspect `res.ok` and does NOT parse or
|
|
70
|
+
* reshape the body. A 4xx/5xx comes back as a resolved `Response` (the caller
|
|
71
|
+
* reads `.status`/`.headers`/`.body`), NOT a thrown {@link CographError}. The
|
|
72
|
+
* only rejection paths are a genuine network failure or a timeout abort —
|
|
73
|
+
* exactly the cases where there is no HTTP response to hand back.
|
|
74
|
+
*
|
|
75
|
+
* `init.headers` is merged last so a caller can add/override headers; `init.body`,
|
|
76
|
+
* when a non-string is passed, is JSON-stringified for convenience.
|
|
77
|
+
*/
|
|
78
|
+
requestRaw(method: string, path: string, init?: {
|
|
79
|
+
body?: unknown;
|
|
80
|
+
headers?: Record<string, string>;
|
|
81
|
+
timeoutMs?: number;
|
|
82
|
+
}): Promise<Response>;
|
|
53
83
|
/**
|
|
54
84
|
* Probe the backend to determine reachability and whether endpoints
|
|
55
85
|
* require an X-API-Key header. Used at shell startup to distinguish
|
|
@@ -154,6 +184,42 @@ declare class Client {
|
|
|
154
184
|
typeSummary(kg: string, typeName: string): Promise<TypeSummary>;
|
|
155
185
|
/** Search types or attributes by name substring within a KG. */
|
|
156
186
|
exploreSearch(kg: string, q: string, kind?: "type" | "attr"): Promise<Array<Record<string, unknown>>>;
|
|
187
|
+
/**
|
|
188
|
+
* One page of entity instances of a type for the Explorer Data table
|
|
189
|
+
* (`GET /explore/kgs/{kg}/types/{type}/records`). Keyset-paginated by entity
|
|
190
|
+
* URI: pass the previous page's `next_cursor` as `cursor`. `limit` is clamped
|
|
191
|
+
* server-side to 1..200 (default 50).
|
|
192
|
+
*/
|
|
193
|
+
exploreRecords(kg: string, typeName: string, opts?: {
|
|
194
|
+
limit?: number;
|
|
195
|
+
cursor?: string;
|
|
196
|
+
}): Promise<TypeRecordsPage>;
|
|
197
|
+
/** Undirected type→type edges for the Explorer overview graph
|
|
198
|
+
* (`GET /explore/kgs/{kg}/type-edges`). Returns `[{source, target, weight}]`. */
|
|
199
|
+
exploreTypeEdges(kg: string): Promise<TypeEdge[]>;
|
|
200
|
+
/** Infer + persist normalization rules for a type's predicates, returned ranked
|
|
201
|
+
* by confidence desc (`POST /normalize/suggest?kg&type`). */
|
|
202
|
+
normalizeSuggest(kg: string, type: string): Promise<NormalizationRule[]>;
|
|
203
|
+
/** List stored normalization rules, optionally filtered by KG and/or status
|
|
204
|
+
* (`GET /normalize/rules?kg&status`). */
|
|
205
|
+
normalizeRules(opts?: {
|
|
206
|
+
kg?: string;
|
|
207
|
+
status?: string;
|
|
208
|
+
}): Promise<NormalizationRule[]>;
|
|
209
|
+
/** Confirm a suggested normalization rule (`POST /normalize/rules/{id}/confirm`). */
|
|
210
|
+
normalizeConfirmRule(ruleId: string): Promise<NormalizationRule>;
|
|
211
|
+
/** Reject a suggested normalization rule (`POST /normalize/rules/{id}/reject`). */
|
|
212
|
+
normalizeRejectRule(ruleId: string): Promise<NormalizationRule>;
|
|
213
|
+
/** Apply a confirmed normalization rule in the background; the server acks 202
|
|
214
|
+
* (`POST /normalize/rules/{id}/apply`). */
|
|
215
|
+
normalizeApplyRule(ruleId: string): Promise<Record<string, unknown>>;
|
|
216
|
+
/** Recommend ontology relationships/changes for the active KG
|
|
217
|
+
* (`POST /ontology/recommend`). Body shape is passed through unchanged.
|
|
218
|
+
*
|
|
219
|
+
* NOTE: this targets the *premium* ontology-recommender route, which is only
|
|
220
|
+
* mounted on deployments carrying the proprietary layer. It 404s on a bare
|
|
221
|
+
* OSS deployment. */
|
|
222
|
+
ontologyRecommend(body?: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
157
223
|
}
|
|
158
224
|
/**
|
|
159
225
|
* A single ontology change resolved against the existing schema. The same
|
|
@@ -329,5 +395,158 @@ interface AgentResult {
|
|
|
329
395
|
kind: "answer" | "clarify" | "plan" | "result" | "error";
|
|
330
396
|
[key: string]: unknown;
|
|
331
397
|
}
|
|
398
|
+
/** One row in the Explorer Data table — an entity instance with its attribute
|
|
399
|
+
* values. `id` is the entity URI; `name` is the display name; the remaining
|
|
400
|
+
* keys are per-attribute values (all stringly-typed for display). */
|
|
401
|
+
interface TypeRecord {
|
|
402
|
+
id: string;
|
|
403
|
+
name: string;
|
|
404
|
+
[attr: string]: string;
|
|
405
|
+
}
|
|
406
|
+
/** A page of {@link TypeRecord}s returned by {@link Client.exploreRecords}.
|
|
407
|
+
* `next_cursor` is the last entity URI of this page; pass it back as `cursor`
|
|
408
|
+
* to fetch the following page, or `null` when there are no more rows. */
|
|
409
|
+
interface TypeRecordsPage {
|
|
410
|
+
columns: string[];
|
|
411
|
+
rows: TypeRecord[];
|
|
412
|
+
total: number;
|
|
413
|
+
next_cursor: string | null;
|
|
414
|
+
}
|
|
415
|
+
/** An undirected type→type edge in the Explorer overview graph, weighted by the
|
|
416
|
+
* number of instance relationships it summarizes. */
|
|
417
|
+
interface TypeEdge {
|
|
418
|
+
source: string;
|
|
419
|
+
target: string;
|
|
420
|
+
weight: number;
|
|
421
|
+
}
|
|
422
|
+
/** A stored normalization rule (suggested / confirmed / rejected / applied).
|
|
423
|
+
* Open beyond the documented fields because the rule's `params` shape varies by
|
|
424
|
+
* `rule_type` (e.g. `strip_emoji`, `list_explode`). */
|
|
425
|
+
interface NormalizationRule {
|
|
426
|
+
id: string;
|
|
427
|
+
kg_name: string;
|
|
428
|
+
type_name: string;
|
|
429
|
+
predicate: string;
|
|
430
|
+
rule_type: string;
|
|
431
|
+
target_kind?: string;
|
|
432
|
+
params?: Record<string, unknown>;
|
|
433
|
+
confidence?: number;
|
|
434
|
+
rationale?: string;
|
|
435
|
+
status: "suggested" | "confirmed" | "rejected" | "applied" | string;
|
|
436
|
+
created_at?: string;
|
|
437
|
+
applied_at?: string | null;
|
|
438
|
+
[key: string]: unknown;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Raw / passthrough surface — reached via {@link Client.raw}. Each method maps
|
|
442
|
+
* to ONE canonical backend operation, builds the path internally (callers pass
|
|
443
|
+
* NO path string), and returns the backend {@link Response} VERBATIM:
|
|
444
|
+
*
|
|
445
|
+
* - it does NOT throw on a non-2xx status (a 404/500 resolves as a `Response`
|
|
446
|
+
* whose `.status` the caller inspects — contrast the typed methods, which
|
|
447
|
+
* throw {@link CographError}); and
|
|
448
|
+
* - it does NOT parse or reshape the body (the caller gets the unread stream;
|
|
449
|
+
* contrast e.g. {@link Client.listKgs}, which unwraps `{kgs:[]}`).
|
|
450
|
+
*
|
|
451
|
+
* Every method funnels through {@link Client.requestRaw}, so the base URL,
|
|
452
|
+
* `X-API-Key`, `/graphs/{tenant}` prefix, JSON content-type and timeout are
|
|
453
|
+
* centralized in exactly one place. The only rejection paths are a network
|
|
454
|
+
* failure or a timeout — the cases where there is no HTTP response to return.
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* ```ts
|
|
458
|
+
* const client = new Client({ apiKey, tenant });
|
|
459
|
+
* // Webapp proxy pattern: forward the backend response 1:1, no reshaping.
|
|
460
|
+
* const res = await client.raw.enrichJobs(); // GET …/enrich/jobs
|
|
461
|
+
* return new Response(res.body, { status: res.status, headers: res.headers });
|
|
462
|
+
*
|
|
463
|
+
* // A non-2xx is a Response, not a throw:
|
|
464
|
+
* const r = await client.raw.enrichJob("does-not-exist");
|
|
465
|
+
* if (r.status === 404) { ... } // no try/catch needed
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
468
|
+
declare class RawApi {
|
|
469
|
+
private readonly client;
|
|
470
|
+
constructor(client: Client);
|
|
471
|
+
/** `POST /graphs/{tenant}/agent` — one turn of the unified Ask-AI agent. */
|
|
472
|
+
agent(body: unknown, init?: RawInit): Promise<Response>;
|
|
473
|
+
/** `POST /graphs/{tenant}/ask` — natural-language question. */
|
|
474
|
+
ask(body: unknown, init?: RawInit): Promise<Response>;
|
|
475
|
+
/** `POST /graphs/{tenant}/ingest` — ingest text/json (or csv) content. */
|
|
476
|
+
ingest(body: unknown, init?: RawInit): Promise<Response>;
|
|
477
|
+
/** `POST /graphs/{tenant}/ingest/csv/schema` — infer a CSV schema mapping. */
|
|
478
|
+
ingestCsvSchema(body: unknown, init?: RawInit): Promise<Response>;
|
|
479
|
+
/** `POST /graphs/{tenant}/ingest/csv/rows` — write a batch of mapped rows. */
|
|
480
|
+
ingestCsvRows(body: unknown, init?: RawInit): Promise<Response>;
|
|
481
|
+
/** `POST /graphs/{tenant}/enrich/jobs` — plan + run an enrichment job. */
|
|
482
|
+
enrichCreateJob(body: unknown, init?: RawInit): Promise<Response>;
|
|
483
|
+
/** `GET /graphs/{tenant}/enrich/jobs` — list recent enrichment jobs. */
|
|
484
|
+
enrichJobs(init?: RawInit): Promise<Response>;
|
|
485
|
+
/** `GET /graphs/{tenant}/enrich/jobs/{id}` — fetch a single job. */
|
|
486
|
+
enrichJob(jobId: string, init?: RawInit): Promise<Response>;
|
|
487
|
+
/** `GET /graphs/{tenant}/enrich/jobs/{id}/conflicts` — conflict review queue. */
|
|
488
|
+
enrichConflicts(jobId: string, init?: RawInit): Promise<Response>;
|
|
489
|
+
/** `POST /graphs/{tenant}/enrich/jobs/{id}/apply` — apply review decisions. */
|
|
490
|
+
enrichApply(jobId: string, body: unknown, init?: RawInit): Promise<Response>;
|
|
491
|
+
/** `DELETE /graphs/{tenant}/enrich/jobs/{id}` — cancel a job. */
|
|
492
|
+
enrichCancel(jobId: string, init?: RawInit): Promise<Response>;
|
|
493
|
+
/** `GET /graphs/{tenant}/ontology/types` — list ontology types. */
|
|
494
|
+
ontologyTypes(init?: RawInit): Promise<Response>;
|
|
495
|
+
/** `POST /graphs/{tenant}/ontology/resolve` — resolve an NL ontology change. */
|
|
496
|
+
ontologyResolve(body: unknown, init?: RawInit): Promise<Response>;
|
|
497
|
+
/** `POST /graphs/{tenant}/ontology/recommend` — recommend ontology changes.
|
|
498
|
+
* Premium route: only mounted on deployments with the proprietary layer,
|
|
499
|
+
* 404s on bare OSS. */
|
|
500
|
+
ontologyRecommend(body: unknown, init?: RawInit): Promise<Response>;
|
|
501
|
+
/** `POST /graphs/{tenant}/ontology/apply` — apply one resolved change. */
|
|
502
|
+
ontologyApply(body: unknown, init?: RawInit): Promise<Response>;
|
|
503
|
+
/** `GET /graphs/{tenant}/kgs` — list knowledge graphs. */
|
|
504
|
+
kgs(init?: RawInit): Promise<Response>;
|
|
505
|
+
/** `POST /graphs/{tenant}/kgs` — create a knowledge graph. */
|
|
506
|
+
createKg(body: unknown, init?: RawInit): Promise<Response>;
|
|
507
|
+
/** `DELETE /graphs/{tenant}/kgs/{name}` — delete a knowledge graph. */
|
|
508
|
+
deleteKg(name: string, init?: RawInit): Promise<Response>;
|
|
509
|
+
/** `GET /graphs/{tenant}/explore/kgs/{kg}/types/{type}/summary`. */
|
|
510
|
+
exploreSummary(kg: string, typeName: string, init?: RawInit): Promise<Response>;
|
|
511
|
+
/** `GET /graphs/{tenant}/explore/kgs/{kg}/types/{type}/records?limit&cursor`. */
|
|
512
|
+
exploreRecords(kg: string, typeName: string, opts?: {
|
|
513
|
+
limit?: number;
|
|
514
|
+
cursor?: string;
|
|
515
|
+
}, init?: RawInit): Promise<Response>;
|
|
516
|
+
/** `GET /graphs/{tenant}/explore/kgs/{kg}/type-edges`. */
|
|
517
|
+
exploreTypeEdges(kg: string, init?: RawInit): Promise<Response>;
|
|
518
|
+
/** `GET /graphs/{tenant}/kgs/{kg}/type-counts`. */
|
|
519
|
+
typeCounts(kg: string, init?: RawInit): Promise<Response>;
|
|
520
|
+
/** `GET /graphs/{tenant}/explore/search?kg&q&kind`. */
|
|
521
|
+
exploreSearch(kg: string, q: string, kind?: "type" | "attr", init?: RawInit): Promise<Response>;
|
|
522
|
+
/** `POST /graphs/{tenant}/normalize/suggest?kg&type` — infer + persist rules. */
|
|
523
|
+
normalizeSuggest(kg: string, type: string, init?: RawInit): Promise<Response>;
|
|
524
|
+
/** `GET /graphs/{tenant}/normalize/rules?kg&status` — list stored rules. */
|
|
525
|
+
normalizeRules(opts?: {
|
|
526
|
+
kg?: string;
|
|
527
|
+
status?: string;
|
|
528
|
+
}, init?: RawInit): Promise<Response>;
|
|
529
|
+
/** `POST /graphs/{tenant}/normalize/rules` — create a user-authored rule. */
|
|
530
|
+
normalizeCreateRule(body: unknown, init?: RawInit): Promise<Response>;
|
|
531
|
+
/** `POST /graphs/{tenant}/normalize/rules/{id}/confirm`. */
|
|
532
|
+
normalizeConfirmRule(ruleId: string, init?: RawInit): Promise<Response>;
|
|
533
|
+
/** `POST /graphs/{tenant}/normalize/rules/{id}/reject`. */
|
|
534
|
+
normalizeRejectRule(ruleId: string, init?: RawInit): Promise<Response>;
|
|
535
|
+
/** `POST /graphs/{tenant}/normalize/rules/{id}/apply`. */
|
|
536
|
+
normalizeApplyRule(ruleId: string, init?: RawInit): Promise<Response>;
|
|
537
|
+
/** `POST /v1/me/tenants` — create/grant a tenant for the authed user. */
|
|
538
|
+
createTenant(body: unknown, init?: RawInit): Promise<Response>;
|
|
539
|
+
/** `DELETE /v1/me/tenants/{id}` — remove a tenant grant. */
|
|
540
|
+
deleteTenant(tenantId: string, init?: RawInit): Promise<Response>;
|
|
541
|
+
/** `GET /v1/me/tenants` — list tenants the authed user can access. */
|
|
542
|
+
tenants(init?: RawInit): Promise<Response>;
|
|
543
|
+
}
|
|
544
|
+
/** Per-call overrides for a {@link RawApi} method — extra/override headers and a
|
|
545
|
+
* custom timeout. A `body` here is ignored by methods that take an explicit
|
|
546
|
+
* body argument (they set it themselves). */
|
|
547
|
+
interface RawInit {
|
|
548
|
+
headers?: Record<string, string>;
|
|
549
|
+
timeoutMs?: number;
|
|
550
|
+
}
|
|
332
551
|
|
|
333
|
-
export { type AgentResult, type AgentTurnOptions, type AskOptions, Client, type ClientOptions, CographError, type ConflictPolicy, type ConflictReview, type EnrichJob, type EnrichJobCreate, type EnrichRequest, type EnrichmentTier, type IngestOptions, type JobProgress, type JobStatus, type JobSummary, type OntologyApplyResult, type OntologyResolveResult, type ResolvedChange, type ReviewDecision, type RowAction, type RowResult, type Verdict };
|
|
552
|
+
export { type AgentResult, type AgentTurnOptions, type AskOptions, Client, type ClientOptions, CographError, type ConflictPolicy, type ConflictReview, type EnrichJob, type EnrichJobCreate, type EnrichRequest, type EnrichmentTier, type IngestOptions, type JobProgress, type JobStatus, type JobSummary, type NormalizationRule, type OntologyApplyResult, type OntologyResolveResult, RawApi, type RawInit, type ResolvedChange, type ReviewDecision, type RowAction, type RowResult, type TypeEdge, type TypeRecord, type TypeRecordsPage, type Verdict };
|