@hydradb/mcp 1.2.1 → 1.2.2
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/CHANGELOG.md +121 -0
- package/README.md +170 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.js +40 -3
- package/dist/config.js.map +1 -1
- package/dist/cypher.d.ts +51 -0
- package/dist/cypher.js +145 -0
- package/dist/cypher.js.map +1 -0
- package/dist/descriptions.d.ts +55 -0
- package/dist/descriptions.js +150 -1
- package/dist/descriptions.js.map +1 -1
- package/dist/http-config.d.ts +160 -0
- package/dist/http-config.js +253 -0
- package/dist/http-config.js.map +1 -0
- package/dist/http.d.ts +31 -0
- package/dist/http.js +350 -0
- package/dist/http.js.map +1 -0
- package/dist/hydra/client.d.ts +21 -1
- package/dist/hydra/client.js +20 -12
- package/dist/hydra/client.js.map +1 -1
- package/dist/hydra/errors.d.ts +14 -0
- package/dist/hydra/errors.js +16 -0
- package/dist/hydra/errors.js.map +1 -1
- package/dist/hydra/graph.d.ts +82 -0
- package/dist/hydra/graph.js +217 -0
- package/dist/hydra/graph.js.map +1 -0
- package/dist/hydra/index.d.ts +3 -1
- package/dist/hydra/index.js +2 -1
- package/dist/hydra/index.js.map +1 -1
- package/dist/server.d.ts +7 -1
- package/dist/server.js +359 -11
- package/dist/server.js.map +1 -1
- package/dist/tool-names.d.ts +5 -0
- package/dist/tool-names.js +15 -0
- package/dist/tool-names.js.map +1 -1
- package/package.json +10 -2
package/dist/hydra/client.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { HydraDBClient } from "@hydradb/sdk";
|
|
17
17
|
import type { HydraDB as SDK } from "@hydradb/sdk";
|
|
18
|
+
import { GraphResource } from "./graph.js";
|
|
18
19
|
export type ContextKind = "memory" | "knowledge";
|
|
19
20
|
/**
|
|
20
21
|
* Sized to fit inside a typical MCP host's tool timeout rather than outlast it,
|
|
@@ -88,6 +89,8 @@ export interface QueryParams {
|
|
|
88
89
|
numRelatedChunks?: number;
|
|
89
90
|
/** Per-call collection override. */
|
|
90
91
|
collection?: string;
|
|
92
|
+
/** Per-call database override. */
|
|
93
|
+
database?: string;
|
|
91
94
|
}
|
|
92
95
|
export interface ConversationTurn {
|
|
93
96
|
user: string;
|
|
@@ -123,6 +126,8 @@ export interface IngestParams {
|
|
|
123
126
|
/** Filename to attach when ingesting knowledge text as a document. */
|
|
124
127
|
filename?: string;
|
|
125
128
|
collection?: string;
|
|
129
|
+
/** Per-call database override. */
|
|
130
|
+
database?: string;
|
|
126
131
|
}
|
|
127
132
|
export interface ListParams {
|
|
128
133
|
kind?: ContextKind;
|
|
@@ -130,16 +135,22 @@ export interface ListParams {
|
|
|
130
135
|
page?: number;
|
|
131
136
|
pageSize?: number;
|
|
132
137
|
collection?: string;
|
|
138
|
+
/** Per-call database override. */
|
|
139
|
+
database?: string;
|
|
133
140
|
}
|
|
134
141
|
export interface InspectParams {
|
|
135
142
|
id: string;
|
|
136
143
|
mode?: string;
|
|
137
144
|
expirySeconds?: number;
|
|
138
145
|
collection?: string;
|
|
146
|
+
/** Per-call database override. */
|
|
147
|
+
database?: string;
|
|
139
148
|
}
|
|
140
149
|
export interface IngestionStatusParams {
|
|
141
150
|
ids: string | string[];
|
|
142
151
|
collection?: string;
|
|
152
|
+
/** Per-call database override. */
|
|
153
|
+
database?: string;
|
|
143
154
|
}
|
|
144
155
|
export interface RelationsParams {
|
|
145
156
|
id?: string;
|
|
@@ -147,11 +158,15 @@ export interface RelationsParams {
|
|
|
147
158
|
limit?: number;
|
|
148
159
|
cursor?: number;
|
|
149
160
|
collection?: string;
|
|
161
|
+
/** Per-call database override. */
|
|
162
|
+
database?: string;
|
|
150
163
|
}
|
|
151
164
|
export interface DeleteParams {
|
|
152
165
|
ids: string[];
|
|
153
166
|
kind: ContextKind;
|
|
154
167
|
collection?: string;
|
|
168
|
+
/** Per-call database override. */
|
|
169
|
+
database?: string;
|
|
155
170
|
}
|
|
156
171
|
export interface CreateDatabaseParams {
|
|
157
172
|
database: string;
|
|
@@ -167,7 +182,7 @@ declare abstract class Resource {
|
|
|
167
182
|
private readonly database;
|
|
168
183
|
private readonly collection?;
|
|
169
184
|
protected constructor(sdk: HydraDBClient, database: string, collection?: string | undefined);
|
|
170
|
-
protected scope(override?: string): ScopeFields;
|
|
185
|
+
protected scope(override?: string, dbOverride?: string): ScopeFields;
|
|
171
186
|
protected call<T>(path: string, fn: () => Promise<unknown>): Promise<T>;
|
|
172
187
|
}
|
|
173
188
|
export declare class ContextResource extends Resource {
|
|
@@ -216,6 +231,11 @@ export declare class DatabasesResource extends Resource {
|
|
|
216
231
|
export declare class HydraDB {
|
|
217
232
|
readonly context: ContextResource;
|
|
218
233
|
readonly databases: DatabasesResource;
|
|
234
|
+
/**
|
|
235
|
+
* BYOG graph operations. Not backed by the SDK — see ./graph.ts for why —
|
|
236
|
+
* but exposed here so callers reach every HydraDB surface through one object.
|
|
237
|
+
*/
|
|
238
|
+
readonly graph: GraphResource;
|
|
219
239
|
constructor(config: HydraConfig, sdk?: HydraDBClient);
|
|
220
240
|
}
|
|
221
241
|
export {};
|
package/dist/hydra/client.js
CHANGED
|
@@ -17,6 +17,7 @@ import { Buffer } from "node:buffer";
|
|
|
17
17
|
import { HydraDBClient } from "@hydradb/sdk";
|
|
18
18
|
import { unwrap } from "./envelope.js";
|
|
19
19
|
import { translateError } from "./errors.js";
|
|
20
|
+
import { GraphResource } from "./graph.js";
|
|
20
21
|
/**
|
|
21
22
|
* Sized to fit inside a typical MCP host's tool timeout rather than outlast it,
|
|
22
23
|
* so a stalled call fails with a HydraDB diagnostic the caller can act on
|
|
@@ -52,11 +53,12 @@ class Resource {
|
|
|
52
53
|
this.database = database;
|
|
53
54
|
this.collection = collection;
|
|
54
55
|
}
|
|
55
|
-
scope(override) {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
scope(override, dbOverride) {
|
|
57
|
+
const database = dbOverride?.trim() || this.database;
|
|
58
|
+
const collection = override?.trim() || this.collection;
|
|
59
|
+
return collection != null && collection !== ""
|
|
60
|
+
? { database, collection }
|
|
61
|
+
: { database };
|
|
60
62
|
}
|
|
61
63
|
async call(path, fn) {
|
|
62
64
|
try {
|
|
@@ -100,7 +102,7 @@ export class ContextResource extends Resource {
|
|
|
100
102
|
}
|
|
101
103
|
const queryBy = params.queryBy ?? (params.operator != null ? "text" : undefined);
|
|
102
104
|
return this.call("/query", () => this.sdk.query({
|
|
103
|
-
...this.scope(params.collection),
|
|
105
|
+
...this.scope(params.collection, params.database),
|
|
104
106
|
query: params.query,
|
|
105
107
|
type: params.kind,
|
|
106
108
|
operator: params.operator,
|
|
@@ -124,7 +126,7 @@ export class ContextResource extends Resource {
|
|
|
124
126
|
*/
|
|
125
127
|
async ingest(params, opts) {
|
|
126
128
|
const request = {
|
|
127
|
-
...this.scope(params.collection),
|
|
129
|
+
...this.scope(params.collection, params.database),
|
|
128
130
|
type: params.kind,
|
|
129
131
|
};
|
|
130
132
|
if (params.upsert != null) {
|
|
@@ -202,7 +204,7 @@ export class ContextResource extends Resource {
|
|
|
202
204
|
/** List memories or knowledge sources (SDK `context.list`). */
|
|
203
205
|
list(params = {}, opts) {
|
|
204
206
|
return this.call("/context/list", () => this.sdk.context.list({
|
|
205
|
-
...this.scope(params.collection),
|
|
207
|
+
...this.scope(params.collection, params.database),
|
|
206
208
|
type: params.kind,
|
|
207
209
|
ids: params.ids,
|
|
208
210
|
page: params.page,
|
|
@@ -212,7 +214,7 @@ export class ContextResource extends Resource {
|
|
|
212
214
|
/** Fetch a source's content (SDK `context.inspect`; was "fetch content"). */
|
|
213
215
|
inspect(params, opts) {
|
|
214
216
|
return this.call("/context/inspect", () => this.sdk.context.inspect({
|
|
215
|
-
...this.scope(params.collection),
|
|
217
|
+
...this.scope(params.collection, params.database),
|
|
216
218
|
id: params.id,
|
|
217
219
|
mode: params.mode,
|
|
218
220
|
expirySeconds: params.expirySeconds,
|
|
@@ -221,14 +223,14 @@ export class ContextResource extends Resource {
|
|
|
221
223
|
/** Per-source indexing progress (SDK `context.status`). */
|
|
222
224
|
ingestionStatus(params, opts) {
|
|
223
225
|
return this.call("/context/status", () => this.sdk.context.status({
|
|
224
|
-
...this.scope(params.collection),
|
|
226
|
+
...this.scope(params.collection, params.database),
|
|
225
227
|
ids: params.ids,
|
|
226
228
|
}, req(opts)));
|
|
227
229
|
}
|
|
228
230
|
/** Knowledge-graph relations (SDK `context.relations`). */
|
|
229
231
|
relations(params = {}) {
|
|
230
232
|
return this.call("/context/relations", () => this.sdk.context.relations({
|
|
231
|
-
...this.scope(params.collection),
|
|
233
|
+
...this.scope(params.collection, params.database),
|
|
232
234
|
id: params.id,
|
|
233
235
|
type: params.kind,
|
|
234
236
|
limit: params.limit,
|
|
@@ -238,7 +240,7 @@ export class ContextResource extends Resource {
|
|
|
238
240
|
/** Delete memories or knowledge sources (SDK `context.delete`). */
|
|
239
241
|
delete(params, opts) {
|
|
240
242
|
return this.call("/context", () => this.sdk.context.delete({
|
|
241
|
-
...this.scope(params.collection),
|
|
243
|
+
...this.scope(params.collection, params.database),
|
|
242
244
|
ids: params.ids,
|
|
243
245
|
type: params.kind,
|
|
244
246
|
}, req(opts)));
|
|
@@ -298,6 +300,12 @@ export class HydraDB {
|
|
|
298
300
|
});
|
|
299
301
|
this.context = new ContextResource(client, config.database, config.collection);
|
|
300
302
|
this.databases = new DatabasesResource(client, config.database, config.collection);
|
|
303
|
+
this.graph = new GraphResource({
|
|
304
|
+
token: config.token,
|
|
305
|
+
...(config.baseUrl != null ? { baseUrl: config.baseUrl } : {}),
|
|
306
|
+
timeoutSeconds: config.timeoutSeconds ?? DEFAULT_TIMEOUT_SECONDS,
|
|
307
|
+
maxRetries: config.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
308
|
+
});
|
|
301
309
|
}
|
|
302
310
|
}
|
|
303
311
|
//# sourceMappingURL=client.js.map
|
package/dist/hydra/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/hydra/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/hydra/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAI3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAC1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAoBrC;;;;;;;;;;;GAWG;AACH,MAAM,aAAa,GAAG;IACrB,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC9C,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC7C,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IACjD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAe,EAAE,EAAE,CAC7C,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,OAAO,EAAE,GAAG,IAAI,CA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,CAAC,CAAC;QACJ,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,UAAU,CAAC,CAAC;QAC/E,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CACrC,MAAM,EACN,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,UAAU,CACjB,CAAC;QACF,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC;YAC9B,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,uBAAuB;YAChE,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,mBAAmB;SACpD,CAAC,CAAC;IACJ,CAAC;CACD"}
|
package/dist/hydra/errors.d.ts
CHANGED
|
@@ -30,6 +30,20 @@ export declare class HydraWrapperError extends Error {
|
|
|
30
30
|
cause?: unknown;
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Build the same error from a raw HTTP response, for calls that do not go
|
|
35
|
+
* through the SDK.
|
|
36
|
+
*
|
|
37
|
+
* The BYOG endpoints have no SDK resource to throw `HydraDBError`, so
|
|
38
|
+
* `translateError` alone would send every one of their failures down its
|
|
39
|
+
* generic branch and drop the response body — losing the error code, the
|
|
40
|
+
* server's explanation and the request id, which on a rejected Cypher query is
|
|
41
|
+
* the entire diagnosis.
|
|
42
|
+
*
|
|
43
|
+
* Routing them here instead keeps ONE formatting path, so a BYOG failure and an
|
|
44
|
+
* SDK failure are indistinguishable to everything above the wrapper.
|
|
45
|
+
*/
|
|
46
|
+
export declare function responseError(path: string, status: number, body: unknown): HydraWrapperError;
|
|
33
47
|
/**
|
|
34
48
|
* Translate any error thrown by an SDK call into a `HydraWrapperError` carrying
|
|
35
49
|
* the byte-identical `Hydra DB ${path} → ${status}: ${body}` message.
|
package/dist/hydra/errors.js
CHANGED
|
@@ -124,6 +124,22 @@ function truncate(text) {
|
|
|
124
124
|
return text;
|
|
125
125
|
return `${text.slice(0, MAX_BODY_CHARS)}… (truncated, ${text.length} chars)`;
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* Build the same error from a raw HTTP response, for calls that do not go
|
|
129
|
+
* through the SDK.
|
|
130
|
+
*
|
|
131
|
+
* The BYOG endpoints have no SDK resource to throw `HydraDBError`, so
|
|
132
|
+
* `translateError` alone would send every one of their failures down its
|
|
133
|
+
* generic branch and drop the response body — losing the error code, the
|
|
134
|
+
* server's explanation and the request id, which on a rejected Cypher query is
|
|
135
|
+
* the entire diagnosis.
|
|
136
|
+
*
|
|
137
|
+
* Routing them here instead keeps ONE formatting path, so a BYOG failure and an
|
|
138
|
+
* SDK failure are indistinguishable to everything above the wrapper.
|
|
139
|
+
*/
|
|
140
|
+
export function responseError(path, status, body) {
|
|
141
|
+
return new HydraWrapperError(`Hydra DB ${path} → ${status}: ${bodyToString(body)}`, path, { status, body });
|
|
142
|
+
}
|
|
127
143
|
/**
|
|
128
144
|
* Translate any error thrown by an SDK call into a `HydraWrapperError` carrying
|
|
129
145
|
* the byte-identical `Hydra DB ${path} → ${status}: ${body}` message.
|
package/dist/hydra/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/hydra/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAU3C,YACC,OAAe,EACf,IAAY,EACZ,IAA2D;QAE3D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,C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,YAAY,IAAI,WAAW,OAAO,EAAE,EAAE,IAAI,EAAE;QACxE,KAAK,EAAE,GAAG;KACV,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The BYOG (Bring Your Own Graph) half of the wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Everything else in this directory delegates to `@hydradb/sdk`. This file
|
|
5
|
+
* cannot: the generated SDK at the pinned 2.1.2 exposes `context`, `databases`,
|
|
6
|
+
* `connectors` and `webhooks` and has no `byog` resource at all, so the
|
|
7
|
+
* `/byog/*` endpoints are unreachable through it.
|
|
8
|
+
*
|
|
9
|
+
* So this is a hand-rolled HTTP path — but it is NOT a second client. It sits
|
|
10
|
+
* behind the same wrapper surface, unwraps the same `HandlerEnvelope` by shape
|
|
11
|
+
* (see ./envelope), and raises the same `HydraWrapperError` with the same
|
|
12
|
+
* message template (see ./errors). A caller cannot tell which of its methods
|
|
13
|
+
* went through the SDK and which did not, which is the property that matters:
|
|
14
|
+
* when the SDK grows a `byog` resource, this file is replaced and nothing above
|
|
15
|
+
* it changes.
|
|
16
|
+
*
|
|
17
|
+
* CONTRACT §2 rule 1 pins the SDK exactly because generated method names churn.
|
|
18
|
+
* That reasoning is unaffected here — there is no generated name to be
|
|
19
|
+
* insulated from yet.
|
|
20
|
+
*/
|
|
21
|
+
export interface GraphConfig {
|
|
22
|
+
token: string;
|
|
23
|
+
baseUrl?: string;
|
|
24
|
+
timeoutSeconds?: number;
|
|
25
|
+
maxRetries?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface GraphQueryParams {
|
|
28
|
+
database: string;
|
|
29
|
+
collection: string;
|
|
30
|
+
query: string;
|
|
31
|
+
params?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface GraphScopeParams {
|
|
34
|
+
database: string;
|
|
35
|
+
collection?: string;
|
|
36
|
+
}
|
|
37
|
+
/** One row of a Cypher result: keys are the RETURN column names. */
|
|
38
|
+
export type GraphRow = Record<string, unknown>;
|
|
39
|
+
export interface RequestOptions {
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
}
|
|
42
|
+
export declare class GraphResource {
|
|
43
|
+
private readonly config;
|
|
44
|
+
private readonly baseUrl;
|
|
45
|
+
private readonly timeoutMs;
|
|
46
|
+
private readonly maxRetries;
|
|
47
|
+
constructor(config: GraphConfig);
|
|
48
|
+
/**
|
|
49
|
+
* Run Cypher against one collection (`POST /byog/query`).
|
|
50
|
+
*
|
|
51
|
+
* Returns the rows verbatim — an array of row objects keyed by the query's
|
|
52
|
+
* RETURN column names. A write with no RETURN yields `[]`, which is a
|
|
53
|
+
* success and must not be read as a failure.
|
|
54
|
+
*/
|
|
55
|
+
query(params: GraphQueryParams, opts?: RequestOptions): Promise<GraphRow[]>;
|
|
56
|
+
/** Create a graph database (`POST /byog/databases`). Ready immediately. */
|
|
57
|
+
createDatabase(database: string, opts?: RequestOptions): Promise<{
|
|
58
|
+
database?: string;
|
|
59
|
+
status?: string;
|
|
60
|
+
cluster?: string;
|
|
61
|
+
}>;
|
|
62
|
+
/** List the collections in a graph database (`GET /byog/collections`). */
|
|
63
|
+
listCollections(params: GraphScopeParams, opts?: RequestOptions): Promise<string[]>;
|
|
64
|
+
/** Drop one collection and all its data (`DELETE /byog/collections`). Idempotent. */
|
|
65
|
+
dropCollection(params: {
|
|
66
|
+
database: string;
|
|
67
|
+
collection: string;
|
|
68
|
+
}, opts?: RequestOptions): Promise<Record<string, unknown>>;
|
|
69
|
+
/**
|
|
70
|
+
* Drop a graph database (`DELETE /byog/databases`).
|
|
71
|
+
*
|
|
72
|
+
* `deleted` is false when the database was created through the standard
|
|
73
|
+
* database API and merely holds graph collections — in that case only the
|
|
74
|
+
* collections go. That distinction is reported, not smoothed over.
|
|
75
|
+
*/
|
|
76
|
+
dropDatabase(database: string, opts?: RequestOptions): Promise<{
|
|
77
|
+
deleted?: boolean;
|
|
78
|
+
deleted_collections?: string[];
|
|
79
|
+
}>;
|
|
80
|
+
private send;
|
|
81
|
+
private attempt;
|
|
82
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The BYOG (Bring Your Own Graph) half of the wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Everything else in this directory delegates to `@hydradb/sdk`. This file
|
|
5
|
+
* cannot: the generated SDK at the pinned 2.1.2 exposes `context`, `databases`,
|
|
6
|
+
* `connectors` and `webhooks` and has no `byog` resource at all, so the
|
|
7
|
+
* `/byog/*` endpoints are unreachable through it.
|
|
8
|
+
*
|
|
9
|
+
* So this is a hand-rolled HTTP path — but it is NOT a second client. It sits
|
|
10
|
+
* behind the same wrapper surface, unwraps the same `HandlerEnvelope` by shape
|
|
11
|
+
* (see ./envelope), and raises the same `HydraWrapperError` with the same
|
|
12
|
+
* message template (see ./errors). A caller cannot tell which of its methods
|
|
13
|
+
* went through the SDK and which did not, which is the property that matters:
|
|
14
|
+
* when the SDK grows a `byog` resource, this file is replaced and nothing above
|
|
15
|
+
* it changes.
|
|
16
|
+
*
|
|
17
|
+
* CONTRACT §2 rule 1 pins the SDK exactly because generated method names churn.
|
|
18
|
+
* That reasoning is unaffected here — there is no generated name to be
|
|
19
|
+
* insulated from yet.
|
|
20
|
+
*/
|
|
21
|
+
import { unwrap } from "./envelope.js";
|
|
22
|
+
import { HydraWrapperError, responseError, translateError } from "./errors.js";
|
|
23
|
+
/** The SDK's own default, restated so this file does not depend on importing it. */
|
|
24
|
+
const DEFAULT_BASE_URL = "https://api.hydradb.com";
|
|
25
|
+
/**
|
|
26
|
+
* Status codes worth retrying.
|
|
27
|
+
*
|
|
28
|
+
* 429 and 5xx are documented as transient. 4xx other than 429 are not: a
|
|
29
|
+
* rejected construct, a Cypher error and a bad collection name all fail
|
|
30
|
+
* identically on retry, so retrying them only delays the message.
|
|
31
|
+
*/
|
|
32
|
+
function isRetryable(status) {
|
|
33
|
+
return status === 429 || (status >= 500 && status <= 599);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A 2xx whose body is not the shape this endpoint promises.
|
|
37
|
+
*
|
|
38
|
+
* Raised rather than coerced to an empty result. An empty array is a perfectly
|
|
39
|
+
* ordinary answer here — a query that matched nothing, a database with no
|
|
40
|
+
* graphs — so silently substituting one for a malformed response makes a broken
|
|
41
|
+
* integration indistinguishable from a true negative, which is the one case a
|
|
42
|
+
* caller cannot debug. The `path` and a bounded preview of what actually
|
|
43
|
+
* arrived are carried through so the failure is actionable.
|
|
44
|
+
*/
|
|
45
|
+
function unexpectedShape(path, expected, got) {
|
|
46
|
+
let preview;
|
|
47
|
+
try {
|
|
48
|
+
preview = JSON.stringify(got) ?? String(got);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
preview = String(got);
|
|
52
|
+
}
|
|
53
|
+
if (preview.length > 200)
|
|
54
|
+
preview = `${preview.slice(0, 200)}…`;
|
|
55
|
+
return new HydraWrapperError(`Hydra DB ${path} → ERR: expected ${expected}, got ${preview}. ` +
|
|
56
|
+
"This is a response-shape mismatch, not an empty result.", path, { body: got });
|
|
57
|
+
}
|
|
58
|
+
export class GraphResource {
|
|
59
|
+
constructor(config) {
|
|
60
|
+
this.config = config;
|
|
61
|
+
// Trailing slashes would produce `//byog/query`, which some proxies treat
|
|
62
|
+
// as a different path.
|
|
63
|
+
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
64
|
+
this.timeoutMs = (config.timeoutSeconds ?? 30) * 1000;
|
|
65
|
+
this.maxRetries = config.maxRetries ?? 2;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Run Cypher against one collection (`POST /byog/query`).
|
|
69
|
+
*
|
|
70
|
+
* Returns the rows verbatim — an array of row objects keyed by the query's
|
|
71
|
+
* RETURN column names. A write with no RETURN yields `[]`, which is a
|
|
72
|
+
* success and must not be read as a failure.
|
|
73
|
+
*/
|
|
74
|
+
async query(params, opts) {
|
|
75
|
+
const body = {
|
|
76
|
+
database: params.database,
|
|
77
|
+
collection: params.collection,
|
|
78
|
+
query: params.query,
|
|
79
|
+
...(params.params != null ? { params: params.params } : {}),
|
|
80
|
+
};
|
|
81
|
+
const rows = await this.send("/byog/query", "POST", body, opts);
|
|
82
|
+
// `data` is ALWAYS an array on success — verified against the live API,
|
|
83
|
+
// including a write with no RETURN, which yields `[]`. So anything else
|
|
84
|
+
// means the response contract moved, and coercing it to `[]` would
|
|
85
|
+
// present that as a legitimate "no rows matched": the caller would read a
|
|
86
|
+
// broken integration as an empty graph and act on it. Fail loudly instead.
|
|
87
|
+
if (!Array.isArray(rows)) {
|
|
88
|
+
throw unexpectedShape("/byog/query", "an array of row objects", rows);
|
|
89
|
+
}
|
|
90
|
+
// Element-wise, not just the container. `renderRows` calls `Object.keys`
|
|
91
|
+
// on each row, which throws a bare TypeError on `null` and on a string —
|
|
92
|
+
// an unactionable crash inside a tool handler, where the caller sees a
|
|
93
|
+
// stack rather than "the response was not what we expected".
|
|
94
|
+
const bad = rows.findIndex((row) => row == null || typeof row !== "object" || Array.isArray(row));
|
|
95
|
+
if (bad !== -1) {
|
|
96
|
+
throw unexpectedShape("/byog/query", `an array of row objects (row ${bad} is not one)`, rows[bad]);
|
|
97
|
+
}
|
|
98
|
+
return rows;
|
|
99
|
+
}
|
|
100
|
+
/** Create a graph database (`POST /byog/databases`). Ready immediately. */
|
|
101
|
+
createDatabase(database, opts) {
|
|
102
|
+
return this.send("/byog/databases", "POST", { database }, opts);
|
|
103
|
+
}
|
|
104
|
+
/** List the collections in a graph database (`GET /byog/collections`). */
|
|
105
|
+
async listCollections(params, opts) {
|
|
106
|
+
const res = await this.send(`/byog/collections?database=${encodeURIComponent(params.database)}`, "GET", undefined, opts);
|
|
107
|
+
// Same reasoning as `query`: a missing or non-array `collections` is a
|
|
108
|
+
// contract change, and reporting it as "no collections yet" would send
|
|
109
|
+
// the caller off to create graphs that already exist.
|
|
110
|
+
if (!Array.isArray(res?.collections)) {
|
|
111
|
+
throw unexpectedShape("/byog/collections", "an object with a `collections` array", res);
|
|
112
|
+
}
|
|
113
|
+
// A non-string element would be rendered as a collection name the caller
|
|
114
|
+
// could then pass back as scope, so it is reported rather than coerced.
|
|
115
|
+
const notAName = res.collections.findIndex((name) => typeof name !== "string");
|
|
116
|
+
if (notAName !== -1) {
|
|
117
|
+
throw unexpectedShape("/byog/collections", `an array of collection names (index ${notAName} is not a string)`, res.collections[notAName]);
|
|
118
|
+
}
|
|
119
|
+
return res.collections;
|
|
120
|
+
}
|
|
121
|
+
/** Drop one collection and all its data (`DELETE /byog/collections`). Idempotent. */
|
|
122
|
+
dropCollection(params, opts) {
|
|
123
|
+
return this.send("/byog/collections", "DELETE", params, opts);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Drop a graph database (`DELETE /byog/databases`).
|
|
127
|
+
*
|
|
128
|
+
* `deleted` is false when the database was created through the standard
|
|
129
|
+
* database API and merely holds graph collections — in that case only the
|
|
130
|
+
* collections go. That distinction is reported, not smoothed over.
|
|
131
|
+
*/
|
|
132
|
+
dropDatabase(database, opts) {
|
|
133
|
+
return this.send("/byog/databases", "DELETE", { database }, opts);
|
|
134
|
+
}
|
|
135
|
+
// --- Transport ---
|
|
136
|
+
async send(path, method, body, opts) {
|
|
137
|
+
let lastError;
|
|
138
|
+
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
139
|
+
try {
|
|
140
|
+
return await this.attempt(path, method, body, opts);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
lastError = err;
|
|
144
|
+
const status = err instanceof HydraWrapperError ? err.status : undefined;
|
|
145
|
+
// A caller who cancelled is not waiting for a retry.
|
|
146
|
+
if (opts?.signal?.aborted)
|
|
147
|
+
throw err;
|
|
148
|
+
if (attempt === this.maxRetries)
|
|
149
|
+
break;
|
|
150
|
+
if (status != null && !isRetryable(status))
|
|
151
|
+
break;
|
|
152
|
+
// Exponential backoff. Bounded so a 429 on the last attempt does not
|
|
153
|
+
// hold the MCP host's tool timeout open for its own sake.
|
|
154
|
+
const delay = Math.min(250 * 2 ** attempt, 2000);
|
|
155
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
throw lastError;
|
|
159
|
+
}
|
|
160
|
+
async attempt(path, method, body, opts) {
|
|
161
|
+
// The host's cancellation and our own deadline both have to be able to
|
|
162
|
+
// abort the request, and `AbortSignal.any` is not available on every Node
|
|
163
|
+
// 18 this package supports — so they are combined by hand.
|
|
164
|
+
const controller = new AbortController();
|
|
165
|
+
const timer = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
166
|
+
const onAbort = () => controller.abort();
|
|
167
|
+
opts?.signal?.addEventListener("abort", onAbort, { once: true });
|
|
168
|
+
try {
|
|
169
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
170
|
+
method,
|
|
171
|
+
headers: {
|
|
172
|
+
Authorization: `Bearer ${this.config.token}`,
|
|
173
|
+
"Content-Type": "application/json",
|
|
174
|
+
// CONTRACT §2 rule 6. The SDK sends this on every call; a
|
|
175
|
+
// hand-rolled path that omitted it would silently get v1
|
|
176
|
+
// behaviour from the same endpoints.
|
|
177
|
+
"API-Version": "2",
|
|
178
|
+
},
|
|
179
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
180
|
+
signal: controller.signal,
|
|
181
|
+
});
|
|
182
|
+
const text = await response.text();
|
|
183
|
+
let parsed;
|
|
184
|
+
try {
|
|
185
|
+
parsed = text === "" ? null : JSON.parse(text);
|
|
186
|
+
}
|
|
187
|
+
catch {
|
|
188
|
+
parsed = text;
|
|
189
|
+
}
|
|
190
|
+
if (!response.ok) {
|
|
191
|
+
// Hand the parsed envelope to the shared formatter so a BYOG
|
|
192
|
+
// failure reads exactly like an SDK one, error code and request id
|
|
193
|
+
// and all.
|
|
194
|
+
throw responseError(path, response.status, parsed);
|
|
195
|
+
}
|
|
196
|
+
return unwrap(parsed);
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
if (err instanceof HydraWrapperError)
|
|
200
|
+
throw err;
|
|
201
|
+
// Distinguish our own deadline from the caller's cancellation: they
|
|
202
|
+
// need different actions, and "aborted" alone says neither.
|
|
203
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
204
|
+
if (opts?.signal?.aborted) {
|
|
205
|
+
throw new HydraWrapperError(`Hydra DB ${path} → ERR: request cancelled by the caller`, path, { cause: err });
|
|
206
|
+
}
|
|
207
|
+
throw new HydraWrapperError(`Hydra DB ${path} → ERR: request timed out after ${this.timeoutMs / 1000}s`, path, { cause: err });
|
|
208
|
+
}
|
|
209
|
+
throw translateError(path, err);
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
clearTimeout(timer);
|
|
213
|
+
opts?.signal?.removeEventListener("abort", onAbort);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/hydra/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE/E,oFAAoF;AACpF,MAAM,gBAAgB,GAAG,yBAAyB,CAAC;AA4BnD;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,MAAc;IAClC,OAAO,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,eAAe,CAAC,IAAY,EAAE,QAAgB,EAAE,GAAY;IACpE,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACJ,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAA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AC;gBACH,CAAC;gBACD,MAAM,IAAI,iBAAiB,CAC1B,YAAY,IAAI,mCAAmC,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAC3E,IAAI,EACJ,EAAE,KAAK,EAAE,GAAG,EAAE,CACd,CAAC;YACH,CAAC;YAED,MAAM,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACjC,CAAC;gBAAS,CAAC;YACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,EAAE,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;IACF,CAAC;CACD"}
|
package/dist/hydra/index.d.ts
CHANGED
|
@@ -7,5 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export { HydraDB, ContextResource, DatabasesResource, DEFAULT_TIMEOUT_SECONDS, DEFAULT_MAX_RETRIES, } from "./client.js";
|
|
9
9
|
export type { HydraConfig, ContextKind, RequestOptions, QueryKind, ConversationTurn, QueryParams, IngestParams, ListParams, InspectParams, IngestionStatusParams, RelationsParams, DeleteParams, CreateDatabaseParams, } from "./client.js";
|
|
10
|
-
export {
|
|
10
|
+
export { GraphResource } from "./graph.js";
|
|
11
|
+
export type { GraphConfig, GraphQueryParams, GraphScopeParams, GraphRow, } from "./graph.js";
|
|
12
|
+
export { HydraWrapperError, responseError, translateError } from "./errors.js";
|
|
11
13
|
export { unwrap } from "./envelope.js";
|
package/dist/hydra/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* other client repos (per CONTRACT.md).
|
|
7
7
|
*/
|
|
8
8
|
export { HydraDB, ContextResource, DatabasesResource, DEFAULT_TIMEOUT_SECONDS, DEFAULT_MAX_RETRIES, } from "./client.js";
|
|
9
|
-
export {
|
|
9
|
+
export { GraphResource } from "./graph.js";
|
|
10
|
+
export { HydraWrapperError, responseError, translateError } from "./errors.js";
|
|
10
11
|
export { unwrap } from "./envelope.js";
|
|
11
12
|
//# sourceMappingURL=index.js.map
|
package/dist/hydra/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hydra/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,GACnB,MAAM,aAAa,CAAC;AAgBrB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hydra/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACN,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,GACnB,MAAM,aAAa,CAAC;AAgBrB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAO3C,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC"}
|