@hydradb/mcp 1.2.0 → 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 +158 -0
- package/README.md +172 -2
- 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 +170 -13
- 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 +36 -2
- package/dist/hydra/client.js +46 -14
- 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 +387 -12
- 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/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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CAAC,IAAI,CAAC,EAAE,EAC7D,IAAI,EACJ,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,CACtC,CAAC;IACH,CAAC;IAED,sEAAsE;IACtE,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjE,OAAO,IAAI,iBAAiB,CAAC,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;AA4B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AAY,iBAAiB;gBAAE,MAAM,GAAG,CAAC;YAEhD,oEAAoE;YACpE,4DAA4D;YAC5D,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBACvD,IAAI,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;oBAC3B,MAAM,IAAI,iBAAiB,CAC1B,YAAY,IAAI,yCAAyC,EACzD,IAAI,EACJ,EAAE,KAAK,EAAE,GAAG,EAAE,CACd,CAAC;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"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GraphConfig } from "./config.js";
|
|
1
2
|
import { HydraDB } from "./hydra/index.js";
|
|
2
3
|
/** Stop accepting tool calls. Idempotent. */
|
|
3
4
|
export declare function beginShutdown(): void;
|
|
@@ -18,7 +19,12 @@ export declare function inFlightCount(): number;
|
|
|
18
19
|
export declare function legacyToolsEnabled(env?: NodeJS.ProcessEnv): boolean;
|
|
19
20
|
/** Test-only: reset the once-per-process alias warning dedupe. */
|
|
20
21
|
export declare function __resetAliasWarnings(): void;
|
|
21
|
-
export declare function createHydraDBServer(hydraOverride?: HydraDB
|
|
22
|
+
export declare function createHydraDBServer(hydraOverride?: HydraDB,
|
|
23
|
+
/**
|
|
24
|
+
* Graph scope/gating override, for tests and embedders. Without it the graph
|
|
25
|
+
* config is read from the environment exactly as the rest of the config is.
|
|
26
|
+
*/
|
|
27
|
+
graphOverride?: Partial<GraphConfig>): import("@modelcontextprotocol/sdk/server").Server<{
|
|
22
28
|
method: string;
|
|
23
29
|
params?: {
|
|
24
30
|
[x: string]: unknown;
|