@hydradb/mcp 1.2.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +48 -2
- package/dist/adapters.d.ts +3 -3
- package/dist/adapters.js.map +1 -1
- package/dist/descriptions.d.ts +24 -0
- package/dist/descriptions.js +63 -3
- package/dist/descriptions.js.map +1 -1
- package/dist/http-config.d.ts +31 -1
- package/dist/http-config.js +29 -29
- package/dist/http-config.js.map +1 -1
- package/dist/http.js +82 -5
- package/dist/http.js.map +1 -1
- package/dist/hydra/client.d.ts +224 -5
- package/dist/hydra/client.js +166 -9
- package/dist/hydra/client.js.map +1 -1
- package/dist/hydra/graph.d.ts +1 -5
- package/dist/hydra/graph.js +5 -92
- package/dist/hydra/graph.js.map +1 -1
- package/dist/hydra/index.d.ts +4 -1
- package/dist/hydra/index.js +2 -0
- package/dist/hydra/index.js.map +1 -1
- package/dist/hydra/transport.d.ts +37 -0
- package/dist/hydra/transport.js +114 -0
- package/dist/hydra/transport.js.map +1 -0
- package/dist/oauth.d.ts +109 -0
- package/dist/oauth.js +228 -0
- package/dist/oauth.js.map +1 -0
- package/dist/server.d.ts +9 -1
- package/dist/server.js +265 -7
- package/dist/server.js.map +1 -1
- package/dist/tool-names.d.ts +10 -1
- package/dist/tool-names.js +17 -0
- package/dist/tool-names.js.map +1 -1
- package/package.json +2 -2
package/dist/http-config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-config.js","sourceRoot":"","sources":["../src/http-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;
|
|
1
|
+
{"version":3,"file":"http-config.js","sourceRoot":"","sources":["../src/http-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EACN,kBAAkB,E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;QACtE,mDAAmD;QACnD,UAAU,EACT,QAAQ,EAAE,UAAU;YACpB,WAAW,CAAC,OAAO,EAAE,uBAAuB,CAAC;YAC7C,IAAI,CAAC,UAAU;KAChB,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,QAAQ,KAAU,CAAC;AAE5B,kFAAkF;AAClF,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,OAAe;IAKzD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AAC/D,CAAC"}
|
package/dist/http.js
CHANGED
|
@@ -24,6 +24,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
24
24
|
import { HydraDB } from "./hydra/index.js";
|
|
25
25
|
import { buildAllowedHosts, jsonRpcError, parseList, parsePort, resolveHttpServerConfig, resolveRequestCredentials, } from "./http-config.js";
|
|
26
26
|
import { logger } from "./logger.js";
|
|
27
|
+
import { introspect, isAccessToken, metadataUrl, protectedResourceMetadata, wwwAuthenticate, } from "./oauth.js";
|
|
27
28
|
import { awaitInFlight, beginShutdown, createHydraDBServer, inFlightCount, } from "./server.js";
|
|
28
29
|
/**
|
|
29
30
|
* The largest request body accepted before parsing.
|
|
@@ -49,6 +50,14 @@ const MAX_REQUEST_BODY = "8mb";
|
|
|
49
50
|
function banner(message) {
|
|
50
51
|
console.error(`[hydradb-mcp] ${message}`);
|
|
51
52
|
}
|
|
53
|
+
/** The bearer value from an `Authorization` header, scheme-insensitive. */
|
|
54
|
+
function bearerFromHeader(value) {
|
|
55
|
+
const raw = Array.isArray(value) ? value[0] : value;
|
|
56
|
+
if (!raw)
|
|
57
|
+
return undefined;
|
|
58
|
+
const match = /^\s*Bearer\s+(.+)$/i.exec(raw);
|
|
59
|
+
return (match ? match[1] : raw).trim() || undefined;
|
|
60
|
+
}
|
|
52
61
|
/** JSON-RPC error codes used for transport-level failures (spec: -32000 range). */
|
|
53
62
|
const JSONRPC_UNAUTHORIZED = -32001;
|
|
54
63
|
const JSONRPC_BAD_REQUEST = -32602;
|
|
@@ -64,6 +73,10 @@ const JSONRPC_MISDIRECTED = -32000;
|
|
|
64
73
|
export function createHttpApp(config) {
|
|
65
74
|
const { bindAddress, allowedOrigins, allowedHosts } = config;
|
|
66
75
|
const allowsAllOrigins = allowedOrigins.includes("*");
|
|
76
|
+
// OAuth is a per-deployment capability, not a per-request one, so it is
|
|
77
|
+
// resolved once. `null` means every OAuth surface below is absent and this
|
|
78
|
+
// server is byte-for-byte the pre-OAuth one.
|
|
79
|
+
const oauth = config.oauth ?? null;
|
|
67
80
|
const app = express();
|
|
68
81
|
// Off by default so a direct client cannot spoof `X-Forwarded-*`; a
|
|
69
82
|
// deployment behind a known proxy sets TRUST_PROXY to recover the real client
|
|
@@ -124,7 +137,11 @@ export function createHttpApp(config) {
|
|
|
124
137
|
},
|
|
125
138
|
// The client reads the session id and negotiated protocol version off
|
|
126
139
|
// the response; without exposing them a browser cannot complete a session.
|
|
127
|
-
|
|
140
|
+
// WWW-Authenticate is the OAuth discovery entry point: a browser-based
|
|
141
|
+
// client (claude.ai) that cannot read it off the 401 never learns where
|
|
142
|
+
// to log in, so the whole flow silently fails for exactly the clients
|
|
143
|
+
// OAuth exists for.
|
|
144
|
+
exposedHeaders: ["Mcp-Session-Id", "Mcp-Protocol-Version", "WWW-Authenticate"],
|
|
128
145
|
allowedHeaders: [
|
|
129
146
|
"Content-Type",
|
|
130
147
|
"Authorization",
|
|
@@ -157,16 +174,68 @@ export function createHttpApp(config) {
|
|
|
157
174
|
// --- The MCP endpoint ---
|
|
158
175
|
// Serves MCP at both the root `/` (e.g. https://mcp.hydradb.com) and `/mcp`
|
|
159
176
|
// so clients pointing at either URL connect seamlessly.
|
|
177
|
+
// --- OAuth Protected Resource Metadata (RFC 9728) ---
|
|
178
|
+
//
|
|
179
|
+
// The one document a client needs to get from "401" to "open the browser at
|
|
180
|
+
// the right place". Served at the root form and the `/mcp` path form, since
|
|
181
|
+
// a client tries the path-inserted URL first when the endpoint has a path.
|
|
182
|
+
// Registered only when OAuth is configured, so an unconfigured server has
|
|
183
|
+
// no new routes at all.
|
|
184
|
+
if (oauth) {
|
|
185
|
+
app.get(["/.well-known/oauth-protected-resource", "/.well-known/oauth-protected-resource/mcp"], (_req, res) => {
|
|
186
|
+
res.setHeader("Cache-Control", "public, max-age=300");
|
|
187
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
188
|
+
res.json(protectedResourceMetadata(oauth));
|
|
189
|
+
});
|
|
190
|
+
}
|
|
160
191
|
app.all(["/", "/mcp"], async (req, res) => {
|
|
192
|
+
// An OAuth access token arrives in the same `Authorization: Bearer` slot
|
|
193
|
+
// an API key does. It is told apart by prefix and exchanged, via the
|
|
194
|
+
// issuer, for the API key and scope the user approved on the consent
|
|
195
|
+
// screen. From there it is indistinguishable from a caller who sent that
|
|
196
|
+
// key directly: the same resolver runs, and the tool layer never learns
|
|
197
|
+
// OAuth exists.
|
|
198
|
+
let identity;
|
|
199
|
+
const bearer = bearerFromHeader(req.headers.authorization);
|
|
200
|
+
if (oauth && isAccessToken(bearer)) {
|
|
201
|
+
const result = await introspect(oauth, bearer);
|
|
202
|
+
if (!result.ok) {
|
|
203
|
+
if (result.reason === "unavailable") {
|
|
204
|
+
logger.error("token introspection unavailable", { detail: result.detail });
|
|
205
|
+
res
|
|
206
|
+
.status(503)
|
|
207
|
+
.json(jsonRpcError(JSONRPC_INTERNAL_ERROR, "Authorization service unavailable"));
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
res.setHeader("WWW-Authenticate", wwwAuthenticate(oauth, "invalid_token", result.reason === "wrong_audience"
|
|
211
|
+
? "token was not issued for this server"
|
|
212
|
+
: "token is invalid, expired or revoked"));
|
|
213
|
+
res
|
|
214
|
+
.status(401)
|
|
215
|
+
.json(jsonRpcError(JSONRPC_UNAUTHORIZED, "Invalid or expired access token"));
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const t = result.token;
|
|
219
|
+
identity = {
|
|
220
|
+
apiKey: t.apiKey,
|
|
221
|
+
...(t.database != null ? { database: t.database } : {}),
|
|
222
|
+
...(t.collection != null ? { collection: t.collection } : {}),
|
|
223
|
+
...(t.allowedDatabases ? { allowedDatabases: t.allowedDatabases } : {}),
|
|
224
|
+
...(t.allowedCollections ? { allowedCollections: t.allowedCollections } : {}),
|
|
225
|
+
};
|
|
226
|
+
// A token is a credential; nothing carrying one may be cached.
|
|
227
|
+
res.setHeader("Cache-Control", "no-store");
|
|
228
|
+
}
|
|
161
229
|
// Who is this request for? On a hosted process the answer lives entirely
|
|
162
230
|
// in the request, so it is resolved here and a missing/incomplete answer
|
|
163
231
|
// is refused before any server is built.
|
|
164
|
-
const resolution = resolveRequestCredentials(req.headers, process.env);
|
|
232
|
+
const resolution = resolveRequestCredentials(req.headers, process.env, identity);
|
|
165
233
|
if (!resolution.ok) {
|
|
166
234
|
// 401 gets a WWW-Authenticate header so a spec-compliant client knows
|
|
167
|
-
// how to authenticate rather than just seeing a bare refusal.
|
|
235
|
+
// how to authenticate rather than just seeing a bare refusal. With
|
|
236
|
+
// OAuth configured that header is the whole discovery entry point.
|
|
168
237
|
if (resolution.status === 401) {
|
|
169
|
-
res.setHeader("WWW-Authenticate", 'Bearer realm="Hydra DB MCP"');
|
|
238
|
+
res.setHeader("WWW-Authenticate", oauth ? wwwAuthenticate(oauth) : 'Bearer realm="Hydra DB MCP"');
|
|
170
239
|
}
|
|
171
240
|
res
|
|
172
241
|
.status(resolution.status)
|
|
@@ -181,13 +250,17 @@ export function createHttpApp(config) {
|
|
|
181
250
|
token: creds.apiKey,
|
|
182
251
|
database: creds.database,
|
|
183
252
|
collection: creds.collection,
|
|
253
|
+
...(creds.allowedDatabases ? { allowedDatabases: creds.allowedDatabases } : {}),
|
|
254
|
+
...(creds.allowedCollections
|
|
255
|
+
? { allowedCollections: creds.allowedCollections }
|
|
256
|
+
: {}),
|
|
184
257
|
...(creds.baseUrl != null ? { baseUrl: creds.baseUrl } : {}),
|
|
185
258
|
...(creds.timeoutSeconds != null
|
|
186
259
|
? { timeoutSeconds: creds.timeoutSeconds }
|
|
187
260
|
: {}),
|
|
188
261
|
...(creds.maxRetries != null ? { maxRetries: creds.maxRetries } : {}),
|
|
189
262
|
});
|
|
190
|
-
const server = createHydraDBServer(hydra, creds.graph);
|
|
263
|
+
const server = createHydraDBServer(hydra, creds.graph, { oauthTools: identity != null });
|
|
191
264
|
// Stateless: this pair serves exactly this request and is discarded when
|
|
192
265
|
// the response closes. Tearing them down on `close` — which fires for a
|
|
193
266
|
// clean end AND for the error path below (it sends a response, which then
|
|
@@ -320,6 +393,10 @@ function main() {
|
|
|
320
393
|
"multi-tenant deployment so each caller must authenticate. See SECURITY.md.");
|
|
321
394
|
}
|
|
322
395
|
const app = createHttpApp(config);
|
|
396
|
+
if (config.oauth) {
|
|
397
|
+
banner(`OAuth enabled: issuer ${config.oauth.issuer}, resource ${config.oauth.resource} ` +
|
|
398
|
+
`(metadata at ${metadataUrl(config.oauth)})`);
|
|
399
|
+
}
|
|
323
400
|
const httpServer = app
|
|
324
401
|
.listen(config.port, config.bindAddress, () => {
|
|
325
402
|
// Startup banners: on stderr so an operator sees where it bound
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAyB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AAEnG,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EACN,iBAAiB,EAEjB,YAAY,EACZ,SAAS,EACT,SAAS,EACT,uBAAuB,EACvB,yBAAyB,GACzB,MAAM,kB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CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACtB,MAAM,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IAEJ,gBAAgB,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAED,4EAA4E;AAC5E,6EAA6E;AAC7E,yBAAyB;AACzB,MAAM,eAAe,GACpB,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,UAAU,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;AAEvC,IAAI,eAAe,EAAE,CAAC;IACrB,IAAI,EAAE,CAAC;AACR,CAAC;AAED,+EAA+E;AAC/E,kBAAkB;AAClB,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC"}
|
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 { type RawTransport } from "./transport.js";
|
|
18
19
|
import { GraphResource } from "./graph.js";
|
|
19
20
|
export type ContextKind = "memory" | "knowledge";
|
|
20
21
|
/**
|
|
@@ -47,6 +48,14 @@ export interface HydraConfig {
|
|
|
47
48
|
database: string;
|
|
48
49
|
/** Collection scope (canonical name for the sub-tenant). */
|
|
49
50
|
collection?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Databases a per-call `database` override may name. Absent means any.
|
|
53
|
+
* Set from an OAuth grant the user confined to specific databases; the
|
|
54
|
+
* default `database` is always allowed.
|
|
55
|
+
*/
|
|
56
|
+
allowedDatabases?: string[];
|
|
57
|
+
/** Collections a per-call `collection` override may name. Absent means any. */
|
|
58
|
+
allowedCollections?: string[];
|
|
50
59
|
/** Optional base URL override; defaults to the SDK's environment. */
|
|
51
60
|
baseUrl?: string;
|
|
52
61
|
/**
|
|
@@ -59,6 +68,8 @@ export interface HydraConfig {
|
|
|
59
68
|
timeoutSeconds?: number;
|
|
60
69
|
/** Retries per call. The SDK defaults to 2; set explicitly so it is a choice. */
|
|
61
70
|
maxRetries?: number;
|
|
71
|
+
/** Test seam for the hand-rolled HTTP path; production never sets it. */
|
|
72
|
+
fetchFn?: typeof fetch;
|
|
62
73
|
}
|
|
63
74
|
export interface QueryParams {
|
|
64
75
|
query: string;
|
|
@@ -85,10 +96,37 @@ export interface QueryParams {
|
|
|
85
96
|
ids?: string[];
|
|
86
97
|
/** Exact-match filters over stored metadata. No ranges, no partial matches. */
|
|
87
98
|
metadataFilters?: Record<string, unknown>;
|
|
99
|
+
/**
|
|
100
|
+
* Principals to answer as (PRO-1684 document ACLs): an email, a
|
|
101
|
+
* `domain:<host>`, or a `group:<provider>:<id>`. Results are restricted to
|
|
102
|
+
* documents whose access list admits at least one of them.
|
|
103
|
+
*
|
|
104
|
+
* Omitted means NO ACL scoping — every document this key can reach. An empty
|
|
105
|
+
* array is treated the SAME as omitted by the API (verified against staging:
|
|
106
|
+
* `acl: []` and no `acl` both returned 134 sources where an unknown
|
|
107
|
+
* principal returned 130), so it is not a way to ask for "nobody"; the
|
|
108
|
+
* design doc's rule is that absent and `[]` alike mean unrestricted.
|
|
109
|
+
*
|
|
110
|
+
* A principal the deployment does not know fails CLOSED: it matches only
|
|
111
|
+
* documents carrying no access list of their own, never a restricted one.
|
|
112
|
+
*/
|
|
113
|
+
acl?: string[];
|
|
88
114
|
/** Adjacent chunks pulled in alongside each match, for surrounding context. */
|
|
89
115
|
numRelatedChunks?: number;
|
|
116
|
+
/**
|
|
117
|
+
* App-aware knowledge retrieval: exact IDs and actors, thread reconstruction,
|
|
118
|
+
* and parent/child expansion over connector-ingested sources. Applies to
|
|
119
|
+
* knowledge hybrid queries; the server ignores it elsewhere.
|
|
120
|
+
*/
|
|
121
|
+
queryApps?: boolean;
|
|
90
122
|
/** Per-call collection override. */
|
|
91
123
|
collection?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Multi-collection scope: a list for equal weighting, or a {collection:
|
|
126
|
+
* weight} object to rank some higher than others. Mutually exclusive with
|
|
127
|
+
* `collection` — see the guard in `query`.
|
|
128
|
+
*/
|
|
129
|
+
collections?: SDK.SearchQueryRequestCollections;
|
|
92
130
|
/** Per-call database override. */
|
|
93
131
|
database?: string;
|
|
94
132
|
}
|
|
@@ -134,6 +172,19 @@ export interface ListParams {
|
|
|
134
172
|
ids?: string[];
|
|
135
173
|
page?: number;
|
|
136
174
|
pageSize?: number;
|
|
175
|
+
/**
|
|
176
|
+
* Principals to answer as (PRO-1684 document ACLs): an email, a
|
|
177
|
+
* `domain:<host>`, or a `group:<provider>:<id>`. Results are restricted to
|
|
178
|
+
* documents whose access list admits at least one of them.
|
|
179
|
+
*
|
|
180
|
+
* Omitted means NO ACL scoping — every document this key can reach. An empty
|
|
181
|
+
* array is treated the SAME as omitted by the API, so it is not a way to ask
|
|
182
|
+
* for "nobody" (design doc: absent and `[]` alike mean unrestricted).
|
|
183
|
+
*
|
|
184
|
+
* A principal the deployment does not know fails CLOSED: it matches only
|
|
185
|
+
* documents carrying no access list of their own, never a restricted one.
|
|
186
|
+
*/
|
|
187
|
+
acl?: string[];
|
|
137
188
|
collection?: string;
|
|
138
189
|
/** Per-call database override. */
|
|
139
190
|
database?: string;
|
|
@@ -142,6 +193,19 @@ export interface InspectParams {
|
|
|
142
193
|
id: string;
|
|
143
194
|
mode?: string;
|
|
144
195
|
expirySeconds?: number;
|
|
196
|
+
/**
|
|
197
|
+
* Principals to answer as (PRO-1684 document ACLs): an email, a
|
|
198
|
+
* `domain:<host>`, or a `group:<provider>:<id>`. Results are restricted to
|
|
199
|
+
* documents whose access list admits at least one of them.
|
|
200
|
+
*
|
|
201
|
+
* Omitted means NO ACL scoping — every document this key can reach. An empty
|
|
202
|
+
* array is treated the SAME as omitted by the API, so it is not a way to ask
|
|
203
|
+
* for "nobody" (design doc: absent and `[]` alike mean unrestricted).
|
|
204
|
+
*
|
|
205
|
+
* A principal the deployment does not know fails CLOSED: it matches only
|
|
206
|
+
* documents carrying no access list of their own, never a restricted one.
|
|
207
|
+
*/
|
|
208
|
+
acl?: string[];
|
|
145
209
|
collection?: string;
|
|
146
210
|
/** Per-call database override. */
|
|
147
211
|
database?: string;
|
|
@@ -152,11 +216,88 @@ export interface IngestionStatusParams {
|
|
|
152
216
|
/** Per-call database override. */
|
|
153
217
|
database?: string;
|
|
154
218
|
}
|
|
219
|
+
/** One member of a connected subgraph (wire shape, unchanged from the API). */
|
|
220
|
+
export interface SubgraphMember {
|
|
221
|
+
source_id: string;
|
|
222
|
+
title?: string;
|
|
223
|
+
app_kind?: string;
|
|
224
|
+
app_provider?: string;
|
|
225
|
+
app_external_id?: string;
|
|
226
|
+
thread_id?: string;
|
|
227
|
+
/** Hops from the seed; 0 is the seed itself. */
|
|
228
|
+
depth: number;
|
|
229
|
+
hydration?: string;
|
|
230
|
+
discovered_via?: string;
|
|
231
|
+
discovered_relation?: string;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* One edge of the subgraph. `source` and `target` are Source nodes, so their
|
|
235
|
+
* `entity_id` is the member's item id; `relations[0].canonical_predicate` is
|
|
236
|
+
* the edge type (`relates_to`, `same_thread`, `child_of`, ...).
|
|
237
|
+
*/
|
|
238
|
+
export interface SubgraphRelation {
|
|
239
|
+
source?: {
|
|
240
|
+
entity_id?: string;
|
|
241
|
+
name?: string;
|
|
242
|
+
};
|
|
243
|
+
target?: {
|
|
244
|
+
entity_id?: string;
|
|
245
|
+
name?: string;
|
|
246
|
+
};
|
|
247
|
+
relations?: {
|
|
248
|
+
canonical_predicate?: string;
|
|
249
|
+
}[];
|
|
250
|
+
}
|
|
251
|
+
export interface SubgraphResult {
|
|
252
|
+
seed_source_id: string;
|
|
253
|
+
sources: SubgraphMember[];
|
|
254
|
+
relations: SubgraphRelation[];
|
|
255
|
+
auxiliary_relations: unknown[];
|
|
256
|
+
auxiliary_truncated: boolean;
|
|
257
|
+
is_truncated: boolean;
|
|
258
|
+
max_depth_reached: number;
|
|
259
|
+
success: boolean;
|
|
260
|
+
message: string;
|
|
261
|
+
}
|
|
262
|
+
export interface SubgraphParams {
|
|
263
|
+
/** The item whose connected subgraph to return. */
|
|
264
|
+
id: string;
|
|
265
|
+
kind?: ContextKind;
|
|
266
|
+
/** Max traversal depth in hops (server default 5). */
|
|
267
|
+
depth?: number;
|
|
268
|
+
/** Max members returned (server default 200). */
|
|
269
|
+
maxSources?: number;
|
|
270
|
+
/**
|
|
271
|
+
* Principals to answer as (PRO-1684 document ACLs): an email, a
|
|
272
|
+
* `domain:<host>`, or a `group:<provider>:<id>`. The subgraph contains
|
|
273
|
+
* only items those principals may see, filtered at every hop.
|
|
274
|
+
*
|
|
275
|
+
* Omitted means NO ACL scoping. An empty array is treated the SAME as
|
|
276
|
+
* omitted by the API, so it is not a way to ask for "nobody".
|
|
277
|
+
*/
|
|
278
|
+
acl?: string[];
|
|
279
|
+
collection?: string;
|
|
280
|
+
/** Per-call database override. */
|
|
281
|
+
database?: string;
|
|
282
|
+
}
|
|
155
283
|
export interface RelationsParams {
|
|
156
284
|
id?: string;
|
|
157
285
|
kind?: ContextKind;
|
|
158
286
|
limit?: number;
|
|
159
287
|
cursor?: number;
|
|
288
|
+
/**
|
|
289
|
+
* Principals to answer as (PRO-1684 document ACLs): an email, a
|
|
290
|
+
* `domain:<host>`, or a `group:<provider>:<id>`. Results are restricted to
|
|
291
|
+
* documents whose access list admits at least one of them.
|
|
292
|
+
*
|
|
293
|
+
* Omitted means NO ACL scoping — every document this key can reach. An empty
|
|
294
|
+
* array is treated the SAME as omitted by the API, so it is not a way to ask
|
|
295
|
+
* for "nobody" (design doc: absent and `[]` alike mean unrestricted).
|
|
296
|
+
*
|
|
297
|
+
* A principal the deployment does not know fails CLOSED: it matches only
|
|
298
|
+
* documents carrying no access list of their own, never a restricted one.
|
|
299
|
+
*/
|
|
300
|
+
acl?: string[];
|
|
160
301
|
collection?: string;
|
|
161
302
|
/** Per-call database override. */
|
|
162
303
|
database?: string;
|
|
@@ -177,16 +318,75 @@ type ScopeFields = {
|
|
|
177
318
|
database: string;
|
|
178
319
|
collection?: string;
|
|
179
320
|
};
|
|
321
|
+
type MultiScopeFields = {
|
|
322
|
+
database: string;
|
|
323
|
+
collections: SDK.SearchQueryRequestCollections;
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* A per-call `database` named one the connection is not allowed to touch.
|
|
327
|
+
*
|
|
328
|
+
* Written for the agent that reads it as a tool error: it names what IS
|
|
329
|
+
* allowed and where the choice was made, so the agent can either use an
|
|
330
|
+
* allowed database or tell the user to reconnect with wider access, rather
|
|
331
|
+
* than retrying blindly.
|
|
332
|
+
*/
|
|
333
|
+
export declare class ScopeNotAllowedError extends Error {
|
|
334
|
+
readonly kind: "database" | "collection";
|
|
335
|
+
readonly requested: string;
|
|
336
|
+
readonly allowed: readonly string[];
|
|
337
|
+
constructor(kind: "database" | "collection", requested: string, allowed: readonly string[]);
|
|
338
|
+
}
|
|
339
|
+
/** Kept for the name callers already import; the database case of the above. */
|
|
340
|
+
export declare const DatabaseNotAllowedError: typeof ScopeNotAllowedError;
|
|
341
|
+
/** Throws unless `database` is one the connection may use. */
|
|
342
|
+
export declare function assertDatabaseAllowed(database: string, allowed: readonly string[] | undefined): void;
|
|
343
|
+
/**
|
|
344
|
+
* Throws unless `collection` is one the connection may use.
|
|
345
|
+
*
|
|
346
|
+
* Separate from the database check because confinement has to cover both:
|
|
347
|
+
* a caller pinned to one database can otherwise step sideways into a
|
|
348
|
+
* collection the consent screen never showed, and `drop_collection` makes
|
|
349
|
+
* that destructive.
|
|
350
|
+
*/
|
|
351
|
+
export declare function assertCollectionAllowed(collection: string, allowed: readonly string[] | undefined): void;
|
|
180
352
|
declare abstract class Resource {
|
|
181
353
|
protected readonly sdk: HydraDBClient;
|
|
182
354
|
private readonly database;
|
|
183
355
|
private readonly collection?;
|
|
184
|
-
|
|
356
|
+
private readonly allowedDatabases?;
|
|
357
|
+
private readonly allowedCollections?;
|
|
358
|
+
/**
|
|
359
|
+
* The hand-rolled HTTP path, for the endpoints the SDK does not expose
|
|
360
|
+
* (CONTRACT §2 rule 7). Optional only so tests that inject a fake SDK and
|
|
361
|
+
* never touch such an endpoint need not build one.
|
|
362
|
+
*/
|
|
363
|
+
protected readonly raw?: RawTransport | undefined;
|
|
364
|
+
protected constructor(sdk: HydraDBClient, database: string, collection?: string | undefined, allowedDatabases?: readonly string[] | undefined, allowedCollections?: readonly string[] | undefined,
|
|
365
|
+
/**
|
|
366
|
+
* The hand-rolled HTTP path, for the endpoints the SDK does not expose
|
|
367
|
+
* (CONTRACT §2 rule 7). Optional only so tests that inject a fake SDK and
|
|
368
|
+
* never touch such an endpoint need not build one.
|
|
369
|
+
*/
|
|
370
|
+
raw?: RawTransport | undefined);
|
|
185
371
|
protected scope(override?: string, dbOverride?: string): ScopeFields;
|
|
372
|
+
/**
|
|
373
|
+
* Scope for a query that names SEVERAL collections.
|
|
374
|
+
*
|
|
375
|
+
* Deliberately does NOT fall back to the configured default collection. The
|
|
376
|
+
* server folds the singular `collection` into the deprecated `sub_tenant_id`
|
|
377
|
+
* and refuses any request that carries it alongside a multi-scope selector,
|
|
378
|
+
* so injecting the default here would turn every `collections` call on a
|
|
379
|
+
* scoped connection into a 400. Naming the collections IS the scope.
|
|
380
|
+
*
|
|
381
|
+
* Confinement is enforced on the same path as `scope`: every named
|
|
382
|
+
* collection is checked, so a multi-scope selector cannot reach past what an
|
|
383
|
+
* OAuth connection was confined to.
|
|
384
|
+
*/
|
|
385
|
+
protected multiScope(collections: SDK.SearchQueryRequestCollections, dbOverride?: string): MultiScopeFields;
|
|
186
386
|
protected call<T>(path: string, fn: () => Promise<unknown>): Promise<T>;
|
|
187
387
|
}
|
|
188
388
|
export declare class ContextResource extends Resource {
|
|
189
|
-
constructor(sdk: HydraDBClient, database: string, collection?: string);
|
|
389
|
+
constructor(sdk: HydraDBClient, database: string, collection?: string, allowedDatabases?: readonly string[], allowedCollections?: readonly string[], raw?: RawTransport);
|
|
190
390
|
/**
|
|
191
391
|
* The single retrieval entry point (SDK `client.query`).
|
|
192
392
|
*
|
|
@@ -201,20 +401,31 @@ export declare class ContextResource extends Resource {
|
|
|
201
401
|
* Every other failure in this wrapper rejects, and a caller that only handles
|
|
202
402
|
* `.catch()` would otherwise see this one escape as a synchronous throw.
|
|
203
403
|
*/
|
|
204
|
-
ingest(params: IngestParams, opts?: RequestOptions): Promise<SDK.
|
|
404
|
+
ingest(params: IngestParams, opts?: RequestOptions): Promise<SDK.IngestionV2IngestResponse>;
|
|
205
405
|
/** List memories or knowledge sources (SDK `context.list`). */
|
|
206
|
-
list(params?: ListParams, opts?: RequestOptions): Promise<SDK.
|
|
406
|
+
list(params?: ListParams, opts?: RequestOptions): Promise<SDK.ListV2ListResponse>;
|
|
207
407
|
/** Fetch a source's content (SDK `context.inspect`; was "fetch content"). */
|
|
208
408
|
inspect(params: InspectParams, opts?: RequestOptions): Promise<SDK.FetchV2SourceFetchResponse>;
|
|
209
409
|
/** Per-source indexing progress (SDK `context.status`). */
|
|
210
410
|
ingestionStatus(params: IngestionStatusParams, opts?: RequestOptions): Promise<SDK.IngestionV2BatchProcessingStatus>;
|
|
411
|
+
/**
|
|
412
|
+
* The connected subgraph of one item (`GET /context/{id}/subgraph`): every
|
|
413
|
+
* item reachable from it through item-level relations — explicit links, a
|
|
414
|
+
* shared thread, parent/child — plus the relations among the members and
|
|
415
|
+
* the structural graph around them.
|
|
416
|
+
*
|
|
417
|
+
* No SDK resource for this yet, so it takes the raw path (CONTRACT §2 rule
|
|
418
|
+
* 7): same header, same envelope unwrap, same error type as everything else
|
|
419
|
+
* here. When the SDK grows `context.subgraph`, only this method changes.
|
|
420
|
+
*/
|
|
421
|
+
subgraph(params: SubgraphParams, opts?: RequestOptions): Promise<SubgraphResult>;
|
|
211
422
|
/** Knowledge-graph relations (SDK `context.relations`). */
|
|
212
423
|
relations(params?: RelationsParams): Promise<SDK.GraphGraphRelationsResponse>;
|
|
213
424
|
/** Delete memories or knowledge sources (SDK `context.delete`). */
|
|
214
425
|
delete(params: DeleteParams, opts?: RequestOptions): Promise<SDK.SourcesMemoryDeleteResponse>;
|
|
215
426
|
}
|
|
216
427
|
export declare class DatabasesResource extends Resource {
|
|
217
|
-
constructor(sdk: HydraDBClient, database: string, collection?: string);
|
|
428
|
+
constructor(sdk: HydraDBClient, database: string, collection?: string, allowedDatabases?: readonly string[], allowedCollections?: readonly string[]);
|
|
218
429
|
create(params: CreateDatabaseParams): Promise<SDK.TenantsTenantCreateAcceptedResponse>;
|
|
219
430
|
delete(database: string): Promise<SDK.TenantsTenantDeleteResponse>;
|
|
220
431
|
list(): Promise<SDK.TenantsTenantIdsResponse>;
|
|
@@ -231,6 +442,14 @@ export declare class DatabasesResource extends Resource {
|
|
|
231
442
|
export declare class HydraDB {
|
|
232
443
|
readonly context: ContextResource;
|
|
233
444
|
readonly databases: DatabasesResource;
|
|
445
|
+
/** The default database every unscoped call uses. */
|
|
446
|
+
readonly database: string;
|
|
447
|
+
/** Databases a per-call override may name; undefined means any. */
|
|
448
|
+
readonly allowedDatabases?: readonly string[];
|
|
449
|
+
/** Collections a per-call override may name; undefined means any. */
|
|
450
|
+
readonly allowedCollections?: readonly string[];
|
|
451
|
+
/** The default collection every unscoped call uses. */
|
|
452
|
+
readonly collection?: string;
|
|
234
453
|
/**
|
|
235
454
|
* BYOG graph operations. Not backed by the SDK — see ./graph.ts for why —
|
|
236
455
|
* but exposed here so callers reach every HydraDB surface through one object.
|