@hydradb/mcp 1.0.0 → 1.1.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.
@@ -1,92 +1,183 @@
1
1
  /**
2
2
  * Tool descriptions for the Hydra DB MCP server.
3
3
  * Kept in a separate file for easy editing and localisation.
4
+ *
5
+ * Every canonical tool (CONTRACT §3) and every deprecated alias has an entry.
6
+ * Alias descriptions are prefixed with a DEPRECATED notice naming the canonical
7
+ * replacement so the model prefers the new name.
4
8
  */
5
- import { TOOL_NAMES } from "./tool-names.js";
9
+ import { ALIAS_REPLACEMENTS, TOOL_NAMES } from "./tool-names.js";
10
+ // Shared parameter blurbs, reused across canonical tools and their aliases.
11
+ const PARAM = {
12
+ query: "The search query to find relevant memories",
13
+ max_results: "Maximum number of memory chunks to return (1-50, default: 10)",
14
+ mode: "Recall mode: 'fast' for quick semantic search, 'thinking' for deeper personalised recall with graph traversal (default: 'thinking')",
15
+ graph_context: "Whether to include knowledge graph relations in results (default: true)",
16
+ text: "The information to store in memory",
17
+ title: "Optional title for the memory entry (default: 'MCP Memory')",
18
+ source_id: "Optional source identifier to group related memories together. You can use this as " +
19
+ "your session ID or any other unique identifier for a conversation",
20
+ infer: "Whether Hydra DB should extract insights and build knowledge graph from this text (default: true)",
21
+ is_markdown: "Whether the text is in markdown format (default: false)",
22
+ turns: "Array of conversation turns, each with a 'user' and 'assistant' field",
23
+ user_name: "Optional name of the user for personalisation (default: 'User')",
24
+ kind: "Which context family to list: 'memory' or 'knowledge' (default: 'memory')",
25
+ source_ids: "Optional array of specific source IDs to filter by. If omitted, lists all sources.",
26
+ fetch_source_id: "The source ID to fetch content for",
27
+ fetch_mode: "Fetch mode: 'content' for text, 'url' for presigned URL, 'both' for both (default: 'content')",
28
+ delete_id: "The ID of the item to delete",
29
+ delete_kind: "Which context family the ID belongs to: 'memory' or 'knowledge' (default: 'memory')",
30
+ memory_id: "The ID of the memory to delete",
31
+ };
32
+ function deprecated(alias, body) {
33
+ return `DEPRECATED — use \`${ALIAS_REPLACEMENTS[alias]}\` instead. ${body}`;
34
+ }
35
+ const SEARCH_BODY = "Search through Hydra DB State-of-the-art agentic memories. Returns relevant chunks with " +
36
+ "graph-enriched context including entity paths and knowledge graph relations. " +
37
+ "Use this to find previously stored information, past conversations, user preferences, " +
38
+ "or any knowledge that has been ingested into Hydra DB memory. " +
39
+ "Supports both fast semantic search and deeper thinking mode with graph traversal.";
40
+ const STORE_BODY = "Save important information to Hydra DB State-of-the-art agentic memory. Use this to persist " +
41
+ "facts, preferences, decisions, notes, or any text the user wants remembered across " +
42
+ "sessions. Hydra DB automatically extracts insights, preferences, and builds a knowledge " +
43
+ "graph from the stored content. Supports plain text and markdown.";
44
+ const CONVERSATION_BODY = "Ingest one or more user-assistant conversation turns into Hydra DB memory. " +
45
+ "Hydra DB will extract insights, preferences, and knowledge graph entities from the " +
46
+ "conversation. Use this to store conversation history so it can be recalled later. " +
47
+ "Each turn is a pair of user message and assistant response.";
48
+ const LIST_MEMORIES_BODY = "List all stored user memories in Hydra DB. Returns memory IDs and their content. " +
49
+ "Use this to browse what has been stored, verify memories exist, or find memory IDs " +
50
+ "for deletion.";
51
+ const LIST_SOURCES_BODY = "List all ingested sources in Hydra DB memory. Returns source IDs, titles, types, " +
52
+ "and metadata. Use this to see what data sources have been ingested and to find " +
53
+ "source IDs for fetching content.";
54
+ const INSPECT_BODY = "Fetch the full content of a specific source by its source ID from Hydra DB. " +
55
+ "Returns the original text content that was ingested. Use this to retrieve " +
56
+ "the complete content of a previously stored source.";
6
57
  export const TOOL_DESCRIPTIONS = {
58
+ // --- Canonical tools (CONTRACT §3) ---
59
+ [TOOL_NAMES.QUERY]: {
60
+ title: "Query Hydra DB",
61
+ description: SEARCH_BODY,
62
+ params: {
63
+ query: PARAM.query,
64
+ max_results: PARAM.max_results,
65
+ mode: PARAM.mode,
66
+ graph_context: PARAM.graph_context,
67
+ },
68
+ },
69
+ [TOOL_NAMES.INGEST]: {
70
+ title: "Ingest into Hydra DB",
71
+ description: STORE_BODY +
72
+ " To ingest a conversation instead of a single note, provide `turns` " +
73
+ "(user/assistant pairs) rather than `text`.",
74
+ params: {
75
+ text: PARAM.text,
76
+ title: PARAM.title,
77
+ source_id: PARAM.source_id,
78
+ infer: PARAM.infer,
79
+ is_markdown: PARAM.is_markdown,
80
+ turns: "Optional conversation turns to ingest instead of `text`; each has a 'user' and 'assistant' field",
81
+ user_name: PARAM.user_name,
82
+ },
83
+ },
84
+ [TOOL_NAMES.LIST]: {
85
+ title: "List Hydra DB Context",
86
+ description: "List stored memories or ingested knowledge sources in Hydra DB. " +
87
+ "Use `kind` to choose which family to browse.",
88
+ params: {
89
+ kind: PARAM.kind,
90
+ source_ids: PARAM.source_ids,
91
+ },
92
+ },
93
+ [TOOL_NAMES.INSPECT]: {
94
+ title: "Inspect Hydra DB Source",
95
+ description: INSPECT_BODY,
96
+ params: {
97
+ source_id: PARAM.fetch_source_id,
98
+ mode: PARAM.fetch_mode,
99
+ },
100
+ },
101
+ [TOOL_NAMES.DELETE]: {
102
+ title: "Delete from Hydra DB",
103
+ description: "Delete a memory or knowledge source from Hydra DB by its ID. " +
104
+ "Use `kind` to select which family the ID belongs to. This action is irreversible.",
105
+ params: {
106
+ id: PARAM.delete_id,
107
+ kind: PARAM.delete_kind,
108
+ },
109
+ },
110
+ // --- Deprecated aliases ---
7
111
  [TOOL_NAMES.SEARCH]: {
8
- title: "Search Hydra DB Memory",
9
- description: "Search through Hydra DB State-of-the-art agentic memories. Returns relevant chunks with " +
10
- "graph-enriched context including entity paths and knowledge graph relations. " +
11
- "Use this to find previously stored information, past conversations, user preferences, " +
12
- "or any knowledge that has been ingested into Hydra DB memory. " +
13
- "Supports both fast semantic search and deeper thinking mode with graph traversal.",
112
+ title: "Search Hydra DB Memory (deprecated)",
113
+ description: deprecated(TOOL_NAMES.SEARCH, SEARCH_BODY),
14
114
  params: {
15
- query: "The search query to find relevant memories",
16
- max_results: "Maximum number of memory chunks to return (1-50, default: 10)",
17
- mode: "Recall mode: 'fast' for quick semantic search, 'thinking' for deeper personalised recall with graph traversal (default: 'thinking')",
18
- graph_context: "Whether to include knowledge graph relations in results (default: true)",
115
+ query: PARAM.query,
116
+ max_results: PARAM.max_results,
117
+ mode: PARAM.mode,
118
+ graph_context: PARAM.graph_context,
19
119
  },
20
120
  },
21
121
  [TOOL_NAMES.STORE]: {
22
- title: "Store to Hydra DB Memory",
23
- description: "Save important information to Hydra DB State-of-the-art agentic memory. Use this to persist " +
24
- "facts, preferences, decisions, notes, or any text the user wants remembered across " +
25
- "sessions. Hydra DB automatically extracts insights, preferences, and builds a knowledge " +
26
- "graph from the stored content. Supports plain text and markdown.",
122
+ title: "Store to Hydra DB Memory (deprecated)",
123
+ description: deprecated(TOOL_NAMES.STORE, STORE_BODY),
27
124
  params: {
28
- text: "The information to store in memory",
29
- title: "Optional title for the memory entry (default: 'MCP Memory')",
30
- source_id: "Optional source identifier to group related memories together. You can use this as " +
31
- "your session ID or any other unique identifier for a conversation",
32
- infer: "Whether Hydra DB should extract insights and build knowledge graph from this text (default: true)",
33
- is_markdown: "Whether the text is in markdown format (default: false)",
125
+ text: PARAM.text,
126
+ title: PARAM.title,
127
+ source_id: PARAM.source_id,
128
+ infer: PARAM.infer,
129
+ is_markdown: PARAM.is_markdown,
34
130
  },
35
131
  },
36
132
  [TOOL_NAMES.INGEST_CONVERSATION]: {
37
- title: "Ingest Conversation",
38
- description: "Ingest one or more user-assistant conversation turns into Hydra DB memory. " +
39
- "Hydra DB will extract insights, preferences, and knowledge graph entities from the " +
40
- "conversation. Use this to store conversation history so it can be recalled later. " +
41
- "Each turn is a pair of user message and assistant response.",
133
+ title: "Ingest Conversation (deprecated)",
134
+ description: deprecated(TOOL_NAMES.INGEST_CONVERSATION, CONVERSATION_BODY),
42
135
  params: {
43
- turns: "Array of conversation turns, each with a 'user' and 'assistant' field",
136
+ turns: PARAM.turns,
44
137
  source_id: "Source identifier to group all turns from the same session together",
45
- user_name: "Optional name of the user for personalisation (default: 'User')",
138
+ user_name: PARAM.user_name,
46
139
  },
47
140
  },
48
141
  [TOOL_NAMES.LIST_MEMORIES]: {
49
- title: "List Memories",
50
- description: "List all stored user memories in Hydra DB. Returns memory IDs and their content. " +
51
- "Use this to browse what has been stored, verify memories exist, or find memory IDs " +
52
- "for deletion.",
142
+ title: "List Memories (deprecated)",
143
+ description: deprecated(TOOL_NAMES.LIST_MEMORIES, LIST_MEMORIES_BODY),
53
144
  },
54
- [TOOL_NAMES.DELETE_MEMORY]: {
55
- title: "Delete Memory",
56
- description: "Delete a specific user memory from Hydra DB by its memory ID. " +
57
- `Use ${TOOL_NAMES.LIST_MEMORIES} first to find the memory ID you want to delete. ` +
58
- "This action is irreversible.",
145
+ [TOOL_NAMES.LIST_SOURCES]: {
146
+ title: "List Sources (deprecated)",
147
+ description: deprecated(TOOL_NAMES.LIST_SOURCES, LIST_SOURCES_BODY),
59
148
  params: {
60
- memory_id: "The ID of the memory to delete",
149
+ source_ids: PARAM.source_ids,
61
150
  },
62
151
  },
63
152
  [TOOL_NAMES.FETCH_CONTENT]: {
64
- title: "Fetch Source Content",
65
- description: "Fetch the full content of a specific source by its source ID from Hydra DB. " +
66
- "Returns the original text content that was ingested. Use this to retrieve " +
67
- "the complete content of a previously stored source.",
153
+ title: "Fetch Source Content (deprecated)",
154
+ description: deprecated(TOOL_NAMES.FETCH_CONTENT, INSPECT_BODY),
68
155
  params: {
69
- source_id: "The source ID to fetch content for",
70
- mode: "Fetch mode: 'content' for text, 'url' for presigned URL, 'both' for both (default: 'content')",
156
+ source_id: PARAM.fetch_source_id,
157
+ mode: PARAM.fetch_mode,
71
158
  },
72
159
  },
73
- [TOOL_NAMES.LIST_SOURCES]: {
74
- title: "List Sources",
75
- description: "List all ingested sources in Hydra DB memory. Returns source IDs, titles, types, " +
76
- "and metadata. Use this to see what data sources have been ingested and to find " +
77
- "source IDs for fetching content.",
160
+ [TOOL_NAMES.DELETE_MEMORY]: {
161
+ title: "Delete Memory (deprecated)",
162
+ description: deprecated(TOOL_NAMES.DELETE_MEMORY, "Delete a specific user memory from Hydra DB by its memory ID. This action is irreversible."),
78
163
  params: {
79
- source_ids: "Optional array of specific source IDs to filter by. If omitted, lists all sources.",
164
+ memory_id: PARAM.memory_id,
80
165
  },
81
166
  },
82
167
  };
83
168
  export const SERVER_INSTRUCTIONS = "Hydra DB MCP server for State-of-the-art agentic memory management. " +
84
- `Use ${TOOL_NAMES.SEARCH} to find relevant memories and knowledge graph context. ` +
85
- `Use ${TOOL_NAMES.STORE} to save important information for future recall. ` +
86
- `Use ${TOOL_NAMES.INGEST_CONVERSATION} to store conversation history. ` +
87
- `Use ${TOOL_NAMES.LIST_MEMORIES} to browse stored memories. ` +
88
- `Use ${TOOL_NAMES.DELETE_MEMORY} to remove specific memories. ` +
89
- `Use ${TOOL_NAMES.FETCH_CONTENT} to retrieve full source content. ` +
90
- `Use ${TOOL_NAMES.LIST_SOURCES} to see all ingested data sources. ` +
169
+ `Use ${TOOL_NAMES.QUERY} to find relevant memories and knowledge graph context. ` +
170
+ `Use ${TOOL_NAMES.INGEST} to save information (a note via 'text', or a conversation via 'turns'). ` +
171
+ `Use ${TOOL_NAMES.LIST} to browse stored memories or knowledge sources. ` +
172
+ `Use ${TOOL_NAMES.INSPECT} to retrieve the full content of a source. ` +
173
+ `Use ${TOOL_NAMES.DELETE} to remove a memory or knowledge source. ` +
174
+ "Deprecated aliases remain available for backward compatibility but should not be used in new integrations: " +
175
+ `${TOOL_NAMES.SEARCH} ${TOOL_NAMES.QUERY}, ` +
176
+ `${TOOL_NAMES.STORE} → ${TOOL_NAMES.INGEST}, ` +
177
+ `${TOOL_NAMES.INGEST_CONVERSATION} → ${TOOL_NAMES.INGEST}, ` +
178
+ `${TOOL_NAMES.LIST_MEMORIES} → ${TOOL_NAMES.LIST}, ` +
179
+ `${TOOL_NAMES.LIST_SOURCES} → ${TOOL_NAMES.LIST}, ` +
180
+ `${TOOL_NAMES.FETCH_CONTENT} → ${TOOL_NAMES.INSPECT}, ` +
181
+ `${TOOL_NAMES.DELETE_MEMORY} → ${TOOL_NAMES.DELETE}. ` +
91
182
  "All tools require a valid Hydra DB API key and tenant ID configured via environment variables.";
92
183
  //# sourceMappingURL=descriptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../src/descriptions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEjE,4EAA4E;AAC5E,MAAM,KAAK,GAAG;IACb,KAAK,EAAE,4CAA4C;IACnD,WAAW,EAAE,+DAA+D;IAC5E,IAAI,EAAE,qIAAqI;IAC3I,aAAa,EACZ,yEAAyE;IAC1E,IAAI,EAAE,oCAAoC;IAC1C,KAAK,EAAE,6DAA6D;IACpE,SAAS,EACR,qFAAqF;QACrF,mEAAmE;IACpE,KAAK,EAAE,mGAAmG;IAC1G,WAAW,EAAE,yDAAyD;IACtE,KAAK,EAAE,uEAAuE;IAC9E,SAAS,EAAE,iEAAiE;IAC5E,IAAI,EAAE,2EAA2E;IACjF,UAAU,EACT,oFAAoF;IACrF,eAAe,EAAE,oCAAoC;IACrD,UAAU,EACT,+FAA+F;IAChG,SAAS,EAAE,8BAA8B;IACzC,WAAW,EACV,qFAAqF;IACtF,SAAS,EAAE,gCAAgC;CAClC,CAAC;AAEX,SAAS,UAAU,CAAC,KAAa,EAAE,IAAY;IAC9C,OAAO,sBAAsB,kBAAkB,CAAC,KAAK,CAAC,eAAe,IAAI,EAAE,CAAC;AAC7E,CAAC;AAED,MAAM,WAAW,GAChB,0FAA0F;IAC1F,+EAA+E;IAC/E,wFAAwF;IACxF,gEAAgE;IAChE,mFAAmF,CAAC;AAErF,MAAM,UAAU,GACf,8FAA8F;IAC9F,qFAAqF;IACrF,0FAA0F;IAC1F,kEAAkE,CAAC;AAEpE,MAAM,iBAAiB,GACtB,6EAA6E;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I;IAC9C,GAAG,UAAU,CAAC,mBAAmB,MAAM,UAAU,CAAC,MAAM,IAAI;IAC5D,GAAG,UAAU,CAAC,aAAa,MAAM,UAAU,CAAC,IAAI,IAAI;IACpD,GAAG,UAAU,CAAC,YAAY,MAAM,UAAU,CAAC,IAAI,IAAI;IACnD,GAAG,UAAU,CAAC,aAAa,MAAM,UAAU,CAAC,OAAO,IAAI;IACvD,GAAG,UAAU,CAAC,aAAa,MAAM,UAAU,CAAC,MAAM,IAAI;IACtD,gGAAgG,CAAC"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Thin, hand-owned wrapper around the generated `@hydradb/sdk`.
3
+ *
4
+ * This is the single place the MCP server (and, later, the OpenClaw port of
5
+ * this same pattern) touches the SDK. It:
6
+ * - owns the SDK at an EXACT pin (see package.json `"@hydradb/sdk": "2.1.2"`),
7
+ * - exposes the canonical vocabulary from CONTRACT.md §2 (camelCase in TS),
8
+ * - injects scope (`database` / `collection`) that the SDK reads from no env,
9
+ * - unwraps the `HandlerEnvelope` by shape (see ./envelope),
10
+ * - translates SDK errors into a stable host error (see ./errors).
11
+ *
12
+ * Injected DEFAULTS (alpha, recency bias, mode, upsert, ingest instructions)
13
+ * are deliberately NOT baked in here — per CONTRACT §2 rule 5 those are host
14
+ * behaviour and are supplied by the caller, so this wrapper stays portable.
15
+ */
16
+ import { HydraDBClient } from "@hydradb/sdk";
17
+ import type { HydraDB as SDK } from "@hydradb/sdk";
18
+ export type ContextKind = "memory" | "knowledge";
19
+ export interface HydraConfig {
20
+ /** Bearer token (the HydraDB API key). */
21
+ token: string;
22
+ /** Database scope (canonical name for the tenant). */
23
+ database: string;
24
+ /** Collection scope (canonical name for the sub-tenant). */
25
+ collection?: string;
26
+ /** Optional base URL override; defaults to the SDK's environment. */
27
+ baseUrl?: string;
28
+ }
29
+ export interface QueryParams {
30
+ query: string;
31
+ kind?: ContextKind;
32
+ operator?: "or" | "and" | "phrase";
33
+ maxResults?: number;
34
+ mode?: "fast" | "thinking" | "auto";
35
+ graphContext?: boolean;
36
+ alpha?: number;
37
+ recencyBias?: number;
38
+ /** Per-call collection override. */
39
+ collection?: string;
40
+ }
41
+ export interface ConversationTurn {
42
+ user: string;
43
+ assistant: string;
44
+ }
45
+ export interface IngestParams {
46
+ kind: ContextKind;
47
+ /** Free text to ingest (memory note or knowledge document body). */
48
+ text?: string;
49
+ /** Conversation turns to ingest as a memory. */
50
+ pairs?: ConversationTurn[];
51
+ title?: string;
52
+ sourceId?: string;
53
+ userName?: string;
54
+ infer?: boolean;
55
+ isMarkdown?: boolean;
56
+ /** Passed through only when `infer` is truthy (host-owned default text). */
57
+ customInstructions?: string;
58
+ upsert?: boolean;
59
+ /** Filename to attach when ingesting knowledge text as a document. */
60
+ filename?: string;
61
+ collection?: string;
62
+ }
63
+ export interface ListParams {
64
+ kind?: ContextKind;
65
+ ids?: string[];
66
+ page?: number;
67
+ pageSize?: number;
68
+ collection?: string;
69
+ }
70
+ export interface InspectParams {
71
+ id: string;
72
+ mode?: string;
73
+ expirySeconds?: number;
74
+ collection?: string;
75
+ }
76
+ export interface IngestionStatusParams {
77
+ ids: string | string[];
78
+ collection?: string;
79
+ }
80
+ export interface RelationsParams {
81
+ id?: string;
82
+ kind?: ContextKind;
83
+ limit?: number;
84
+ cursor?: number;
85
+ collection?: string;
86
+ }
87
+ export interface DeleteParams {
88
+ ids: string[];
89
+ kind: ContextKind;
90
+ collection?: string;
91
+ }
92
+ export interface CreateDatabaseParams {
93
+ database: string;
94
+ databaseMetadataSchema?: SDK.TenantsCustomPropertyDefinition[];
95
+ embeddingsDimension?: number;
96
+ }
97
+ type ScopeFields = {
98
+ database: string;
99
+ collection?: string;
100
+ };
101
+ declare abstract class Resource {
102
+ protected readonly sdk: HydraDBClient;
103
+ private readonly database;
104
+ private readonly collection?;
105
+ protected constructor(sdk: HydraDBClient, database: string, collection?: string | undefined);
106
+ protected scope(override?: string): ScopeFields;
107
+ protected call<T>(path: string, fn: () => Promise<unknown>): Promise<T>;
108
+ }
109
+ export declare class ContextResource extends Resource {
110
+ constructor(sdk: HydraDBClient, database: string, collection?: string);
111
+ /** The single retrieval entry point (SDK `client.query`). */
112
+ query(params: QueryParams): Promise<SDK.SearchV2RetrievalResult>;
113
+ /** Ingest a memory or knowledge item (SDK `context.ingest`, multipart). */
114
+ ingest(params: IngestParams): Promise<SDK.IngestionV2SourceUploadResponse>;
115
+ /** List memories or knowledge sources (SDK `context.list`). */
116
+ list(params?: ListParams): Promise<SDK.ListV2SourceListResponse>;
117
+ /** Fetch a source's content (SDK `context.inspect`; was "fetch content"). */
118
+ inspect(params: InspectParams): Promise<SDK.FetchV2SourceFetchResponse>;
119
+ /** Per-source indexing progress (SDK `context.status`). */
120
+ ingestionStatus(params: IngestionStatusParams): Promise<SDK.IngestionV2BatchProcessingStatus>;
121
+ /** Knowledge-graph relations (SDK `context.relations`). */
122
+ relations(params?: RelationsParams): Promise<SDK.GraphGraphRelationsResponse>;
123
+ /** Delete memories or knowledge sources (SDK `context.delete`). */
124
+ delete(params: DeleteParams): Promise<SDK.SourcesMemoryDeleteResponse>;
125
+ }
126
+ export declare class DatabasesResource extends Resource {
127
+ constructor(sdk: HydraDBClient, database: string, collection?: string);
128
+ create(params: CreateDatabaseParams): Promise<SDK.TenantsTenantCreateAcceptedResponse>;
129
+ delete(database: string): Promise<SDK.TenantsTenantDeleteResponse>;
130
+ list(): Promise<SDK.TenantsTenantIdsResponse>;
131
+ collections(database: string): Promise<SDK.TenantsSubTenantIdsResponse>;
132
+ stats(database: string): Promise<SDK.TenantsTenantStatsResponse>;
133
+ /** Infra provisioning readiness — renamed away from `status` (SDK `databases.status`). */
134
+ readiness(database: string): Promise<SDK.TenantsInfraStatusResponseV2>;
135
+ }
136
+ /**
137
+ * The canonical HydraDB client surface. Construct once per process from config;
138
+ * pass an existing `HydraDBClient` as the second argument to inject a mocked
139
+ * SDK transport (used by the conformance runner).
140
+ */
141
+ export declare class HydraDB {
142
+ readonly context: ContextResource;
143
+ readonly databases: DatabasesResource;
144
+ constructor(config: HydraConfig, sdk?: HydraDBClient);
145
+ }
146
+ export {};
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Thin, hand-owned wrapper around the generated `@hydradb/sdk`.
3
+ *
4
+ * This is the single place the MCP server (and, later, the OpenClaw port of
5
+ * this same pattern) touches the SDK. It:
6
+ * - owns the SDK at an EXACT pin (see package.json `"@hydradb/sdk": "2.1.2"`),
7
+ * - exposes the canonical vocabulary from CONTRACT.md §2 (camelCase in TS),
8
+ * - injects scope (`database` / `collection`) that the SDK reads from no env,
9
+ * - unwraps the `HandlerEnvelope` by shape (see ./envelope),
10
+ * - translates SDK errors into a stable host error (see ./errors).
11
+ *
12
+ * Injected DEFAULTS (alpha, recency bias, mode, upsert, ingest instructions)
13
+ * are deliberately NOT baked in here — per CONTRACT §2 rule 5 those are host
14
+ * behaviour and are supplied by the caller, so this wrapper stays portable.
15
+ */
16
+ import { Buffer } from "node:buffer";
17
+ import { HydraDBClient } from "@hydradb/sdk";
18
+ import { unwrap } from "./envelope.js";
19
+ import { translateError } from "./errors.js";
20
+ function kindToType(kind) {
21
+ return kind;
22
+ }
23
+ class Resource {
24
+ constructor(sdk, database, collection) {
25
+ this.sdk = sdk;
26
+ this.database = database;
27
+ this.collection = collection;
28
+ }
29
+ scope(override) {
30
+ const collection = override ?? this.collection;
31
+ return collection != null
32
+ ? { database: this.database, collection }
33
+ : { database: this.database };
34
+ }
35
+ async call(path, fn) {
36
+ try {
37
+ return unwrap(await fn());
38
+ }
39
+ catch (err) {
40
+ throw translateError(path, err);
41
+ }
42
+ }
43
+ }
44
+ export class ContextResource extends Resource {
45
+ constructor(sdk, database, collection) {
46
+ super(sdk, database, collection);
47
+ }
48
+ /** The single retrieval entry point (SDK `client.query`). */
49
+ query(params) {
50
+ return this.call("/query", () => this.sdk.query({
51
+ ...this.scope(params.collection),
52
+ query: params.query,
53
+ type: kindToType(params.kind),
54
+ operator: params.operator,
55
+ maxResults: params.maxResults,
56
+ mode: params.mode,
57
+ graphContext: params.graphContext,
58
+ alpha: params.alpha,
59
+ recencyBias: params.recencyBias,
60
+ }));
61
+ }
62
+ /** Ingest a memory or knowledge item (SDK `context.ingest`, multipart). */
63
+ ingest(params) {
64
+ const request = {
65
+ ...this.scope(params.collection),
66
+ type: kindToType(params.kind),
67
+ };
68
+ if (params.upsert != null) {
69
+ request.upsert = String(params.upsert);
70
+ }
71
+ if (params.kind === "memory") {
72
+ const infer = params.infer ?? true;
73
+ const item = {};
74
+ if (params.pairs != null)
75
+ item.user_assistant_pairs = params.pairs;
76
+ if (params.text != null)
77
+ item.text = params.text;
78
+ item.infer = infer;
79
+ item.is_markdown = params.isMarkdown ?? false;
80
+ // Preserve the v1 omission behaviour: custom_instructions is only
81
+ // attached when inference is enabled.
82
+ if (infer && params.customInstructions != null) {
83
+ item.custom_instructions = params.customInstructions;
84
+ }
85
+ if (params.sourceId != null)
86
+ item.source_id = params.sourceId;
87
+ if (params.title != null)
88
+ item.title = params.title;
89
+ if (params.userName != null)
90
+ item.user_name = params.userName;
91
+ request.memories = JSON.stringify([item]);
92
+ }
93
+ else {
94
+ // Knowledge is multipart with the document as a file part — never the
95
+ // `app_knowledge` JSON field (guards the DX-G-002 class of bug).
96
+ if (params.text != null) {
97
+ request.documents = {
98
+ data: Buffer.from(params.text, "utf-8"),
99
+ // The title rides on the filename; the server's
100
+ // document_metadata does not accept a `title` key.
101
+ filename: params.filename ?? `${params.title ?? "document"}.md`,
102
+ contentType: "text/markdown",
103
+ };
104
+ }
105
+ }
106
+ return this.call("/context/ingest", () => this.sdk.context.ingest(request));
107
+ }
108
+ /** List memories or knowledge sources (SDK `context.list`). */
109
+ list(params = {}) {
110
+ return this.call("/context/list", () => this.sdk.context.list({
111
+ ...this.scope(params.collection),
112
+ type: kindToType(params.kind),
113
+ ids: params.ids,
114
+ page: params.page,
115
+ pageSize: params.pageSize,
116
+ }));
117
+ }
118
+ /** Fetch a source's content (SDK `context.inspect`; was "fetch content"). */
119
+ inspect(params) {
120
+ return this.call("/context/inspect", () => this.sdk.context.inspect({
121
+ ...this.scope(params.collection),
122
+ id: params.id,
123
+ mode: params.mode,
124
+ expirySeconds: params.expirySeconds,
125
+ }));
126
+ }
127
+ /** Per-source indexing progress (SDK `context.status`). */
128
+ ingestionStatus(params) {
129
+ return this.call("/context/status", () => this.sdk.context.status({
130
+ ...this.scope(params.collection),
131
+ ids: params.ids,
132
+ }));
133
+ }
134
+ /** Knowledge-graph relations (SDK `context.relations`). */
135
+ relations(params = {}) {
136
+ return this.call("/context/relations", () => this.sdk.context.relations({
137
+ ...this.scope(params.collection),
138
+ id: params.id,
139
+ type: kindToType(params.kind),
140
+ limit: params.limit,
141
+ cursor: params.cursor,
142
+ }));
143
+ }
144
+ /** Delete memories or knowledge sources (SDK `context.delete`). */
145
+ delete(params) {
146
+ return this.call("/context", () => this.sdk.context.delete({
147
+ ...this.scope(params.collection),
148
+ ids: params.ids,
149
+ type: kindToType(params.kind),
150
+ }));
151
+ }
152
+ }
153
+ export class DatabasesResource extends Resource {
154
+ constructor(sdk, database, collection) {
155
+ super(sdk, database, collection);
156
+ }
157
+ create(params) {
158
+ return this.call("/databases", () => this.sdk.databases.create({
159
+ database: params.database,
160
+ databaseMetadataSchema: params.databaseMetadataSchema,
161
+ embeddingsDimension: params.embeddingsDimension,
162
+ }));
163
+ }
164
+ delete(database) {
165
+ return this.call("/databases", () => this.sdk.databases.delete({ database }));
166
+ }
167
+ list() {
168
+ return this.call("/databases", () => this.sdk.databases.list());
169
+ }
170
+ collections(database) {
171
+ return this.call("/databases/collections", () => this.sdk.databases.collections({ database }));
172
+ }
173
+ stats(database) {
174
+ return this.call("/databases/stats", () => this.sdk.databases.stats({ database }));
175
+ }
176
+ /** Infra provisioning readiness — renamed away from `status` (SDK `databases.status`). */
177
+ readiness(database) {
178
+ return this.call("/databases/status", () => this.sdk.databases.status({ database }));
179
+ }
180
+ }
181
+ /**
182
+ * The canonical HydraDB client surface. Construct once per process from config;
183
+ * pass an existing `HydraDBClient` as the second argument to inject a mocked
184
+ * SDK transport (used by the conformance runner).
185
+ */
186
+ export class HydraDB {
187
+ constructor(config, sdk) {
188
+ const client = sdk ??
189
+ new HydraDBClient({
190
+ token: config.token,
191
+ ...(config.baseUrl != null ? { baseUrl: config.baseUrl } : {}),
192
+ });
193
+ this.context = new ContextResource(client, config.database, config.collection);
194
+ this.databases = new DatabasesResource(client, config.database, config.collection);
195
+ }
196
+ }
197
+ //# sourceMappingURL=client.js.map
@@ -0,0 +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;AAI7C,SAAS,UAAU,CAAC,IAA6B;IAChD,OAAO,IAAI,CAAC;AACb,CAAC;AA4FD,MAAe,QAAQ;IACtB,YACoB,GAAkB,EACpB,QAAgB,EAChB,UAAmB;QAFjB,QAAG,GAAH,GAAG,CAAe;QACpB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,eAAU,GAAV,UAAU,CAAS;IAClC,CAAC;IAEM,KAAK,CAAC,QAAiB;QAChC,MAAM,UAAU,GAAG,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC;QAC/C,OAAO,UAAU,IAAI,IAAI;YACxB,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE;YACzC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAChC,CAAC;IAES,KAAK,CAAC,IAAI,CAAI,IAAY,EAAE,EAA0B;QAC/D,IAAI,CAAC;YACJ,OAAO,MAAM,CAAI,MAAM,EAAE,E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AAI,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9D,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;IACH,CAAC;CACD"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * HandlerEnvelope unwrapping.
3
+ *
4
+ * Most `@hydradb/sdk` methods resolve to a `HandlerEnvelope{ data, success, meta,
5
+ * error }` and we want the inner `data`. But not every method is enveloped
6
+ * (`databases.updateMetadataSchema` and most `connectors.*` return bare
7
+ * objects), so we unwrap by *checking the envelope shape* rather than assuming
8
+ * it: a value is an envelope only if it carries a top-level `data` property
9
+ * alongside one of the envelope siblings (`success` / `meta` / `error`).
10
+ *
11
+ * Payload types (e.g. `FetchV2SourceFetchResponse`) may themselves carry a
12
+ * `success` field, but never a top-level `data`, so they are correctly left
13
+ * untouched when they arrive already unwrapped.
14
+ */
15
+ export declare function unwrap<T>(value: unknown): T;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * HandlerEnvelope unwrapping.
3
+ *
4
+ * Most `@hydradb/sdk` methods resolve to a `HandlerEnvelope{ data, success, meta,
5
+ * error }` and we want the inner `data`. But not every method is enveloped
6
+ * (`databases.updateMetadataSchema` and most `connectors.*` return bare
7
+ * objects), so we unwrap by *checking the envelope shape* rather than assuming
8
+ * it: a value is an envelope only if it carries a top-level `data` property
9
+ * alongside one of the envelope siblings (`success` / `meta` / `error`).
10
+ *
11
+ * Payload types (e.g. `FetchV2SourceFetchResponse`) may themselves carry a
12
+ * `success` field, but never a top-level `data`, so they are correctly left
13
+ * untouched when they arrive already unwrapped.
14
+ */
15
+ function isEnvelope(value) {
16
+ if (value == null || typeof value !== "object")
17
+ return false;
18
+ if (!("data" in value))
19
+ return false;
20
+ return "success" in value || "meta" in value || "error" in value;
21
+ }
22
+ export function unwrap(value) {
23
+ if (isEnvelope(value)) {
24
+ return value.data;
25
+ }
26
+ return value;
27
+ }
28
+ //# sourceMappingURL=envelope.js.map